diff --git a/.gitignore b/.gitignore index 4da1bd7..8fc41a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,15 @@ app_run_tree/ meta_run_tree/ +*.exe +*.pdb +*.o process/ reference/ working_data/ +nssm_log.log +sysroot/ +*.DS_Store +*.vscode +*.vscode/* +*.dSYM +run_tree/data/live_data diff --git a/README.md b/README.md index ddbba99..35225ed 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,17 @@ Building Lumenarium requires having MSVC installed (sorry, Windows only for now! 2. Run the appropriate build batch file - for Windows: use `build\build_app_msvc_win32_debug.bat` - other platforms coming soon +3. Build scripts will output executables into the app_run_tree directory, by platform ## Run Lumenarium Windows - Debug -1. Just run `win32_msvc\debug\win32_foldhaus.exe` +1. Run `app_run_tree\win32_msvc\debug\win32_foldhaus.exe` + +If you want to run in headless mode: +1. Run `app_run_tree\win32_msvc\debug\win32_foldhaus.exe -headless` ## Debug Lumenarium -###Windows +### Windows Building in debug mode outputs pdb file info that can be read by Visual Studio or RemedyBG (preferred debugging solution, but ymmv). You can just open the exe in either application and it'll find the pdb file in the same directory ## What Is Lumenarium? diff --git a/admin.txt b/admin.txt new file mode 100644 index 0000000..98ecab0 --- /dev/null +++ b/admin.txt @@ -0,0 +1,28 @@ +# Project Admin Stuff + +## Priorities + +1. Upgrade Lumenarium's plumbing +2. Begin work on Incenter + +## TODO + +1. Upgrade Lumenarium's plumbing + x. switch over to compiling with clang & bash based build scripts + x. better platform layer separation + 3. osx and webgl layers, possibly linux? + x. remove dll compiling, just build all in one go + 5. improve ui + [ ] get widgets and widget ids working + - see a trick of fate + [ ] clip widgets to regions + [ ] text rendering + [ ] interaction + [ ] layout manager + - do layout the way youre doing styling - optional pointer to a struct + and fallback on some global default + +2. Incenter + 1. Sculpture generation from list of lat-long coordinates + 2. + diff --git a/app_run_tree/data/blumen_animations/ambient_patterns/ambient_1.foldanim b/app_run_tree/data/blumen_animations/ambient_patterns/ambient_1.foldanim new file mode 100644 index 0000000..42794d8 --- /dev/null +++ b/app_run_tree/data/blumen_animations/ambient_patterns/ambient_1.foldanim @@ -0,0 +1,56 @@ +lumenarium_animation_file; +animation_name: "digital_fire"; +layers_count: 3; +blocks_count: 4; +playable_range:{ + min: 0; + max: 10000; +}; +layers:{ + layer:{ + name: "mask1"; + blend: "Add"; + }; + layer:{ + name: "mask2"; + blend: "Add"; + }; + layer:{ + name: "color"; + blend: "Multiply"; + }; +}; +blocks:{ + block:{ + frame_range:{ + min: 0; + max: 19; + }; + layer_index: 0; + animation_name: "Pattern_BulbMask"; + }; + block:{ + frame_range:{ + min: 0; + max: 10000; + }; + layer_index: 1; + animation_name: "Pattern_Leafy"; + }; + block:{ + frame_range:{ + min: 0; + max: 5156; + }; + layer_index: 2; + animation_name: "Pattern_Rainbow"; + }; + block:{ + frame_range:{ + min: 5040; + max: 10000; + }; + layer_index: 2; + animation_name: "Pattern_Wavy"; + }; +}; diff --git a/app_run_tree/data/blumen_animations/ambient_patterns/fishy_0.foldanim b/app_run_tree/data/blumen_animations/ambient_patterns/fishy_0.foldanim new file mode 100644 index 0000000..562f43d --- /dev/null +++ b/app_run_tree/data/blumen_animations/ambient_patterns/fishy_0.foldanim @@ -0,0 +1,48 @@ +lumenarium_animation_file; +animation_name: "fishy_0"; +layers_count: 3; +blocks_count: 3; +playable_range:{ + min: 0; + max: 3600; +}; +layers:{ + layer:{ + name: "[New Layer]"; + blend: "Add"; + }; + layer:{ + name: "[New Layer]"; + blend: "Add"; + }; + layer:{ + name: "Color"; + blend: "Multiply"; + }; +}; +blocks:{ + block:{ + frame_range:{ + min: 0; + max: 3600; + }; + layer_index: 2; + animation_name: "Pattern_HueShift"; + }; + block:{ + frame_range:{ + min: 0; + max: 3600; + }; + layer_index: 1; + animation_name: "Pattern_StemSolid"; + }; + block:{ + frame_range:{ + min: 0; + max: 3600; + }; + layer_index: 0; + animation_name: "Pattern_VerticalLines"; + }; +}; diff --git a/app_run_tree/data/blumen_animations/ambient_patterns/patchy_loading_bar.foldanim b/app_run_tree/data/blumen_animations/ambient_patterns/patchy_loading_bar.foldanim new file mode 100644 index 0000000..1fe290a --- /dev/null +++ b/app_run_tree/data/blumen_animations/ambient_patterns/patchy_loading_bar.foldanim @@ -0,0 +1,36 @@ +lumenarium_animation_file; +animation_name: "patchy_loading_bar_0"; +layers_count: 2; +blocks_count: 2; +playable_range:{ + min: 0; + max: 3350; +}; +layers:{ + layer:{ + name: "[New Layer]"; + blend: "Add"; + }; + layer:{ + name: "[New Layer]"; + blend: "Multiply"; + }; +}; +blocks:{ + block:{ + frame_range:{ + min: 0; + max: 3600; + }; + layer_index: 1; + animation_name: "Pattern_Patchy"; + }; + block:{ + frame_range:{ + min: 0; + max: 3600; + }; + layer_index: 0; + animation_name: "Pattern_GrowFadeMask"; + }; +}; diff --git a/app_run_tree/data/blumen_animations/ambient_patterns/primary_hue_0.foldanim b/app_run_tree/data/blumen_animations/ambient_patterns/primary_hue_0.foldanim new file mode 100644 index 0000000..66670b8 --- /dev/null +++ b/app_run_tree/data/blumen_animations/ambient_patterns/primary_hue_0.foldanim @@ -0,0 +1,28 @@ +lumenarium_animation_file; +animation_name: "primary_hue_0"; +layers_count: 2; +blocks_count: 1; +playable_range:{ + min: 0; + max: 360; +}; +layers:{ + layer:{ + name: "[New Layer]"; + blend: "Add"; + }; + layer:{ + name: "[New Layer]"; + blend: "Add"; + }; +}; +blocks:{ + block:{ + frame_range:{ + min: 0; + max: 36000; + }; + layer_index: 1; + animation_name: "Pattern_PrimaryHue"; + }; +}; diff --git a/app_run_tree/data/blumen_animations/ambient_patterns/rainbow_0.foldanim b/app_run_tree/data/blumen_animations/ambient_patterns/rainbow_0.foldanim new file mode 100644 index 0000000..edb16ec --- /dev/null +++ b/app_run_tree/data/blumen_animations/ambient_patterns/rainbow_0.foldanim @@ -0,0 +1,32 @@ +lumenarium_animation_file; +animation_name: "rainbow"; +layers_count: 3; +blocks_count: 1; +playable_range:{ + min: 0; + max: 36000; +}; +layers:{ + layer:{ + name: "Mask"; + blend: "Add"; + }; + layer:{ + name: "Color"; + blend: "Add"; + }; + layer:{ + name: "[New Layer]"; + blend: "Add"; + }; +}; +blocks:{ + block:{ + frame_range:{ + min: 0; + max: 36000; + }; + layer_index: 1; + animation_name: "Pattern_Rainbow"; + }; +}; diff --git a/app_run_tree/data/blumen_animations/ambient_patterns/rainbow_loading_bar.foldanim b/app_run_tree/data/blumen_animations/ambient_patterns/rainbow_loading_bar.foldanim new file mode 100644 index 0000000..6f6f0c6 --- /dev/null +++ b/app_run_tree/data/blumen_animations/ambient_patterns/rainbow_loading_bar.foldanim @@ -0,0 +1,28 @@ +lumenarium_animation_file; +animation_name: "rainbow_loading_bar_0"; +layers_count: 2; +blocks_count: 1; +playable_range:{ + min: 0; + max: 9000; +}; +layers:{ + layer:{ + name: "[New Layer]"; + blend: "Add"; + }; + layer:{ + name: "[New Layer]"; + blend: "Add"; + }; +}; +blocks:{ + block:{ + frame_range:{ + min: 0; + max: 9000; + }; + layer_index: 1; + animation_name: "Pattern_RainbowLoadingBar"; + }; +}; diff --git a/app_run_tree/data/blumen_animations/ambient_patterns/wavy_0.foldanim b/app_run_tree/data/blumen_animations/ambient_patterns/wavy_0.foldanim new file mode 100644 index 0000000..bc4979c --- /dev/null +++ b/app_run_tree/data/blumen_animations/ambient_patterns/wavy_0.foldanim @@ -0,0 +1,36 @@ +lumenarium_animation_file; +animation_name: "wavy_0"; +layers_count: 2; +blocks_count: 2; +playable_range:{ + min: 0; + max: 7200; +}; +layers:{ + layer:{ + name: "[New Layer]"; + blend: "Overwrite"; + }; + layer:{ + name: "Color"; + blend: "Multiply"; + }; +}; +blocks:{ + block:{ + frame_range:{ + min: 0; + max: 7200; + }; + layer_index: 1; + animation_name: "Pattern_Wavy"; + }; + block:{ + frame_range:{ + min: 78; + max: 3571; + }; + layer_index: 0; + animation_name: "Pattern_Leafy"; + }; +}; diff --git a/app_run_tree/data/blumen_animations/audio_responses/voice_command.foldanim b/app_run_tree/data/blumen_animations/audio_responses/voice_command.foldanim new file mode 100644 index 0000000..9a5339b --- /dev/null +++ b/app_run_tree/data/blumen_animations/audio_responses/voice_command.foldanim @@ -0,0 +1,36 @@ +lumenarium_animation_file; +animation_name: "voice_anim"; +layers_count: 2; +blocks_count: 2; +playable_range:{ + min: 0; + max: 3600; +}; +layers:{ + layer:{ + name: "Base"; + blend: "Add"; + }; + layer:{ + name: "Add In"; + blend: "Overwrite"; + }; +}; +blocks:{ + block:{ + frame_range:{ + min: 0; + max: 3600; + }; + layer_index: 0; + animation_name: "Pattern_VoicePattern"; + }; + block:{ + frame_range:{ + min: 0; + max: 3600; + }; + layer_index: 1; + animation_name: "Pattern_VoiceAddIns"; + }; +}; diff --git a/app_run_tree/data/blumen_animations/awaken.foldanim b/app_run_tree/data/blumen_animations/awaken.foldanim new file mode 100644 index 0000000..b82e48f --- /dev/null +++ b/app_run_tree/data/blumen_animations/awaken.foldanim @@ -0,0 +1,88 @@ +lumenarium_animation_file; +animation_name: "awaken"; +layers_count: 3; +blocks_count: 8; +playable_range:{ + min: 0; + max: 7200; +}; +layers:{ + layer:{ + name: "[New Layer]"; + blend: "Add"; + }; + layer:{ + name: "[New Layer]"; + blend: "Add"; + }; + layer:{ + name: "[New Layer]"; + blend: "Multiply"; + }; +}; +blocks:{ + block:{ + frame_range:{ + min: 0; + max: 1363; + }; + layer_index: 0; + animation_name: "Pattern_Leafy"; + }; + block:{ + frame_range:{ + min: 1169; + max: 7200; + }; + layer_index: 0; + animation_name: "Pattern_BulbMask"; + }; + block:{ + frame_range:{ + min: 5525; + max: 7200; + }; + layer_index: 2; + animation_name: "Pattern_Wavy"; + }; + block:{ + frame_range:{ + min: 2135; + max: 2555; + }; + layer_index: 1; + animation_name: "Pattern_None"; + }; + block:{ + frame_range:{ + min: 2470; + max: 7200; + }; + layer_index: 1; + animation_name: "Pattern_StemSolid"; + }; + block:{ + frame_range:{ + min: 0; + max: 1917; + }; + layer_index: 2; + animation_name: "Pattern_Blue"; + }; + block:{ + frame_range:{ + min: 1823; + max: 3803; + }; + layer_index: 2; + animation_name: "Pattern_RainbowLoadingBar"; + }; + block:{ + frame_range:{ + min: 3670; + max: 5720; + }; + layer_index: 2; + animation_name: "Pattern_Rainbow"; + }; +}; diff --git a/app_run_tree/data/blumen_animations/off_anim.foldanim b/app_run_tree/data/blumen_animations/off_anim.foldanim new file mode 100644 index 0000000..d7a3d45 --- /dev/null +++ b/app_run_tree/data/blumen_animations/off_anim.foldanim @@ -0,0 +1,12 @@ +lumenarium_animation_file; +animation_name: "off_anim"; +layers_count: 0; +blocks_count: 0; +playable_range:{ + min: 0; + max: 2; +}; +layers:{ +}; +blocks:{ +}; diff --git a/bin/compile.bat b/bin/compile.bat new file mode 100644 index 0000000..b623ea0 --- /dev/null +++ b/bin/compile.bat @@ -0,0 +1,2 @@ +@echo off +build\build_app_msvc_win32_debug.bat \ No newline at end of file diff --git a/debug.bat b/bin/debug.bat similarity index 100% rename from debug.bat rename to bin/debug.bat diff --git a/bin/gen_incenter_cities.js b/bin/gen_incenter_cities.js new file mode 100644 index 0000000..bf78e0c --- /dev/null +++ b/bin/gen_incenter_cities.js @@ -0,0 +1,89 @@ +const fs = require("fs"); + +const IN_FILE_PATH_PRIMARY = "../run_tree/data/cities_final.json"; +const IN_FILE_PATH_SECONDARY = "../run_tree/data/cities_secondary_final.json"; +const OUT_FILE_PATH = "../src_v2/user_space/incenter_gen_cities.h" + +function print_city_desc (city, prefix, dest, gets_own_universe) +{ + const city_ascii = city.city_ascii + .toLowerCase() + .replaceAll(' ', '_') + .replaceAll('-', '_') + .replaceAll('\'', '') + .replaceAll('`', ''); + + const city_id = `${prefix}_${city_ascii}`; + const { lat, lng } = city; + + dest.enum_out += ` ${city_id} = ${dest.enum_counter++},\n`; + + const universe = gets_own_universe ? city_id : "incenter_secondary_city_universe"; + + dest.desc_out += ` [${city_id}] = { + .id = ${city_id}, + .lat = ${lat}, + .lon = ${lng}, + .sacn_universe = ${universe}, + },\n`; + + dest.strings_out += ` [${city_id}] = "${city_id}",\n`; +} + +function main () +{ + const primary_file = fs.readFileSync(IN_FILE_PATH_PRIMARY, {}); + const primary_json = JSON.parse(primary_file); + + const secondary_file = fs.readFileSync(IN_FILE_PATH_SECONDARY, {}); + const secondary_json = JSON.parse(secondary_file); + + let out = "// NOTE: This file is autogenerated by csv_to_cstruct.js\n"; + + let enum_counter = 0; + let enum_out = "// NOTE: These are values for Incenter_City_Id\nenum {\n"; + enum_out += ` city_black_rock = ${enum_counter++},\n`; + + let desc_out = "global Incenter_City_Desc city_descs[] = {\n"; + + let strings_out = "global char* city_strings[] = {\n"; + + let dest = { + enum_counter, + enum_out, + desc_out, + strings_out, + }; + + primary_json.forEach((city) => { + print_city_desc(city, "city", dest, true); + }); + + // Add Black Rock City + dest.desc_out += `\n // Black Rock City\n [city_black_rock] = { + .id = city_black_rock, + .lat = -90.0f, + .lon = 0, + .sacn_universe = city_black_rock, + },\n`; + + dest.strings_out += ` [city_black_rock] = "city_black_rock",\n`; + dest.enum_out += " city_count,\n"; + dest.enum_out += " city_secondary_first = city_count + 1,\n"; + + secondary_json.forEach((city) => { + print_city_desc(city, "city_secondary", dest, false); + }); + + dest.enum_out += " city_secondary_count,\n"; + dest.enum_out += "};\n\n"; + dest.desc_out += "};\n\n"; + dest.strings_out += "};\n\n"; + + out += dest.enum_out; + out += dest.desc_out; + out += dest.strings_out; + fs.writeFileSync(OUT_FILE_PATH, out, {}); +} + +main(); diff --git a/run.bat b/bin/run.bat similarity index 100% rename from run.bat rename to bin/run.bat diff --git a/build/build.sh b/build/build.sh new file mode 100755 index 0000000..832c948 --- /dev/null +++ b/build/build.sh @@ -0,0 +1,9 @@ +set -e + +SCRIPT_REL_DIR=$(dirname "${BASH_SOURCE[0]}") +$SCRIPT_REL_DIR/build_.sh debug osx arm64 +# $SCRIPT_REL_DIR/build_.sh debug wasm intel + +# pushd "run_tree/raspi/arm64/debug" +# clang -o lumenarium /home/pi/dev/Lumenarium/src_v2/platform/raspi/lumenarium_first_raspi.c -lm +# popd diff --git a/build/build_.sh b/build/build_.sh new file mode 100755 index 0000000..68daf04 --- /dev/null +++ b/build/build_.sh @@ -0,0 +1,378 @@ +#!/bin/bash + +# Ensure an error makes the script bail +set -e + +# -------------------------------------------- +# Usage + +print_usage () { + echo + echo Build Command Syntax: + echo " $0 [mode] [platform] [arch]" + echo + echo "Release Mode Options:" + echo " debug" + echo " prod" + echo + echo "Platform Options:" + echo " win32" + echo " osx" + echo " wasm" + echo " raspi" + echo + echo "Arch Options: (architecture)" + echo " intel (valid with Platform Win32 and OSX) (default)" + echo " arm64 (only valid for Platform OSX)" +} + +# -------------------------------------------- +# Arguments +MODE=$1 +PLATFORM=$2 +ARCH=$3 +PACKAGE=$4 + +if [ "${MODE}" == "" ] | [ "${PLATFORM}" == "" ] +then + print_usage + exit 0 +fi + +# Default to Intel architecture if none provided +if [ "${ARCH}" == "" ] +then + ARCH="intel" +fi + +if [ "${ARCH}" != "intel" ] && [ "${ARCH}" != "arm64" ] +then + echo "Uknown target architecture: ${ARCH}" + print_usage + exit 0 + +fi + +# -------------------------------------------- +# Utilities + +pushdir () { + command pushd "$@" > /dev/null +} + +popdir () { + command popd "$@" > /dev/null +} + +add_flag () { + local -n ref=$1 + ref="$ref $2" +} + +# -------------------------------------------- +# Getting Project Path +# +# Project is stored in PROJECT_PATH + +SCRIPT_REL_DIR=$(dirname "${BASH_SOURCE[0]}") +pushdir $SCRIPT_REL_DIR +pushdir .. +PROJECT_PATH=$(pwd) +popdir +popdir + +# -------------------------------------------- +# Platform/Mode Specific Variables + +# Compiler Selection + +Compiler_win32="cl" +Compiler_osx="clang" +Compiler_raspi="clang" +WasiSdk="/c/drive/apps/wasi-sdk" +Compiler_wasm="$WasiSdk/bin/clang++" +Compiler_linux="clang++" + +# Platform Entry Points + +PlatformEntry_win32="src_v2/platform/win32/lumenarium_first_win32.cpp" +PlatformEntry_osx="src_v2/platform/osx/lumenarium_first_osx.c" +PlatformEntry_wasm="src_v2/platform/wasm/lumenarium_first_wasm.cpp" +PlatformEntry_linux="src_v2/platform/linux/lumenarium_first_linux.cpp" +PlatformEntry_raspi="src_v2/platform/raspi/lumenarium_first_raspi.c" + +# Intermediate Outputs + +CompilerOutput_win32="lumenarium.o" +CompilerOutput_osx="lumenarium" +CompilerOutput_wasm="lumenarium.wasm" +CompilerOutput_linux="" +CompilerOutput_raspi="lumenarium" + +# Executables + +LinkerOutput_win32="lumenarium.exe" +LinkerOutput_osx="lumenarium" +LinkerOutput_wasm="lumenarium.wasm" +LinkerOutput_linux="" +LinkerOutput_raspi="lumenarium" + +# Wasm Sys Root +WasmSysRoot="${PROJECT_PATH}/src_v2/platform/wasm/sysroot/" + +# Compiler Flags + +CompilerFlags_win32="-nologo" +CompilerFlags_win32+=" -FC" # display errors with full path +CompilerFlags_win32+=" -WX" # treat warnings as errors +CompilerFlags_win32+=" -W4" # output warning level +CompilerFlags_win32+=" -Z7" # generate C compatible debug info +# CompilerFlags_win32+="-Oi" # generate intrinsic functions +# CompilerFlags_win32+="-MTd" # create a debug multithreaded exe w/ Libcmtd.lib +# CompilerFlags_win32+="-fp:fast" # fast floating point model +CompilerFlags_win32+=" -wd4505" # +CompilerFlags_win32+=" -wd4100" # +CompilerFlags_win32+=" -wd4189" # +CompilerFlags_win32+=" -wd4702" # +CompilerFlags_win32+=" -wd4996" # _CRT_SECURE_NO_WARNINGS + +CompilerFlags_osx="" + +CompilerFlags_wasm="" +CompilerFlags_wasm+=" -Wno-writable-strings" # +CompilerFlags_wasm+=" --target=wasm32" # +CompilerFlags_wasm+=" -nostdlib" # +CompilerFlags_wasm+=" -Wl,--no-entry" # +CompilerFlags_wasm+=" -Wl,--allow-undefined" # +CompilerFlags_wasm+=" -Wl,--export-all" # + +CompilerFlags_linux=" -pthread" + +CompilerFlags_raspi=" -pthread" # "--target=arm-rpi-linux-gnueabihf" # "--target=arm-linux-gnueabihf" #target +CompilerFlags_raspi+=" -lm" # link with local system math libraries + + +CompilerFlags_DEBUG_win32="" +CompilerFlags_DEBUG_win32+=" -Od" # +CompilerFlags_DEBUG_win32+=" -Zi" # +CompilerFlags_DEBUG_win32+=" -DDEBUG" # +# add_flag CompilerFlags_DEBUG_win32 "-DPRINT_ASSERTS" + +CompilerFlags_DEBUG="-O0" +CompilerFlags_DEBUG+=" -g" # +CompilerFlags_DEBUG+=" -DDEBUG" # +if [ "${PLATFORM}" != "raspi" ] +then + CompilerFlags_DEBUG+=" -fsanitize=address" #address sanitizer +fi + +CompilerFlags_PROD=" -O3" + +# Compiler flags that no matter what, we want to define +# for the most part these pass the build parameters into the executable +CompilerFlags_common=" -DPLATFORM_${PLATFORM}=1 -DMODE_${MODE}=1 -DARCH_${ARCH}=1" + +# Linker Flags + +LinkerFlags_win32=" -NOLOGO" +LinkerFlags_win32+=" -incremental:no" # +LinkerFlags_win32+=" -subsystem:windows" # +# add_flag LinkerFlags_win32 "-entry:WinMain" # +LinkerFlags_win32+=" -opt:ref" # eliminate functions that are never referenced + +LinkerFlags_osx="" + +LinkerFlags_wasm="--no-entry" +LinkerFlags_wasm+=" --export-dynamic" # +LinkerFlags_wasm+=" --unresolved-symbols=import-functions" # + +LinkerFlags_linux="" +LinkerFlags_raspi="-fuse-ld=lld" + +LinkerFlags_DEBUG="-debug" +LinkerFlags_PROD="" + +# Linker Libs + +LinkerLibs_win32="user32.lib kernel32.lib gdi32.lib opengl32.lib" +# winmm.lib gdi32.lib dsound.lib Ws2_32.lib Comdlg32.lib Winspool.lib" + +LinkerLibs_osx="-framework OpenGL -framework Cocoa -framework IOKit ${PROJECT_PATH}/src_v2/libs/glfw_osx/lib-universal/libglfw3.a" +LinkerLibs_wasm="" +LinkerLibs_linux="" +LinkerLibs_raspi="" + +# -------------------------------------------- +# Varible Selection + +# Select Platform Variables + +if [ "${PLATFORM}" == "win32" ] +then + Compiler=$Compiler_win32 + PlatformEntry=$PlatformEntry_win32 + CompilerFlags=$CompilerFlags_win32 + CompilerOutput=$CompilerOutput_win32 + LinkerOutput=$LinkerOutput_win32 + LinkerFlags=$LinkerFlags_win32 + LinkerLibs=$LinkerLibs_win32 + +elif [ "${PLATFORM}" == "osx" ] +then + Compiler=$Compiler_osx + PlatformEntry=$PlatformEntry_osx + CompilerFlags=$CompilerFlags_osx + CompilerOutput=$CompilerOutput_osx + LinkerOutput=$LinkerOutput_osx + LinkerFlags=$LinkerFlags_osx + LinkerLibs=$LinkerLibs_osx + + if [ "${ARCH}" == "arm64" ] + then + CompilerFlags="${CompilerFlags} -arch arm64" + elif [ "${ARCH}" == "intel" ] + then + CompilerFlags="${CompilerFlags} -arch x86_64" + else + echo "ERROR: Unrecognized Arch: ${ARCH}" + exit 0 + fi + +elif [ "${PLATFORM}" == "wasm" ] +then + Compiler=$Compiler_wasm + PlatformEntry=$PlatformEntry_wasm + CompilerFlags=$CompilerFlags_wasm + CompilerOutput=$CompilerOutput_wasm + LinkerOutput=$LinkerOutput_wasm + LinkerFlags=$LinkerFlags_wasm + LinkerLibs=$LinkerLibs_wasm + +elif [ "${PLATFORM}" == "linux" ] +then + Compiler=$Compiler_linux + PlatformEntry=$PlatformEntry_linux + CompilerFlags=$CompilerFlags_linux + CompilerOutput=$CompilerOutput_linux + LinkerOutput=$LinkerOutput_linux + LinkerFlags=$LinkerFlags_linux + LinkerLibs=$LinkerLibs_linux + +elif [ "${PLATFORM}" == "raspi" ] +then + Compiler=$Compiler_raspi + PlatformEntry=$PlatformEntry_raspi + CompilerFlags=$CompilerFlags_raspi + CompilerOutput=$CompilerOutput_raspi + LinkerOutput=$LinkerOutput_raspi + LinkerFlags=$LinkerFlags_raspi + LinkerLibs=$LinkerLibs_raspi +else + echo "Attempting to build for an unknown platform: ${PLATFORM}" + print_usage + exit 0 + +fi + +# Select Release Mode Variables + +if [ "${MODE}" == "debug" ] +then + if [ $PLATFORM == "win32" ] + then + CompilerFlags="${CompilerFlags} ${CompilerFlags_DEBUG_win32}" + else + CompilerFlags="${CompilerFlags} ${CompilerFlags_DEBUG}" + fi + + LinkerFlags="${LinkerFlags} ${LinkerFlags_DEBUG}" + +elif [ "${MODE}" == "prod" ] +then + CompilerFlags="${CompilerFlags} ${CompilerFlags_PROD}" + LinkerFlags="${LinkerFlags} ${LinkerFlags_PROD}" + +else + echo "Attempting to build for an unknown release mode: ${MODE}" + print_usage + exit 0 + +fi + +# Common Flags +CompilerFlags="${CompilerFlags} ${CompilerFlags_common}" + +# -------------------------------------------- +# Build Path Construction +# +# This determines where the generated executable will +# be located. In general, it can be found at +# project_path/run_tree/platform/arch/release_mode/lumenarium.exe +# +# This section also ensures that the path requested actually exists + +BuildDir="${PROJECT_PATH}/run_tree/${PLATFORM}/${ARCH}/${MODE}" +EntryPath="${PROJECT_PATH}/${PlatformEntry}" + +# Exception for wasm, which doesn't care about cpu architecture +if [ $PLATFORM == "wasm" ] +then + BuildDir="${PROJECT_PATH}/run_tree/${PLATFORM}/${MODE}" + +fi + +# Make the build directory, +# "-p" flag makes it make the entire tree, and not emit errors if it +# exists. +mkdir -p "${BuildDir}" + +# -------------------------------------------- +# Compilation + +echo "Building To: ${BuildDir}/${LinkerOutput}" +echo +pushdir $BuildDir + +echo "Cleaning: ${CompilerOutput} and ${LinkerOutput}" +rm -rf ${CompilerOutput} ${LinkerOutput} + +echo "COMPILING..." +if [ $PLATFORM == "win32" ] +then + $Compiler \ + $CompilerFlags \ + $EntryPath \ + -link \ + $LinkerFlags \ + $LinkerLibs \ + -OUT:${LinkerOutput} + +elif [ $PLATFORM == "wasm" ] +then + $Compiler \ + $CompilerFlags \ + -o $LinkerOutput \ + $EntryPath + cp \ + "${PROJECT_PATH}/src_v2/platform/wasm/lumenarium_wasm_imports.js" \ + ./lumenarium_wasm_imports.js + +else + + # Preprocessing Steps + ConvertCsvEntry="${PROJECT_PATH}/src_v2/tools/convert_csv.c" + $Compiler \ + -o convert_csv \ + $CompilerFlags \ + $ConvertCsvEntry \ + $LinkerLibs + + ./convert_csv + + echo "$Compiler -o $LinkerOutput $CompilerFlags $EntryPath $LinkerLibs" + $Compiler -o $LinkerOutput $CompilerFlags $EntryPath $LinkerLibs + +fi + +echo "Finished..." +popdir diff --git a/build/build_app_msvc_win32_debug.bat b/build/build_app_msvc_win32_debug.bat index d69d5db..9f523a3 100644 --- a/build/build_app_msvc_win32_debug.bat +++ b/build/build_app_msvc_win32_debug.bat @@ -8,7 +8,7 @@ call %MyPath%\setup_cl.bat SET CommonCompilerFlags=-nologo -DDEBUG=1 -DPLATFORM_WINDOWS -FC -WX -W4 -Z7 -Oi -GR- -EHsc -EHa- -MTd -fp:fast -fp:except- -IC:\programs-dev\gs_libs\src -SET CommonCompilerFlags=-wd4127 -wd4702 -wd4101 -wd4505 -wd4100 -wd4189 -wd4244 -wd4201 -wd4996 -I%CommonLibs% -O2 %CommonCompilerFlags% +SET CommonCompilerFlags=-wd4127 -wd4702 -wd4101 -wd4505 -wd4100 -wd4189 -wd4244 -wd4201 -wd4996 -I%CommonLibs% -Od %CommonCompilerFlags% SET CommonLinkerFlags= -opt:ref -incremental:no @@ -20,20 +20,27 @@ del *.pdb > NUL 2> NUL echo WAITING FOR PDB TO WRITE > lock.tmp -cl %CommonCompilerFlags% %SourceCodePath%\foldhaus_app.cpp /Fefoldhaus.dll /LD /link %CommonLinkerFlags% %DLLExports% +cl %CommonCompilerFlags% %SourceCodePath%\foldhaus_app.cpp /Fefoldhaus.dll /LD /link %CommoLinkerFlags% %DLLExports% SET LastError=%ERRORLEVEL% del lock.tmp -cl %CommonCompilerFlags% %SourceCodePath%\platform_win32\win32_foldhaus.cpp /link %CommonLinkerFlags% user32.lib winmm.lib gdi32.lib opengl32.lib dsound.lib Ws2_32.lib Comdlg32.lib +cl %CommonCompilerFlags% %SourceCodePath%\platform_win32\win32_foldhaus.cpp /link %CommonLinkerFlags% user32.lib winmm.lib gdi32.lib opengl32.lib dsound.lib Ws2_32.lib Comdlg32.lib Winspool.lib REM COMPILE UTILITY EXES -cl %CommonCompilerFlags% %ProjectDevPath%\src\serial_monitor\first.cpp /Feserial_monitor.exe /link %CommonLinkerFlags% user32.lib winmm.lib gdi32.lib +cl %CommonCompilerFlags% %ProjectDevPath%\src\serial_monitor\first.cpp /Feserial_monitor.exe /link %CommonLinkerFlags% user32.lib winmm.lib gdi32.lib Winspool.lib cl %CommonCompilerFlags% %ProjectDevPath%\src\sculpture_gen\gen_blumen_lumen.cpp /Fegen_blumen_lumen.exe /link %CommonLinkerFlags% user32.lib winmm.lib gdi32.lib +REM COMPILE AND RUN TESTS +cl %CommonCompilerFlags% %ProjectDevPath%\src\tests\sanity_tests.cpp /Fesanity_tests.exe /link %CommonLinkerFlags% user32.lib winmm.lib gdi32.lib + +ECHO SANITY TESTS BEGIN +sanity_tests.exe +ECHO SANITY TESTS END + popd call %MyPath%\_postbuild_win32.bat \ No newline at end of file diff --git a/msdev.bat b/msdev.bat deleted file mode 100644 index 31ca5aa..0000000 --- a/msdev.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -remedybg build\win32_foldhaus.rdbg \ No newline at end of file diff --git a/project.4coder b/project.4coder index 51d1801..c48210c 100644 --- a/project.4coder +++ b/project.4coder @@ -1,39 +1,49 @@ version(1); project_name = "main.exe"; patterns = { -"*.c", -"*.cpp", -"*.h", -"*.m", -"*.bat", -"*.sh", -"*.4coder", + "*.js", + "*.c", + "*.cpp", + "*.h", + "*.m", + "*.bat", + "*.sh", + "*.4coder", }; blacklist_patterns = { -".*", + ".*", }; load_paths_base = { - { "src", .relative = true, .recursive = true, }, - { "meta", .relative = true, .recursive = true, }, - { "gs_libs", .relative = true, .recursive = true, }, + { ".", .relative = true, .recursive = false, }, + { "build", .relative = true, .recursive = false, }, +// { "src", .relative = true, .recursive = true, }, + { "src_v2", .relative = true, .recursive = true, }, + { "meta", .relative = true, .recursive = true, }, + { "gs_libs", .relative = true, .recursive = true, }, }; load_paths = { - { load_paths_base, .os = "win", }, - { load_paths_base, .os = "linux", }, - { load_paths_base, .os = "mac", }, + { load_paths_base, .os = "win", }, + { load_paths_base, .os = "linux", }, + { load_paths_base, .os = "mac", }, }; +enable_virtual_whitespace = true; command_list = { - { .name = "build_application", - .out = "*app compilation*", .footer_panel = false, .save_dirty_files = true, - .cmd = { { "build\build_app_msvc_win32_debug.bat" , .os = "win" }, + { .name = "build_application", + .out = "*compilation*", .footer_panel = false, .save_dirty_files = true, + .cmd = { { "build\build_app_msvc_win32_debug.bat" , .os = "win" }, { "./build.sh", .os = "linux" }, { "./build.sh", .os = "mac" }, }, }, - { .name = "build_meta", - .out = "*meta compilation*", .footer_panel = false, .save_dirty_files = true, - .cmd = { { "build\build_meta_msvc_win32_debug.bat" , .os = "win" }, + { .name = "build_meta", + .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, + .cmd = { { "build\build_meta_msvc_win32_debug.bat" , .os = "win" }, { "./build_meta.sh", .os = "linux" }, { "./build_meta.sh", .os = "mac" }, }, }, + { .name = "build_v2", + .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, + .cmd = { { "bash build\build.sh" , .os = "win" }, + { "build/build.sh", .os = "linux" }, + { "build/build.sh", .os = "mac" }, }, }, }; -fkey_command[1] = "build_application"; +fkey_command[1] = "build_v2"; fkey_command[2] = "build_meta"; diff --git a/run_tree/data/cities_final.json b/run_tree/data/cities_final.json new file mode 100644 index 0000000..f489ff9 --- /dev/null +++ b/run_tree/data/cities_final.json @@ -0,0 +1,613 @@ +[ + { + "city": "Bucharest", + "city_ascii": "Bucharest", + "lat": 44.4, + "lng": 26.0833, + "country": "Romania", + "iso2": "RO", + "iso3": "ROU", + "admin_name": "Bucureşti", + "capital": "primary", + "population": 1883425, + "id": 1642414442 + }, + { + "city": "Brisbane", + "city_ascii": "Brisbane", + "lat": -27.4678, + "lng": 153.0281, + "country": "Australia", + "iso2": "AU", + "iso3": "AUS", + "admin_name": "Queensland", + "capital": "admin", + "population": 2360241, + "id": 1036192929 + }, + { + "city": "Chengdu", + "city_ascii": "Chengdu", + "lat": 30.66, + "lng": 104.0633, + "country": "China", + "iso2": "CN", + "iso3": "CHN", + "admin_name": "Sichuan", + "capital": "admin", + "population": 11920000, + "id": 1156421555 + }, + { + "city": "New Delhi", + "city_ascii": "New Delhi", + "lat": 28.6139, + "lng": 77.209, + "country": "India", + "iso2": "IN", + "iso3": "IND", + "admin_name": "Delhi", + "capital": "primary", + "population": 249998, + "id": 1356215164 + }, + { + "city": "Paris", + "city_ascii": "Paris", + "lat": 48.8566, + "lng": 2.3522, + "country": "France", + "iso2": "FR", + "iso3": "FRA", + "admin_name": "Île-de-France", + "capital": "primary", + "population": 11027000, + "id": 1250015082 + }, + { + "city": "San Francisco", + "city_ascii": "San Francisco", + "lat": 37.7562, + "lng": -122.443, + "country": "United States", + "iso2": "US", + "iso3": "USA", + "admin_name": "California", + "capital": "", + "population": 3592294, + "id": 1840021543 + }, + { + "city": "Denver", + "city_ascii": "Denver", + "lat": 39.7621, + "lng": -104.8759, + "country": "United States", + "iso2": "US", + "iso3": "USA", + "admin_name": "Colorado", + "capital": "admin", + "population": 2876625, + "id": 1840018789 + }, + { + "city": "Ankara", + "city_ascii": "Ankara", + "lat": 39.93, + "lng": 32.85, + "country": "Turkey", + "iso2": "TR", + "iso3": "TUR", + "admin_name": "Ankara", + "capital": "primary", + "population": 77168, + "id": 1792572891 + }, + { + "city": "Harare", + "city_ascii": "Harare", + "lat": -17.8292, + "lng": 31.0522, + "country": "Zimbabwe", + "iso2": "ZW", + "iso3": "ZWE", + "admin_name": "Harare", + "capital": "primary", + "population": 2150000, + "id": 1716196799 + }, + { + "city": "Hanoi", + "city_ascii": "Hanoi", + "lat": 21.0245, + "lng": 105.8412, + "country": "Vietnam", + "iso2": "VN", + "iso3": "VNM", + "admin_name": "Hà Nội", + "capital": "primary", + "population": 8246600, + "id": 1704413791 + }, + { + "city": "Washington", + "city_ascii": "Washington", + "lat": 38.9047, + "lng": -77.0163, + "country": "United States", + "iso2": "US", + "iso3": "USA", + "admin_name": "District of Columbia", + "capital": "primary", + "population": 5379184, + "id": 1840006060 + }, + { + "city": "Bangkok", + "city_ascii": "Bangkok", + "lat": 13.75, + "lng": 100.5167, + "country": "Thailand", + "iso2": "TH", + "iso3": "THA", + "admin_name": "Krung Thep Maha Nakhon", + "capital": "primary", + "population": 17573000, + "id": 1764068610 + }, + { + "city": "Tunis", + "city_ascii": "Tunis", + "lat": 36.8008, + "lng": 10.18, + "country": "Tunisia", + "iso2": "TN", + "iso3": "TUN", + "admin_name": "Tunis", + "capital": "primary", + "population": 1056247, + "id": 1788742103 + }, + { + "city": "Seoul", + "city_ascii": "Seoul", + "lat": 37.56, + "lng": 126.99, + "country": "South Korea", + "iso2": "KR", + "iso3": "KOR", + "admin_name": "Seoul", + "capital": "primary", + "population": 22394000, + "id": 1410836482 + }, + { + "city": "Belgrade", + "city_ascii": "Belgrade", + "lat": 44.8167, + "lng": 20.4667, + "country": "Serbia", + "iso2": "RS", + "iso3": "SRB", + "admin_name": "Beograd", + "capital": "primary", + "population": 1378682, + "id": 1688374696 + }, + { + "city": "Moscow", + "city_ascii": "Moscow", + "lat": 55.7558, + "lng": 37.6178, + "country": "Russia", + "iso2": "RU", + "iso3": "RUS", + "admin_name": "Moskva", + "capital": "primary", + "population": 17693000, + "id": 1643318494 + }, + { + "city": "Lima", + "city_ascii": "Lima", + "lat": -12.06, + "lng": -77.0375, + "country": "Peru", + "iso2": "PE", + "iso3": "PER", + "admin_name": "Lima", + "capital": "primary", + "population": 8992000, + "id": 1604728603 + }, + { + "city": "Islamabad", + "city_ascii": "Islamabad", + "lat": 33.6989, + "lng": 73.0369, + "country": "Pakistan", + "iso2": "PK", + "iso3": "PAK", + "admin_name": "Islāmābād", + "capital": "primary", + "population": 1014825, + "id": 1586306717 + }, + { + "city": "Abuja", + "city_ascii": "Abuja", + "lat": 9.0556, + "lng": 7.4914, + "country": "Nigeria", + "iso2": "NG", + "iso3": "NGA", + "admin_name": "Federal Capital Territory", + "capital": "primary", + "population": 1235880, + "id": 1566342270 + }, + { + "city": "Managua", + "city_ascii": "Managua", + "lat": 12.15, + "lng": -86.2667, + "country": "Nicaragua", + "iso2": "NI", + "iso3": "NIC", + "admin_name": "Managua", + "capital": "primary", + "population": 1028808, + "id": 1558296252 + }, + { + "city": "Amsterdam", + "city_ascii": "Amsterdam", + "lat": 52.3667, + "lng": 4.8833, + "country": "Netherlands", + "iso2": "NL", + "iso3": "NLD", + "admin_name": "Noord-Holland", + "capital": "primary", + "population": 862965, + "id": 1528355309 + }, + { + "city": "Rabat", + "city_ascii": "Rabat", + "lat": 34.0253, + "lng": -6.8361, + "country": "Morocco", + "iso2": "MA", + "iso3": "MAR", + "admin_name": "Rabat-Salé-Kénitra", + "capital": "primary", + "population": 572717, + "id": 1504023252 + }, + { + "city": "Ulaanbaatar", + "city_ascii": "Ulaanbaatar", + "lat": 47.9214, + "lng": 106.9055, + "country": "Mongolia", + "iso2": "MN", + "iso3": "MNG", + "admin_name": "Ulaanbaatar", + "capital": "primary", + "population": 1396288, + "id": 1496024767 + }, + { + "city": "Mexico City", + "city_ascii": "Mexico City", + "lat": 19.4333, + "lng": -99.1333, + "country": "Mexico", + "iso2": "MX", + "iso3": "MEX", + "admin_name": "Ciudad de México", + "capital": "primary", + "population": 21505000, + "id": 1484247881 + }, + { + "city": "Nairobi", + "city_ascii": "Nairobi", + "lat": -1.2864, + "lng": 36.8172, + "country": "Kenya", + "iso2": "KE", + "iso3": "KEN", + "admin_name": "Nairobi City", + "capital": "primary", + "population": 5545000, + "id": 1404000661 + }, + { + "city": "Tokyo", + "city_ascii": "Tokyo", + "lat": 35.6839, + "lng": 139.7744, + "country": "Japan", + "iso2": "JP", + "iso3": "JPN", + "admin_name": "Tōkyō", + "capital": "primary", + "population": 39105000, + "id": 1392685764 + }, + { + "city": "Baghdad", + "city_ascii": "Baghdad", + "lat": 33.35, + "lng": 44.4167, + "country": "Iraq", + "iso2": "IQ", + "iso3": "IRQ", + "admin_name": "Baghdād", + "capital": "primary", + "population": 6107000, + "id": 1368596238 + }, + { + "city": "Tehran", + "city_ascii": "Tehran", + "lat": 35.7, + "lng": 51.4167, + "country": "Iran", + "iso2": "IR", + "iso3": "IRN", + "admin_name": "Tehrān", + "capital": "primary", + "population": 13819000, + "id": 1364305026 + }, + { + "city": "Jakarta", + "city_ascii": "Jakarta", + "lat": -6.2146, + "lng": 106.8451, + "country": "Indonesia", + "iso2": "ID", + "iso3": "IDN", + "admin_name": "Jakarta", + "capital": "primary", + "population": 35362000, + "id": 1360771077 + }, + { + "city": "Guatemala City", + "city_ascii": "Guatemala City", + "lat": 14.6099, + "lng": -90.5252, + "country": "Guatemala", + "iso2": "GT", + "iso3": "GTM", + "admin_name": "Guatemala", + "capital": "primary", + "population": 2934841, + "id": 1320197916 + }, + { + "city": "Berlin", + "city_ascii": "Berlin", + "lat": 52.5167, + "lng": 13.3833, + "country": "Germany", + "iso2": "DE", + "iso3": "DEU", + "admin_name": "Berlin", + "capital": "primary", + "population": 3664088, + "id": 1276451290 + }, + { + "city": "Addis Ababa", + "city_ascii": "Addis Ababa", + "lat": 9.0272, + "lng": 38.7369, + "country": "Ethiopia", + "iso2": "ET", + "iso3": "ETH", + "admin_name": "Ādīs Ābeba", + "capital": "primary", + "population": 3041002, + "id": 1231824991 + }, + { + "city": "Cairo", + "city_ascii": "Cairo", + "lat": 30.0444, + "lng": 31.2358, + "country": "Egypt", + "iso2": "EG", + "iso3": "EGY", + "admin_name": "Al Qāhirah", + "capital": "primary", + "population": 19787000, + "id": 1818253931 + }, + { + "city": "Quito", + "city_ascii": "Quito", + "lat": -0.22, + "lng": -78.5125, + "country": "Ecuador", + "iso2": "EC", + "iso3": "ECU", + "admin_name": "Pichincha", + "capital": "primary", + "population": 2011388, + "id": 1218441993 + }, + { + "city": "Bogotá", + "city_ascii": "Bogota", + "lat": 4.6126, + "lng": -74.0705, + "country": "Colombia", + "iso2": "CO", + "iso3": "COL", + "admin_name": "Bogotá", + "capital": "primary", + "population": 7743955, + "id": 1170483426 + }, + { + "city": "Beijing", + "city_ascii": "Beijing", + "lat": 39.904, + "lng": 116.4075, + "country": "China", + "iso2": "CN", + "iso3": "CHN", + "admin_name": "Beijing", + "capital": "primary", + "population": 19437000, + "id": 1156228865 + }, + { + "city": "Accra", + "city_ascii": "Accra", + "lat": 5.6037, + "lng": -0.187, + "country": "Ghana", + "iso2": "GH", + "iso3": "GHA", + "admin_name": "Greater Accra", + "capital": "primary", + "population": 2291352, + "id": 1288299415 + }, + { + "city": "Ottawa", + "city_ascii": "Ottawa", + "lat": 45.4247, + "lng": -75.695, + "country": "Canada", + "iso2": "CA", + "iso3": "CAN", + "admin_name": "Ontario", + "capital": "primary", + "population": 989567, + "id": 1124399363 + }, + { + "city": "Brasília", + "city_ascii": "Brasilia", + "lat": -15.7939, + "lng": -47.8828, + "country": "Brazil", + "iso2": "BR", + "iso3": "BRA", + "admin_name": "Distrito Federal", + "capital": "primary", + "population": 3015268, + "id": 1076144436 + }, + { + "city": "La Paz", + "city_ascii": "La Paz", + "lat": -16.4942, + "lng": -68.1475, + "country": "Bolivia", + "iso2": "BO", + "iso3": "BOL", + "admin_name": "La Paz", + "capital": "primary", + "population": 2867504, + "id": 1068000064 + }, + { + "city": "Dhaka", + "city_ascii": "Dhaka", + "lat": 23.7289, + "lng": 90.3944, + "country": "Bangladesh", + "iso2": "BD", + "iso3": "BGD", + "admin_name": "Dhaka", + "capital": "primary", + "population": 16839000, + "id": 1050529279 + }, + { + "city": "Yerevan", + "city_ascii": "Yerevan", + "lat": 40.1814, + "lng": 44.5144, + "country": "Armenia", + "iso2": "AM", + "iso3": "ARM", + "admin_name": "Yerevan", + "capital": "primary", + "population": 1075800, + "id": 1051074169 + }, + { + "city": "Chicago", + "city_ascii": "Chicago", + "lat": 41.8373, + "lng": -87.6862, + "country": "United States", + "iso2": "US", + "iso3": "USA", + "admin_name": "Illinois", + "capital": "", + "population": 8604203, + "id": 1840000494 + }, + { + "city": "Kyiv", + "city_ascii": "Kyiv", + "lat": 50.45, + "lng": 30.5236, + "country": "Ukraine", + "iso2": "UA", + "iso3": "UKR", + "admin_name": "Kyyiv, Misto", + "capital": "primary", + "population": 2963199, + "id": 1804382913 + }, + { + "city": "Dubai", + "city_ascii": "Dubai", + "lat": 25.2697, + "lng": 55.3094, + "country": "United Arab Emirates", + "iso2": "AE", + "iso3": "ARE", + "admin_name": "Dubayy", + "capital": "admin", + "population": 2502715, + "id": 1784736618 + }, + { + "city": "Mumbai", + "city_ascii": "Mumbai", + "lat": 19.0758, + "lng": 72.8775, + "country": "India", + "iso2": "IN", + "iso3": "IND", + "admin_name": "Mahārāshtra", + "capital": "admin", + "population": 22186000, + "id": 1356226629 + }, + { + "city": "Madrid", + "city_ascii": "Madrid", + "lat": 40.4167, + "lng": -3.7167, + "country": "Spain", + "iso2": "ES", + "iso3": "ESP", + "admin_name": "Madrid", + "capital": "primary", + "population": 6006000, + "id": 1724616994 + } +] \ No newline at end of file diff --git a/run_tree/data/cities_secondary_final.json b/run_tree/data/cities_secondary_final.json new file mode 100644 index 0000000..33896c2 --- /dev/null +++ b/run_tree/data/cities_secondary_final.json @@ -0,0 +1,3554 @@ +[ + { + "": 17749, + "city": "Lagos", + "city_ascii": "Lagos", + "lat": 6.45, + "lng": 3.4, + "country": "Nigeria", + "iso2": "NG", + "iso3": "NGA", + "admin_name": "Lagos", + "capital": "minor", + "population": 15487000, + "id": 1566593751, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 18286, + "city": "Kinshasa", + "city_ascii": "Kinshasa", + "lat": -4.3317, + "lng": 15.3139, + "country": "Congo (Kinshasa)", + "iso2": "CD", + "iso3": "COD", + "admin_name": "Kinshasa", + "capital": "primary", + "population": 15056000, + "id": 1180000363, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 19313, + "city": "Luanda", + "city_ascii": "Luanda", + "lat": -8.8383, + "lng": 13.2344, + "country": "Angola", + "iso2": "AO", + "iso3": "AGO", + "admin_name": "Luanda", + "capital": "primary", + "population": 8883000, + "id": 1024949724, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 19441, + "city": "Dar es Salaam", + "city_ascii": "Dar es Salaam", + "lat": -6.8, + "lng": 39.2833, + "country": "Tanzania", + "iso2": "TZ", + "iso3": "TZA", + "admin_name": "Dar es Salaam", + "capital": "primary", + "population": 7461000, + "id": 1834843853, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 19717, + "city": "Khartoum", + "city_ascii": "Khartoum", + "lat": 15.6031, + "lng": 32.5265, + "country": "Sudan", + "iso2": "SD", + "iso3": "SDN", + "admin_name": "Khartoum", + "capital": "primary", + "population": 6017000, + "id": 1729268475, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 19756, + "city": "Giza", + "city_ascii": "Giza", + "lat": 29.987, + "lng": 31.2118, + "country": "Egypt", + "iso2": "EG", + "iso3": "EGY", + "admin_name": "Al Jīzah", + "capital": "admin", + "population": 5598402, + "id": 1818925479, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 23020, + "city": "Abidjan", + "city_ascii": "Abidjan", + "lat": 5.3364, + "lng": -4.0267, + "country": "Côte d'Ivoire", + "iso2": "CI", + "iso3": "CIV", + "admin_name": "Abidjan", + "capital": "primary", + "population": 4980000, + "id": 1384207980, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 25018, + "city": "Johannesburg", + "city_ascii": "Johannesburg", + "lat": -26.2044, + "lng": 28.0416, + "country": "South Africa", + "iso2": "ZA", + "iso3": "ZAF", + "admin_name": "Gauteng", + "capital": "admin", + "population": 4434827, + "id": 1710550792, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 25127, + "city": "Casablanca", + "city_ascii": "Casablanca", + "lat": 33.5992, + "lng": -7.62, + "country": "Morocco", + "iso2": "MA", + "iso3": "MAR", + "admin_name": "Casablanca-Settat", + "capital": "admin", + "population": 4370000, + "id": 1504175315, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 25967, + "city": "Algiers", + "city_ascii": "Algiers", + "lat": 36.7764, + "lng": 3.0586, + "country": "Algeria", + "iso2": "DZ", + "iso3": "DZA", + "admin_name": "Alger", + "capital": "primary", + "population": 3415811, + "id": 1012973369, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 28906, + "city": "Antananarivo", + "city_ascii": "Antananarivo", + "lat": -18.9386, + "lng": 47.5214, + "country": "Madagascar", + "iso2": "MG", + "iso3": "MDG", + "admin_name": "Antananarivo", + "capital": "primary", + "population": 2610000, + "id": 1450978461, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 29137, + "city": "Ouagadougou", + "city_ascii": "Ouagadougou", + "lat": 12.3686, + "lng": -1.5275, + "country": "Burkina Faso", + "iso2": "BF", + "iso3": "BFA", + "admin_name": "Centre", + "capital": "primary", + "population": 2453496, + "id": 1854029208, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 29177, + "city": "Yaoundé", + "city_ascii": "Yaounde", + "lat": 3.8578, + "lng": 11.5181, + "country": "Cameroon", + "iso2": "CM", + "iso3": "CMR", + "admin_name": "Centre", + "capital": "primary", + "population": 2440462, + "id": 1120298240, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 29426, + "city": "Mogadishu", + "city_ascii": "Mogadishu", + "lat": 2.0408, + "lng": 45.3425, + "country": "Somalia", + "iso2": "SO", + "iso3": "SOM", + "admin_name": "Banaadir", + "capital": "primary", + "population": 2120000, + "id": 1706893395, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 29455, + "city": "Kumasi", + "city_ascii": "Kumasi", + "lat": 6.6833, + "lng": -1.6167, + "country": "Ghana", + "iso2": "GH", + "iso3": "GHA", + "admin_name": "Ashanti", + "capital": "admin", + "population": 2069350, + "id": 1288181103, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 29484, + "city": "Bamako", + "city_ascii": "Bamako", + "lat": 12.6458, + "lng": -7.9922, + "country": "Mali", + "iso2": "ML", + "iso3": "MLI", + "admin_name": "Bamako", + "capital": "primary", + "population": 2009109, + "id": 1466965925, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 30180, + "city": "Blantyre", + "city_ascii": "Blantyre", + "lat": -15.7861, + "lng": 35.0058, + "country": "Malawi", + "iso2": "MW", + "iso3": "MWI", + "admin_name": "Blantyre", + "capital": "admin", + "population": 1895973, + "id": 1454145012, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 32851, + "city": "Meru", + "city_ascii": "Meru", + "lat": 0.05, + "lng": 37.65, + "country": "Kenya", + "iso2": "KE", + "iso3": "KEN", + "admin_name": "Meru", + "capital": "admin", + "population": 1833000, + "id": 1404588252, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 32913, + "city": "Brazzaville", + "city_ascii": "Brazzaville", + "lat": -4.2667, + "lng": 15.2833, + "country": "Congo (Brazzaville)", + "iso2": "CG", + "iso3": "COG", + "admin_name": "Brazzaville", + "capital": "primary", + "population": 1827000, + "id": 1178340306, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 33690, + "city": "Lusaka", + "city_ascii": "Lusaka", + "lat": -15.4167, + "lng": 28.2833, + "country": "Zambia", + "iso2": "ZM", + "iso3": "ZMB", + "admin_name": "Lusaka", + "capital": "primary", + "population": 1742979, + "id": 1894157390, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 34034, + "city": "Conakry", + "city_ascii": "Conakry", + "lat": 9.538, + "lng": -13.6773, + "country": "Guinea", + "iso2": "GN", + "iso3": "GIN", + "admin_name": "Conakry", + "capital": "primary", + "population": 1667864, + "id": 1324568159, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 34063, + "city": "Kampala", + "city_ascii": "Kampala", + "lat": 0.3136, + "lng": 32.5811, + "country": "Uganda", + "iso2": "UG", + "iso3": "UGA", + "admin_name": "Kampala", + "capital": "primary", + "population": 1659600, + "id": 1800406299, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 35321, + "city": "Maputo", + "city_ascii": "Maputo", + "lat": -25.9153, + "lng": 32.5764, + "country": "Mozambique", + "iso2": "MZ", + "iso3": "MOZ", + "admin_name": "Maputo", + "capital": "primary", + "population": 1191613, + "id": 1508074843, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 35370, + "city": "Pikine", + "city_ascii": "Pikine", + "lat": 14.75, + "lng": -17.4, + "country": "Senegal", + "iso2": "SN", + "iso3": "SEN", + "admin_name": "Dakar", + "capital": "", + "population": 1170791, + "id": 1686165071, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 35392, + "city": "Kigali", + "city_ascii": "Kigali", + "lat": -1.9536, + "lng": 30.0606, + "country": "Rwanda", + "iso2": "RW", + "iso3": "RWA", + "admin_name": "Kigali", + "capital": "primary", + "population": 1156663, + "id": 1646923541, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 35511, + "city": "Tripoli", + "city_ascii": "Tripoli", + "lat": 32.8752, + "lng": 13.1875, + "country": "Libya", + "iso2": "LY", + "iso3": "LBY", + "admin_name": "Ţarābulus", + "capital": "primary", + "population": 1126000, + "id": 1434201852, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 35593, + "city": "N’Djamena", + "city_ascii": "N'Djamena", + "lat": 12.11, + "lng": 15.05, + "country": "Chad", + "iso2": "TD", + "iso3": "TCD", + "admin_name": "Ville de N’Djaména", + "capital": "primary", + "population": 1092066, + "id": 1148708596, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 35635, + "city": "Nouakchott", + "city_ascii": "Nouakchott", + "lat": 18.0858, + "lng": -15.9785, + "country": "Mauritania", + "iso2": "MR", + "iso3": "MRT", + "admin_name": "", + "capital": "primary", + "population": 1077169, + "id": 1478414984, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 35738, + "city": "Niamey", + "city_ascii": "Niamey", + "lat": 13.5086, + "lng": 2.1111, + "country": "Niger", + "iso2": "NE", + "iso3": "NER", + "admin_name": "Niamey", + "capital": "primary", + "population": 1026848, + "id": 1562932886, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 35807, + "city": "Monrovia", + "city_ascii": "Monrovia", + "lat": 6.3106, + "lng": -10.8047, + "country": "Liberia", + "iso2": "LR", + "iso3": "LBR", + "admin_name": "Montserrado", + "capital": "primary", + "population": 1021762, + "id": 1430477826, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 35891, + "city": "Asmara", + "city_ascii": "Asmara", + "lat": 15.3333, + "lng": 38.9167, + "country": "Eritrea", + "iso2": "ER", + "iso3": "ERI", + "admin_name": "Ma’ākel", + "capital": "primary", + "population": 963000, + "id": 1232791236, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 35906, + "city": "Freetown", + "city_ascii": "Freetown", + "lat": 8.4833, + "lng": -13.2331, + "country": "Sierra Leone", + "iso2": "SL", + "iso3": "SLE", + "admin_name": "Western Area", + "capital": "primary", + "population": 951000, + "id": 1694085071, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 36008, + "city": "Bangui", + "city_ascii": "Bangui", + "lat": 4.3732, + "lng": 18.5628, + "country": "Central African Republic", + "iso2": "CF", + "iso3": "CAF", + "admin_name": "Bangui", + "capital": "primary", + "population": 889231, + "id": 1140080881, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 36055, + "city": "Lomé", + "city_ascii": "Lome", + "lat": 6.1319, + "lng": 1.2228, + "country": "Togo", + "iso2": "TG", + "iso3": "TGO", + "admin_name": "Maritime", + "capital": "primary", + "population": 837437, + "id": 1768409132, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 36064, + "city": "Libreville", + "city_ascii": "Libreville", + "lat": 0.3901, + "lng": 9.4544, + "country": "Gabon", + "iso2": "GA", + "iso3": "GAB", + "admin_name": "Estuaire", + "capital": "primary", + "population": 797003, + "id": 1266952885, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 36156, + "city": "Cotonou", + "city_ascii": "Cotonou", + "lat": 6.402, + "lng": 2.5180000000000002, + "country": "Benin", + "iso2": "BJ", + "iso3": "BEN", + "admin_name": "Littoral", + "capital": "primary", + "population": 762000, + "id": 1204955174, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 36489, + "city": "Bujumbura", + "city_ascii": "Bujumbura", + "lat": -3.3825, + "lng": 29.3611, + "country": "Burundi", + "iso2": "BI", + "iso3": "BDI", + "admin_name": "Bujumbura Mairie", + "capital": "primary", + "population": 658859, + "id": 1108101689, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 37050, + "city": "Djibouti", + "city_ascii": "Djibouti", + "lat": 11.595, + "lng": 43.1481, + "country": "Djibouti", + "iso2": "DJ", + "iso3": "DJI", + "admin_name": "Djibouti", + "capital": "primary", + "population": 562000, + "id": 1262028958, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 37993, + "city": "Bissau", + "city_ascii": "Bissau", + "lat": 11.8592, + "lng": -15.5956, + "country": "Guinea-Bissau", + "iso2": "GW", + "iso3": "GNB", + "admin_name": "Bissau", + "capital": "primary", + "population": 395954, + "id": 1624168850, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38004, + "city": "Juba", + "city_ascii": "Juba", + "lat": 4.85, + "lng": 31.6, + "country": "South Sudan", + "iso2": "SS", + "iso3": "SSD", + "admin_name": "Central Equatoria", + "capital": "primary", + "population": 372410, + "id": 1728444337, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38021, + "city": "Maseru", + "city_ascii": "Maseru", + "lat": -29.31, + "lng": 27.48, + "country": "Lesotho", + "iso2": "LS", + "iso3": "LSO", + "admin_name": "Maseru", + "capital": "primary", + "population": 330790, + "id": 1426977668, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38052, + "city": "Windhoek", + "city_ascii": "Windhoek", + "lat": -22.57, + "lng": 17.0836, + "country": "Namibia", + "iso2": "", + "iso3": "NAM", + "admin_name": "Khomas", + "capital": "primary", + "population": 322500, + "id": 1516802003, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38376, + "city": "Gaborone", + "city_ascii": "Gaborone", + "lat": -24.6569, + "lng": 25.9086, + "country": "Botswana", + "iso2": "BW", + "iso3": "BWA", + "admin_name": "Gaborone", + "capital": "primary", + "population": 231626, + "id": 1072756768, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38464, + "city": "Saint-Denis", + "city_ascii": "Saint-Denis", + "lat": -20.8789, + "lng": 55.4481, + "country": "Reunion", + "iso2": "RE", + "iso3": "REU", + "admin_name": "", + "capital": "primary", + "population": 190047, + "id": 1638024662, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38466, + "city": "Malabo", + "city_ascii": "Malabo", + "lat": 3.7521, + "lng": 8.7737, + "country": "Equatorial Guinea", + "iso2": "GQ", + "iso3": "GNQ", + "admin_name": "Bioko Norte", + "capital": "primary", + "population": 187302, + "id": 1226861333, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38508, + "city": "Port Louis", + "city_ascii": "Port Louis", + "lat": -20.1667, + "lng": 57.5, + "country": "Mauritius", + "iso2": "MU", + "iso3": "MUS", + "admin_name": "Port Louis", + "capital": "primary", + "population": 149194, + "id": 1480131261, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38910, + "city": "Praia", + "city_ascii": "Praia", + "lat": 14.9177, + "lng": -23.5092, + "country": "Cabo Verde", + "iso2": "CV", + "iso3": "CPV", + "admin_name": "Praia", + "capital": "primary", + "population": 127832, + "id": 1132398770, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38934, + "city": "Moroni", + "city_ascii": "Moroni", + "lat": -11.7036, + "lng": 43.2536, + "country": "Comoros", + "iso2": "KM", + "iso3": "COM", + "admin_name": "Grande Comore", + "capital": "primary", + "population": 111329, + "id": 1174793581, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38959, + "city": "Mbabane", + "city_ascii": "Mbabane", + "lat": -26.3208, + "lng": 31.1617, + "country": "Swaziland", + "iso2": "SZ", + "iso3": "SWZ", + "admin_name": "Hhohho", + "capital": "primary", + "population": 94874, + "id": 1748811945, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 38997, + "city": "São Tomé", + "city_ascii": "Sao Tome", + "lat": 0.3333, + "lng": 6.7333, + "country": "Sao Tome And Principe", + "iso2": "ST", + "iso3": "STP", + "admin_name": "São Tomé", + "capital": "primary", + "population": 56166, + "id": 1678301324, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 39058, + "city": "Banjul", + "city_ascii": "Banjul", + "lat": 13.4531, + "lng": -16.5775, + "country": "The Gambia", + "iso2": "GM", + "iso3": "GMB", + "admin_name": "Banjul", + "capital": "primary", + "population": 31356, + "id": 1270723713, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 39067, + "city": "Mamoudzou", + "city_ascii": "Mamoudzou", + "lat": -12.7871, + "lng": 45.275, + "country": "Mayotte", + "iso2": "YT", + "iso3": "MYT", + "admin_name": "", + "capital": "primary", + "population": 32057, + "id": 1175099654, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 39072, + "city": "Victoria", + "city_ascii": "Victoria", + "lat": -4.6236, + "lng": 55.4544, + "country": "Seychelles", + "iso2": "SC", + "iso3": "SYC", + "admin_name": "English River", + "capital": "primary", + "population": 26450, + "id": 1690193579, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 39277, + "city": "Jamestown", + "city_ascii": "Jamestown", + "lat": -15.9251, + "lng": -5.7179, + "country": "Saint Helena, Ascension, And Tristan Da Cunha", + "iso2": "SH", + "iso3": "SHN", + "admin_name": "Saint Helena", + "capital": "primary", + "population": 714, + "id": 1654761576, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 41316, + "city": "Bulawayo", + "city_ascii": "Bulawayo", + "lat": -20.1667, + "lng": 28.5667, + "country": "Zimbabwe", + "iso2": "ZW", + "iso3": "ZWE", + "admin_name": "Bulawayo", + "capital": "admin", + "population": 653337, + "id": 1716032632, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 41529, + "city": "Sidi Bouzid", + "city_ascii": "Sidi Bouzid", + "lat": 35.0381, + "lng": 9.4858, + "country": "Tunisia", + "iso2": "TN", + "iso3": "TUN", + "admin_name": "Sidi Bouzid", + "capital": "admin", + "population": 429912, + "id": 1788196439, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 41767, + "city": "Nazrēt", + "city_ascii": "Nazret", + "lat": 8.55, + "lng": 39.2667, + "country": "Ethiopia", + "iso2": "ET", + "iso3": "ETH", + "admin_name": "Oromīya", + "capital": "", + "population": 324000, + "id": 1231826873, + "_merge": "left_only", + "Continent": "Africa" + }, + { + "": 0, + "city": "Delhi", + "city_ascii": "Delhi", + "lat": 28.6667, + "lng": 77.2167, + "country": "India", + "iso2": "IN", + "iso3": "IND", + "admin_name": "Delhi", + "capital": "admin", + "population": 31870000, + "id": 1356872604, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 1598, + "city": "Manila", + "city_ascii": "Manila", + "lat": 14.6, + "lng": 120.9833, + "country": "Philippines", + "iso2": "PH", + "iso3": "PHL", + "admin_name": "Manila", + "capital": "primary", + "population": 23971000, + "id": 1608618140, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 6741, + "city": "Shanghai", + "city_ascii": "Shanghai", + "lat": 31.1667, + "lng": 121.4667, + "country": "China", + "iso2": "CN", + "iso3": "CHN", + "admin_name": "Shanghai", + "capital": "admin", + "population": 22118000, + "id": 1156073548, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 16423, + "city": "Ōsaka", + "city_ascii": "Osaka", + "lat": 34.751999999999995, + "lng": 135.4582, + "country": "Japan", + "iso2": "JP", + "iso3": "JPN", + "admin_name": "Ōsaka", + "capital": "admin", + "population": 15490000, + "id": 1392419823, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 17825, + "city": "Istanbul", + "city_ascii": "Istanbul", + "lat": 41.01, + "lng": 28.9603, + "country": "Turkey", + "iso2": "TR", + "iso3": "TUR", + "admin_name": "İstanbul", + "capital": "admin", + "population": 15311000, + "id": 1792756324, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 18175, + "city": "Karachi", + "city_ascii": "Karachi", + "lat": 24.86, + "lng": 67.01, + "country": "Pakistan", + "iso2": "PK", + "iso3": "PAK", + "admin_name": "Sindh", + "capital": "admin", + "population": 15292000, + "id": 1586129469, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 18376, + "city": "Ho Chi Minh City", + "city_ascii": "Ho Chi Minh City", + "lat": 10.8167, + "lng": 106.6333, + "country": "Vietnam", + "iso2": "VN", + "iso3": "VNM", + "admin_name": "Hồ Chí Minh", + "capital": "admin", + "population": 13954000, + "id": 1704774326, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 19406, + "city": "Kuala Lumpur", + "city_ascii": "Kuala Lumpur", + "lat": 3.1478, + "lng": 101.6953, + "country": "Malaysia", + "iso2": "MY", + "iso3": "MYS", + "admin_name": "Kuala Lumpur", + "capital": "primary", + "population": 8639000, + "id": 1458988644, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 19505, + "city": "Hong Kong", + "city_ascii": "Hong Kong", + "lat": 22.3069, + "lng": 114.1831, + "country": "Hong Kong", + "iso2": "HK", + "iso3": "HKG", + "admin_name": "", + "capital": "primary", + "population": 7398000, + "id": 1344982653, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 19677, + "city": "Riyadh", + "city_ascii": "Riyadh", + "lat": 24.65, + "lng": 46.71, + "country": "Saudi Arabia", + "iso2": "SA", + "iso3": "SAU", + "admin_name": "Ar Riyāḑ", + "capital": "primary", + "population": 6889000, + "id": 1682999334, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 20850, + "city": "Rangoon", + "city_ascii": "Rangoon", + "lat": 16.795, + "lng": 96.16, + "country": "Myanmar", + "iso2": "MM", + "iso3": "MMR", + "admin_name": "Yangon", + "capital": "primary", + "population": 5430000, + "id": 1104616656, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 23019, + "city": "Singapore", + "city_ascii": "Singapore", + "lat": 1.3, + "lng": 103.8, + "country": "Singapore", + "iso2": "SG", + "iso3": "SGP", + "admin_name": "Central Singapore", + "capital": "primary", + "population": 5271000, + "id": 1702341327, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 25827, + "city": "Kabul", + "city_ascii": "Kabul", + "lat": 34.5328, + "lng": 69.1658, + "country": "Afghanistan", + "iso2": "AF", + "iso3": "AFG", + "admin_name": "Kābul", + "capital": "primary", + "population": 4273156, + "id": 1004993580, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 25872, + "city": "Amman", + "city_ascii": "Amman", + "lat": 31.95, + "lng": 35.9333, + "country": "Jordan", + "iso2": "JO", + "iso3": "JOR", + "admin_name": "Al ‘Āşimah", + "capital": "primary", + "population": 4007526, + "id": 1400522593, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 25891, + "city": "Busan", + "city_ascii": "Busan", + "lat": 35.1, + "lng": 129.0403, + "country": "South Korea", + "iso2": "KR", + "iso3": "KOR", + "admin_name": "Busan", + "capital": "admin", + "population": 3453198, + "id": 1410601465, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 26206, + "city": "Mashhad", + "city_ascii": "Mashhad", + "lat": 36.3069, + "lng": 59.6042, + "country": "Iran", + "iso2": "IR", + "iso3": "IRN", + "admin_name": "Khorāsān-e Raẕavī", + "capital": "admin", + "population": 3001184, + "id": 1364123206, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 26467, + "city": "Kuwait City", + "city_ascii": "Kuwait City", + "lat": 29.375, + "lng": 47.98, + "country": "Kuwait", + "iso2": "KW", + "iso3": "KWT", + "admin_name": "Al ‘Āşimah", + "capital": "primary", + "population": 2989000, + "id": 1414102075, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 26471, + "city": "Sanaa", + "city_ascii": "Sanaa", + "lat": 15.35, + "lng": 44.2, + "country": "Yemen", + "iso2": "YE", + "iso3": "YEM", + "admin_name": "Amānat al ‘Āşimah", + "capital": "primary", + "population": 2957000, + "id": 1887750814, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 26513, + "city": "Bandung", + "city_ascii": "Bandung", + "lat": -6.95, + "lng": 107.5667, + "country": "Indonesia", + "iso2": "ID", + "iso3": "IDN", + "admin_name": "Jawa Barat", + "capital": "admin", + "population": 2875673, + "id": 1360313023, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 28792, + "city": "Pyongyang", + "city_ascii": "Pyongyang", + "lat": 39.03, + "lng": 125.73, + "country": "North Korea", + "iso2": "KP", + "iso3": "PRK", + "admin_name": "P’yŏngyang", + "capital": "primary", + "population": 2863000, + "id": 1408738594, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 28935, + "city": "Chattogram", + "city_ascii": "Chattogram", + "lat": 22.335, + "lng": 91.8325, + "country": "Bangladesh", + "iso2": "BD", + "iso3": "BGD", + "admin_name": "Chittagong", + "capital": "admin", + "population": 2581643, + "id": 1050830722, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 29078, + "city": "Tashkent", + "city_ascii": "Tashkent", + "lat": 41.3, + "lng": 69.2667, + "country": "Uzbekistan", + "iso2": "UZ", + "iso3": "UZB", + "admin_name": "Toshkent", + "capital": "primary", + "population": 2497900, + "id": 1860331871, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 29213, + "city": "Baku", + "city_ascii": "Baku", + "lat": 40.3667, + "lng": 49.8352, + "country": "Azerbaijan", + "iso2": "AZ", + "iso3": "AZE", + "admin_name": "Bakı", + "capital": "primary", + "population": 2181800, + "id": 1031946365, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 29399, + "city": "Phnom Penh", + "city_ascii": "Phnom Penh", + "lat": 11.5696, + "lng": 104.921, + "country": "Cambodia", + "iso2": "KH", + "iso3": "KHM", + "admin_name": "Phnom Penh", + "capital": "primary", + "population": 2129371, + "id": 1116260534, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 29702, + "city": "Aleppo", + "city_ascii": "Aleppo", + "lat": 36.2, + "lng": 37.15, + "country": "Syria", + "iso2": "SY", + "iso3": "SYR", + "admin_name": "Ḩalab", + "capital": "admin", + "population": 1916781, + "id": 1760366651, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 29814, + "city": "Almaty", + "city_ascii": "Almaty", + "lat": 43.25, + "lng": 76.9, + "country": "Kazakhstan", + "iso2": "KZ", + "iso3": "KAZ", + "admin_name": "Almaty", + "capital": "admin", + "population": 1916822, + "id": 1398351701, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 33991, + "city": "Mosul", + "city_ascii": "Mosul", + "lat": 36.3667, + "lng": 43.1167, + "country": "Iraq", + "iso2": "IQ", + "iso3": "IRQ", + "admin_name": "Nīnawá", + "capital": "admin", + "population": 1694000, + "id": 1368194914, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 34194, + "city": "Abu Dhabi", + "city_ascii": "Abu Dhabi", + "lat": 24.4511, + "lng": 54.3969, + "country": "United Arab Emirates", + "iso2": "AE", + "iso3": "ARE", + "admin_name": "Abū Z̧aby", + "capital": "primary", + "population": 1483000, + "id": 1784176710, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 34737, + "city": "Muscat", + "city_ascii": "Muscat", + "lat": 23.6139, + "lng": 58.5922, + "country": "Oman", + "iso2": "OM", + "iso3": "OMN", + "admin_name": "Masqaţ", + "capital": "primary", + "population": 1421409, + "id": 1512035506, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 35362, + "city": "Doha", + "city_ascii": "Doha", + "lat": 25.3, + "lng": 51.5333, + "country": "Qatar", + "iso2": "QA", + "iso3": "QAT", + "admin_name": "Ad Dawḩah", + "capital": "primary", + "population": 1186023, + "id": 1634459660, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 35552, + "city": "Tbilisi", + "city_ascii": "Tbilisi", + "lat": 41.7225, + "lng": 44.7925, + "country": "Georgia", + "iso2": "GE", + "iso3": "GEO", + "admin_name": "Tbilisi", + "capital": "primary", + "population": 1118035, + "id": 1268203191, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 35657, + "city": "Bishkek", + "city_ascii": "Bishkek", + "lat": 42.8667, + "lng": 74.5667, + "country": "Kyrgyzstan", + "iso2": "KG", + "iso3": "KGZ", + "admin_name": "Bishkek", + "capital": "primary", + "population": 1053900, + "id": 1417191971, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 35695, + "city": "Kathmandu", + "city_ascii": "Kathmandu", + "lat": 27.7167, + "lng": 85.3667, + "country": "Nepal", + "iso2": "NP", + "iso3": "NPL", + "admin_name": "Bāgmatī", + "capital": "primary", + "population": 975453, + "id": 1524589448, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 35912, + "city": "Vientiane", + "city_ascii": "Vientiane", + "lat": 17.9667, + "lng": 102.6, + "country": "Laos", + "iso2": "LA", + "iso3": "LAO", + "admin_name": "Viangchan", + "capital": "primary", + "population": 948487, + "id": 1418732714, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 35931, + "city": "Jerusalem", + "city_ascii": "Jerusalem", + "lat": 31.7833, + "lng": 35.2167, + "country": "Israel", + "iso2": "IL", + "iso3": "ISR", + "admin_name": "Jerusalem", + "capital": "primary", + "population": 919438, + "id": 1376261644, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 36140, + "city": "Dushanbe", + "city_ascii": "Dushanbe", + "lat": 38.5731, + "lng": 68.7864, + "country": "Tajikistan", + "iso2": "TJ", + "iso3": "TJK", + "admin_name": "Dushanbe", + "capital": "primary", + "population": 778500, + "id": 1762930616, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 36169, + "city": "Colombo", + "city_ascii": "Colombo", + "lat": 6.9167, + "lng": 79.8333, + "country": "Sri Lanka", + "iso2": "LK", + "iso3": "LKA", + "admin_name": "Western", + "capital": "primary", + "population": 752993, + "id": 1144251314, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 37930, + "city": "Beirut", + "city_ascii": "Beirut", + "lat": 33.8869, + "lng": 35.5131, + "country": "Lebanon", + "iso2": "LB", + "iso3": "LBN", + "admin_name": "Beyrouth", + "capital": "primary", + "population": 361366, + "id": 1422847713, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 38032, + "city": "Nicosia", + "city_ascii": "Nicosia", + "lat": 35.1725, + "lng": 33.365, + "country": "Cyprus", + "iso2": "CY", + "iso3": "CYP", + "admin_name": "Lefkosía", + "capital": "primary", + "population": 330000, + "id": 1196944155, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 38417, + "city": "Dili", + "city_ascii": "Dili", + "lat": -8.5536, + "lng": 125.5783, + "country": "Timor-Leste", + "iso2": "TL", + "iso3": "TLS", + "admin_name": "Díli", + "capital": "primary", + "population": 222323, + "id": 1626308942, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 38430, + "city": "Male", + "city_ascii": "Male", + "lat": 4.175, + "lng": 73.5083, + "country": "Maldives", + "iso2": "MV", + "iso3": "MDV", + "admin_name": "Maale", + "capital": "primary", + "population": 133019, + "id": 1462441685, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 38504, + "city": "Manama", + "city_ascii": "Manama", + "lat": 26.225, + "lng": 50.5775, + "country": "Bahrain", + "iso2": "BH", + "iso3": "BHR", + "admin_name": "Al ‘Āşimah", + "capital": "primary", + "population": 157474, + "id": 1048989486, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 38939, + "city": "Thimphu", + "city_ascii": "Thimphu", + "lat": 27.4833, + "lng": 89.6333, + "country": "Bhutan", + "iso2": "BT", + "iso3": "BTN", + "admin_name": "Thimphu", + "capital": "primary", + "population": 104000, + "id": 1064010361, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 39011, + "city": "Bandar Seri Begawan", + "city_ascii": "Bandar Seri Begawan", + "lat": 4.9167, + "lng": 114.9167, + "country": "Brunei", + "iso2": "BN", + "iso3": "BRN", + "admin_name": "Brunei and Muara", + "capital": "primary", + "population": 50000, + "id": 1096465895, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 39084, + "city": "Ashgabat", + "city_ascii": "Ashgabat", + "lat": 37.95, + "lng": 58.3833, + "country": "Turkmenistan", + "iso2": "TM", + "iso3": "TKM", + "admin_name": "Ahal", + "capital": "primary", + "population": 19426, + "id": 1795049992, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 41315, + "city": "Macau", + "city_ascii": "Macau", + "lat": 22.203000000000003, + "lng": 113.545, + "country": "Macau", + "iso2": "MO", + "iso3": "MAC", + "admin_name": "", + "capital": "", + "population": 568700, + "id": 1446227359, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 42286, + "city": "Nonthaburi", + "city_ascii": "Nonthaburi", + "lat": 13.8667, + "lng": 100.5167, + "country": "Thailand", + "iso2": "TH", + "iso3": "THA", + "admin_name": "Nonthaburi", + "capital": "admin", + "population": 255671, + "id": 1764667935, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 42695, + "city": "Mörön", + "city_ascii": "Moron", + "lat": 49.6375, + "lng": 100.1614, + "country": "Mongolia", + "iso2": "MN", + "iso3": "MNG", + "admin_name": "Hövsgöl", + "capital": "admin", + "population": 134530, + "id": 1496482400, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 42721, + "city": "Gyumri", + "city_ascii": "Gyumri", + "lat": 40.7894, + "lng": 43.8475, + "country": "Armenia", + "iso2": "AM", + "iso3": "ARM", + "admin_name": "Shirak", + "capital": "admin", + "population": 121976, + "id": 1051341374, + "_merge": "left_only", + "Continent": "Asia" + }, + { + "": 18455, + "city": "London", + "city_ascii": "London", + "lat": 51.5072, + "lng": -0.1275, + "country": "United Kingdom", + "iso2": "GB", + "iso3": "GBR", + "admin_name": "London, City of", + "capital": "primary", + "population": 11120000, + "id": 1826645935, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 21515, + "city": "Saint Petersburg", + "city_ascii": "Saint Petersburg", + "lat": 59.95, + "lng": 30.3167, + "country": "Russia", + "iso2": "RU", + "iso3": "RUS", + "admin_name": "Sankt-Peterburg", + "capital": "admin", + "population": 5384342, + "id": 1643616350, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 23404, + "city": "Barcelona", + "city_ascii": "Barcelona", + "lat": 41.3825, + "lng": 2.1769, + "country": "Spain", + "iso2": "ES", + "iso3": "ESP", + "admin_name": "Catalonia", + "capital": "admin", + "population": 4735000, + "id": 1724594040, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 26652, + "city": "Rome", + "city_ascii": "Rome", + "lat": 41.8931, + "lng": 12.4828, + "country": "Italy", + "iso2": "IT", + "iso3": "ITA", + "admin_name": "Lazio", + "capital": "primary", + "population": 2872800, + "id": 1380382862, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 29517, + "city": "Minsk", + "city_ascii": "Minsk", + "lat": 53.9022, + "lng": 27.5618, + "country": "Belarus", + "iso2": "BY", + "iso3": "BLR", + "admin_name": "Minsk", + "capital": "primary", + "population": 2009786, + "id": 1112348503, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 29943, + "city": "Vienna", + "city_ascii": "Vienna", + "lat": 48.2083, + "lng": 16.3725, + "country": "Austria", + "iso2": "AT", + "iso3": "AUT", + "admin_name": "Wien", + "capital": "primary", + "population": 1911191, + "id": 1040261752, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 30209, + "city": "Hamburg", + "city_ascii": "Hamburg", + "lat": 53.55, + "lng": 10, + "country": "Germany", + "iso2": "DE", + "iso3": "DEU", + "admin_name": "Hamburg", + "capital": "admin", + "population": 1852478, + "id": 1276041799, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 32931, + "city": "Warsaw", + "city_ascii": "Warsaw", + "lat": 52.23, + "lng": 21.0111, + "country": "Poland", + "iso2": "PL", + "iso3": "POL", + "admin_name": "Mazowieckie", + "capital": "primary", + "population": 1790658, + "id": 1616024847, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 33222, + "city": "Brussels", + "city_ascii": "Brussels", + "lat": 50.8353, + "lng": 4.3314, + "country": "Belgium", + "iso2": "BE", + "iso3": "BEL", + "admin_name": "Brussels-Capital Region", + "capital": "primary", + "population": 1743000, + "id": 1056469830, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 33725, + "city": "Budapest", + "city_ascii": "Budapest", + "lat": 47.4983, + "lng": 19.0408, + "country": "Hungary", + "iso2": "HU", + "iso3": "HUN", + "admin_name": "Budapest", + "capital": "primary", + "population": 1723836, + "id": 1348611435, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 34202, + "city": "Kharkiv", + "city_ascii": "Kharkiv", + "lat": 50, + "lng": 36.2292, + "country": "Ukraine", + "iso2": "UA", + "iso3": "UKR", + "admin_name": "Kharkivs’ka Oblast’", + "capital": "admin", + "population": 1446107, + "id": 1804588111, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 34825, + "city": "Prague", + "city_ascii": "Prague", + "lat": 50.0833, + "lng": 14.4167, + "country": "Czechia", + "iso2": "CZ", + "iso3": "CZE", + "admin_name": "Praha, Hlavní Město", + "capital": "primary", + "population": 1335084, + "id": 1203744823, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 35155, + "city": "Sofia", + "city_ascii": "Sofia", + "lat": 42.6979, + "lng": 23.3217, + "country": "Bulgaria", + "iso2": "BG", + "iso3": "BGR", + "admin_name": "Sofia-Grad", + "capital": "primary", + "population": 1277411, + "id": 1100762037, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 35623, + "city": "Copenhagen", + "city_ascii": "Copenhagen", + "lat": 55.6805, + "lng": 12.5615, + "country": "Denmark", + "iso2": "DK", + "iso3": "DNK", + "admin_name": "Hovedstaden", + "capital": "primary", + "population": 1085000, + "id": 1208763942, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 35839, + "city": "Stockholm", + "city_ascii": "Stockholm", + "lat": 59.3294, + "lng": 18.0686, + "country": "Sweden", + "iso2": "SE", + "iso3": "SWE", + "admin_name": "Stockholm", + "capital": "primary", + "population": 975819, + "id": 1752425602, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 36083, + "city": "Zagreb", + "city_ascii": "Zagreb", + "lat": 45.8131, + "lng": 15.9772, + "country": "Croatia", + "iso2": "HR", + "iso3": "HRV", + "admin_name": "Zagreb, Grad", + "capital": "primary", + "population": 790017, + "id": 1191233290, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 36191, + "city": "Oslo", + "city_ascii": "Oslo", + "lat": 59.9111, + "lng": 10.7528, + "country": "Norway", + "iso2": "NO", + "iso3": "NOR", + "admin_name": "Oslo", + "capital": "primary", + "population": 693494, + "id": 1578324706, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 36352, + "city": "Athens", + "city_ascii": "Athens", + "lat": 37.9842, + "lng": 23.7281, + "country": "Greece", + "iso2": "GR", + "iso3": "GRC", + "admin_name": "Attikí", + "capital": "primary", + "population": 664046, + "id": 1300715560, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 36508, + "city": "Helsinki", + "city_ascii": "Helsinki", + "lat": 60.1756, + "lng": 24.9342, + "country": "Finland", + "iso2": "FI", + "iso3": "FIN", + "admin_name": "Uusimaa", + "capital": "primary", + "population": 642045, + "id": 1246177997, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 36720, + "city": "Skopje", + "city_ascii": "Skopje", + "lat": 41.9833, + "lng": 21.4333, + "country": "Macedonia", + "iso2": "MK", + "iso3": "MKD", + "admin_name": "Skopje", + "capital": "primary", + "population": 640000, + "id": 1807600615, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 36791, + "city": "Chisinau", + "city_ascii": "Chisinau", + "lat": 47.0228, + "lng": 28.8353, + "country": "Moldova", + "iso2": "MD", + "iso3": "MDA", + "admin_name": "Chişinău", + "capital": "primary", + "population": 639000, + "id": 1498011437, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 36872, + "city": "Riga", + "city_ascii": "Riga", + "lat": 56.9475, + "lng": 24.1069, + "country": "Latvia", + "iso2": "LV", + "iso3": "LVA", + "admin_name": "Rīga", + "capital": "primary", + "population": 614618, + "id": 1428586192, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 36933, + "city": "Vilnius", + "city_ascii": "Vilnius", + "lat": 54.6833, + "lng": 25.2833, + "country": "Lithuania", + "iso2": "LT", + "iso3": "LTU", + "admin_name": "Vilniaus Miestas", + "capital": "primary", + "population": 574147, + "id": 1440887149, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 37056, + "city": "Dublin", + "city_ascii": "Dublin", + "lat": 53.3497, + "lng": -6.2603, + "country": "Ireland", + "iso2": "IE", + "iso3": "IRL", + "admin_name": "Dublin", + "capital": "primary", + "population": 553165, + "id": 1372595407, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 37097, + "city": "The Hague", + "city_ascii": "The Hague", + "lat": 52.08, + "lng": 4.31, + "country": "Netherlands", + "iso2": "NL", + "iso3": "NLD", + "admin_name": "Zuid-Holland", + "capital": "primary", + "population": 537833, + "id": 1528799905, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 37471, + "city": "Lisbon", + "city_ascii": "Lisbon", + "lat": 38.708, + "lng": -9.139, + "country": "Portugal", + "iso2": "PT", + "iso3": "PRT", + "admin_name": "Lisboa", + "capital": "primary", + "population": 506654, + "id": 1620619017, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 37768, + "city": "Bratislava", + "city_ascii": "Bratislava", + "lat": 48.1447, + "lng": 17.1128, + "country": "Slovakia", + "iso2": "SK", + "iso3": "SVK", + "admin_name": "Bratislavský", + "capital": "primary", + "population": 475503, + "id": 1703195001, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 37905, + "city": "Tallinn", + "city_ascii": "Tallinn", + "lat": 59.4372, + "lng": 24.745, + "country": "Estonia", + "iso2": "EE", + "iso3": "EST", + "admin_name": "Harjumaa", + "capital": "primary", + "population": 438341, + "id": 1233260021, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 37942, + "city": "Tirana", + "city_ascii": "Tirana", + "lat": 41.33, + "lng": 19.82, + "country": "Albania", + "iso2": "AL", + "iso3": "ALB", + "admin_name": "Tiranë", + "capital": "primary", + "population": 418495, + "id": 1008162156, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 38130, + "city": "Ljubljana", + "city_ascii": "Ljubljana", + "lat": 46.05, + "lng": 14.5167, + "country": "Slovenia", + "iso2": "SI", + "iso3": "SVN", + "admin_name": "Ljubljana", + "capital": "primary", + "population": 286745, + "id": 1705917455, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 38339, + "city": "Sarajevo", + "city_ascii": "Sarajevo", + "lat": 43.8563, + "lng": 18.4132, + "country": "Bosnia And Herzegovina", + "iso2": "BA", + "iso3": "BIH", + "admin_name": "Bosnia and Herzegovina, Federation of", + "capital": "primary", + "population": 275524, + "id": 1070966777, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 38463, + "city": "Gibraltar", + "city_ascii": "Gibraltar", + "lat": 36.1324, + "lng": -5.3781, + "country": "Gibraltar", + "iso2": "GI", + "iso3": "GIB", + "admin_name": "", + "capital": "primary", + "population": 187083, + "id": 1292385245, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 38480, + "city": "Podgorica", + "city_ascii": "Podgorica", + "lat": 42.4397, + "lng": 19.2661, + "country": "Montenegro", + "iso2": "ME", + "iso3": "MNE", + "admin_name": "Podgorica", + "capital": "primary", + "population": 174515, + "id": 1499454516, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 38515, + "city": "Bern", + "city_ascii": "Bern", + "lat": 46.948, + "lng": 7.4474, + "country": "Switzerland", + "iso2": "CH", + "iso3": "CHE", + "admin_name": "Bern", + "capital": "primary", + "population": 133798, + "id": 1756374318, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 38874, + "city": "Luxembourg", + "city_ascii": "Luxembourg", + "lat": 49.6106, + "lng": 6.1328, + "country": "Luxembourg", + "iso2": "LU", + "iso3": "LUX", + "admin_name": "Luxembourg", + "capital": "primary", + "population": 128512, + "id": 1442262731, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 38897, + "city": "Reykjavík", + "city_ascii": "Reykjavik", + "lat": 64.1475, + "lng": -21.935, + "country": "Iceland", + "iso2": "IS", + "iso3": "ISL", + "admin_name": "", + "capital": "primary", + "population": 128793, + "id": 1352327190, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 39022, + "city": "Monaco", + "city_ascii": "Monaco", + "lat": 43.7396, + "lng": 7.4069, + "country": "Monaco", + "iso2": "MC", + "iso3": "MCO", + "admin_name": "", + "capital": "primary", + "population": 36371, + "id": 1492854256, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 39057, + "city": "Saint Helier", + "city_ascii": "Saint Helier", + "lat": 49.1858, + "lng": -2.11, + "country": "Jersey", + "iso2": "JE", + "iso3": "JEY", + "admin_name": "", + "capital": "primary", + "population": 33522, + "id": 1832490253, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 39069, + "city": "Douglas", + "city_ascii": "Douglas", + "lat": 54.15, + "lng": -4.4819, + "country": "Isle Of Man", + "iso2": "IM", + "iso3": "IMN", + "admin_name": "", + "capital": "primary", + "population": 27938, + "id": 1833688345, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 39074, + "city": "Andorra la Vella", + "city_ascii": "Andorra la Vella", + "lat": 42.5, + "lng": 1.5, + "country": "Andorra", + "iso2": "AD", + "iso3": "AND", + "admin_name": "Andorra la Vella", + "capital": "primary", + "population": 22615, + "id": 1020828846, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 39141, + "city": "Tórshavn", + "city_ascii": "Torshavn", + "lat": 62, + "lng": -6.7833, + "country": "Faroe Islands", + "iso2": "FO", + "iso3": "FRO", + "admin_name": "", + "capital": "primary", + "population": 13326, + "id": 1234904517, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 39171, + "city": "Valletta", + "city_ascii": "Valletta", + "lat": 35.8978, + "lng": 14.5125, + "country": "Malta", + "iso2": "MT", + "iso3": "MLT", + "admin_name": "Valletta", + "capital": "primary", + "population": 6444, + "id": 1470574399, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 39246, + "city": "Vaduz", + "city_ascii": "Vaduz", + "lat": 47.1397, + "lng": 9.5219, + "country": "Liechtenstein", + "iso2": "LI", + "iso3": "LIE", + "admin_name": "Vaduz", + "capital": "primary", + "population": 5668, + "id": 1438317747, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 39259, + "city": "San Marino", + "city_ascii": "San Marino", + "lat": 43.931999999999995, + "lng": 12.4484, + "country": "San Marino", + "iso2": "SM", + "iso3": "SMR", + "admin_name": "San Marino Città", + "capital": "primary", + "population": 4040, + "id": 1674741947, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 39270, + "city": "Vatican City", + "city_ascii": "Vatican City", + "lat": 41.9033, + "lng": 12.4534, + "country": "Vatican City", + "iso2": "VA", + "iso3": "VAT", + "admin_name": "", + "capital": "primary", + "population": 825, + "id": 1336000000, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 39297, + "city": "Marseille", + "city_ascii": "Marseille", + "lat": 43.2964, + "lng": 5.37, + "country": "France", + "iso2": "FR", + "iso3": "FRA", + "admin_name": "Provence-Alpes-Côte d’Azur", + "capital": "admin", + "population": 868277, + "id": 1250774071, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 41616, + "city": "Novi Sad", + "city_ascii": "Novi Sad", + "lat": 45.2644, + "lng": 19.8317, + "country": "Serbia", + "iso2": "RS", + "iso3": "SRB", + "admin_name": "Novi Sad", + "capital": "admin", + "population": 380000, + "id": 1688169087, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 41813, + "city": "Cluj-Napoca", + "city_ascii": "Cluj-Napoca", + "lat": 46.78, + "lng": 23.5594, + "country": "Romania", + "iso2": "RO", + "iso3": "ROU", + "admin_name": "Cluj", + "capital": "admin", + "population": 324576, + "id": 1642503974, + "_merge": "left_only", + "Continent": "Europe" + }, + { + "": 8284, + "city": "New York", + "city_ascii": "New York", + "lat": 40.6943, + "lng": -73.9249, + "country": "United States", + "iso2": "US", + "iso3": "USA", + "admin_name": "New York", + "capital": "", + "population": 18713220, + "id": 1840034016, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 19867, + "city": "Guadalajara", + "city_ascii": "Guadalajara", + "lat": 20.6767, + "lng": -103.3475, + "country": "Mexico", + "iso2": "MX", + "iso3": "MEX", + "admin_name": "Jalisco", + "capital": "admin", + "population": 5437000, + "id": 1484950208, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 20891, + "city": "Toronto", + "city_ascii": "Toronto", + "lat": 43.7417, + "lng": -79.3733, + "country": "Canada", + "iso2": "CA", + "iso3": "CAN", + "admin_name": "Ontario", + "capital": "admin", + "population": 5429524, + "id": 1124279679, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 28953, + "city": "Santo Domingo", + "city_ascii": "Santo Domingo", + "lat": 18.4764, + "lng": -69.8933, + "country": "Dominican Republic", + "iso2": "DO", + "iso3": "DOM", + "admin_name": "Ozama", + "capital": "primary", + "population": 2581827, + "id": 1214636202, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 29309, + "city": "Havana", + "city_ascii": "Havana", + "lat": 23.1367, + "lng": -82.3589, + "country": "Cuba", + "iso2": "CU", + "iso3": "CUB", + "admin_name": "La Habana", + "capital": "primary", + "population": 2141652, + "id": 1192752771, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 35282, + "city": "Comayagüela", + "city_ascii": "Comayaguela", + "lat": 14.0833, + "lng": -87.2167, + "country": "Honduras", + "iso2": "HN", + "iso3": "HND", + "admin_name": "Francisco Morazán", + "capital": "", + "population": 1250000, + "id": 1340762485, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 35824, + "city": "Port-au-Prince", + "city_ascii": "Port-au-Prince", + "lat": 18.5425, + "lng": -72.3386, + "country": "Haiti", + "iso2": "HT", + "iso3": "HTI", + "admin_name": "Ouest", + "capital": "primary", + "population": 987310, + "id": 1332401940, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 36033, + "city": "Panama City", + "city_ascii": "Panama City", + "lat": 9, + "lng": -79.5, + "country": "Panama", + "iso2": "PA", + "iso3": "PAN", + "admin_name": "Panamá", + "capital": "primary", + "population": 880691, + "id": 1591672475, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 36915, + "city": "Kingston", + "city_ascii": "Kingston", + "lat": 17.9714, + "lng": -76.7931, + "country": "Jamaica", + "iso2": "JM", + "iso3": "JAM", + "admin_name": "Kingston", + "capital": "primary", + "population": 580000, + "id": 1388709177, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 36995, + "city": "San Salvador", + "city_ascii": "San Salvador", + "lat": 13.6989, + "lng": -89.1914, + "country": "El Salvador", + "iso2": "SV", + "iso3": "SLV", + "admin_name": "San Salvador", + "capital": "primary", + "population": 567698, + "id": 1222647454, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 38112, + "city": "San José", + "city_ascii": "San Jose", + "lat": 9.9333, + "lng": -84.0833, + "country": "Costa Rica", + "iso2": "CR", + "iso3": "CRI", + "admin_name": "San José", + "capital": "primary", + "population": 288054, + "id": 1188749877, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 38372, + "city": "Nassau", + "city_ascii": "Nassau", + "lat": 25.0667, + "lng": -77.3333, + "country": "The Bahamas", + "iso2": "BS", + "iso3": "BHS", + "admin_name": "", + "capital": "primary", + "population": 274400, + "id": 1044318561, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 38375, + "city": "Fort-de-France", + "city_ascii": "Fort-de-France", + "lat": 14.6104, + "lng": -61.08, + "country": "Martinique", + "iso2": "MQ", + "iso3": "MTQ", + "admin_name": "", + "capital": "primary", + "population": 253995, + "id": 1474969110, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 38514, + "city": "Willemstad", + "city_ascii": "Willemstad", + "lat": 12.107999999999999, + "lng": -68.935, + "country": "Curaçao", + "iso2": "CW", + "iso3": "CUW", + "admin_name": "", + "capital": "primary", + "population": 150000, + "id": 1531000000, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 38933, + "city": "Bridgetown", + "city_ascii": "Bridgetown", + "lat": 13.0975, + "lng": -59.6167, + "country": "Barbados", + "iso2": "BB", + "iso3": "BRB", + "admin_name": "Saint Michael", + "capital": "primary", + "population": 110000, + "id": 1052274244, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 38988, + "city": "Castries", + "city_ascii": "Castries", + "lat": 14.0167, + "lng": -60.9833, + "country": "Saint Lucia", + "iso2": "LC", + "iso3": "LCA", + "admin_name": "Castries", + "capital": "primary", + "population": 70000, + "id": 1662922505, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39010, + "city": "Hamilton", + "city_ascii": "Hamilton", + "lat": 32.2942, + "lng": -64.7839, + "country": "Bermuda", + "iso2": "BM", + "iso3": "BMU", + "admin_name": "Hamilton", + "capital": "primary", + "population": 52320, + "id": 1060000000, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39023, + "city": "Port of Spain", + "city_ascii": "Port of Spain", + "lat": 10.6667, + "lng": -61.5167, + "country": "Trinidad And Tobago", + "iso2": "TT", + "iso3": "TTO", + "admin_name": "Port of Spain", + "capital": "primary", + "population": 37074, + "id": 1780670676, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39055, + "city": "Oranjestad", + "city_ascii": "Oranjestad", + "lat": 12.5186, + "lng": -70.0358, + "country": "Aruba", + "iso2": "AW", + "iso3": "ABW", + "admin_name": "", + "capital": "primary", + "population": 34980, + "id": 1533513057, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39071, + "city": "George Town", + "city_ascii": "George Town", + "lat": 19.2866, + "lng": -81.3744, + "country": "Cayman Islands", + "iso2": "KY", + "iso3": "CYM", + "admin_name": "", + "capital": "primary", + "population": 27704, + "id": 1136159124, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39073, + "city": "Kingstown", + "city_ascii": "Kingstown", + "lat": 13.1667, + "lng": -61.2333, + "country": "Saint Vincent And The Grenadines", + "iso2": "VC", + "iso3": "VCT", + "admin_name": "Saint George", + "capital": "primary", + "population": 25000, + "id": 1670376659, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39081, + "city": "Saint John’s", + "city_ascii": "Saint John's", + "lat": 17.1211, + "lng": -61.8447, + "country": "Antigua And Barbuda", + "iso2": "AG", + "iso3": "ATG", + "admin_name": "Saint John", + "capital": "primary", + "population": 21926, + "id": 1028912067, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39108, + "city": "Nuuk", + "city_ascii": "Nuuk", + "lat": 64.175, + "lng": -51.7333, + "country": "Greenland", + "iso2": "GL", + "iso3": "GRL", + "admin_name": "Sermersooq", + "capital": "primary", + "population": 18326, + "id": 1304028354, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39130, + "city": "Belmopan", + "city_ascii": "Belmopan", + "lat": 17.25, + "lng": -88.7675, + "country": "Belize", + "iso2": "BZ", + "iso3": "BLZ", + "admin_name": "Cayo", + "capital": "primary", + "population": 17222, + "id": 1084586375, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39139, + "city": "Roseau", + "city_ascii": "Roseau", + "lat": 15.3, + "lng": -61.3833, + "country": "Dominica", + "iso2": "DM", + "iso3": "DMA", + "admin_name": "Saint George", + "capital": "primary", + "population": 16582, + "id": 1212060440, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39140, + "city": "Basseterre", + "city_ascii": "Basseterre", + "lat": 17.2983, + "lng": -62.7342, + "country": "Saint Kitts And Nevis", + "iso2": "KN", + "iso3": "KNA", + "admin_name": "Saint George Basseterre", + "capital": "primary", + "population": 13220, + "id": 1659198919, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39239, + "city": "Grand Turk", + "city_ascii": "Grand Turk", + "lat": 21.4664, + "lng": -71.13600000000001, + "country": "Turks And Caicos Islands", + "iso2": "TC", + "iso3": "TCA", + "admin_name": "", + "capital": "primary", + "population": 5801, + "id": 1796965313, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39258, + "city": "Saint George’s", + "city_ascii": "Saint George's", + "lat": 12.0444, + "lng": -61.7417, + "country": "Grenada", + "iso2": "GD", + "iso3": "GRD", + "admin_name": "Saint George", + "capital": "primary", + "population": 4315, + "id": 1308891766, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39272, + "city": "Basse-Terre", + "city_ascii": "Basse-Terre", + "lat": 16.0104, + "lng": -61.7055, + "country": "Guadeloupe", + "iso2": "GP", + "iso3": "GLP", + "admin_name": "", + "capital": "primary", + "population": 307, + "id": 1312938008, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 39280, + "city": "Brades", + "city_ascii": "Brades", + "lat": 16.7928, + "lng": -62.2106, + "country": "Montserrat", + "iso2": "MS", + "iso3": "MSR", + "admin_name": "Saint Peter", + "capital": "primary", + "population": 391, + "id": 1500971198, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 41341, + "city": "Villa Nueva", + "city_ascii": "Villa Nueva", + "lat": 14.5314, + "lng": -90.5964, + "country": "Guatemala", + "iso2": "GT", + "iso3": "GTM", + "admin_name": "Guatemala", + "capital": "minor", + "population": 618397, + "id": 1320353009, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 42179, + "city": "San Juan", + "city_ascii": "San Juan", + "lat": 18.4037, + "lng": -66.0636, + "country": "Puerto Rico", + "iso2": "PR", + "iso3": "PRI", + "admin_name": "Puerto Rico", + "capital": "primary", + "population": 323279, + "id": 1630035577, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 42235, + "city": "Boaco", + "city_ascii": "Boaco", + "lat": 12.4667, + "lng": -85.6667, + "country": "Nicaragua", + "iso2": "NI", + "iso3": "NIC", + "admin_name": "Boaco", + "capital": "admin", + "population": 317000, + "id": 1558023610, + "_merge": "left_only", + "Continent": "North America" + }, + { + "": 23046, + "city": "Sydney", + "city_ascii": "Sydney", + "lat": -33.865, + "lng": 151.2094, + "country": "Australia", + "iso2": "AU", + "iso3": "AUS", + "admin_name": "New South Wales", + "capital": "admin", + "population": 4840600, + "id": 1036074917, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 34753, + "city": "Auckland", + "city_ascii": "Auckland", + "lat": -36.85, + "lng": 174.7833, + "country": "New Zealand", + "iso2": "NZ", + "iso3": "NZL", + "admin_name": "Auckland", + "capital": "admin", + "population": 1346091, + "id": 1554435911, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 38084, + "city": "Port Moresby", + "city_ascii": "Port Moresby", + "lat": -9.4789, + "lng": 147.1494, + "country": "Papua New Guinea", + "iso2": "PG", + "iso3": "PNG", + "admin_name": "National Capital", + "capital": "primary", + "population": 317374, + "id": 1598685395, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 38873, + "city": "Papeete", + "city_ascii": "Papeete", + "lat": -17.5334, + "lng": -149.5667, + "country": "French Polynesia", + "iso2": "PF", + "iso3": "PYF", + "admin_name": "Îles du Vent", + "capital": "primary", + "population": 131695, + "id": 1258907380, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 38968, + "city": "Nouméa", + "city_ascii": "Noumea", + "lat": -22.2625, + "lng": 166.4443, + "country": "New Caledonia", + "iso2": "NC", + "iso3": "NCL", + "admin_name": "Province Sud", + "capital": "primary", + "population": 93060, + "id": 1540958092, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 38971, + "city": "Honiara", + "city_ascii": "Honiara", + "lat": -9.4333, + "lng": 159.95, + "country": "Solomon Islands", + "iso2": "SB", + "iso3": "SLB", + "admin_name": "Honiara", + "capital": "primary", + "population": 84520, + "id": 1090737486, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 38980, + "city": "Suva", + "city_ascii": "Suva", + "lat": -18.1333, + "lng": 178.4333, + "country": "Fiji", + "iso2": "FJ", + "iso3": "FJI", + "admin_name": "Rewa", + "capital": "primary", + "population": 88271, + "id": 1242615095, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39004, + "city": "Port-Vila", + "city_ascii": "Port-Vila", + "lat": -17.7333, + "lng": 168.3167, + "country": "Vanuatu", + "iso2": "VU", + "iso3": "VUT", + "admin_name": "Shefa", + "capital": "primary", + "population": 51437, + "id": 1548805075, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39041, + "city": "Apia", + "city_ascii": "Apia", + "lat": -13.8333, + "lng": -171.8333, + "country": "Samoa", + "iso2": "WS", + "iso3": "WSM", + "admin_name": "Tuamasaga", + "capital": "primary", + "population": 37708, + "id": 1882489296, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39053, + "city": "Tarawa", + "city_ascii": "Tarawa", + "lat": 1.3382, + "lng": 173.0176, + "country": "Kiribati", + "iso2": "KI", + "iso3": "KIR", + "admin_name": "", + "capital": "primary", + "population": 28802, + "id": 1296152641, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39068, + "city": "Majuro", + "city_ascii": "Majuro", + "lat": 7.0918, + "lng": 171.3802, + "country": "Marshall Islands", + "iso2": "MH", + "iso3": "MHL", + "admin_name": "Majuro", + "capital": "primary", + "population": 30000, + "id": 1584000000, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39082, + "city": "Nuku‘alofa", + "city_ascii": "Nuku`alofa", + "lat": -21.1347, + "lng": -175.2083, + "country": "Tonga", + "iso2": "TO", + "iso3": "TON", + "admin_name": "Tongatapu", + "capital": "primary", + "population": 23221, + "id": 1776737461, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39170, + "city": "Pago Pago", + "city_ascii": "Pago Pago", + "lat": -14.274000000000001, + "lng": -170.7046, + "country": "American Samoa", + "iso2": "AS", + "iso3": "ASM", + "admin_name": "", + "capital": "primary", + "population": 12576, + "id": 1016976740, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39240, + "city": "Palikir", + "city_ascii": "Palikir", + "lat": 6.9178, + "lng": 158.185, + "country": "Federated States of Micronesia", + "iso2": "FM", + "iso3": "FSM", + "admin_name": "Pohnpei", + "capital": "primary", + "population": 6227, + "id": 1583008885, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39245, + "city": "Funafuti", + "city_ascii": "Funafuti", + "lat": -8.5243, + "lng": 179.1942, + "country": "Tuvalu", + "iso2": "TV", + "iso3": "TUV", + "admin_name": "Funafuti", + "capital": "primary", + "population": 6025, + "id": 1798251391, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39257, + "city": "Avarua", + "city_ascii": "Avarua", + "lat": -21.206999999999997, + "lng": -159.77100000000002, + "country": "Cook Islands", + "iso2": "CK", + "iso3": "COK", + "admin_name": "", + "capital": "primary", + "population": 5445, + "id": 1184217570, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39268, + "city": "Capitol Hill", + "city_ascii": "Capitol Hill", + "lat": 15.2137, + "lng": 145.7546, + "country": "Northern Mariana Islands", + "iso2": "MP", + "iso3": "MNP", + "admin_name": "", + "capital": "primary", + "population": 2500, + "id": 1580556972, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39271, + "city": "Alofi", + "city_ascii": "Alofi", + "lat": -19.055999999999997, + "lng": -169.921, + "country": "Niue", + "iso2": "NU", + "iso3": "NIU", + "admin_name": "", + "capital": "primary", + "population": 1611, + "id": 1570882835, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39274, + "city": "Hagåtña", + "city_ascii": "Hagta", + "lat": 13.4745, + "lng": 144.7504, + "country": "Guam", + "iso2": "GU", + "iso3": "GUM", + "admin_name": "", + "capital": "primary", + "population": 1051, + "id": 1316937540, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 39285, + "city": "Ngerulmud", + "city_ascii": "Ngerulmud", + "lat": 7.5006, + "lng": 134.6242, + "country": "Palau", + "iso2": "PW", + "iso3": "PLW", + "admin_name": "Melekeok", + "capital": "primary", + "population": 271, + "id": 1585525081, + "_merge": "left_only", + "Continent": "Oceania" + }, + { + "": 3138, + "city": "São Paulo", + "city_ascii": "Sao Paulo", + "lat": -23.5504, + "lng": -46.6339, + "country": "Brazil", + "iso2": "BR", + "iso3": "BRA", + "admin_name": "São Paulo", + "capital": "admin", + "population": 22495000, + "id": 1076532519, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 16104, + "city": "Buenos Aires", + "city_ascii": "Buenos Aires", + "lat": -34.5997, + "lng": -58.3819, + "country": "Argentina", + "iso2": "AR", + "iso3": "ARG", + "admin_name": "Buenos Aires, Ciudad Autónoma de", + "capital": "primary", + "population": 16216000, + "id": 1032717330, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 19506, + "city": "Santiago", + "city_ascii": "Santiago", + "lat": -33.45, + "lng": -70.6667, + "country": "Chile", + "iso2": "CL", + "iso3": "CHL", + "admin_name": "Región Metropolitana", + "capital": "primary", + "population": 7026000, + "id": 1152554349, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 24538, + "city": "Timbío", + "city_ascii": "Timbio", + "lat": 2.3528, + "lng": -76.6819, + "country": "Colombia", + "iso2": "CO", + "iso3": "COL", + "admin_name": "Cauca", + "capital": "minor", + "population": 4444444, + "id": 1170815311, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 26124, + "city": "Santa Cruz", + "city_ascii": "Santa Cruz", + "lat": -17.7892, + "lng": -63.1975, + "country": "Bolivia", + "iso2": "BO", + "iso3": "BOL", + "admin_name": "Santa Cruz", + "capital": "admin", + "population": 3151676, + "id": 1068129363, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 28829, + "city": "Guayaquil", + "city_ascii": "Guayaquil", + "lat": -2.19, + "lng": -79.8875, + "country": "Ecuador", + "iso2": "EC", + "iso3": "ECU", + "admin_name": "Guayas", + "capital": "admin", + "population": 2723665, + "id": 1218802178, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 29605, + "city": "Caracas", + "city_ascii": "Caracas", + "lat": 10.5, + "lng": -66.9333, + "country": "Venezuela", + "iso2": "VE", + "iso3": "VEN", + "admin_name": "Distrito Capital", + "capital": "primary", + "population": 1943901, + "id": 1862748204, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 35098, + "city": "Montevideo", + "city_ascii": "Montevideo", + "lat": -34.8667, + "lng": -56.1667, + "country": "Uruguay", + "iso2": "UY", + "iso3": "URY", + "admin_name": "Montevideo", + "capital": "primary", + "population": 1319108, + "id": 1858107000, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 35407, + "city": "Callao", + "city_ascii": "Callao", + "lat": -12.0611, + "lng": -77.1333, + "country": "Peru", + "iso2": "PE", + "iso3": "PER", + "admin_name": "Callao", + "capital": "admin", + "population": 1129854, + "id": 1604422141, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 37427, + "city": "Asunción", + "city_ascii": "Asuncion", + "lat": -25.3, + "lng": -57.6333, + "country": "Paraguay", + "iso2": "PY", + "iso3": "PRY", + "admin_name": "Asunción", + "capital": "primary", + "population": 524190, + "id": 1600057911, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 38403, + "city": "Paramaribo", + "city_ascii": "Paramaribo", + "lat": 5.8667, + "lng": -55.1667, + "country": "Suriname", + "iso2": "SR", + "iso3": "SUR", + "admin_name": "Paramaribo", + "capital": "primary", + "population": 223757, + "id": 1740518660, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 38451, + "city": "Georgetown", + "city_ascii": "Georgetown", + "lat": 6.7833, + "lng": -58.1667, + "country": "Guyana", + "iso2": "GY", + "iso3": "GUY", + "admin_name": "Demerara-Mahaica", + "capital": "primary", + "population": 200500, + "id": 1328160906, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 38990, + "city": "Cayenne", + "city_ascii": "Cayenne", + "lat": 4.933, + "lng": -52.33, + "country": "French Guiana", + "iso2": "GF", + "iso3": "GUF", + "admin_name": "", + "capital": "primary", + "population": 61550, + "id": 1254304969, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 39269, + "city": "Stanley", + "city_ascii": "Stanley", + "lat": -51.7, + "lng": -57.85, + "country": "Falkland Islands (Islas Malvinas)", + "iso2": "FK", + "iso3": "FLK", + "admin_name": "", + "capital": "primary", + "population": 2213, + "id": 1238780509, + "_merge": "left_only", + "Continent": "South America" + }, + { + "": 39296, + "city": "Grytviken", + "city_ascii": "Grytviken", + "lat": -54.2806, + "lng": -36.508, + "country": "South Georgia And South Sandwich Islands", + "iso2": "GS", + "iso3": "SGS", + "admin_name": "", + "capital": "", + "population": 99, + "id": 1239048837, + "_merge": "left_only", + "Continent": "South America" + } +] \ No newline at end of file diff --git a/run_tree/data/font.ttf b/run_tree/data/font.ttf new file mode 100644 index 0000000..06aafc0 Binary files /dev/null and b/run_tree/data/font.ttf differ diff --git a/run_tree/data/incenter_data/c/question_1.h b/run_tree/data/incenter_data/c/question_1.h new file mode 100644 index 0000000..252704f --- /dev/null +++ b/run_tree/data/incenter_data/c/question_1.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_1_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.7211155378486056, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.6813559322033899, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.5084745762711864, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.6507936507936508, }, +[4] = { city_paris, 2022, MONTH_jan, 0.5611355457816873, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.7130232558139535, }, +[6] = { city_denver, 2022, MONTH_jan, 0.7130232558139535, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.8550185873605948, }, +[8] = { city_harare, 2022, MONTH_jan, 0.5, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.3597560975609756, }, +[10] = { city_washington, 2022, MONTH_jan, 0.7130232558139535, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.5555555555555556, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.5942028985507246, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.3597560975609756, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.632, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.5081967213114754, }, +[16] = { city_lima, 2022, MONTH_jan, 0.5, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.6526315789473685, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.8888888888888888, }, +[19] = { city_managua, 2022, MONTH_jan, 0.6774193548387096, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.6104783599088838, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.4523809523809524, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.5084745762711864, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.5747718230751229, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.5, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.3949372298826919, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.7, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.7, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.45276162790697677, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.6774193548387096, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.6714178544636159, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.5, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.5942028985507246, }, +[33] = { city_quito, 2022, MONTH_jan, 0.48148148148148145, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.5698324022346368, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.5084745762711864, }, +[36] = { city_accra, 2022, MONTH_jan, 0.5, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.7213114754098361, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.7555555555555555, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.7555555555555555, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.7348066298342542, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.8550185873605948, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.7130232558139535, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.46875, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.7, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.6507936507936508, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.5716845878136201, }, +}; +global u32 question_1_len = sizeof(question_1_data) / sizeof(question_1_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_10.h b/run_tree/data/incenter_data/c/question_10.h new file mode 100644 index 0000000..777ea36 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_10.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_10_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.7907915993537964, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.9196675900277008, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.8922570016474465, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.8931259407927747, }, +[4] = { city_paris, 2022, MONTH_jan, 0.8915187376725838, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.8767605633802817, }, +[6] = { city_denver, 2022, MONTH_jan, 0.8822393822393823, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.8529289572081429, }, +[8] = { city_harare, 2022, MONTH_jan, 0.5197693574958814, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.9733333333333334, }, +[10] = { city_washington, 2022, MONTH_jan, 0.885, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.8386880856760375, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.7669983416252073, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.8907630522088353, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.8032629558541267, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.8402501421262081, }, +[16] = { city_lima, 2022, MONTH_jan, 0.8164874551971326, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.8931259407927747, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.7283049472830495, }, +[19] = { city_managua, 2022, MONTH_jan, 0.8558333333333333, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.9145383104125737, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.8283333333333334, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.6910866910866911, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.9178632969557725, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.8371907422186752, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.9025679758308157, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.7039864291772688, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.6967267869071476, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.939043451078462, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.9072416598860863, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.8915187376725838, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.8747967479674796, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.7172643869891576, }, +[33] = { city_quito, 2022, MONTH_jan, 0.8932203389830509, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.8940789473684211, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.8922570016474465, }, +[36] = { city_accra, 2022, MONTH_jan, 0.8371907422186752, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.8638626182180189, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.9008595988538682, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.7321688500727802, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.9066666666666666, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.8845836768342952, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.8559870550161812, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.8059105431309904, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.7172643869891576, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.8931259407927747, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.8915187376725838, }, +}; +global u32 question_10_len = sizeof(question_10_data) / sizeof(question_10_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_11.h b/run_tree/data/incenter_data/c/question_11.h new file mode 100644 index 0000000..d9efea5 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_11.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_11_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.7527472527472527, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.7346938775510204, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.75, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.8222222222222222, }, +[4] = { city_paris, 2022, MONTH_jan, 0.5690460306871248, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.7624035281146637, }, +[6] = { city_denver, 2022, MONTH_jan, 0.7624035281146637, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.6437054631828979, }, +[8] = { city_harare, 2022, MONTH_jan, 0.8, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.8148148148148148, }, +[10] = { city_washington, 2022, MONTH_jan, 0.7624035281146637, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.5384615384615384, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.8431372549019608, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.8148148148148148, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.6818181818181818, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.4065934065934066, }, +[16] = { city_lima, 2022, MONTH_jan, 0.8235294117647058, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.8105263157894737, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.7142857142857143, }, +[19] = { city_managua, 2022, MONTH_jan, 0.8571428571428571, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.7003676470588235, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.7058823529411765, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.75, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.7737030411449016, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.8, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.4397765363128492, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.7, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.7, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.8859470468431772, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.8571428571428571, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.6584922797456857, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.8, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.8431372549019608, }, +[33] = { city_quito, 2022, MONTH_jan, 0.8181818181818182, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.7089552238805971, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.75, }, +[36] = { city_accra, 2022, MONTH_jan, 0.8, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.6509695290858726, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.8969465648854962, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.8969465648854962, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.8523206751054853, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.6437054631828979, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.7624035281146637, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.8181818181818182, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.7, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.8222222222222222, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.7440191387559809, }, +}; +global u32 question_11_len = sizeof(question_11_data) / sizeof(question_11_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_12.h b/run_tree/data/incenter_data/c/question_12.h new file mode 100644 index 0000000..1ebdb9f --- /dev/null +++ b/run_tree/data/incenter_data/c/question_12.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_12_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.4789180588703262, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.827357970215113, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.600926538716082, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.42355889724310775, }, +[4] = { city_paris, 2022, MONTH_jan, 0.8413114754098361, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.6807511737089202, }, +[6] = { city_denver, 2022, MONTH_jan, 0.6730769230769231, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.6662309368191721, }, +[8] = { city_harare, 2022, MONTH_jan, 0.7267489711934156, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.4633333333333333, }, +[10] = { city_washington, 2022, MONTH_jan, 0.7408637873754153, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.522, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.8239731768650461, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.5084337349397591, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.6408518877057116, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.5629834254143646, }, +[16] = { city_lima, 2022, MONTH_jan, 0.6192857142857143, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.42355889724310775, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.6176232821341956, }, +[19] = { city_managua, 2022, MONTH_jan, 0.7441666666666666, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.8019323671497585, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.5075, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.4340659340659341, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.6657093624353819, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.5442338072669827, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.6260162601626016, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.7216666666666667, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.40493662441627754, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.470625, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.7831558567279767, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.8413114754098361, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.45934959349593496, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.7814845704753962, }, +[33] = { city_quito, 2022, MONTH_jan, 0.6958333333333333, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.7730263157894737, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.600926538716082, }, +[36] = { city_accra, 2022, MONTH_jan, 0.5442338072669827, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.7073170731707317, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.6152099886492622, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.7289946576007771, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.7075, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.6059113300492611, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.6844660194174758, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.4786656322730799, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.7814845704753962, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.42355889724310775, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.8413114754098361, }, +}; +global u32 question_12_len = sizeof(question_12_data) / sizeof(question_12_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_13.h b/run_tree/data/incenter_data/c/question_13.h new file mode 100644 index 0000000..426020d --- /dev/null +++ b/run_tree/data/incenter_data/c/question_13.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_13_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.08285385500575373, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.09841628959276018, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.08166666666666667, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.20042987641053198, }, +[4] = { city_paris, 2022, MONTH_jan, 0.031207598371777476, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.1670616113744076, }, +[6] = { city_denver, 2022, MONTH_jan, 0.15145631067961166, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.14479830148619957, }, +[8] = { city_harare, 2022, MONTH_jan, 0.3549459684123026, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.08166666666666667, }, +[10] = { city_washington, 2022, MONTH_jan, 0.14214046822742474, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.18401611820013433, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.28439597315436244, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.157429718875502, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.0691333982473223, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.07294264339152119, }, +[16] = { city_lima, 2022, MONTH_jan, 0.18324607329842932, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.20042987641053198, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.18892508143322476, }, +[19] = { city_managua, 2022, MONTH_jan, 0.11083333333333334, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.09620098039215687, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.5508333333333333, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.2658924205378973, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.3469387755102041, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.37571312143439284, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.0972644376899696, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.16893039049235994, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.07811447811447811, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.0608640807316304, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.322213181448332, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.031207598371777476, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.15637860082304528, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.16893039049235994, }, +[33] = { city_quito, 2022, MONTH_jan, 0.14830875975715524, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.13355263157894737, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.08166666666666667, }, +[36] = { city_accra, 2022, MONTH_jan, 0.37571312143439284, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.14758586361373818, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.20054384772263767, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.14959016393442623, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.13162544169611307, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.03935599284436494, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.1563517915309446, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.055281342546890426, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.16893039049235994, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.20042987641053198, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.031207598371777476, }, +}; +global u32 question_13_len = sizeof(question_13_data) / sizeof(question_13_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_14.h b/run_tree/data/incenter_data/c/question_14.h new file mode 100644 index 0000000..fdfb753 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_14.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_14_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.6968174204355109, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.4254484304932735, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.15694768410529825, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.37493632195618953, }, +[4] = { city_paris, 2022, MONTH_jan, 0.31785003317850036, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.6515513126491647, }, +[6] = { city_denver, 2022, MONTH_jan, 0.700587084148728, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.39265898420828, }, +[8] = { city_harare, 2022, MONTH_jan, 0.76814011676397, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.145, }, +[10] = { city_washington, 2022, MONTH_jan, 0.6761744966442953, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.529689608636977, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.7771236333052985, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.09799196787148594, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.6625891946992865, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.5068903535050928, }, +[16] = { city_lima, 2022, MONTH_jan, 0.7326086956521739, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.37493632195618953, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.6726238830219334, }, +[19] = { city_managua, 2022, MONTH_jan, 0.6166666666666667, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.37310308738880166, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.5525, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.43933823529411764, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.6502890173410405, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.5854632587859425, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.4491803278688525, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.74, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.48944860449285227, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.3997445721583653, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.7050538525269263, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.31785003317850036, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.6325350949628407, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.74, }, +[33] = { city_quito, 2022, MONTH_jan, 0.5373635600335852, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.7315789473684211, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.15694768410529825, }, +[36] = { city_accra, 2022, MONTH_jan, 0.5854632587859425, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.2929318068690891, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.8714953271028038, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.48205383848454636, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.215, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.7328308207705193, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.6830870279146142, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.7300813008130081, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.74, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.37493632195618953, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.31785003317850036, }, +}; +global u32 question_14_len = sizeof(question_14_data) / sizeof(question_14_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_15.h b/run_tree/data/incenter_data/c/question_15.h new file mode 100644 index 0000000..95199c2 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_15.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_15_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.8681318681318682, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.842741935483871, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.75, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.8444444444444444, }, +[4] = { city_paris, 2022, MONTH_jan, 0.7975257342525262, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.8898026315789473, }, +[6] = { city_denver, 2022, MONTH_jan, 0.8898026315789473, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.8466111771700356, }, +[8] = { city_harare, 2022, MONTH_jan, 1, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.8507462686567164, }, +[10] = { city_washington, 2022, MONTH_jan, 0.8898026315789473, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.7692307692307693, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.8653846153846154, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.8507462686567164, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.8838383838383839, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.7934782608695652, }, +[16] = { city_lima, 2022, MONTH_jan, 0.9705882352941176, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.8121827411167513, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.8571428571428571, }, +[19] = { city_managua, 2022, MONTH_jan, 1, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.9004566210045662, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.7352941176470589, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.75, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.8772086117297698, }, +[24] = { city_nairobi, 2022, MONTH_jan, 1, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.41568278012920473, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.8, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.8, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.8562753036437247, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 1, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.8590785907859079, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 1, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.8653846153846154, }, +[33] = { city_quito, 2022, MONTH_jan, 0.8695652173913043, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.8656716417910447, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.75, }, +[36] = { city_accra, 2022, MONTH_jan, 1, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.8402203856749312, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.8950381679389313, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.8950381679389313, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.9041666666666667, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.8466111771700356, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.8898026315789473, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.8636363636363636, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.8, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.8444444444444444, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.8524590163934426, }, +}; +global u32 question_15_len = sizeof(question_15_data) / sizeof(question_15_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_16.h b/run_tree/data/incenter_data/c/question_16.h new file mode 100644 index 0000000..1bedb2e --- /dev/null +++ b/run_tree/data/incenter_data/c/question_16.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_16_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.6252144082332761, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.21300448430493274, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.8102633355840648, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.7666836474783495, }, +[4] = { city_paris, 2022, MONTH_jan, 0.1596806387225549, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.23954372623574144, }, +[6] = { city_denver, 2022, MONTH_jan, 0.21940928270042195, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.8744531933508312, }, +[8] = { city_harare, 2022, MONTH_jan, 0.9385004212299916, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.8875, }, +[10] = { city_washington, 2022, MONTH_jan, 0.2643884892086331, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.6720647773279352, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.8076580587711487, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.8481927710843373, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.763023493360572, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.738166566806471, }, +[16] = { city_lima, 2022, MONTH_jan, 0.44288872512896094, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.7666836474783495, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.9618196588139724, }, +[19] = { city_managua, 2022, MONTH_jan, 0.4816666666666667, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.27867095391211144, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.91, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.7175245098039216, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.3929398148148148, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.8004926108374384, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.5046491969568893, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.9116666666666666, }, +[27] = { city_tehran, 2022, MONTH_jan, 1, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.9195402298850575, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.6255178127589064, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.1596806387225549, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.8911055694098088, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.9116666666666666, }, +[33] = { city_quito, 2022, MONTH_jan, 0.4869857262804366, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.4, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.8102633355840648, }, +[36] = { city_accra, 2022, MONTH_jan, 0.8004926108374384, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.20034843205574912, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.1588785046728972, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.43232438606510565, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.9798826487845766, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.8872881355932203, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.2586805555555556, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.7552447552447552, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.9116666666666666, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.7666836474783495, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.1596806387225549, }, +}; +global u32 question_16_len = sizeof(question_16_data) / sizeof(question_16_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_17.h b/run_tree/data/incenter_data/c/question_17.h new file mode 100644 index 0000000..50f8064 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_17.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_17_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.3517305893358279, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.7251693002257337, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.6752336448598131, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.28718882817243474, }, +[4] = { city_paris, 2022, MONTH_jan, 0.8590694538098449, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.7202881152460985, }, +[6] = { city_denver, 2022, MONTH_jan, 0.7637795275590551, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.22046174739701221, }, +[8] = { city_harare, 2022, MONTH_jan, 0.4797297297297297, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.08583333333333333, }, +[10] = { city_washington, 2022, MONTH_jan, 0.7687074829931972, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.39174560216508797, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.18357933579335795, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.242570281124498, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.23599137931034483, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.3582286847323199, }, +[16] = { city_lima, 2022, MONTH_jan, 0.21016166281755197, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.28718882817243474, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.4920502092050209, }, +[19] = { city_managua, 2022, MONTH_jan, 0.3875, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.5708571428571428, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.28583333333333333, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.5067401960784313, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.1445221445221445, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.5110356536502547, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.6290018832391714, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.475736568457539, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.7332421340629275, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.3570284982388729, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.5788135593220339, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.8590694538098449, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.17217981340118746, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.475736568457539, }, +[33] = { city_quito, 2022, MONTH_jan, 0.4667235494880546, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.6217105263157895, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.6752336448598131, }, +[36] = { city_accra, 2022, MONTH_jan, 0.5110356536502547, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.7775012444001991, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.5541561712846348, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.5235414534288638, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.34421364985163205, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.365832614322692, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.760797342192691, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.28751311647429173, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.475736568457539, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.28718882817243474, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.8590694538098449, }, +}; +global u32 question_17_len = sizeof(question_17_data) / sizeof(question_17_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_18.h b/run_tree/data/incenter_data/c/question_18.h new file mode 100644 index 0000000..da16a28 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_18.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_18_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.40350877192982454, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.6732617297908423, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.6871880199667221, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.4288, }, +[4] = { city_paris, 2022, MONTH_jan, 0.6646090534979424, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.5142857142857142, }, +[6] = { city_denver, 2022, MONTH_jan, 0.528957528957529, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.5759139784946237, }, +[8] = { city_harare, 2022, MONTH_jan, 0.538971807628524, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.7172643869891576, }, +[10] = { city_washington, 2022, MONTH_jan, 0.5456081081081081, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.5256756756756756, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.34995625546806647, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.5742971887550201, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.46930280957336107, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.48936170212765956, }, +[16] = { city_lima, 2022, MONTH_jan, 0.5945144551519644, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.4288, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.41254125412541254, }, +[19] = { city_managua, 2022, MONTH_jan, 0.6333333333333333, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.7243367935409458, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.5133333333333333, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.5415140415140415, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.5577712609970674, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.4683127572016461, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.5072463768115942, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.43166666666666664, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.6534320323014805, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.733607855559075, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.5899339933993399, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.6646090534979424, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.46716541978387366, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.3588290840415486, }, +[33] = { city_quito, 2022, MONTH_jan, 0.5719207579672696, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.6966887417218544, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.6871880199667221, }, +[36] = { city_accra, 2022, MONTH_jan, 0.4683127572016461, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.6124937779990045, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.644878706199461, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.7341961174713788, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.4765694076038904, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.5004262574595055, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.5481239804241436, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.5114235500878734, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.3588290840415486, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.4288, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.6646090534979424, }, +}; +global u32 question_18_len = sizeof(question_18_data) / sizeof(question_18_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_19.h b/run_tree/data/incenter_data/c/question_19.h new file mode 100644 index 0000000..2e2ca80 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_19.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_19_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.7082644628099174, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.8521205357142857, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.9380856760374833, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.7483477376715811, }, +[4] = { city_paris, 2022, MONTH_jan, 0.8271523178807947, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.7714285714285715, }, +[6] = { city_denver, 2022, MONTH_jan, 0.7393822393822393, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.735936188077246, }, +[8] = { city_harare, 2022, MONTH_jan, 0.7394190871369295, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.9416666666666667, }, +[10] = { city_washington, 2022, MONTH_jan, 0.8, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.7437457741717377, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.5396825396825397, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.9164658634538153, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.6821782178217822, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.8499717992103779, }, +[16] = { city_lima, 2022, MONTH_jan, 0.5747211895910781, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.7483477376715811, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.6848534201954397, }, +[19] = { city_managua, 2022, MONTH_jan, 0.55, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.8363922391190352, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.82, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.7635919364691509, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.6364685516445471, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.6780876494023904, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.7748344370860927, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.78, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.6942204301075269, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.8313479623824451, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.6363636363636364, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.8271523178807947, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.7589134125636672, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.5408333333333334, }, +[33] = { city_quito, 2022, MONTH_jan, 0.5179916317991632, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.5506578947368421, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.9380856760374833, }, +[36] = { city_accra, 2022, MONTH_jan, 0.6780876494023904, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.8128422100547537, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.5583962812318419, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.5051749630359783, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.9416666666666667, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.6306156405990017, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.7963875205254516, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.830249396621078, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.5408333333333334, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.7483477376715811, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.8271523178807947, }, +}; +global u32 question_19_len = sizeof(question_19_data) / sizeof(question_19_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_2.h b/run_tree/data/incenter_data/c/question_2.h new file mode 100644 index 0000000..9271e22 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_2.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_2_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.8087649402390438, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.7064846416382252, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.6440677966101694, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.7936507936507936, }, +[4] = { city_paris, 2022, MONTH_jan, 0.6832853946947907, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.814797580269893, }, +[6] = { city_denver, 2022, MONTH_jan, 0.814797580269893, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.870817843866171, }, +[8] = { city_harare, 2022, MONTH_jan, 0.7857142857142857, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.6257668711656442, }, +[10] = { city_washington, 2022, MONTH_jan, 0.814797580269893, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.47058823529411764, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.6571428571428571, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.6257668711656442, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.8, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.8032786885245902, }, +[16] = { city_lima, 2022, MONTH_jan, 0.8, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.7448275862068966, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.9411764705882353, }, +[19] = { city_managua, 2022, MONTH_jan, 0.8125, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.5527714502657555, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.7619047619047619, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.6440677966101694, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.825, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.7857142857142857, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.665843621399177, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.7058823529411765, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.7058823529411765, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.7700145560407569, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.8125, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.6601796407185628, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.7857142857142857, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.6571428571428571, }, +[33] = { city_quito, 2022, MONTH_jan, 0.7241379310344828, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.7722222222222223, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.6440677966101694, }, +[36] = { city_accra, 2022, MONTH_jan, 0.7857142857142857, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.7915690866510539, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.8020833333333334, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.8020833333333334, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.8126721763085399, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.870817843866171, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.814797580269893, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.8125, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.7058823529411765, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.7936507936507936, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.7365591397849462, }, +}; +global u32 question_2_len = sizeof(question_2_data) / sizeof(question_2_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_20.h b/run_tree/data/incenter_data/c/question_20.h new file mode 100644 index 0000000..e204bd2 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_20.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_20_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.008906882591093117, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.06120157215047726, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.014885874958650347, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.05456570155902005, }, +[4] = { city_paris, 2022, MONTH_jan, 0.07147540983606557, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.06863905325443787, }, +[6] = { city_denver, 2022, MONTH_jan, 0.06395348837209303, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.007591733445803458, }, +[8] = { city_harare, 2022, MONTH_jan, 0.07966804979253111, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.021666666666666667, }, +[10] = { city_washington, 2022, MONTH_jan, 0.05852842809364549, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.13266666666666665, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.009369676320272573, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.01606425702811245, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.014691478942213516, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.0061624649859943975, }, +[16] = { city_lima, 2022, MONTH_jan, 0.023038156947444204, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.05456570155902005, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.09248554913294797, }, +[19] = { city_managua, 2022, MONTH_jan, 0.11166666666666666, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.01694915254237288, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.041666666666666664, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.11233211233211234, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.047756041426927506, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.1770573566084788, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.0037425149700598802, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.037800687285223365, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.06412825651302605, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.2173776662484316, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.06795302013422819, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.07147540983606557, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.11595394736842106, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.0016680567139282735, }, +[33] = { city_quito, 2022, MONTH_jan, 0.05396290050590219, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.1118421052631579, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.014885874958650347, }, +[36] = { city_accra, 2022, MONTH_jan, 0.1770573566084788, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.05301144848183176, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.017452006980802792, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.08312958435207823, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.03836317135549872, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.02875924404272802, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.06188925081433225, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.01675977653631285, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.0016680567139282735, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.05456570155902005, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.07147540983606557, }, +}; +global u32 question_20_len = sizeof(question_20_data) / sizeof(question_20_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_21.h b/run_tree/data/incenter_data/c/question_21.h new file mode 100644 index 0000000..1941474 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_21.h @@ -0,0 +1,1951 @@ +static Incenter_Data_Row question_21_data[] = { +[0] = { city_brisbane, 1965, MONTH_jan, 0.05562621593475342, }, +[1] = { city_brisbane, 1966, MONTH_jan, 0.05071894645690918, }, +[2] = { city_brisbane, 1967, MONTH_jan, 0.049495487213134765, }, +[3] = { city_brisbane, 1968, MONTH_jan, 0.04865467548370361, }, +[4] = { city_brisbane, 1969, MONTH_jan, 0.05086987972259521, }, +[5] = { city_brisbane, 1970, MONTH_jan, 0.05421450614929199, }, +[6] = { city_brisbane, 1971, MONTH_jan, 0.05822727203369141, }, +[7] = { city_brisbane, 1972, MONTH_jan, 0.05599285125732422, }, +[8] = { city_brisbane, 1973, MONTH_jan, 0.055886645317077634, }, +[9] = { city_brisbane, 1974, MONTH_jan, 0.05955109596252441, }, +[10] = { city_brisbane, 1975, MONTH_jan, 0.06297008037567138, }, +[11] = { city_brisbane, 1976, MONTH_jan, 0.05793421268463135, }, +[12] = { city_brisbane, 1977, MONTH_jan, 0.05269774913787842, }, +[13] = { city_brisbane, 1978, MONTH_jan, 0.0550869607925415, }, +[14] = { city_brisbane, 1979, MONTH_jan, 0.051658406257629394, }, +[15] = { city_brisbane, 1980, MONTH_jan, 0.04862271785736084, }, +[16] = { city_brisbane, 1981, MONTH_jan, 0.04930354595184326, }, +[17] = { city_brisbane, 1982, MONTH_jan, 0.046367826461791994, }, +[18] = { city_brisbane, 1983, MONTH_jan, 0.045344815254211426, }, +[19] = { city_brisbane, 1984, MONTH_jan, 0.04718454360961914, }, +[20] = { city_brisbane, 1985, MONTH_jan, 0.04863154888153076, }, +[21] = { city_brisbane, 1986, MONTH_jan, 0.047985596656799315, }, +[22] = { city_brisbane, 1987, MONTH_jan, 0.04532893180847168, }, +[23] = { city_brisbane, 1988, MONTH_jan, 0.046416802406311033, }, +[24] = { city_brisbane, 1989, MONTH_jan, 0.044199533462524414, }, +[25] = { city_brisbane, 1990, MONTH_jan, 0.044593911170959476, }, +[26] = { city_brisbane, 1991, MONTH_jan, 0.047400617599487306, }, +[27] = { city_brisbane, 1992, MONTH_jan, 0.04731717109680176, }, +[28] = { city_brisbane, 1993, MONTH_jan, 0.0475942850112915, }, +[29] = { city_brisbane, 1994, MONTH_jan, 0.045271806716918946, }, +[30] = { city_brisbane, 1995, MONTH_jan, 0.04239725112915039, }, +[31] = { city_brisbane, 1996, MONTH_jan, 0.0423659086227417, }, +[32] = { city_brisbane, 1997, MONTH_jan, 0.04145838737487793, }, +[33] = { city_brisbane, 1998, MONTH_jan, 0.04037755966186524, }, +[34] = { city_brisbane, 1999, MONTH_jan, 0.04008933544158935, }, +[35] = { city_brisbane, 2000, MONTH_jan, 0.03988877773284912, }, +[36] = { city_brisbane, 2001, MONTH_jan, 0.0387076210975647, }, +[37] = { city_brisbane, 2002, MONTH_jan, 0.03931450366973877, }, +[38] = { city_brisbane, 2003, MONTH_jan, 0.040149688720703125, }, +[39] = { city_brisbane, 2004, MONTH_jan, 0.04036560535430908, }, +[40] = { city_brisbane, 2005, MONTH_jan, 0.04313553333282471, }, +[41] = { city_brisbane, 2006, MONTH_jan, 0.04233413219451904, }, +[42] = { city_brisbane, 2007, MONTH_jan, 0.039767227172851555, }, +[43] = { city_brisbane, 2008, MONTH_jan, 0.03681326389312744, }, +[44] = { city_brisbane, 2009, MONTH_jan, 0.03920266151428222, }, +[45] = { city_brisbane, 2010, MONTH_jan, 0.04312804698944092, }, +[46] = { city_brisbane, 2011, MONTH_jan, 0.05698980808258056, }, +[47] = { city_brisbane, 2012, MONTH_jan, 0.05700209140777588, }, +[48] = { city_brisbane, 2013, MONTH_jan, 0.06525868892669678, }, +[49] = { city_brisbane, 2014, MONTH_jan, 0.05979823112487793, }, +[50] = { city_brisbane, 2015, MONTH_jan, 0.06290020942687988, }, +[51] = { city_brisbane, 2016, MONTH_jan, 0.07189175605773926, }, +[52] = { city_brisbane, 2017, MONTH_jan, 0.06750126838684083, }, +[53] = { city_brisbane, 2018, MONTH_jan, 0.08300061225891113, }, +[54] = { city_brisbane, 2019, MONTH_jan, 0.08880722045898437, }, +[55] = { city_brisbane, 2020, MONTH_jan, 0.10789811134338381, }, +[56] = { city_brisbane, 2021, MONTH_jan, 0.12933531761169434, }, +[57] = { city_dhaka, 1971, MONTH_jan, 0.03859757661819458, }, +[58] = { city_dhaka, 1972, MONTH_jan, 0.03406534433364868, }, +[59] = { city_dhaka, 1973, MONTH_jan, 0.050243868827819824, }, +[60] = { city_dhaka, 1974, MONTH_jan, 0.03463459491729736, }, +[61] = { city_dhaka, 1975, MONTH_jan, 0.06043976306915283, }, +[62] = { city_dhaka, 1976, MONTH_jan, 0.05868124008178711, }, +[63] = { city_dhaka, 1977, MONTH_jan, 0.05079775810241699, }, +[64] = { city_dhaka, 1978, MONTH_jan, 0.05536711692810058, }, +[65] = { city_dhaka, 1979, MONTH_jan, 0.05825671672821045, }, +[66] = { city_dhaka, 1980, MONTH_jan, 0.049608802795410155, }, +[67] = { city_dhaka, 1981, MONTH_jan, 0.05016649723052979, }, +[68] = { city_dhaka, 1982, MONTH_jan, 0.03805250644683838, }, +[69] = { city_dhaka, 1983, MONTH_jan, 0.048706588745117185, }, +[70] = { city_dhaka, 1984, MONTH_jan, 0.06105583190917969, }, +[71] = { city_dhaka, 1985, MONTH_jan, 0.04526681423187256, }, +[72] = { city_dhaka, 1986, MONTH_jan, 0.025327975749969478, }, +[73] = { city_dhaka, 1987, MONTH_jan, 0.026365013122558595, }, +[74] = { city_dhaka, 1988, MONTH_jan, 0.030908639430999755, }, +[75] = { city_dhaka, 1989, MONTH_jan, 0.03907864093780518, }, +[76] = { city_dhaka, 1990, MONTH_jan, 0.03539271354675293, }, +[77] = { city_dhaka, 1991, MONTH_jan, 0.03477609157562256, }, +[78] = { city_dhaka, 1992, MONTH_jan, 0.030288853645324708, }, +[79] = { city_dhaka, 1993, MONTH_jan, 0.02104328870773315, }, +[80] = { city_dhaka, 1994, MONTH_jan, 0.02761680603027344, }, +[81] = { city_dhaka, 1995, MONTH_jan, 0.010269947052001951, }, +[82] = { city_dhaka, 1996, MONTH_jan, 0.01947564125061035, }, +[83] = { city_dhaka, 1997, MONTH_jan, 0.018034275770187375, }, +[84] = { city_dhaka, 1998, MONTH_jan, 0.020371236801147462, }, +[85] = { city_dhaka, 1999, MONTH_jan, 0.0193972909450531, }, +[86] = { city_dhaka, 2000, MONTH_jan, 0.016270726919174194, }, +[87] = { city_dhaka, 2001, MONTH_jan, 0.01875003218650818, }, +[88] = { city_dhaka, 2002, MONTH_jan, 0.01362207531929016, }, +[89] = { city_dhaka, 2003, MONTH_jan, 0.012784041166305542, }, +[90] = { city_dhaka, 2004, MONTH_jan, 0.012296963930130005, }, +[91] = { city_dhaka, 2005, MONTH_jan, 0.011353458166122437, }, +[92] = { city_dhaka, 2006, MONTH_jan, 0.010463094711303711, }, +[93] = { city_dhaka, 2007, MONTH_jan, 0.010207374095916748, }, +[94] = { city_dhaka, 2008, MONTH_jan, 0.012218128442764282, }, +[95] = { city_dhaka, 2009, MONTH_jan, 0.0051176011562347416, }, +[96] = { city_dhaka, 2010, MONTH_jan, 0.008648931980133057, }, +[97] = { city_dhaka, 2011, MONTH_jan, 0.009513694643974304, }, +[98] = { city_dhaka, 2012, MONTH_jan, 0.008256486654281615, }, +[99] = { city_dhaka, 2013, MONTH_jan, 0.007885019183158875, }, +[100] = { city_dhaka, 2014, MONTH_jan, 0.0064616197347640994, }, +[101] = { city_dhaka, 2015, MONTH_jan, 0.008184085488319398, }, +[102] = { city_dhaka, 2016, MONTH_jan, 0.008060975074768066, }, +[103] = { city_dhaka, 2017, MONTH_jan, 0.00894644320011139, }, +[104] = { city_dhaka, 2018, MONTH_jan, 0.007471175193786621, }, +[105] = { city_dhaka, 2019, MONTH_jan, 0.00675128698348999, }, +[106] = { city_dhaka, 2020, MONTH_jan, 0.006580818295478821, }, +[107] = { city_dhaka, 2021, MONTH_jan, 0.0065014690160751345, }, +[108] = { city_brasilia, 1965, MONTH_jan, 0.2754872131347656, }, +[109] = { city_brasilia, 1966, MONTH_jan, 0.27618213653564455, }, +[110] = { city_brasilia, 1967, MONTH_jan, 0.27880290985107425, }, +[111] = { city_brasilia, 1968, MONTH_jan, 0.2555575370788575, }, +[112] = { city_brasilia, 1969, MONTH_jan, 0.2505621910095215, }, +[113] = { city_brasilia, 1970, MONTH_jan, 0.2690108108520508, }, +[114] = { city_brasilia, 1971, MONTH_jan, 0.26817771911621097, }, +[115] = { city_brasilia, 1972, MONTH_jan, 0.2739073371887207, }, +[116] = { city_brasilia, 1973, MONTH_jan, 0.2610169982910156, }, +[117] = { city_brasilia, 1974, MONTH_jan, 0.2692813491821289, }, +[118] = { city_brasilia, 1975, MONTH_jan, 0.279958610534668, }, +[119] = { city_brasilia, 1976, MONTH_jan, 0.2916008758544922, }, +[120] = { city_brasilia, 1977, MONTH_jan, 0.3108434295654297, }, +[121] = { city_brasilia, 1978, MONTH_jan, 0.31529354095458983, }, +[122] = { city_brasilia, 1979, MONTH_jan, 0.3338748931884766, }, +[123] = { city_brasilia, 1980, MONTH_jan, 0.3618800735473633, }, +[124] = { city_brasilia, 1981, MONTH_jan, 0.3750487899780273, }, +[125] = { city_brasilia, 1982, MONTH_jan, 0.3909782028198242, }, +[126] = { city_brasilia, 1983, MONTH_jan, 0.41867771148681643, }, +[127] = { city_brasilia, 1984, MONTH_jan, 0.43218948364257814, }, +[128] = { city_brasilia, 1985, MONTH_jan, 0.43929534912109375, }, +[129] = { city_brasilia, 1986, MONTH_jan, 0.4321952438354492, }, +[130] = { city_brasilia, 1987, MONTH_jan, 0.42777210235595703, }, +[131] = { city_brasilia, 1988, MONTH_jan, 0.4401119613647461, }, +[132] = { city_brasilia, 1989, MONTH_jan, 0.44574317932128904, }, +[133] = { city_brasilia, 1990, MONTH_jan, 0.4527548599243164, }, +[134] = { city_brasilia, 1991, MONTH_jan, 0.4586178970336914, }, +[135] = { city_brasilia, 1992, MONTH_jan, 0.44902706146240234, }, +[136] = { city_brasilia, 1993, MONTH_jan, 0.4515962982177734, }, +[137] = { city_brasilia, 1994, MONTH_jan, 0.44565601348876954, }, +[138] = { city_brasilia, 1995, MONTH_jan, 0.4434580993652344, }, +[139] = { city_brasilia, 1996, MONTH_jan, 0.44081958770751956, }, +[140] = { city_brasilia, 1997, MONTH_jan, 0.43489933013916016, }, +[141] = { city_brasilia, 1998, MONTH_jan, 0.43571971893310546, }, +[142] = { city_brasilia, 1999, MONTH_jan, 0.43143802642822265, }, +[143] = { city_brasilia, 2000, MONTH_jan, 0.4328843307495117, }, +[144] = { city_brasilia, 2001, MONTH_jan, 0.39111621856689455, }, +[145] = { city_brasilia, 2002, MONTH_jan, 0.4075665283203125, }, +[146] = { city_brasilia, 2003, MONTH_jan, 0.4228412628173828, }, +[147] = { city_brasilia, 2004, MONTH_jan, 0.4228615570068359, }, +[148] = { city_brasilia, 2005, MONTH_jan, 0.4314569854736328, }, +[149] = { city_brasilia, 2006, MONTH_jan, 0.4304596328735352, }, +[150] = { city_brasilia, 2007, MONTH_jan, 0.4438022613525391, }, +[151] = { city_brasilia, 2008, MONTH_jan, 0.4336677551269531, }, +[152] = { city_brasilia, 2009, MONTH_jan, 0.4630883026123047, }, +[153] = { city_brasilia, 2010, MONTH_jan, 0.4424653625488281, }, +[154] = { city_brasilia, 2011, MONTH_jan, 0.4391006088256836, }, +[155] = { city_brasilia, 2012, MONTH_jan, 0.42066368103027346, }, +[156] = { city_brasilia, 2013, MONTH_jan, 0.39836597442626953, }, +[157] = { city_brasilia, 2014, MONTH_jan, 0.38852745056152344, }, +[158] = { city_brasilia, 2015, MONTH_jan, 0.4060352325439453, }, +[159] = { city_brasilia, 2016, MONTH_jan, 0.43538700103759764, }, +[160] = { city_brasilia, 2017, MONTH_jan, 0.4328067779541016, }, +[161] = { city_brasilia, 2018, MONTH_jan, 0.46080497741699217, }, +[162] = { city_brasilia, 2019, MONTH_jan, 0.4730484390258789, }, +[163] = { city_brasilia, 2020, MONTH_jan, 0.4947188186645508, }, +[164] = { city_brasilia, 2021, MONTH_jan, 0.46219749450683595, }, +[165] = { city_ottawa, 1965, MONTH_jan, 0.2513864898681641, }, +[166] = { city_ottawa, 1966, MONTH_jan, 0.2619474792480469, }, +[167] = { city_ottawa, 1967, MONTH_jan, 0.2561042594909668, }, +[168] = { city_ottawa, 1968, MONTH_jan, 0.24474010467529297, }, +[169] = { city_ottawa, 1969, MONTH_jan, 0.25521268844604494, }, +[170] = { city_ottawa, 1970, MONTH_jan, 0.2502507591247558, }, +[171] = { city_ottawa, 1971, MONTH_jan, 0.24927824020385747, }, +[172] = { city_ottawa, 1972, MONTH_jan, 0.25893644332885746, }, +[173] = { city_ottawa, 1973, MONTH_jan, 0.2555288314819336, }, +[174] = { city_ottawa, 1974, MONTH_jan, 0.2681158256530762, }, +[175] = { city_ottawa, 1975, MONTH_jan, 0.2615631484985352, }, +[176] = { city_ottawa, 1976, MONTH_jan, 0.2633203506469727, }, +[177] = { city_ottawa, 1977, MONTH_jan, 0.25808473587036135, }, +[178] = { city_ottawa, 1978, MONTH_jan, 0.2705876922607422, }, +[179] = { city_ottawa, 1979, MONTH_jan, 0.2729702377319336, }, +[180] = { city_ottawa, 1980, MONTH_jan, 0.2753968620300293, }, +[181] = { city_ottawa, 1981, MONTH_jan, 0.29403928756713865, }, +[182] = { city_ottawa, 1982, MONTH_jan, 0.29416236877441404, }, +[183] = { city_ottawa, 1983, MONTH_jan, 0.30499225616455083, }, +[184] = { city_ottawa, 1984, MONTH_jan, 0.30855842590332033, }, +[185] = { city_ottawa, 1985, MONTH_jan, 0.3161163330078125, }, +[186] = { city_ottawa, 1986, MONTH_jan, 0.32045928955078123, }, +[187] = { city_ottawa, 1987, MONTH_jan, 0.316495418548584, }, +[188] = { city_ottawa, 1988, MONTH_jan, 0.29611337661743165, }, +[189] = { city_ottawa, 1989, MONTH_jan, 0.2781739616394043, }, +[190] = { city_ottawa, 1990, MONTH_jan, 0.29480998992919916, }, +[191] = { city_ottawa, 1991, MONTH_jan, 0.30499427795410156, }, +[192] = { city_ottawa, 1992, MONTH_jan, 0.30512109756469724, }, +[193] = { city_ottawa, 1993, MONTH_jan, 0.3045089340209961, }, +[194] = { city_ottawa, 1994, MONTH_jan, 0.2992730140686035, }, +[195] = { city_ottawa, 1995, MONTH_jan, 0.2988811683654785, }, +[196] = { city_ottawa, 1996, MONTH_jan, 0.3087930679321289, }, +[197] = { city_ottawa, 1997, MONTH_jan, 0.3028490447998047, }, +[198] = { city_ottawa, 1998, MONTH_jan, 0.29307371139526367, }, +[199] = { city_ottawa, 1999, MONTH_jan, 0.29588794708251953, }, +[200] = { city_ottawa, 2000, MONTH_jan, 0.297678165435791, }, +[201] = { city_ottawa, 2001, MONTH_jan, 0.282014102935791, }, +[202] = { city_ottawa, 2002, MONTH_jan, 0.2854655647277832, }, +[203] = { city_ottawa, 2003, MONTH_jan, 0.2718001365661621, }, +[204] = { city_ottawa, 2004, MONTH_jan, 0.2682792282104492, }, +[205] = { city_ottawa, 2005, MONTH_jan, 0.2826547622680664, }, +[206] = { city_ottawa, 2006, MONTH_jan, 0.2761646842956543, }, +[207] = { city_ottawa, 2007, MONTH_jan, 0.2769431495666504, }, +[208] = { city_ottawa, 2008, MONTH_jan, 0.2859009170532227, }, +[209] = { city_ottawa, 2009, MONTH_jan, 0.2920944976806641, }, +[210] = { city_ottawa, 2010, MONTH_jan, 0.27789688110351557, }, +[211] = { city_ottawa, 2011, MONTH_jan, 0.2862636947631836, }, +[212] = { city_ottawa, 2012, MONTH_jan, 0.2897691345214844, }, +[213] = { city_ottawa, 2013, MONTH_jan, 0.2894182777404785, }, +[214] = { city_ottawa, 2014, MONTH_jan, 0.2814776039123535, }, +[215] = { city_ottawa, 2015, MONTH_jan, 0.2876414680480957, }, +[216] = { city_ottawa, 2016, MONTH_jan, 0.29652599334716795, }, +[217] = { city_ottawa, 2017, MONTH_jan, 0.2967363929748535, }, +[218] = { city_ottawa, 2018, MONTH_jan, 0.28814517974853515, }, +[219] = { city_ottawa, 2019, MONTH_jan, 0.2858637619018555, }, +[220] = { city_ottawa, 2020, MONTH_jan, 0.3054215049743652, }, +[221] = { city_ottawa, 2021, MONTH_jan, 0.29888439178466797, }, +[222] = { city_chengdu, 1965, MONTH_jan, 0.042534070014953615, }, +[223] = { city_beijing, 1965, MONTH_jan, 0.042534070014953615, }, +[224] = { city_chengdu, 1966, MONTH_jan, 0.039831228256225586, }, +[225] = { city_beijing, 1966, MONTH_jan, 0.039831228256225586, }, +[226] = { city_chengdu, 1967, MONTH_jan, 0.038183979988098145, }, +[227] = { city_beijing, 1967, MONTH_jan, 0.038183979988098145, }, +[228] = { city_chengdu, 1968, MONTH_jan, 0.04458870887756348, }, +[229] = { city_beijing, 1968, MONTH_jan, 0.04458870887756348, }, +[230] = { city_chengdu, 1969, MONTH_jan, 0.03727402210235596, }, +[231] = { city_beijing, 1969, MONTH_jan, 0.03727402210235596, }, +[232] = { city_chengdu, 1970, MONTH_jan, 0.03009592294692993, }, +[233] = { city_beijing, 1970, MONTH_jan, 0.03009592294692993, }, +[234] = { city_chengdu, 1971, MONTH_jan, 0.030704047679901123, }, +[235] = { city_beijing, 1971, MONTH_jan, 0.030704047679901123, }, +[236] = { city_chengdu, 1972, MONTH_jan, 0.0322759747505188, }, +[237] = { city_beijing, 1972, MONTH_jan, 0.0322759747505188, }, +[238] = { city_chengdu, 1973, MONTH_jan, 0.03417015075683594, }, +[239] = { city_beijing, 1973, MONTH_jan, 0.03417015075683594, }, +[240] = { city_chengdu, 1974, MONTH_jan, 0.03749354600906372, }, +[241] = { city_beijing, 1974, MONTH_jan, 0.03749354600906372, }, +[242] = { city_chengdu, 1975, MONTH_jan, 0.035038237571716306, }, +[243] = { city_beijing, 1975, MONTH_jan, 0.035038237571716306, }, +[244] = { city_chengdu, 1976, MONTH_jan, 0.03372568368911743, }, +[245] = { city_beijing, 1976, MONTH_jan, 0.03372568368911743, }, +[246] = { city_chengdu, 1977, MONTH_jan, 0.03228713989257812, }, +[247] = { city_beijing, 1977, MONTH_jan, 0.03228713989257812, }, +[248] = { city_chengdu, 1978, MONTH_jan, 0.027594637870788575, }, +[249] = { city_beijing, 1978, MONTH_jan, 0.027594637870788575, }, +[250] = { city_chengdu, 1979, MONTH_jan, 0.03008899211883545, }, +[251] = { city_beijing, 1979, MONTH_jan, 0.03008899211883545, }, +[252] = { city_chengdu, 1980, MONTH_jan, 0.035661976337432864, }, +[253] = { city_beijing, 1980, MONTH_jan, 0.035661976337432864, }, +[254] = { city_chengdu, 1981, MONTH_jan, 0.040664968490600584, }, +[255] = { city_beijing, 1981, MONTH_jan, 0.040664968490600584, }, +[256] = { city_chengdu, 1982, MONTH_jan, 0.044212722778320314, }, +[257] = { city_beijing, 1982, MONTH_jan, 0.044212722778320314, }, +[258] = { city_chengdu, 1983, MONTH_jan, 0.048234906196594235, }, +[259] = { city_beijing, 1983, MONTH_jan, 0.048234906196594235, }, +[260] = { city_chengdu, 1984, MONTH_jan, 0.045154547691345213, }, +[261] = { city_beijing, 1984, MONTH_jan, 0.045154547691345213, }, +[262] = { city_chengdu, 1985, MONTH_jan, 0.04441830158233642, }, +[263] = { city_beijing, 1985, MONTH_jan, 0.04441830158233642, }, +[264] = { city_chengdu, 1986, MONTH_jan, 0.043385276794433596, }, +[265] = { city_beijing, 1986, MONTH_jan, 0.043385276794433596, }, +[266] = { city_chengdu, 1987, MONTH_jan, 0.04255547523498535, }, +[267] = { city_beijing, 1987, MONTH_jan, 0.04255547523498535, }, +[268] = { city_chengdu, 1988, MONTH_jan, 0.043230724334716794, }, +[269] = { city_beijing, 1988, MONTH_jan, 0.043230724334716794, }, +[270] = { city_chengdu, 1989, MONTH_jan, 0.044680271148681644, }, +[271] = { city_beijing, 1989, MONTH_jan, 0.044680271148681644, }, +[272] = { city_chengdu, 1990, MONTH_jan, 0.04723667621612549, }, +[273] = { city_beijing, 1990, MONTH_jan, 0.04723667621612549, }, +[274] = { city_chengdu, 1991, MONTH_jan, 0.04424777984619141, }, +[275] = { city_beijing, 1991, MONTH_jan, 0.04424777984619141, }, +[276] = { city_chengdu, 1992, MONTH_jan, 0.04412701606750488, }, +[277] = { city_beijing, 1992, MONTH_jan, 0.04412701606750488, }, +[278] = { city_chengdu, 1993, MONTH_jan, 0.04757860660552979, }, +[279] = { city_beijing, 1993, MONTH_jan, 0.04757860660552979, }, +[280] = { city_chengdu, 1994, MONTH_jan, 0.04952474117279053, }, +[281] = { city_beijing, 1994, MONTH_jan, 0.04952474117279053, }, +[282] = { city_chengdu, 1995, MONTH_jan, 0.05553820133209229, }, +[283] = { city_beijing, 1995, MONTH_jan, 0.05553820133209229, }, +[284] = { city_chengdu, 1996, MONTH_jan, 0.05143133163452149, }, +[285] = { city_beijing, 1996, MONTH_jan, 0.05143133163452149, }, +[286] = { city_chengdu, 1997, MONTH_jan, 0.05361733913421631, }, +[287] = { city_beijing, 1997, MONTH_jan, 0.05361733913421631, }, +[288] = { city_chengdu, 1998, MONTH_jan, 0.054277782440185544, }, +[289] = { city_beijing, 1998, MONTH_jan, 0.054277782440185544, }, +[290] = { city_chengdu, 1999, MONTH_jan, 0.05188285827636719, }, +[291] = { city_beijing, 1999, MONTH_jan, 0.05188285827636719, }, +[292] = { city_chengdu, 2000, MONTH_jan, 0.05656925201416016, }, +[293] = { city_beijing, 2000, MONTH_jan, 0.05656925201416016, }, +[294] = { city_chengdu, 2001, MONTH_jan, 0.06618624210357665, }, +[295] = { city_beijing, 2001, MONTH_jan, 0.06618624210357665, }, +[296] = { city_chengdu, 2002, MONTH_jan, 0.0628048849105835, }, +[297] = { city_beijing, 2002, MONTH_jan, 0.0628048849105835, }, +[298] = { city_chengdu, 2003, MONTH_jan, 0.05301109313964844, }, +[299] = { city_beijing, 2003, MONTH_jan, 0.05301109313964844, }, +[300] = { city_chengdu, 2004, MONTH_jan, 0.05600940227508545, }, +[301] = { city_beijing, 2004, MONTH_jan, 0.05600940227508545, }, +[302] = { city_chengdu, 2005, MONTH_jan, 0.05554481029510498, }, +[303] = { city_beijing, 2005, MONTH_jan, 0.05554481029510498, }, +[304] = { city_chengdu, 2006, MONTH_jan, 0.055779824256896975, }, +[305] = { city_beijing, 2006, MONTH_jan, 0.055779824256896975, }, +[306] = { city_chengdu, 2007, MONTH_jan, 0.0571853494644165, }, +[307] = { city_beijing, 2007, MONTH_jan, 0.0571853494644165, }, +[308] = { city_chengdu, 2008, MONTH_jan, 0.07268667221069336, }, +[309] = { city_beijing, 2008, MONTH_jan, 0.07268667221069336, }, +[310] = { city_chengdu, 2009, MONTH_jan, 0.06935531616210938, }, +[311] = { city_beijing, 2009, MONTH_jan, 0.06935531616210938, }, +[312] = { city_chengdu, 2010, MONTH_jan, 0.07615997791290283, }, +[313] = { city_beijing, 2010, MONTH_jan, 0.07615997791290283, }, +[314] = { city_chengdu, 2011, MONTH_jan, 0.07084204196929932, }, +[315] = { city_beijing, 2011, MONTH_jan, 0.07084204196929932, }, +[316] = { city_chengdu, 2012, MONTH_jan, 0.08522597312927246, }, +[317] = { city_beijing, 2012, MONTH_jan, 0.08522597312927246, }, +[318] = { city_chengdu, 2013, MONTH_jan, 0.08959421157836914, }, +[319] = { city_beijing, 2013, MONTH_jan, 0.08959421157836914, }, +[320] = { city_chengdu, 2014, MONTH_jan, 0.10197330474853515, }, +[321] = { city_beijing, 2014, MONTH_jan, 0.10197330474853515, }, +[322] = { city_chengdu, 2015, MONTH_jan, 0.10787498474121093, }, +[323] = { city_beijing, 2015, MONTH_jan, 0.10787498474121093, }, +[324] = { city_chengdu, 2016, MONTH_jan, 0.11530946731567385, }, +[325] = { city_beijing, 2016, MONTH_jan, 0.11530946731567385, }, +[326] = { city_chengdu, 2017, MONTH_jan, 0.12138820648193359, }, +[327] = { city_beijing, 2017, MONTH_jan, 0.12138820648193359, }, +[328] = { city_chengdu, 2018, MONTH_jan, 0.12807393074035645, }, +[329] = { city_beijing, 2018, MONTH_jan, 0.12807393074035645, }, +[330] = { city_chengdu, 2019, MONTH_jan, 0.1351595973968506, }, +[331] = { city_beijing, 2019, MONTH_jan, 0.1351595973968506, }, +[332] = { city_chengdu, 2020, MONTH_jan, 0.1424287223815918, }, +[333] = { city_beijing, 2020, MONTH_jan, 0.1424287223815918, }, +[334] = { city_chengdu, 2021, MONTH_jan, 0.14946244239807127, }, +[335] = { city_beijing, 2021, MONTH_jan, 0.14946244239807127, }, +[336] = { city_bogota, 1965, MONTH_jan, 0.11788208961486817, }, +[337] = { city_bogota, 1966, MONTH_jan, 0.12017394065856933, }, +[338] = { city_bogota, 1967, MONTH_jan, 0.12580106735229493, }, +[339] = { city_bogota, 1968, MONTH_jan, 0.13300461769104005, }, +[340] = { city_bogota, 1969, MONTH_jan, 0.1452613925933838, }, +[341] = { city_bogota, 1970, MONTH_jan, 0.14817516326904298, }, +[342] = { city_bogota, 1971, MONTH_jan, 0.15987798690795899, }, +[343] = { city_bogota, 1972, MONTH_jan, 0.15767953872680665, }, +[344] = { city_bogota, 1973, MONTH_jan, 0.17170427322387696, }, +[345] = { city_bogota, 1974, MONTH_jan, 0.17395509719848634, }, +[346] = { city_bogota, 1975, MONTH_jan, 0.19235607147216796, }, +[347] = { city_bogota, 1976, MONTH_jan, 0.1940712547302246, }, +[348] = { city_bogota, 1977, MONTH_jan, 0.1936701011657715, }, +[349] = { city_bogota, 1978, MONTH_jan, 0.20862884521484376, }, +[350] = { city_bogota, 1979, MONTH_jan, 0.2154510498046875, }, +[351] = { city_bogota, 1980, MONTH_jan, 0.23044971466064454, }, +[352] = { city_bogota, 1981, MONTH_jan, 0.2221888542175293, }, +[353] = { city_bogota, 1982, MONTH_jan, 0.22697723388671875, }, +[354] = { city_bogota, 1983, MONTH_jan, 0.2179018783569336, }, +[355] = { city_bogota, 1984, MONTH_jan, 0.23639833450317382, }, +[356] = { city_bogota, 1985, MONTH_jan, 0.2444196128845215, }, +[357] = { city_bogota, 1986, MONTH_jan, 0.27276325225830084, }, +[358] = { city_bogota, 1987, MONTH_jan, 0.2731085395812988, }, +[359] = { city_bogota, 1988, MONTH_jan, 0.28748077392578125, }, +[360] = { city_bogota, 1989, MONTH_jan, 0.29793998718261716, }, +[361] = { city_bogota, 1990, MONTH_jan, 0.32640933990478516, }, +[362] = { city_bogota, 1991, MONTH_jan, 0.3169980049133301, }, +[363] = { city_bogota, 1992, MONTH_jan, 0.2460545539855957, }, +[364] = { city_bogota, 1993, MONTH_jan, 0.27847396850585937, }, +[365] = { city_bogota, 1994, MONTH_jan, 0.2980908203125, }, +[366] = { city_bogota, 1995, MONTH_jan, 0.2933157730102539, }, +[367] = { city_bogota, 1996, MONTH_jan, 0.31475914001464844, }, +[368] = { city_bogota, 1997, MONTH_jan, 0.27334064483642573, }, +[369] = { city_bogota, 1998, MONTH_jan, 0.26691463470458987, }, +[370] = { city_bogota, 1999, MONTH_jan, 0.3137824821472168, }, +[371] = { city_bogota, 2000, MONTH_jan, 0.29556066513061524, }, +[372] = { city_bogota, 2001, MONTH_jan, 0.3060448455810547, }, +[373] = { city_bogota, 2002, MONTH_jan, 0.32692554473876956, }, +[374] = { city_bogota, 2003, MONTH_jan, 0.3338913345336914, }, +[375] = { city_bogota, 2004, MONTH_jan, 0.3450545501708984, }, +[376] = { city_bogota, 2005, MONTH_jan, 0.35053531646728514, }, +[377] = { city_bogota, 2006, MONTH_jan, 0.34142719268798827, }, +[378] = { city_bogota, 2007, MONTH_jan, 0.35182762145996094, }, +[379] = { city_bogota, 2008, MONTH_jan, 0.33941410064697264, }, +[380] = { city_bogota, 2009, MONTH_jan, 0.31377744674682617, }, +[381] = { city_bogota, 2010, MONTH_jan, 0.30092037200927735, }, +[382] = { city_bogota, 2011, MONTH_jan, 0.34515674591064455, }, +[383] = { city_bogota, 2012, MONTH_jan, 0.3174613380432129, }, +[384] = { city_bogota, 2013, MONTH_jan, 0.29385107040405273, }, +[385] = { city_bogota, 2014, MONTH_jan, 0.2836468505859375, }, +[386] = { city_bogota, 2015, MONTH_jan, 0.280216178894043, }, +[387] = { city_bogota, 2016, MONTH_jan, 0.2770881271362305, }, +[388] = { city_bogota, 2017, MONTH_jan, 0.3282905960083008, }, +[389] = { city_bogota, 2018, MONTH_jan, 0.31999549865722654, }, +[390] = { city_bogota, 2019, MONTH_jan, 0.29890342712402346, }, +[391] = { city_bogota, 2020, MONTH_jan, 0.3077278709411621, }, +[392] = { city_bogota, 2021, MONTH_jan, 0.33020408630371095, }, +[393] = { city_quito, 1965, MONTH_jan, 0.0850521469116211, }, +[394] = { city_quito, 1966, MONTH_jan, 0.0924820613861084, }, +[395] = { city_quito, 1967, MONTH_jan, 0.09417126655578612, }, +[396] = { city_quito, 1968, MONTH_jan, 0.08330953598022461, }, +[397] = { city_quito, 1969, MONTH_jan, 0.08701672554016113, }, +[398] = { city_quito, 1970, MONTH_jan, 0.08106535911560059, }, +[399] = { city_quito, 1971, MONTH_jan, 0.08015813827514648, }, +[400] = { city_quito, 1972, MONTH_jan, 0.07758965969085693, }, +[401] = { city_quito, 1973, MONTH_jan, 0.07086233615875244, }, +[402] = { city_quito, 1974, MONTH_jan, 0.06978053569793702, }, +[403] = { city_quito, 1975, MONTH_jan, 0.08653943061828613, }, +[404] = { city_quito, 1976, MONTH_jan, 0.07572480201721192, }, +[405] = { city_quito, 1977, MONTH_jan, 0.05873260498046875, }, +[406] = { city_quito, 1978, MONTH_jan, 0.07960052967071533, }, +[407] = { city_quito, 1979, MONTH_jan, 0.0685176420211792, }, +[408] = { city_quito, 1980, MONTH_jan, 0.06642500877380371, }, +[409] = { city_quito, 1981, MONTH_jan, 0.05350114345550537, }, +[410] = { city_quito, 1982, MONTH_jan, 0.0559368371963501, }, +[411] = { city_quito, 1983, MONTH_jan, 0.10982114791870115, }, +[412] = { city_quito, 1984, MONTH_jan, 0.18537538528442382, }, +[413] = { city_quito, 1985, MONTH_jan, 0.15903298377990724, }, +[414] = { city_quito, 1986, MONTH_jan, 0.18563940048217772, }, +[415] = { city_quito, 1987, MONTH_jan, 0.2051675033569336, }, +[416] = { city_quito, 1988, MONTH_jan, 0.18759294509887695, }, +[417] = { city_quito, 1989, MONTH_jan, 0.1867353248596191, }, +[418] = { city_quito, 1990, MONTH_jan, 0.18208444595336912, }, +[419] = { city_quito, 1991, MONTH_jan, 0.16781824111938476, }, +[420] = { city_quito, 1992, MONTH_jan, 0.1652834701538086, }, +[421] = { city_quito, 1993, MONTH_jan, 0.18627613067626952, }, +[422] = { city_quito, 1994, MONTH_jan, 0.19351001739501952, }, +[423] = { city_quito, 1995, MONTH_jan, 0.160936336517334, }, +[424] = { city_quito, 1996, MONTH_jan, 0.17381893157958983, }, +[425] = { city_quito, 1997, MONTH_jan, 0.16071613311767577, }, +[426] = { city_quito, 1998, MONTH_jan, 0.15920068740844728, }, +[427] = { city_quito, 1999, MONTH_jan, 0.19251895904541017, }, +[428] = { city_quito, 2000, MONTH_jan, 0.21613927841186523, }, +[429] = { city_quito, 2001, MONTH_jan, 0.19692354202270507, }, +[430] = { city_quito, 2002, MONTH_jan, 0.21095178604125978, }, +[431] = { city_quito, 2003, MONTH_jan, 0.19533443450927734, }, +[432] = { city_quito, 2004, MONTH_jan, 0.1873490524291992, }, +[433] = { city_quito, 2005, MONTH_jan, 0.1659660530090332, }, +[434] = { city_quito, 2006, MONTH_jan, 0.16251609802246095, }, +[435] = { city_quito, 2007, MONTH_jan, 0.1955727195739746, }, +[436] = { city_quito, 2008, MONTH_jan, 0.22617521286010744, }, +[437] = { city_quito, 2009, MONTH_jan, 0.18929243087768555, }, +[438] = { city_quito, 2010, MONTH_jan, 0.15936485290527344, }, +[439] = { city_quito, 2011, MONTH_jan, 0.19198841094970703, }, +[440] = { city_quito, 2012, MONTH_jan, 0.19840085983276368, }, +[441] = { city_quito, 2013, MONTH_jan, 0.1737746238708496, }, +[442] = { city_quito, 2014, MONTH_jan, 0.1727614212036133, }, +[443] = { city_quito, 2015, MONTH_jan, 0.19640232086181642, }, +[444] = { city_quito, 2016, MONTH_jan, 0.2362802505493164, }, +[445] = { city_quito, 2017, MONTH_jan, 0.2833585739135743, }, +[446] = { city_quito, 2018, MONTH_jan, 0.2738693428039551, }, +[447] = { city_quito, 2019, MONTH_jan, 0.31769020080566407, }, +[448] = { city_quito, 2020, MONTH_jan, 0.3603577423095703, }, +[449] = { city_quito, 2021, MONTH_jan, 0.32354198455810546, }, +[450] = { city_cairo, 1965, MONTH_jan, 0.055878944396972656, }, +[451] = { city_cairo, 1966, MONTH_jan, 0.055950436592102054, }, +[452] = { city_cairo, 1967, MONTH_jan, 0.07041625022888183, }, +[453] = { city_cairo, 1968, MONTH_jan, 0.09956792831420898, }, +[454] = { city_cairo, 1969, MONTH_jan, 0.16082429885864258, }, +[455] = { city_cairo, 1970, MONTH_jan, 0.1516463565826416, }, +[456] = { city_cairo, 1971, MONTH_jan, 0.1587799835205078, }, +[457] = { city_cairo, 1972, MONTH_jan, 0.14635689735412596, }, +[458] = { city_cairo, 1973, MONTH_jan, 0.15458051681518556, }, +[459] = { city_cairo, 1974, MONTH_jan, 0.16143081665039063, }, +[460] = { city_cairo, 1975, MONTH_jan, 0.16160579681396484, }, +[461] = { city_cairo, 1976, MONTH_jan, 0.15923643112182614, }, +[462] = { city_cairo, 1977, MONTH_jan, 0.16571006774902344, }, +[463] = { city_cairo, 1978, MONTH_jan, 0.17237102508544921, }, +[464] = { city_cairo, 1979, MONTH_jan, 0.15267534255981444, }, +[465] = { city_cairo, 1980, MONTH_jan, 0.13694029808044433, }, +[466] = { city_cairo, 1981, MONTH_jan, 0.12526339530944824, }, +[467] = { city_cairo, 1982, MONTH_jan, 0.11533038139343262, }, +[468] = { city_cairo, 1983, MONTH_jan, 0.09980415344238279, }, +[469] = { city_cairo, 1984, MONTH_jan, 0.08979602813720704, }, +[470] = { city_cairo, 1985, MONTH_jan, 0.08225811958312988, }, +[471] = { city_cairo, 1986, MONTH_jan, 0.07888433456420899, }, +[472] = { city_cairo, 1987, MONTH_jan, 0.0743703556060791, }, +[473] = { city_cairo, 1988, MONTH_jan, 0.07214404582977295, }, +[474] = { city_cairo, 1989, MONTH_jan, 0.07353952407836914, }, +[475] = { city_cairo, 1990, MONTH_jan, 0.07520865440368653, }, +[476] = { city_cairo, 1991, MONTH_jan, 0.07396338939666748, }, +[477] = { city_cairo, 1992, MONTH_jan, 0.07380685806274415, }, +[478] = { city_cairo, 1993, MONTH_jan, 0.07595428943634033, }, +[479] = { city_cairo, 1994, MONTH_jan, 0.07676783084869385, }, +[480] = { city_cairo, 1995, MONTH_jan, 0.07558946132659912, }, +[481] = { city_cairo, 1996, MONTH_jan, 0.07361753940582276, }, +[482] = { city_cairo, 1997, MONTH_jan, 0.07243848800659179, }, +[483] = { city_cairo, 1998, MONTH_jan, 0.07154178619384766, }, +[484] = { city_cairo, 1999, MONTH_jan, 0.07409151077270508, }, +[485] = { city_cairo, 2000, MONTH_jan, 0.07416068077087402, }, +[486] = { city_cairo, 2001, MONTH_jan, 0.07225909233093261, }, +[487] = { city_cairo, 2002, MONTH_jan, 0.06795775890350342, }, +[488] = { city_cairo, 2003, MONTH_jan, 0.059376978874206544, }, +[489] = { city_cairo, 2004, MONTH_jan, 0.05634644031524658, }, +[490] = { city_cairo, 2005, MONTH_jan, 0.05385705947875977, }, +[491] = { city_cairo, 2006, MONTH_jan, 0.05172313690185547, }, +[492] = { city_cairo, 2007, MONTH_jan, 0.053631553649902346, }, +[493] = { city_cairo, 2008, MONTH_jan, 0.05414237022399902, }, +[494] = { city_cairo, 2009, MONTH_jan, 0.04800594806671143, }, +[495] = { city_cairo, 2010, MONTH_jan, 0.04461719036102295, }, +[496] = { city_cairo, 2011, MONTH_jan, 0.04331544399261475, }, +[497] = { city_cairo, 2012, MONTH_jan, 0.041802897453308105, }, +[498] = { city_cairo, 2013, MONTH_jan, 0.04177184581756592, }, +[499] = { city_cairo, 2014, MONTH_jan, 0.04181652545928955, }, +[500] = { city_cairo, 2015, MONTH_jan, 0.043288531303405764, }, +[501] = { city_cairo, 2016, MONTH_jan, 0.041314678192138674, }, +[502] = { city_cairo, 2017, MONTH_jan, 0.038699905872344974, }, +[503] = { city_cairo, 2018, MONTH_jan, 0.04055405616760254, }, +[504] = { city_cairo, 2019, MONTH_jan, 0.05169897556304932, }, +[505] = { city_cairo, 2020, MONTH_jan, 0.06564623832702637, }, +[506] = { city_cairo, 2021, MONTH_jan, 0.06230570793151855, }, +[507] = { city_paris, 1965, MONTH_jan, 0.10584983825683594, }, +[508] = { city_paris, 1966, MONTH_jan, 0.1160239315032959, }, +[509] = { city_paris, 1967, MONTH_jan, 0.09537199020385742, }, +[510] = { city_paris, 1968, MONTH_jan, 0.10092880249023438, }, +[511] = { city_paris, 1969, MONTH_jan, 0.09634167671203611, }, +[512] = { city_paris, 1970, MONTH_jan, 0.09537435531616213, }, +[513] = { city_paris, 1971, MONTH_jan, 0.07942842483520508, }, +[514] = { city_paris, 1972, MONTH_jan, 0.07446317195892334, }, +[515] = { city_paris, 1973, MONTH_jan, 0.06709061622619629, }, +[516] = { city_paris, 1974, MONTH_jan, 0.08016220092773438, }, +[517] = { city_paris, 1975, MONTH_jan, 0.09053054809570313, }, +[518] = { city_paris, 1976, MONTH_jan, 0.06899677753448487, }, +[519] = { city_paris, 1977, MONTH_jan, 0.1059511947631836, }, +[520] = { city_paris, 1978, MONTH_jan, 0.09109526634216308, }, +[521] = { city_paris, 1979, MONTH_jan, 0.08611678123474122, }, +[522] = { city_paris, 1980, MONTH_jan, 0.09114398002624512, }, +[523] = { city_paris, 1981, MONTH_jan, 0.09551752090454102, }, +[524] = { city_paris, 1982, MONTH_jan, 0.09705157279968261, }, +[525] = { city_paris, 1983, MONTH_jan, 0.09325616836547851, }, +[526] = { city_paris, 1984, MONTH_jan, 0.08554503440856934, }, +[527] = { city_paris, 1985, MONTH_jan, 0.07887791156768799, }, +[528] = { city_paris, 1986, MONTH_jan, 0.07764792442321777, }, +[529] = { city_paris, 1987, MONTH_jan, 0.0858464527130127, }, +[530] = { city_paris, 1988, MONTH_jan, 0.09174312591552734, }, +[531] = { city_paris, 1989, MONTH_jan, 0.055997366905212405, }, +[532] = { city_paris, 1990, MONTH_jan, 0.06222640991210938, }, +[533] = { city_paris, 1991, MONTH_jan, 0.0626654052734375, }, +[534] = { city_paris, 1992, MONTH_jan, 0.07399243831634522, }, +[535] = { city_paris, 1993, MONTH_jan, 0.06968883514404296, }, +[536] = { city_paris, 1994, MONTH_jan, 0.08563506126403808, }, +[537] = { city_paris, 1995, MONTH_jan, 0.07823903083801269, }, +[538] = { city_paris, 1996, MONTH_jan, 0.06882894039154053, }, +[539] = { city_paris, 1997, MONTH_jan, 0.0680388879776001, }, +[540] = { city_paris, 1998, MONTH_jan, 0.06470213890075684, }, +[541] = { city_paris, 1999, MONTH_jan, 0.07388863086700441, }, +[542] = { city_paris, 2000, MONTH_jan, 0.06744560718536377, }, +[543] = { city_paris, 2001, MONTH_jan, 0.07405366897583007, }, +[544] = { city_paris, 2002, MONTH_jan, 0.06175621032714844, }, +[545] = { city_paris, 2003, MONTH_jan, 0.059621820449829104, }, +[546] = { city_paris, 2004, MONTH_jan, 0.05970314979553223, }, +[547] = { city_paris, 2005, MONTH_jan, 0.05365334033966065, }, +[548] = { city_paris, 2006, MONTH_jan, 0.059697318077087405, }, +[549] = { city_paris, 2007, MONTH_jan, 0.06638713359832764, }, +[550] = { city_paris, 2008, MONTH_jan, 0.07632267475128174, }, +[551] = { city_paris, 2009, MONTH_jan, 0.0770644998550415, }, +[552] = { city_paris, 2010, MONTH_jan, 0.08220292091369628, }, +[553] = { city_paris, 2011, MONTH_jan, 0.0718551778793335, }, +[554] = { city_paris, 2012, MONTH_jan, 0.0913736343383789, }, +[555] = { city_paris, 2013, MONTH_jan, 0.10459434509277343, }, +[556] = { city_paris, 2014, MONTH_jan, 0.1045927906036377, }, +[557] = { city_paris, 2015, MONTH_jan, 0.10147398948669434, }, +[558] = { city_paris, 2016, MONTH_jan, 0.1097524642944336, }, +[559] = { city_paris, 2017, MONTH_jan, 0.10437264442443847, }, +[560] = { city_paris, 2018, MONTH_jan, 0.12132494926452636, }, +[561] = { city_paris, 2019, MONTH_jan, 0.12384904861450195, }, +[562] = { city_paris, 2020, MONTH_jan, 0.1478874683380127, }, +[563] = { city_paris, 2021, MONTH_jan, 0.13671010971069336, }, +[564] = { city_berlin, 1965, MONTH_jan, 0.016145030260086058, }, +[565] = { city_berlin, 1966, MONTH_jan, 0.01741612911224365, }, +[566] = { city_berlin, 1967, MONTH_jan, 0.01658253788948059, }, +[567] = { city_berlin, 1968, MONTH_jan, 0.01576139807701111, }, +[568] = { city_berlin, 1969, MONTH_jan, 0.011857671737670899, }, +[569] = { city_berlin, 1970, MONTH_jan, 0.015171291828155518, }, +[570] = { city_berlin, 1971, MONTH_jan, 0.01179680585861206, }, +[571] = { city_berlin, 1972, MONTH_jan, 0.011219959259033203, }, +[572] = { city_berlin, 1973, MONTH_jan, 0.012137141227722168, }, +[573] = { city_berlin, 1974, MONTH_jan, 0.014188613891601563, }, +[574] = { city_berlin, 1975, MONTH_jan, 0.014353294372558594, }, +[575] = { city_berlin, 1976, MONTH_jan, 0.011208523511886597, }, +[576] = { city_berlin, 1977, MONTH_jan, 0.013967294692993164, }, +[577] = { city_berlin, 1978, MONTH_jan, 0.01408961057662964, }, +[578] = { city_berlin, 1979, MONTH_jan, 0.013454017639160156, }, +[579] = { city_berlin, 1980, MONTH_jan, 0.01478190541267395, }, +[580] = { city_berlin, 1981, MONTH_jan, 0.015739785432815553, }, +[581] = { city_berlin, 1982, MONTH_jan, 0.01617851257324219, }, +[582] = { city_berlin, 1983, MONTH_jan, 0.014992613792419434, }, +[583] = { city_berlin, 1984, MONTH_jan, 0.0143718421459198, }, +[584] = { city_berlin, 1985, MONTH_jan, 0.013216147422790528, }, +[585] = { city_berlin, 1986, MONTH_jan, 0.014105298519134519, }, +[586] = { city_berlin, 1987, MONTH_jan, 0.015094993114471435, }, +[587] = { city_berlin, 1988, MONTH_jan, 0.015009332895278931, }, +[588] = { city_berlin, 1989, MONTH_jan, 0.013991726636886597, }, +[589] = { city_berlin, 1990, MONTH_jan, 0.013369400501251221, }, +[590] = { city_berlin, 1991, MONTH_jan, 0.012709577083587647, }, +[591] = { city_berlin, 1992, MONTH_jan, 0.015204551219940186, }, +[592] = { city_berlin, 1993, MONTH_jan, 0.01583544135093689, }, +[593] = { city_berlin, 1994, MONTH_jan, 0.01739633440971374, }, +[594] = { city_berlin, 1995, MONTH_jan, 0.01889189839363098, }, +[595] = { city_berlin, 1996, MONTH_jan, 0.016823945045471193, }, +[596] = { city_berlin, 1997, MONTH_jan, 0.018035167455673216, }, +[597] = { city_berlin, 1998, MONTH_jan, 0.019705649614334103, }, +[598] = { city_berlin, 1999, MONTH_jan, 0.02227585792541504, }, +[599] = { city_berlin, 2000, MONTH_jan, 0.028871116638183595, }, +[600] = { city_berlin, 2001, MONTH_jan, 0.029411675930023192, }, +[601] = { city_berlin, 2002, MONTH_jan, 0.03538631916046143, }, +[602] = { city_berlin, 2003, MONTH_jan, 0.03641989707946778, }, +[603] = { city_berlin, 2004, MONTH_jan, 0.04516597747802734, }, +[604] = { city_berlin, 2005, MONTH_jan, 0.052084193229675294, }, +[605] = { city_berlin, 2006, MONTH_jan, 0.060263047218322756, }, +[606] = { city_berlin, 2007, MONTH_jan, 0.07653833389282226, }, +[607] = { city_berlin, 2008, MONTH_jan, 0.07817628383636474, }, +[608] = { city_berlin, 2009, MONTH_jan, 0.08454279899597168, }, +[609] = { city_berlin, 2010, MONTH_jan, 0.08792469024658203, }, +[610] = { city_berlin, 2011, MONTH_jan, 0.10566965103149414, }, +[611] = { city_berlin, 2012, MONTH_jan, 0.11899699211120604, }, +[612] = { city_berlin, 2013, MONTH_jan, 0.12063335418701172, }, +[613] = { city_berlin, 2014, MONTH_jan, 0.13278846740722655, }, +[614] = { city_berlin, 2015, MONTH_jan, 0.14823543548583984, }, +[615] = { city_berlin, 2016, MONTH_jan, 0.14607312202453612, }, +[616] = { city_berlin, 2017, MONTH_jan, 0.16196212768554688, }, +[617] = { city_berlin, 2018, MONTH_jan, 0.17084951400756837, }, +[618] = { city_berlin, 2019, MONTH_jan, 0.18768304824829102, }, +[619] = { city_berlin, 2020, MONTH_jan, 0.21122827529907226, }, +[620] = { city_berlin, 2021, MONTH_jan, 0.19453121185302735, }, +[621] = { city_new_delhi, 1965, MONTH_jan, 0.09149455070495603, }, +[622] = { city_mumbai, 1965, MONTH_jan, 0.09149455070495603, }, +[623] = { city_new_delhi, 1966, MONTH_jan, 0.09270711898803713, }, +[624] = { city_mumbai, 1966, MONTH_jan, 0.09270711898803713, }, +[625] = { city_new_delhi, 1967, MONTH_jan, 0.10058605194091796, }, +[626] = { city_mumbai, 1967, MONTH_jan, 0.10058605194091796, }, +[627] = { city_new_delhi, 1968, MONTH_jan, 0.10857532501220703, }, +[628] = { city_mumbai, 1968, MONTH_jan, 0.10857532501220703, }, +[629] = { city_new_delhi, 1969, MONTH_jan, 0.10873967170715332, }, +[630] = { city_mumbai, 1969, MONTH_jan, 0.10873967170715332, }, +[631] = { city_new_delhi, 1970, MONTH_jan, 0.11784119606018066, }, +[632] = { city_mumbai, 1970, MONTH_jan, 0.11784119606018066, }, +[633] = { city_new_delhi, 1971, MONTH_jan, 0.1242677116394043, }, +[634] = { city_mumbai, 1971, MONTH_jan, 0.1242677116394043, }, +[635] = { city_new_delhi, 1972, MONTH_jan, 0.11463116645812989, }, +[636] = { city_mumbai, 1972, MONTH_jan, 0.11463116645812989, }, +[637] = { city_new_delhi, 1973, MONTH_jan, 0.11957463264465332, }, +[638] = { city_mumbai, 1973, MONTH_jan, 0.11957463264465332, }, +[639] = { city_new_delhi, 1974, MONTH_jan, 0.1086085319519043, }, +[640] = { city_mumbai, 1974, MONTH_jan, 0.1086085319519043, }, +[641] = { city_new_delhi, 1975, MONTH_jan, 0.12067704200744628, }, +[642] = { city_mumbai, 1975, MONTH_jan, 0.12067704200744628, }, +[643] = { city_new_delhi, 1976, MONTH_jan, 0.12036797523498535, }, +[644] = { city_mumbai, 1976, MONTH_jan, 0.12036797523498535, }, +[645] = { city_new_delhi, 1977, MONTH_jan, 0.12415875434875488, }, +[646] = { city_mumbai, 1977, MONTH_jan, 0.12415875434875488, }, +[647] = { city_new_delhi, 1978, MONTH_jan, 0.14818278312683103, }, +[648] = { city_mumbai, 1978, MONTH_jan, 0.14818278312683103, }, +[649] = { city_new_delhi, 1979, MONTH_jan, 0.13540278434753417, }, +[650] = { city_mumbai, 1979, MONTH_jan, 0.13540278434753417, }, +[651] = { city_new_delhi, 1980, MONTH_jan, 0.1345311737060547, }, +[652] = { city_mumbai, 1980, MONTH_jan, 0.1345311737060547, }, +[653] = { city_new_delhi, 1981, MONTH_jan, 0.12948171615600587, }, +[654] = { city_mumbai, 1981, MONTH_jan, 0.12948171615600587, }, +[655] = { city_new_delhi, 1982, MONTH_jan, 0.11035112380981443, }, +[656] = { city_mumbai, 1982, MONTH_jan, 0.11035112380981443, }, +[657] = { city_new_delhi, 1983, MONTH_jan, 0.10110920906066896, }, +[658] = { city_mumbai, 1983, MONTH_jan, 0.10110920906066896, }, +[659] = { city_new_delhi, 1984, MONTH_jan, 0.10576085090637209, }, +[660] = { city_mumbai, 1984, MONTH_jan, 0.10576085090637209, }, +[661] = { city_new_delhi, 1985, MONTH_jan, 0.09670783996582032, }, +[662] = { city_mumbai, 1985, MONTH_jan, 0.09670783996582032, }, +[663] = { city_new_delhi, 1986, MONTH_jan, 0.0916761875152588, }, +[664] = { city_mumbai, 1986, MONTH_jan, 0.0916761875152588, }, +[665] = { city_new_delhi, 1987, MONTH_jan, 0.08030695915222168, }, +[666] = { city_mumbai, 1987, MONTH_jan, 0.08030695915222168, }, +[667] = { city_new_delhi, 1988, MONTH_jan, 0.08229918479919433, }, +[668] = { city_mumbai, 1988, MONTH_jan, 0.08229918479919433, }, +[669] = { city_new_delhi, 1989, MONTH_jan, 0.08742303848266601, }, +[670] = { city_mumbai, 1989, MONTH_jan, 0.08742303848266601, }, +[671] = { city_new_delhi, 1990, MONTH_jan, 0.08542831420898438, }, +[672] = { city_mumbai, 1990, MONTH_jan, 0.08542831420898438, }, +[673] = { city_new_delhi, 1991, MONTH_jan, 0.09029864311218262, }, +[674] = { city_mumbai, 1991, MONTH_jan, 0.09029864311218262, }, +[675] = { city_new_delhi, 1992, MONTH_jan, 0.08140623092651367, }, +[676] = { city_mumbai, 1992, MONTH_jan, 0.08140623092651367, }, +[677] = { city_new_delhi, 1993, MONTH_jan, 0.08035937309265137, }, +[678] = { city_mumbai, 1993, MONTH_jan, 0.08035937309265137, }, +[679] = { city_new_delhi, 1994, MONTH_jan, 0.08667225837707519, }, +[680] = { city_mumbai, 1994, MONTH_jan, 0.08667225837707519, }, +[681] = { city_new_delhi, 1995, MONTH_jan, 0.07686767578125, }, +[682] = { city_mumbai, 1995, MONTH_jan, 0.07686767578125, }, +[683] = { city_new_delhi, 1996, MONTH_jan, 0.06789632797241212, }, +[684] = { city_mumbai, 1996, MONTH_jan, 0.06789632797241212, }, +[685] = { city_new_delhi, 1997, MONTH_jan, 0.06570899486541748, }, +[686] = { city_mumbai, 1997, MONTH_jan, 0.06570899486541748, }, +[687] = { city_new_delhi, 1998, MONTH_jan, 0.07381818294525147, }, +[688] = { city_mumbai, 1998, MONTH_jan, 0.07381818294525147, }, +[689] = { city_new_delhi, 1999, MONTH_jan, 0.0712459659576416, }, +[690] = { city_mumbai, 1999, MONTH_jan, 0.0712459659576416, }, +[691] = { city_new_delhi, 2000, MONTH_jan, 0.06376289367675782, }, +[692] = { city_mumbai, 2000, MONTH_jan, 0.06376289367675782, }, +[693] = { city_new_delhi, 2001, MONTH_jan, 0.0599252462387085, }, +[694] = { city_mumbai, 2001, MONTH_jan, 0.0599252462387085, }, +[695] = { city_new_delhi, 2002, MONTH_jan, 0.057318320274353025, }, +[696] = { city_mumbai, 2002, MONTH_jan, 0.057318320274353025, }, +[697] = { city_new_delhi, 2003, MONTH_jan, 0.05624061584472656, }, +[698] = { city_mumbai, 2003, MONTH_jan, 0.05624061584472656, }, +[699] = { city_new_delhi, 2004, MONTH_jan, 0.07460848808288574, }, +[700] = { city_mumbai, 2004, MONTH_jan, 0.07460848808288574, }, +[701] = { city_new_delhi, 2005, MONTH_jan, 0.06894316673278808, }, +[702] = { city_mumbai, 2005, MONTH_jan, 0.06894316673278808, }, +[703] = { city_new_delhi, 2006, MONTH_jan, 0.07706239700317383, }, +[704] = { city_mumbai, 2006, MONTH_jan, 0.07706239700317383, }, +[705] = { city_new_delhi, 2007, MONTH_jan, 0.07855644702911377, }, +[706] = { city_mumbai, 2007, MONTH_jan, 0.07855644702911377, }, +[707] = { city_new_delhi, 2008, MONTH_jan, 0.07257065296173096, }, +[708] = { city_mumbai, 2008, MONTH_jan, 0.07257065296173096, }, +[709] = { city_new_delhi, 2009, MONTH_jan, 0.06473570346832275, }, +[710] = { city_mumbai, 2009, MONTH_jan, 0.06473570346832275, }, +[711] = { city_new_delhi, 2010, MONTH_jan, 0.0658367109298706, }, +[712] = { city_mumbai, 2010, MONTH_jan, 0.0658367109298706, }, +[713] = { city_new_delhi, 2011, MONTH_jan, 0.075013427734375, }, +[714] = { city_mumbai, 2011, MONTH_jan, 0.075013427734375, }, +[715] = { city_new_delhi, 2012, MONTH_jan, 0.06727289199829102, }, +[716] = { city_mumbai, 2012, MONTH_jan, 0.06727289199829102, }, +[717] = { city_new_delhi, 2013, MONTH_jan, 0.07329665184020996, }, +[718] = { city_mumbai, 2013, MONTH_jan, 0.07329665184020996, }, +[719] = { city_new_delhi, 2014, MONTH_jan, 0.07344336032867432, }, +[720] = { city_mumbai, 2014, MONTH_jan, 0.07344336032867432, }, +[721] = { city_new_delhi, 2015, MONTH_jan, 0.07184645652770996, }, +[722] = { city_mumbai, 2015, MONTH_jan, 0.07184645652770996, }, +[723] = { city_new_delhi, 2016, MONTH_jan, 0.07011397361755371, }, +[724] = { city_mumbai, 2016, MONTH_jan, 0.07011397361755371, }, +[725] = { city_new_delhi, 2017, MONTH_jan, 0.07511875152587891, }, +[726] = { city_mumbai, 2017, MONTH_jan, 0.07511875152587891, }, +[727] = { city_new_delhi, 2018, MONTH_jan, 0.07912805557250976, }, +[728] = { city_mumbai, 2018, MONTH_jan, 0.07912805557250976, }, +[729] = { city_new_delhi, 2019, MONTH_jan, 0.08849618911743164, }, +[730] = { city_mumbai, 2019, MONTH_jan, 0.08849618911743164, }, +[731] = { city_new_delhi, 2020, MONTH_jan, 0.09730036735534668, }, +[732] = { city_mumbai, 2020, MONTH_jan, 0.09730036735534668, }, +[733] = { city_new_delhi, 2021, MONTH_jan, 0.09310850143432615, }, +[734] = { city_mumbai, 2021, MONTH_jan, 0.09310850143432615, }, +[735] = { city_jakarta, 1965, MONTH_jan, 0.06385928153991699, }, +[736] = { city_jakarta, 1966, MONTH_jan, 0.08364607810974121, }, +[737] = { city_jakarta, 1967, MONTH_jan, 0.09505834579467771, }, +[738] = { city_jakarta, 1968, MONTH_jan, 0.1101013946533203, }, +[739] = { city_jakarta, 1969, MONTH_jan, 0.10201886177062988, }, +[740] = { city_jakarta, 1970, MONTH_jan, 0.11570672035217283, }, +[741] = { city_jakarta, 1971, MONTH_jan, 0.04001150131225586, }, +[742] = { city_jakarta, 1972, MONTH_jan, 0.03373836040496826, }, +[743] = { city_jakarta, 1973, MONTH_jan, 0.037743794918060306, }, +[744] = { city_jakarta, 1974, MONTH_jan, 0.039022941589355466, }, +[745] = { city_jakarta, 1975, MONTH_jan, 0.03342118501663208, }, +[746] = { city_jakarta, 1976, MONTH_jan, 0.018672399520874024, }, +[747] = { city_jakarta, 1977, MONTH_jan, 0.023478298187255858, }, +[748] = { city_jakarta, 1978, MONTH_jan, 0.014906297922134399, }, +[749] = { city_jakarta, 1979, MONTH_jan, 0.014562846422195437, }, +[750] = { city_jakarta, 1980, MONTH_jan, 0.012272299528121948, }, +[751] = { city_jakarta, 1981, MONTH_jan, 0.011406815052032471, }, +[752] = { city_jakarta, 1982, MONTH_jan, 0.012204515933990481, }, +[753] = { city_jakarta, 1983, MONTH_jan, 0.017323704957962035, }, +[754] = { city_jakarta, 1984, MONTH_jan, 0.017180938720703125, }, +[755] = { city_jakarta, 1985, MONTH_jan, 0.01980858683586121, }, +[756] = { city_jakarta, 1986, MONTH_jan, 0.02986825704574585, }, +[757] = { city_jakarta, 1987, MONTH_jan, 0.029112305641174317, }, +[758] = { city_jakarta, 1988, MONTH_jan, 0.0302899694442749, }, +[759] = { city_jakarta, 1989, MONTH_jan, 0.03408119440078736, }, +[760] = { city_jakarta, 1990, MONTH_jan, 0.03731863260269165, }, +[761] = { city_jakarta, 1991, MONTH_jan, 0.03812469959259033, }, +[762] = { city_jakarta, 1992, MONTH_jan, 0.044085426330566405, }, +[763] = { city_jakarta, 1993, MONTH_jan, 0.03847653388977051, }, +[764] = { city_jakarta, 1994, MONTH_jan, 0.03521223306655884, }, +[765] = { city_jakarta, 1995, MONTH_jan, 0.035392696857452395, }, +[766] = { city_jakarta, 1996, MONTH_jan, 0.03508815288543701, }, +[767] = { city_jakarta, 1997, MONTH_jan, 0.02477278470993042, }, +[768] = { city_jakarta, 1998, MONTH_jan, 0.04014904499053955, }, +[769] = { city_jakarta, 1999, MONTH_jan, 0.03852458000183105, }, +[770] = { city_jakarta, 2000, MONTH_jan, 0.03733640432357788, }, +[771] = { city_jakarta, 2001, MONTH_jan, 0.04112386703491211, }, +[772] = { city_jakarta, 2002, MONTH_jan, 0.03683813571929931, }, +[773] = { city_jakarta, 2003, MONTH_jan, 0.03221094608306885, }, +[774] = { city_jakarta, 2004, MONTH_jan, 0.034259636402130124, }, +[775] = { city_jakarta, 2005, MONTH_jan, 0.035274262428283694, }, +[776] = { city_jakarta, 2006, MONTH_jan, 0.03220308542251587, }, +[777] = { city_jakarta, 2007, MONTH_jan, 0.03370551109313965, }, +[778] = { city_jakarta, 2008, MONTH_jan, 0.03586532115936279, }, +[779] = { city_jakarta, 2009, MONTH_jan, 0.03655174016952514, }, +[780] = { city_jakarta, 2010, MONTH_jan, 0.043262209892272946, }, +[781] = { city_jakarta, 2011, MONTH_jan, 0.03388597726821899, }, +[782] = { city_jakarta, 2012, MONTH_jan, 0.034713633060455315, }, +[783] = { city_jakarta, 2013, MONTH_jan, 0.0433060359954834, }, +[784] = { city_jakarta, 2014, MONTH_jan, 0.044786324501037596, }, +[785] = { city_jakarta, 2015, MONTH_jan, 0.037929575443267825, }, +[786] = { city_jakarta, 2016, MONTH_jan, 0.05479020118713379, }, +[787] = { city_jakarta, 2017, MONTH_jan, 0.05283773899078369, }, +[788] = { city_jakarta, 2018, MONTH_jan, 0.07393457889556884, }, +[789] = { city_jakarta, 2019, MONTH_jan, 0.07870308876037597, }, +[790] = { city_jakarta, 2020, MONTH_jan, 0.09860146522521973, }, +[791] = { city_jakarta, 2021, MONTH_jan, 0.10385714530944824, }, +[792] = { city_tehran, 1965, MONTH_jan, 0.052250761985778806, }, +[793] = { city_tehran, 1966, MONTH_jan, 0.05151486396789551, }, +[794] = { city_tehran, 1967, MONTH_jan, 0.050412230491638184, }, +[795] = { city_tehran, 1968, MONTH_jan, 0.04931734085083008, }, +[796] = { city_tehran, 1969, MONTH_jan, 0.04837111473083496, }, +[797] = { city_tehran, 1970, MONTH_jan, 0.04415298461914063, }, +[798] = { city_tehran, 1971, MONTH_jan, 0.04332554340362549, }, +[799] = { city_tehran, 1972, MONTH_jan, 0.0501894760131836, }, +[800] = { city_tehran, 1973, MONTH_jan, 0.03557704448699951, }, +[801] = { city_tehran, 1974, MONTH_jan, 0.03455620527267456, }, +[802] = { city_tehran, 1975, MONTH_jan, 0.031140482425689696, }, +[803] = { city_tehran, 1976, MONTH_jan, 0.0309524917602539, }, +[804] = { city_tehran, 1977, MONTH_jan, 0.02825014591217041, }, +[805] = { city_tehran, 1978, MONTH_jan, 0.04526003360748291, }, +[806] = { city_tehran, 1979, MONTH_jan, 0.036342711448669435, }, +[807] = { city_tehran, 1980, MONTH_jan, 0.04064725875854492, }, +[808] = { city_tehran, 1981, MONTH_jan, 0.044219164848327636, }, +[809] = { city_tehran, 1982, MONTH_jan, 0.04111237049102783, }, +[810] = { city_tehran, 1983, MONTH_jan, 0.033884649276733396, }, +[811] = { city_tehran, 1984, MONTH_jan, 0.029317567348480223, }, +[812] = { city_tehran, 1985, MONTH_jan, 0.027088303565979004, }, +[813] = { city_tehran, 1986, MONTH_jan, 0.03455609560012817, }, +[814] = { city_tehran, 1987, MONTH_jan, 0.03573478698730469, }, +[815] = { city_tehran, 1988, MONTH_jan, 0.036968004703521726, }, +[816] = { city_tehran, 1989, MONTH_jan, 0.027610442638397216, }, +[817] = { city_tehran, 1990, MONTH_jan, 0.026902496814727783, }, +[818] = { city_tehran, 1991, MONTH_jan, 0.018835831880569455, }, +[819] = { city_tehran, 1992, MONTH_jan, 0.02795917510986328, }, +[820] = { city_tehran, 1993, MONTH_jan, 0.034577884674072266, }, +[821] = { city_tehran, 1994, MONTH_jan, 0.020214617252349857, }, +[822] = { city_tehran, 1995, MONTH_jan, 0.023263061046600343, }, +[823] = { city_tehran, 1996, MONTH_jan, 0.022645998001098632, }, +[824] = { city_tehran, 1997, MONTH_jan, 0.014810699224472045, }, +[825] = { city_tehran, 1998, MONTH_jan, 0.017921339273452762, }, +[826] = { city_tehran, 1999, MONTH_jan, 0.011498689651489258, }, +[827] = { city_tehran, 2000, MONTH_jan, 0.00808289110660553, }, +[828] = { city_tehran, 2001, MONTH_jan, 0.008181908130645753, }, +[829] = { city_tehran, 2002, MONTH_jan, 0.014433478116989135, }, +[830] = { city_tehran, 2003, MONTH_jan, 0.016837654113769532, }, +[831] = { city_tehran, 2004, MONTH_jan, 0.01884332299232483, }, +[832] = { city_tehran, 2005, MONTH_jan, 0.021426386833190918, }, +[833] = { city_tehran, 2006, MONTH_jan, 0.025007379055023194, }, +[834] = { city_tehran, 2007, MONTH_jan, 0.022706358432769774, }, +[835] = { city_tehran, 2008, MONTH_jan, 0.009235934615135192, }, +[836] = { city_tehran, 2009, MONTH_jan, 0.008136967420578003, }, +[837] = { city_tehran, 2010, MONTH_jan, 0.011950724124908448, }, +[838] = { city_tehran, 2011, MONTH_jan, 0.011898080110549929, }, +[839] = { city_tehran, 2012, MONTH_jan, 0.013722978830337525, }, +[840] = { city_tehran, 2013, MONTH_jan, 0.01525709867477417, }, +[841] = { city_tehran, 2014, MONTH_jan, 0.014402105808258056, }, +[842] = { city_tehran, 2015, MONTH_jan, 0.013088065385818479, }, +[843] = { city_tehran, 2016, MONTH_jan, 0.014465060234069824, }, +[844] = { city_tehran, 2017, MONTH_jan, 0.015620874166488647, }, +[845] = { city_tehran, 2018, MONTH_jan, 0.009227302074432371, }, +[846] = { city_tehran, 2019, MONTH_jan, 0.028368299007415772, }, +[847] = { city_tehran, 2020, MONTH_jan, 0.019643505811691286, }, +[848] = { city_tehran, 2021, MONTH_jan, 0.012903937101364137, }, +[849] = { city_baghdad, 1965, MONTH_jan, 0.009088937044143675, }, +[850] = { city_baghdad, 1966, MONTH_jan, 0.010816304683685305, }, +[851] = { city_baghdad, 1967, MONTH_jan, 0.012241523265838623, }, +[852] = { city_baghdad, 1968, MONTH_jan, 0.013923404216766355, }, +[853] = { city_baghdad, 1969, MONTH_jan, 0.013289313316345218, }, +[854] = { city_baghdad, 1970, MONTH_jan, 0.01301562786102295, }, +[855] = { city_baghdad, 1971, MONTH_jan, 0.013798673152923584, }, +[856] = { city_baghdad, 1972, MONTH_jan, 0.011780089139938355, }, +[857] = { city_baghdad, 1973, MONTH_jan, 0.01737240195274353, }, +[858] = { city_baghdad, 1974, MONTH_jan, 0.02446626663208008, }, +[859] = { city_baghdad, 1975, MONTH_jan, 0.02579850673675537, }, +[860] = { city_baghdad, 1976, MONTH_jan, 0.020427801609039307, }, +[861] = { city_baghdad, 1977, MONTH_jan, 0.02406090497970581, }, +[862] = { city_baghdad, 1978, MONTH_jan, 0.03056793212890625, }, +[863] = { city_baghdad, 1979, MONTH_jan, 0.03528018236160278, }, +[864] = { city_baghdad, 1980, MONTH_jan, 0.020129208564758302, }, +[865] = { city_baghdad, 1981, MONTH_jan, 0.019036805629730223, }, +[866] = { city_baghdad, 1982, MONTH_jan, 0.01808008313179016, }, +[867] = { city_baghdad, 1983, MONTH_jan, 0.01574033737182617, }, +[868] = { city_baghdad, 1984, MONTH_jan, 0.014442424774169921, }, +[869] = { city_baghdad, 1985, MONTH_jan, 0.012590632438659669, }, +[870] = { city_baghdad, 1986, MONTH_jan, 0.010752139091491699, }, +[871] = { city_baghdad, 1987, MONTH_jan, 0.03949446678161621, }, +[872] = { city_baghdad, 1988, MONTH_jan, 0.03410572290420532, }, +[873] = { city_baghdad, 1989, MONTH_jan, 0.030038673877716065, }, +[874] = { city_baghdad, 1990, MONTH_jan, 0.0578435230255127, }, +[875] = { city_baghdad, 1991, MONTH_jan, 0.0428729248046875, }, +[876] = { city_baghdad, 1992, MONTH_jan, 0.06584853172302246, }, +[877] = { city_baghdad, 1993, MONTH_jan, 0.058610520362854, }, +[878] = { city_baghdad, 1994, MONTH_jan, 0.05243114471435547, }, +[879] = { city_baghdad, 1995, MONTH_jan, 0.05992914199829102, }, +[880] = { city_baghdad, 1996, MONTH_jan, 0.054542551040649416, }, +[881] = { city_baghdad, 1997, MONTH_jan, 0.046753549575805665, }, +[882] = { city_baghdad, 1998, MONTH_jan, 0.05869803905487061, }, +[883] = { city_baghdad, 1999, MONTH_jan, 0.04700111389160156, }, +[884] = { city_baghdad, 2000, MONTH_jan, 0.029294536113739018, }, +[885] = { city_baghdad, 2001, MONTH_jan, 0.03016484260559082, }, +[886] = { city_baghdad, 2002, MONTH_jan, 0.03885046482086182, }, +[887] = { city_baghdad, 2003, MONTH_jan, 0.04535982608795166, }, +[888] = { city_baghdad, 2004, MONTH_jan, 0.05081915855407715, }, +[889] = { city_baghdad, 2005, MONTH_jan, 0.04544925212860108, }, +[890] = { city_baghdad, 2006, MONTH_jan, 0.0473859977722168, }, +[891] = { city_baghdad, 2007, MONTH_jan, 0.042728943824768065, }, +[892] = { city_baghdad, 2008, MONTH_jan, 0.02381868362426758, }, +[893] = { city_baghdad, 2009, MONTH_jan, 0.023280267715454103, }, +[894] = { city_baghdad, 2010, MONTH_jan, 0.026375570297241212, }, +[895] = { city_baghdad, 2011, MONTH_jan, 0.023962152004241944, }, +[896] = { city_baghdad, 2012, MONTH_jan, 0.02823270320892334, }, +[897] = { city_baghdad, 2013, MONTH_jan, 0.026760001182556153, }, +[898] = { city_baghdad, 2014, MONTH_jan, 0.01738718867301941, }, +[899] = { city_baghdad, 2015, MONTH_jan, 0.016102989912033083, }, +[900] = { city_baghdad, 2016, MONTH_jan, 0.01836539387702942, }, +[901] = { city_baghdad, 2017, MONTH_jan, 0.011253452301025391, }, +[902] = { city_baghdad, 2018, MONTH_jan, 0.009119535088539124, }, +[903] = { city_baghdad, 2019, MONTH_jan, 0.022772881984710693, }, +[904] = { city_baghdad, 2020, MONTH_jan, 0.016468850374221803, }, +[905] = { city_baghdad, 2021, MONTH_jan, 0.015024909973144531, }, +[906] = { city_tokyo, 1965, MONTH_jan, 0.12335086822509765, }, +[907] = { city_tokyo, 1966, MONTH_jan, 0.11651081085205078, }, +[908] = { city_tokyo, 1967, MONTH_jan, 0.08793859481811524, }, +[909] = { city_tokyo, 1968, MONTH_jan, 0.08451984405517578, }, +[910] = { city_tokyo, 1969, MONTH_jan, 0.0761188268661499, }, +[911] = { city_tokyo, 1970, MONTH_jan, 0.06836434364318848, }, +[912] = { city_tokyo, 1971, MONTH_jan, 0.07166181564331055, }, +[913] = { city_tokyo, 1972, MONTH_jan, 0.06914736270904541, }, +[914] = { city_tokyo, 1973, MONTH_jan, 0.04894681930541992, }, +[915] = { city_tokyo, 1974, MONTH_jan, 0.060309801101684574, }, +[916] = { city_tokyo, 1975, MONTH_jan, 0.06373206615447997, }, +[917] = { city_tokyo, 1976, MONTH_jan, 0.06161350250244141, }, +[918] = { city_tokyo, 1977, MONTH_jan, 0.05355945110321045, }, +[919] = { city_tokyo, 1978, MONTH_jan, 0.049568381309509274, }, +[920] = { city_tokyo, 1979, MONTH_jan, 0.055059475898742674, }, +[921] = { city_tokyo, 1980, MONTH_jan, 0.06194887161254883, }, +[922] = { city_tokyo, 1981, MONTH_jan, 0.062369403839111326, }, +[923] = { city_tokyo, 1982, MONTH_jan, 0.06735273361206055, }, +[924] = { city_tokyo, 1983, MONTH_jan, 0.06926650524139405, }, +[925] = { city_tokyo, 1984, MONTH_jan, 0.05621933937072754, }, +[926] = { city_tokyo, 1985, MONTH_jan, 0.06361672401428223, }, +[927] = { city_tokyo, 1986, MONTH_jan, 0.06296619892120361, }, +[928] = { city_tokyo, 1987, MONTH_jan, 0.058519330024719235, }, +[929] = { city_tokyo, 1988, MONTH_jan, 0.06523026466369629, }, +[930] = { city_tokyo, 1989, MONTH_jan, 0.06458432197570801, }, +[931] = { city_tokyo, 1990, MONTH_jan, 0.05605645179748535, }, +[932] = { city_tokyo, 1991, MONTH_jan, 0.059171295166015624, }, +[933] = { city_tokyo, 1992, MONTH_jan, 0.050801749229431155, }, +[934] = { city_tokyo, 1993, MONTH_jan, 0.05666120529174805, }, +[935] = { city_tokyo, 1994, MONTH_jan, 0.04097033977508545, }, +[936] = { city_tokyo, 1995, MONTH_jan, 0.04652009010314941, }, +[937] = { city_tokyo, 1996, MONTH_jan, 0.045326762199401856, }, +[938] = { city_tokyo, 1997, MONTH_jan, 0.04951632499694824, }, +[939] = { city_tokyo, 1998, MONTH_jan, 0.05170876026153565, }, +[940] = { city_tokyo, 1999, MONTH_jan, 0.048562874794006346, }, +[941] = { city_tokyo, 2000, MONTH_jan, 0.0482745361328125, }, +[942] = { city_tokyo, 2001, MONTH_jan, 0.047163658142089844, }, +[943] = { city_tokyo, 2002, MONTH_jan, 0.04702637195587158, }, +[944] = { city_tokyo, 2003, MONTH_jan, 0.05332041263580322, }, +[945] = { city_tokyo, 2004, MONTH_jan, 0.052576699256896973, }, +[946] = { city_tokyo, 2005, MONTH_jan, 0.04790322780609131, }, +[947] = { city_tokyo, 2006, MONTH_jan, 0.053090085983276365, }, +[948] = { city_tokyo, 2007, MONTH_jan, 0.04761953353881836, }, +[949] = { city_tokyo, 2008, MONTH_jan, 0.04830859184265137, }, +[950] = { city_tokyo, 2009, MONTH_jan, 0.05021396160125732, }, +[951] = { city_tokyo, 2010, MONTH_jan, 0.05684884071350098, }, +[952] = { city_tokyo, 2011, MONTH_jan, 0.057331571578979494, }, +[953] = { city_tokyo, 2012, MONTH_jan, 0.05650204658508301, }, +[954] = { city_tokyo, 2013, MONTH_jan, 0.061299676895141604, }, +[955] = { city_tokyo, 2014, MONTH_jan, 0.06935917377471924, }, +[956] = { city_tokyo, 2015, MONTH_jan, 0.0806879711151123, }, +[957] = { city_tokyo, 2016, MONTH_jan, 0.07975860595703126, }, +[958] = { city_tokyo, 2017, MONTH_jan, 0.08634003639221191, }, +[959] = { city_tokyo, 2018, MONTH_jan, 0.09322304725646972, }, +[960] = { city_tokyo, 2019, MONTH_jan, 0.09565926551818847, }, +[961] = { city_tokyo, 2020, MONTH_jan, 0.11155339241027833, }, +[962] = { city_tokyo, 2021, MONTH_jan, 0.11428995132446287, }, +[963] = { city_mexico_city, 1965, MONTH_jan, 0.08934722900390625, }, +[964] = { city_mexico_city, 1966, MONTH_jan, 0.09633110046386721, }, +[965] = { city_mexico_city, 1967, MONTH_jan, 0.1029133129119873, }, +[966] = { city_mexico_city, 1968, MONTH_jan, 0.1084283447265625, }, +[967] = { city_mexico_city, 1969, MONTH_jan, 0.10475299835205078, }, +[968] = { city_mexico_city, 1970, MONTH_jan, 0.1098171329498291, }, +[969] = { city_mexico_city, 1971, MONTH_jan, 0.10142724990844729, }, +[970] = { city_mexico_city, 1972, MONTH_jan, 0.09780027389526368, }, +[971] = { city_mexico_city, 1973, MONTH_jan, 0.09648298263549805, }, +[972] = { city_mexico_city, 1974, MONTH_jan, 0.09094654083251952, }, +[973] = { city_mexico_city, 1975, MONTH_jan, 0.07784452438354492, }, +[974] = { city_mexico_city, 1976, MONTH_jan, 0.08308449745178223, }, +[975] = { city_mexico_city, 1977, MONTH_jan, 0.08738277435302734, }, +[976] = { city_mexico_city, 1978, MONTH_jan, 0.0659796380996704, }, +[977] = { city_mexico_city, 1979, MONTH_jan, 0.06747371673583985, }, +[978] = { city_mexico_city, 1980, MONTH_jan, 0.058035578727722165, }, +[979] = { city_mexico_city, 1981, MONTH_jan, 0.07537362575531006, }, +[980] = { city_mexico_city, 1982, MONTH_jan, 0.06843096733093262, }, +[981] = { city_mexico_city, 1983, MONTH_jan, 0.06308685779571534, }, +[982] = { city_mexico_city, 1984, MONTH_jan, 0.0683129644393921, }, +[983] = { city_mexico_city, 1985, MONTH_jan, 0.07820509910583497, }, +[984] = { city_mexico_city, 1986, MONTH_jan, 0.0659659194946289, }, +[985] = { city_mexico_city, 1987, MONTH_jan, 0.06118594646453857, }, +[986] = { city_mexico_city, 1988, MONTH_jan, 0.06784612655639649, }, +[987] = { city_mexico_city, 1989, MONTH_jan, 0.07293380260467529, }, +[988] = { city_mexico_city, 1990, MONTH_jan, 0.06830843448638917, }, +[989] = { city_mexico_city, 1991, MONTH_jan, 0.06324604988098144, }, +[990] = { city_mexico_city, 1992, MONTH_jan, 0.0725102186203003, }, +[991] = { city_mexico_city, 1993, MONTH_jan, 0.07209392070770264, }, +[992] = { city_mexico_city, 1994, MONTH_jan, 0.05448117256164551, }, +[993] = { city_mexico_city, 1995, MONTH_jan, 0.07110982418060302, }, +[994] = { city_mexico_city, 1996, MONTH_jan, 0.0760121488571167, }, +[995] = { city_mexico_city, 1997, MONTH_jan, 0.06423584938049316, }, +[996] = { city_mexico_city, 1998, MONTH_jan, 0.05862017154693604, }, +[997] = { city_mexico_city, 1999, MONTH_jan, 0.07305535793304443, }, +[998] = { city_mexico_city, 2000, MONTH_jan, 0.0715089750289917, }, +[999] = { city_mexico_city, 2001, MONTH_jan, 0.06339307308197022, }, +[1000] = { city_mexico_city, 2002, MONTH_jan, 0.05449038505554199, }, +[1001] = { city_mexico_city, 2003, MONTH_jan, 0.046524553298950194, }, +[1002] = { city_mexico_city, 2004, MONTH_jan, 0.053032422065734865, }, +[1003] = { city_mexico_city, 2005, MONTH_jan, 0.05473337173461914, }, +[1004] = { city_mexico_city, 2006, MONTH_jan, 0.055860862731933594, }, +[1005] = { city_mexico_city, 2007, MONTH_jan, 0.052095470428466795, }, +[1006] = { city_mexico_city, 2008, MONTH_jan, 0.06696115970611573, }, +[1007] = { city_mexico_city, 2009, MONTH_jan, 0.04956578254699707, }, +[1008] = { city_mexico_city, 2010, MONTH_jan, 0.06283123970031738, }, +[1009] = { city_mexico_city, 2011, MONTH_jan, 0.058868541717529296, }, +[1010] = { city_mexico_city, 2012, MONTH_jan, 0.054620795249938965, }, +[1011] = { city_mexico_city, 2013, MONTH_jan, 0.05060070037841797, }, +[1012] = { city_mexico_city, 2014, MONTH_jan, 0.06727101802825927, }, +[1013] = { city_mexico_city, 2015, MONTH_jan, 0.060522632598876955, }, +[1014] = { city_mexico_city, 2016, MONTH_jan, 0.06131492614746094, }, +[1015] = { city_mexico_city, 2017, MONTH_jan, 0.06372722148895264, }, +[1016] = { city_mexico_city, 2018, MONTH_jan, 0.06939361095428467, }, +[1017] = { city_mexico_city, 2019, MONTH_jan, 0.0705077075958252, }, +[1018] = { city_mexico_city, 2020, MONTH_jan, 0.09475372314453123, }, +[1019] = { city_mexico_city, 2021, MONTH_jan, 0.1051475429534912, }, +[1020] = { city_rabat, 1965, MONTH_jan, 0.2022709846496582, }, +[1021] = { city_rabat, 1966, MONTH_jan, 0.1334361457824707, }, +[1022] = { city_rabat, 1967, MONTH_jan, 0.11197633743286133, }, +[1023] = { city_rabat, 1968, MONTH_jan, 0.11839537620544434, }, +[1024] = { city_rabat, 1969, MONTH_jan, 0.13958054542541504, }, +[1025] = { city_rabat, 1970, MONTH_jan, 0.13115361213684082, }, +[1026] = { city_rabat, 1971, MONTH_jan, 0.1392387866973877, }, +[1027] = { city_rabat, 1972, MONTH_jan, 0.13526378631591796, }, +[1028] = { city_rabat, 1973, MONTH_jan, 0.09094624519348145, }, +[1029] = { city_rabat, 1974, MONTH_jan, 0.09542439460754397, }, +[1030] = { city_rabat, 1975, MONTH_jan, 0.0713439130783081, }, +[1031] = { city_rabat, 1976, MONTH_jan, 0.06466088294982911, }, +[1032] = { city_rabat, 1977, MONTH_jan, 0.07884840011596679, }, +[1033] = { city_rabat, 1978, MONTH_jan, 0.0770575761795044, }, +[1034] = { city_rabat, 1979, MONTH_jan, 0.0771904230117798, }, +[1035] = { city_rabat, 1980, MONTH_jan, 0.07371124744415283, }, +[1036] = { city_rabat, 1981, MONTH_jan, 0.05136460304260254, }, +[1037] = { city_rabat, 1982, MONTH_jan, 0.027842175960540772, }, +[1038] = { city_rabat, 1983, MONTH_jan, 0.02280400514602661, }, +[1039] = { city_rabat, 1984, MONTH_jan, 0.01712327241897583, }, +[1040] = { city_rabat, 1985, MONTH_jan, 0.02200667381286621, }, +[1041] = { city_rabat, 1986, MONTH_jan, 0.028153402805328367, }, +[1042] = { city_rabat, 1987, MONTH_jan, 0.03506812572479248, }, +[1043] = { city_rabat, 1988, MONTH_jan, 0.037663094997406006, }, +[1044] = { city_rabat, 1989, MONTH_jan, 0.04231739044189453, }, +[1045] = { city_rabat, 1990, MONTH_jan, 0.04359245777130127, }, +[1046] = { city_rabat, 1991, MONTH_jan, 0.04325900077819824, }, +[1047] = { city_rabat, 1992, MONTH_jan, 0.030396227836608888, }, +[1048] = { city_rabat, 1993, MONTH_jan, 0.013822969198226929, }, +[1049] = { city_rabat, 1994, MONTH_jan, 0.023779470920562745, }, +[1050] = { city_rabat, 1995, MONTH_jan, 0.01763482928276062, }, +[1051] = { city_rabat, 1996, MONTH_jan, 0.05402516841888428, }, +[1052] = { city_rabat, 1997, MONTH_jan, 0.05531386375427246, }, +[1053] = { city_rabat, 1998, MONTH_jan, 0.04600728511810303, }, +[1054] = { city_rabat, 1999, MONTH_jan, 0.020588018894195557, }, +[1055] = { city_rabat, 2000, MONTH_jan, 0.019685844182968138, }, +[1056] = { city_rabat, 2001, MONTH_jan, 0.024725899696350098, }, +[1057] = { city_rabat, 2002, MONTH_jan, 0.02324991226196289, }, +[1058] = { city_rabat, 2003, MONTH_jan, 0.03657069444656372, }, +[1059] = { city_rabat, 2004, MONTH_jan, 0.03473497629165649, }, +[1060] = { city_rabat, 2005, MONTH_jan, 0.020816917419433593, }, +[1061] = { city_rabat, 2006, MONTH_jan, 0.020182490348815918, }, +[1062] = { city_rabat, 2007, MONTH_jan, 0.02050191640853882, }, +[1063] = { city_rabat, 2008, MONTH_jan, 0.018975967168807985, }, +[1064] = { city_rabat, 2009, MONTH_jan, 0.04711688995361328, }, +[1065] = { city_rabat, 2010, MONTH_jan, 0.05887355327606201, }, +[1066] = { city_rabat, 2011, MONTH_jan, 0.0364383602142334, }, +[1067] = { city_rabat, 2012, MONTH_jan, 0.031137833595275877, }, +[1068] = { city_rabat, 2013, MONTH_jan, 0.05110578060150146, }, +[1069] = { city_rabat, 2014, MONTH_jan, 0.04458736419677734, }, +[1070] = { city_rabat, 2015, MONTH_jan, 0.053888487815856936, }, +[1071] = { city_rabat, 2016, MONTH_jan, 0.05595184803009033, }, +[1072] = { city_rabat, 2017, MONTH_jan, 0.05286826610565185, }, +[1073] = { city_rabat, 2018, MONTH_jan, 0.0710693359375, }, +[1074] = { city_rabat, 2019, MONTH_jan, 0.07547047138214111, }, +[1075] = { city_rabat, 2020, MONTH_jan, 0.07633952140808105, }, +[1076] = { city_rabat, 2021, MONTH_jan, 0.0763616943359375, }, +[1077] = { city_amsterdam, 1965, MONTH_jan, 0, }, +[1078] = { city_amsterdam, 1966, MONTH_jan, 0, }, +[1079] = { city_amsterdam, 1967, MONTH_jan, 0, }, +[1080] = { city_amsterdam, 1968, MONTH_jan, 0, }, +[1081] = { city_amsterdam, 1969, MONTH_jan, 0, }, +[1082] = { city_amsterdam, 1970, MONTH_jan, 0, }, +[1083] = { city_amsterdam, 1971, MONTH_jan, 0, }, +[1084] = { city_amsterdam, 1972, MONTH_jan, 0, }, +[1085] = { city_amsterdam, 1973, MONTH_jan, 0, }, +[1086] = { city_amsterdam, 1974, MONTH_jan, 0, }, +[1087] = { city_amsterdam, 1975, MONTH_jan, 0.0031152141094207765, }, +[1088] = { city_amsterdam, 1976, MONTH_jan, 0.0031017714738845823, }, +[1089] = { city_amsterdam, 1977, MONTH_jan, 0.0031403565406799318, }, +[1090] = { city_amsterdam, 1978, MONTH_jan, 0.004299201965332031, }, +[1091] = { city_amsterdam, 1979, MONTH_jan, 0.0038009288907051085, }, +[1092] = { city_amsterdam, 1980, MONTH_jan, 0.0037478047609329226, }, +[1093] = { city_amsterdam, 1981, MONTH_jan, 0.004187572598457336, }, +[1094] = { city_amsterdam, 1982, MONTH_jan, 0.0011066412925720215, }, +[1095] = { city_amsterdam, 1983, MONTH_jan, 9.600715339183807e-4, }, +[1096] = { city_amsterdam, 1984, MONTH_jan, 6.805820390582081e-5, }, +[1097] = { city_amsterdam, 1985, MONTH_jan, 0.0017216096818447114, }, +[1098] = { city_amsterdam, 1986, MONTH_jan, 0.002057678997516632, }, +[1099] = { city_amsterdam, 1987, MONTH_jan, 0.002552417516708374, }, +[1100] = { city_amsterdam, 1988, MONTH_jan, 0.003074186444282532, }, +[1101] = { city_amsterdam, 1989, MONTH_jan, 0.003433368802070618, }, +[1102] = { city_amsterdam, 1990, MONTH_jan, 0.0028062096238136293, }, +[1103] = { city_amsterdam, 1991, MONTH_jan, 0.003191479742527008, }, +[1104] = { city_amsterdam, 1992, MONTH_jan, 0.0033999988436698913, }, +[1105] = { city_amsterdam, 1993, MONTH_jan, 0.0037428748607635496, }, +[1106] = { city_amsterdam, 1994, MONTH_jan, 0.00426658183336258, }, +[1107] = { city_amsterdam, 1995, MONTH_jan, 0.0045612013339996335, }, +[1108] = { city_amsterdam, 1996, MONTH_jan, 0.0056391310691833495, }, +[1109] = { city_amsterdam, 1997, MONTH_jan, 0.0063600361347198485, }, +[1110] = { city_amsterdam, 1998, MONTH_jan, 0.007268246412277222, }, +[1111] = { city_amsterdam, 1999, MONTH_jan, 0.007947908639907837, }, +[1112] = { city_amsterdam, 2000, MONTH_jan, 0.00925859272480011, }, +[1113] = { city_amsterdam, 2001, MONTH_jan, 0.009883764982223512, }, +[1114] = { city_amsterdam, 2002, MONTH_jan, 0.011863465309143067, }, +[1115] = { city_amsterdam, 2003, MONTH_jan, 0.011635091304779053, }, +[1116] = { city_amsterdam, 2004, MONTH_jan, 0.015031250715255734, }, +[1117] = { city_amsterdam, 2005, MONTH_jan, 0.020780501365661622, }, +[1118] = { city_amsterdam, 2006, MONTH_jan, 0.023150839805603028, }, +[1119] = { city_amsterdam, 2007, MONTH_jan, 0.024174244403839112, }, +[1120] = { city_amsterdam, 2008, MONTH_jan, 0.02913216352462769, }, +[1121] = { city_amsterdam, 2009, MONTH_jan, 0.034302778244018554, }, +[1122] = { city_amsterdam, 2010, MONTH_jan, 0.032134413719177246, }, +[1123] = { city_amsterdam, 2011, MONTH_jan, 0.03811289310455322, }, +[1124] = { city_amsterdam, 2012, MONTH_jan, 0.03963631391525269, }, +[1125] = { city_amsterdam, 2013, MONTH_jan, 0.03945788860321045, }, +[1126] = { city_amsterdam, 2014, MONTH_jan, 0.03978432416915893, }, +[1127] = { city_amsterdam, 2015, MONTH_jan, 0.04503983974456787, }, +[1128] = { city_amsterdam, 2016, MONTH_jan, 0.04676411151885986, }, +[1129] = { city_amsterdam, 2017, MONTH_jan, 0.05489981651306152, }, +[1130] = { city_amsterdam, 2018, MONTH_jan, 0.059912681579589844, }, +[1131] = { city_amsterdam, 2019, MONTH_jan, 0.07302987575531006, }, +[1132] = { city_amsterdam, 2020, MONTH_jan, 0.10758957862854004, }, +[1133] = { city_amsterdam, 2021, MONTH_jan, 0.12373795509338381, }, +[1134] = { city_islamabad, 1965, MONTH_jan, 0.07898932456970215, }, +[1135] = { city_islamabad, 1966, MONTH_jan, 0.07840171337127684, }, +[1136] = { city_islamabad, 1967, MONTH_jan, 0.0839201831817627, }, +[1137] = { city_islamabad, 1968, MONTH_jan, 0.08885177612304687, }, +[1138] = { city_islamabad, 1969, MONTH_jan, 0.09329750061035157, }, +[1139] = { city_islamabad, 1970, MONTH_jan, 0.08390380859375, }, +[1140] = { city_islamabad, 1971, MONTH_jan, 0.1171886157989502, }, +[1141] = { city_islamabad, 1972, MONTH_jan, 0.1325389575958252, }, +[1142] = { city_islamabad, 1973, MONTH_jan, 0.1308777618408203, }, +[1143] = { city_islamabad, 1974, MONTH_jan, 0.12144384384155271, }, +[1144] = { city_islamabad, 1975, MONTH_jan, 0.13310853958129884, }, +[1145] = { city_islamabad, 1976, MONTH_jan, 0.1423151779174805, }, +[1146] = { city_islamabad, 1977, MONTH_jan, 0.1562037467956543, }, +[1147] = { city_islamabad, 1978, MONTH_jan, 0.18110393524169918, }, +[1148] = { city_islamabad, 1979, MONTH_jan, 0.17961801528930665, }, +[1149] = { city_islamabad, 1980, MONTH_jan, 0.16982366561889647, }, +[1150] = { city_islamabad, 1981, MONTH_jan, 0.16494283676147461, }, +[1151] = { city_islamabad, 1982, MONTH_jan, 0.1682915496826172, }, +[1152] = { city_islamabad, 1983, MONTH_jan, 0.18234487533569335, }, +[1153] = { city_islamabad, 1984, MONTH_jan, 0.1785936164855957, }, +[1154] = { city_islamabad, 1985, MONTH_jan, 0.17652673721313478, }, +[1155] = { city_islamabad, 1986, MONTH_jan, 0.1592543983459473, }, +[1156] = { city_islamabad, 1987, MONTH_jan, 0.1866611099243164, }, +[1157] = { city_islamabad, 1988, MONTH_jan, 0.1841936492919922, }, +[1158] = { city_islamabad, 1989, MONTH_jan, 0.17649538040161133, }, +[1159] = { city_islamabad, 1990, MONTH_jan, 0.16537376403808593, }, +[1160] = { city_islamabad, 1991, MONTH_jan, 0.16701480865478516, }, +[1161] = { city_islamabad, 1992, MONTH_jan, 0.17344545364379882, }, +[1162] = { city_islamabad, 1993, MONTH_jan, 0.17234846115112304, }, +[1163] = { city_islamabad, 1994, MONTH_jan, 0.16347652435302734, }, +[1164] = { city_islamabad, 1995, MONTH_jan, 0.16378124237060546, }, +[1165] = { city_islamabad, 1996, MONTH_jan, 0.1676286506652832, }, +[1166] = { city_islamabad, 1997, MONTH_jan, 0.1289863395690918, }, +[1167] = { city_islamabad, 1998, MONTH_jan, 0.15707118988037108, }, +[1168] = { city_islamabad, 1999, MONTH_jan, 0.13423368453979492, }, +[1169] = { city_islamabad, 2000, MONTH_jan, 0.11344158172607421, }, +[1170] = { city_islamabad, 2001, MONTH_jan, 0.1141504955291748, }, +[1171] = { city_islamabad, 2002, MONTH_jan, 0.12188603401184082, }, +[1172] = { city_islamabad, 2003, MONTH_jan, 0.13333745002746583, }, +[1173] = { city_islamabad, 2004, MONTH_jan, 0.12676342964172363, }, +[1174] = { city_islamabad, 2005, MONTH_jan, 0.1359751033782959, }, +[1175] = { city_islamabad, 2006, MONTH_jan, 0.12633492469787597, }, +[1176] = { city_islamabad, 2007, MONTH_jan, 0.12365367889404297, }, +[1177] = { city_islamabad, 2008, MONTH_jan, 0.10553434371948242, }, +[1178] = { city_islamabad, 2009, MONTH_jan, 0.10885856628417968, }, +[1179] = { city_islamabad, 2010, MONTH_jan, 0.11174628257751465, }, +[1180] = { city_islamabad, 2011, MONTH_jan, 0.1141127872467041, }, +[1181] = { city_islamabad, 2012, MONTH_jan, 0.04317787647247315, }, +[1182] = { city_islamabad, 2013, MONTH_jan, 0.11522516250610351, }, +[1183] = { city_islamabad, 2014, MONTH_jan, 0.11496394157409667, }, +[1184] = { city_islamabad, 2015, MONTH_jan, 0.11174578666687011, }, +[1185] = { city_islamabad, 2016, MONTH_jan, 0.11086973190307615, }, +[1186] = { city_islamabad, 2017, MONTH_jan, 0.09674949645996093, }, +[1187] = { city_islamabad, 2018, MONTH_jan, 0.09416380882263184, }, +[1188] = { city_islamabad, 2019, MONTH_jan, 0.11015737533569336, }, +[1189] = { city_islamabad, 2020, MONTH_jan, 0.12021024703979492, }, +[1190] = { city_islamabad, 2021, MONTH_jan, 0.10622897148132324, }, +[1191] = { city_lima, 1965, MONTH_jan, 0.1374032688140869, }, +[1192] = { city_lima, 1966, MONTH_jan, 0.12172947883605956, }, +[1193] = { city_lima, 1967, MONTH_jan, 0.13394146919250488, }, +[1194] = { city_lima, 1968, MONTH_jan, 0.1411124134063721, }, +[1195] = { city_lima, 1969, MONTH_jan, 0.1524188995361328, }, +[1196] = { city_lima, 1970, MONTH_jan, 0.14120806694030763, }, +[1197] = { city_lima, 1971, MONTH_jan, 0.17272397994995117, }, +[1198] = { city_lima, 1972, MONTH_jan, 0.19887008666992187, }, +[1199] = { city_lima, 1973, MONTH_jan, 0.1857759666442871, }, +[1200] = { city_lima, 1974, MONTH_jan, 0.17592985153198243, }, +[1201] = { city_lima, 1975, MONTH_jan, 0.1786097526550293, }, +[1202] = { city_lima, 1976, MONTH_jan, 0.18501680374145507, }, +[1203] = { city_lima, 1977, MONTH_jan, 0.1907871437072754, }, +[1204] = { city_lima, 1978, MONTH_jan, 0.19592239379882812, }, +[1205] = { city_lima, 1979, MONTH_jan, 0.20157331466674805, }, +[1206] = { city_lima, 1980, MONTH_jan, 0.19488487243652344, }, +[1207] = { city_lima, 1981, MONTH_jan, 0.21093349456787108, }, +[1208] = { city_lima, 1982, MONTH_jan, 0.22348915100097655, }, +[1209] = { city_lima, 1983, MONTH_jan, 0.2438044166564942, }, +[1210] = { city_lima, 1984, MONTH_jan, 0.24780765533447266, }, +[1211] = { city_lima, 1985, MONTH_jan, 0.2695251083374023, }, +[1212] = { city_lima, 1986, MONTH_jan, 0.269285831451416, }, +[1213] = { city_lima, 1987, MONTH_jan, 0.2701639747619629, }, +[1214] = { city_lima, 1988, MONTH_jan, 0.2654584693908691, }, +[1215] = { city_lima, 1989, MONTH_jan, 0.2911813545227051, }, +[1216] = { city_lima, 1990, MONTH_jan, 0.2930202865600586, }, +[1217] = { city_lima, 1991, MONTH_jan, 0.32345062255859375, }, +[1218] = { city_lima, 1992, MONTH_jan, 0.2806740951538086, }, +[1219] = { city_lima, 1993, MONTH_jan, 0.3119631767272949, }, +[1220] = { city_lima, 1994, MONTH_jan, 0.309783992767334, }, +[1221] = { city_lima, 1995, MONTH_jan, 0.28913646697998047, }, +[1222] = { city_lima, 1996, MONTH_jan, 0.2877692604064942, }, +[1223] = { city_lima, 1997, MONTH_jan, 0.28343660354614253, }, +[1224] = { city_lima, 1998, MONTH_jan, 0.2941726493835449, }, +[1225] = { city_lima, 1999, MONTH_jan, 0.301059398651123, }, +[1226] = { city_lima, 2000, MONTH_jan, 0.3249596405029297, }, +[1227] = { city_lima, 2001, MONTH_jan, 0.3552646255493164, }, +[1228] = { city_lima, 2002, MONTH_jan, 0.3535195541381836, }, +[1229] = { city_lima, 2003, MONTH_jan, 0.3660024261474609, }, +[1230] = { city_lima, 2004, MONTH_jan, 0.3229750442504883, }, +[1231] = { city_lima, 2005, MONTH_jan, 0.3184630966186523, }, +[1232] = { city_lima, 2006, MONTH_jan, 0.34128055572509763, }, +[1233] = { city_lima, 2007, MONTH_jan, 0.3103961563110352, }, +[1234] = { city_lima, 2008, MONTH_jan, 0.28021553039550784, }, +[1235] = { city_lima, 2009, MONTH_jan, 0.2833369064331055, }, +[1236] = { city_lima, 2010, MONTH_jan, 0.25213640213012695, }, +[1237] = { city_lima, 2011, MONTH_jan, 0.24354307174682618, }, +[1238] = { city_lima, 2012, MONTH_jan, 0.2401105308532715, }, +[1239] = { city_lima, 2013, MONTH_jan, 0.24136716842651368, }, +[1240] = { city_lima, 2014, MONTH_jan, 0.23940710067749024, }, +[1241] = { city_lima, 2015, MONTH_jan, 0.24024496078491211, }, +[1242] = { city_lima, 2016, MONTH_jan, 0.2257667922973633, }, +[1243] = { city_lima, 2017, MONTH_jan, 0.2617181777954102, }, +[1244] = { city_lima, 2018, MONTH_jan, 0.26795402526855466, }, +[1245] = { city_lima, 2019, MONTH_jan, 0.2662133598327637, }, +[1246] = { city_lima, 2020, MONTH_jan, 0.30744228363037107, }, +[1247] = { city_lima, 2021, MONTH_jan, 0.27741008758544916, }, +[1248] = { city_bucharest, 1965, MONTH_jan, 0.01066218614578247, }, +[1249] = { city_bucharest, 1966, MONTH_jan, 0.0102953040599823, }, +[1250] = { city_bucharest, 1967, MONTH_jan, 0.01315669298171997, }, +[1251] = { city_bucharest, 1968, MONTH_jan, 0.01308521866798401, }, +[1252] = { city_bucharest, 1969, MONTH_jan, 0.01615439534187317, }, +[1253] = { city_bucharest, 1970, MONTH_jan, 0.01898038387298584, }, +[1254] = { city_bucharest, 1971, MONTH_jan, 0.028985319137573243, }, +[1255] = { city_bucharest, 1972, MONTH_jan, 0.0449291467666626, }, +[1256] = { city_bucharest, 1973, MONTH_jan, 0.04244083404541016, }, +[1257] = { city_bucharest, 1974, MONTH_jan, 0.04733458995819092, }, +[1258] = { city_bucharest, 1975, MONTH_jan, 0.04793048858642578, }, +[1259] = { city_bucharest, 1976, MONTH_jan, 0.03851948022842407, }, +[1260] = { city_bucharest, 1977, MONTH_jan, 0.041872053146362304, }, +[1261] = { city_bucharest, 1978, MONTH_jan, 0.04415801525115967, }, +[1262] = { city_bucharest, 1979, MONTH_jan, 0.04625902652740479, }, +[1263] = { city_bucharest, 1980, MONTH_jan, 0.05105916500091553, }, +[1264] = { city_bucharest, 1981, MONTH_jan, 0.051341099739074705, }, +[1265] = { city_bucharest, 1982, MONTH_jan, 0.04819664478302002, }, +[1266] = { city_bucharest, 1983, MONTH_jan, 0.041099562644958496, }, +[1267] = { city_bucharest, 1984, MONTH_jan, 0.04670980453491211, }, +[1268] = { city_bucharest, 1985, MONTH_jan, 0.052583565711975096, }, +[1269] = { city_bucharest, 1986, MONTH_jan, 0.0437827730178833, }, +[1270] = { city_bucharest, 1987, MONTH_jan, 0.04377776622772217, }, +[1271] = { city_bucharest, 1988, MONTH_jan, 0.05665992736816406, }, +[1272] = { city_bucharest, 1989, MONTH_jan, 0.05235843181610107, }, +[1273] = { city_bucharest, 1990, MONTH_jan, 0.04590248107910156, }, +[1274] = { city_bucharest, 1991, MONTH_jan, 0.06907992839813232, }, +[1275] = { city_bucharest, 1992, MONTH_jan, 0.06283785343170166, }, +[1276] = { city_bucharest, 1993, MONTH_jan, 0.07054651737213134, }, +[1277] = { city_bucharest, 1994, MONTH_jan, 0.07641243934631348, }, +[1278] = { city_bucharest, 1995, MONTH_jan, 0.08897040367126464, }, +[1279] = { city_bucharest, 1996, MONTH_jan, 0.08448899269104004, }, +[1280] = { city_bucharest, 1997, MONTH_jan, 0.09899968147277832, }, +[1281] = { city_bucharest, 1998, MONTH_jan, 0.11665589332580567, }, +[1282] = { city_bucharest, 1999, MONTH_jan, 0.12841182708740234, }, +[1283] = { city_bucharest, 2000, MONTH_jan, 0.10396162033081056, }, +[1284] = { city_bucharest, 2001, MONTH_jan, 0.10312889099121093, }, +[1285] = { city_bucharest, 2002, MONTH_jan, 0.10615109443664551, }, +[1286] = { city_bucharest, 2003, MONTH_jan, 0.08716782569885254, }, +[1287] = { city_bucharest, 2004, MONTH_jan, 0.10407816886901855, }, +[1288] = { city_bucharest, 2005, MONTH_jan, 0.1262943172454834, }, +[1289] = { city_bucharest, 2006, MONTH_jan, 0.11172654151916504, }, +[1290] = { city_bucharest, 2007, MONTH_jan, 0.10032530784606934, }, +[1291] = { city_bucharest, 2008, MONTH_jan, 0.10699505805969238, }, +[1292] = { city_bucharest, 2009, MONTH_jan, 0.10989452362060549, }, +[1293] = { city_bucharest, 2010, MONTH_jan, 0.14136738777160646, }, +[1294] = { city_bucharest, 2011, MONTH_jan, 0.11033339500427246, }, +[1295] = { city_bucharest, 2012, MONTH_jan, 0.1043911838531494, }, +[1296] = { city_bucharest, 2013, MONTH_jan, 0.14889094352722168, }, +[1297] = { city_bucharest, 2014, MONTH_jan, 0.17897146224975585, }, +[1298] = { city_bucharest, 2015, MONTH_jan, 0.1851751136779785, }, +[1299] = { city_bucharest, 2016, MONTH_jan, 0.18943086624145508, }, +[1300] = { city_bucharest, 2017, MONTH_jan, 0.16684114456176757, }, +[1301] = { city_bucharest, 2018, MONTH_jan, 0.17542226791381835, }, +[1302] = { city_bucharest, 2019, MONTH_jan, 0.16837947845458984, }, +[1303] = { city_bucharest, 2020, MONTH_jan, 0.17579639434814454, }, +[1304] = { city_bucharest, 2021, MONTH_jan, 0.1748103141784668, }, +[1305] = { city_moscow, 1985, MONTH_jan, 0.049429731369018556, }, +[1306] = { city_moscow, 1986, MONTH_jan, 0.04996936798095703, }, +[1307] = { city_moscow, 1987, MONTH_jan, 0.0478553295135498, }, +[1308] = { city_moscow, 1988, MONTH_jan, 0.046569442749023436, }, +[1309] = { city_moscow, 1989, MONTH_jan, 0.04605263233184814, }, +[1310] = { city_moscow, 1990, MONTH_jan, 0.04898304462432861, }, +[1311] = { city_moscow, 1991, MONTH_jan, 0.050031914710998535, }, +[1312] = { city_moscow, 1992, MONTH_jan, 0.05336780071258545, }, +[1313] = { city_moscow, 1993, MONTH_jan, 0.0578029727935791, }, +[1314] = { city_moscow, 1994, MONTH_jan, 0.06394296646118164, }, +[1315] = { city_moscow, 1995, MONTH_jan, 0.06769153594970703, }, +[1316] = { city_moscow, 1996, MONTH_jan, 0.06157421112060547, }, +[1317] = { city_moscow, 1997, MONTH_jan, 0.06642446517944336, }, +[1318] = { city_moscow, 1998, MONTH_jan, 0.06699800491333008, }, +[1319] = { city_moscow, 1999, MONTH_jan, 0.0669929838180542, }, +[1320] = { city_moscow, 2000, MONTH_jan, 0.06728621482849122, }, +[1321] = { city_moscow, 2001, MONTH_jan, 0.06975970268249512, }, +[1322] = { city_moscow, 2002, MONTH_jan, 0.06492728233337403, }, +[1323] = { city_moscow, 2003, MONTH_jan, 0.060753769874572754, }, +[1324] = { city_moscow, 2004, MONTH_jan, 0.06754271030426025, }, +[1325] = { city_moscow, 2005, MONTH_jan, 0.06603690147399903, }, +[1326] = { city_moscow, 2006, MONTH_jan, 0.06309632778167724, }, +[1327] = { city_moscow, 2007, MONTH_jan, 0.06371350765228272, }, +[1328] = { city_moscow, 2008, MONTH_jan, 0.05867445468902588, }, +[1329] = { city_moscow, 2009, MONTH_jan, 0.06485455513000488, }, +[1330] = { city_moscow, 2010, MONTH_jan, 0.059318561553955075, }, +[1331] = { city_moscow, 2011, MONTH_jan, 0.05585275650024414, }, +[1332] = { city_moscow, 2012, MONTH_jan, 0.0555089282989502, }, +[1333] = { city_moscow, 2013, MONTH_jan, 0.061906685829162596, }, +[1334] = { city_moscow, 2014, MONTH_jan, 0.0588721513748169, }, +[1335] = { city_moscow, 2015, MONTH_jan, 0.05773604393005371, }, +[1336] = { city_moscow, 2016, MONTH_jan, 0.06171404838562012, }, +[1337] = { city_moscow, 2017, MONTH_jan, 0.061212682723999025, }, +[1338] = { city_moscow, 2018, MONTH_jan, 0.06046762466430664, }, +[1339] = { city_moscow, 2019, MONTH_jan, 0.06201229095458984, }, +[1340] = { city_moscow, 2020, MONTH_jan, 0.07069781303405762, }, +[1341] = { city_moscow, 2021, MONTH_jan, 0.06620289325714111, }, +[1342] = { city_seoul, 1965, MONTH_jan, 0.028078150749206544, }, +[1343] = { city_seoul, 1966, MONTH_jan, 0.03209915399551391, }, +[1344] = { city_seoul, 1967, MONTH_jan, 0.027027177810668945, }, +[1345] = { city_seoul, 1968, MONTH_jan, 0.022995977401733397, }, +[1346] = { city_seoul, 1969, MONTH_jan, 0.029266607761383057, }, +[1347] = { city_seoul, 1970, MONTH_jan, 0.02155395030975342, }, +[1348] = { city_seoul, 1971, MONTH_jan, 0.021541755199432373, }, +[1349] = { city_seoul, 1972, MONTH_jan, 0.02153486490249634, }, +[1350] = { city_seoul, 1973, MONTH_jan, 0.016347564458847046, }, +[1351] = { city_seoul, 1974, MONTH_jan, 0.02332909107208252, }, +[1352] = { city_seoul, 1975, MONTH_jan, 0.0187353253364563, }, +[1353] = { city_seoul, 1976, MONTH_jan, 0.017800427675247192, }, +[1354] = { city_seoul, 1977, MONTH_jan, 0.012054132223129272, }, +[1355] = { city_seoul, 1978, MONTH_jan, 0.01396591067314148, }, +[1356] = { city_seoul, 1979, MONTH_jan, 0.01539095163345337, }, +[1357] = { city_seoul, 1980, MONTH_jan, 0.012506891489028931, }, +[1358] = { city_seoul, 1981, MONTH_jan, 0.01615981578826904, }, +[1359] = { city_seoul, 1982, MONTH_jan, 0.010666205883026122, }, +[1360] = { city_seoul, 1983, MONTH_jan, 0.013120517730712891, }, +[1361] = { city_seoul, 1984, MONTH_jan, 0.010462830066680908, }, +[1362] = { city_seoul, 1985, MONTH_jan, 0.015088706016540528, }, +[1363] = { city_seoul, 1986, MONTH_jan, 0.013128159046173095, }, +[1364] = { city_seoul, 1987, MONTH_jan, 0.015100772380828855, }, +[1365] = { city_seoul, 1988, MONTH_jan, 0.006779970526695251, }, +[1366] = { city_seoul, 1989, MONTH_jan, 0.009301869869232178, }, +[1367] = { city_seoul, 1990, MONTH_jan, 0.012995164394378662, }, +[1368] = { city_seoul, 1991, MONTH_jan, 0.008552601337432861, }, +[1369] = { city_seoul, 1992, MONTH_jan, 0.006740404963493347, }, +[1370] = { city_seoul, 1993, MONTH_jan, 0.008389674425125122, }, +[1371] = { city_seoul, 1994, MONTH_jan, 0.004319862127304077, }, +[1372] = { city_seoul, 1995, MONTH_jan, 0.0051026403903961185, }, +[1373] = { city_seoul, 1996, MONTH_jan, 0.004361970424652099, }, +[1374] = { city_seoul, 1997, MONTH_jan, 0.004026863574981689, }, +[1375] = { city_seoul, 1998, MONTH_jan, 0.006597698330879211, }, +[1376] = { city_seoul, 1999, MONTH_jan, 0.00593690276145935, }, +[1377] = { city_seoul, 2000, MONTH_jan, 0.005420218110084534, }, +[1378] = { city_seoul, 2001, MONTH_jan, 0.0031219828128814697, }, +[1379] = { city_seoul, 2002, MONTH_jan, 0.0041857692599296566, }, +[1380] = { city_seoul, 2003, MONTH_jan, 0.005985386967658997, }, +[1381] = { city_seoul, 2004, MONTH_jan, 0.005346380472183228, }, +[1382] = { city_seoul, 2005, MONTH_jan, 0.00453538864850998, }, +[1383] = { city_seoul, 2006, MONTH_jan, 0.004502668976783752, }, +[1384] = { city_seoul, 2007, MONTH_jan, 0.005043082237243653, }, +[1385] = { city_seoul, 2008, MONTH_jan, 0.005293462872505188, }, +[1386] = { city_seoul, 2009, MONTH_jan, 0.005700946450233459, }, +[1387] = { city_seoul, 2010, MONTH_jan, 0.009195590615272522, }, +[1388] = { city_seoul, 2011, MONTH_jan, 0.012539451122283935, }, +[1389] = { city_seoul, 2012, MONTH_jan, 0.01288482666015625, }, +[1390] = { city_seoul, 2013, MONTH_jan, 0.015155628919601441, }, +[1391] = { city_seoul, 2014, MONTH_jan, 0.017640750408172607, }, +[1392] = { city_seoul, 2015, MONTH_jan, 0.019041190147399904, }, +[1393] = { city_seoul, 2016, MONTH_jan, 0.020268120765686036, }, +[1394] = { city_seoul, 2017, MONTH_jan, 0.024301843643188478, }, +[1395] = { city_seoul, 2018, MONTH_jan, 0.02746018409729004, }, +[1396] = { city_seoul, 2019, MONTH_jan, 0.029800333976745606, }, +[1397] = { city_seoul, 2020, MONTH_jan, 0.03142855405807495, }, +[1398] = { city_seoul, 2021, MONTH_jan, 0.037249858379364016, }, +[1399] = { city_madrid, 1965, MONTH_jan, 0.17253438949584962, }, +[1400] = { city_madrid, 1966, MONTH_jan, 0.2111080551147461, }, +[1401] = { city_madrid, 1967, MONTH_jan, 0.16279375076293945, }, +[1402] = { city_madrid, 1968, MONTH_jan, 0.1665400505065918, }, +[1403] = { city_madrid, 1969, MONTH_jan, 0.18460060119628902, }, +[1404] = { city_madrid, 1970, MONTH_jan, 0.1555931854248047, }, +[1405] = { city_madrid, 1971, MONTH_jan, 0.16187814712524415, }, +[1406] = { city_madrid, 1972, MONTH_jan, 0.16690349578857422, }, +[1407] = { city_madrid, 1973, MONTH_jan, 0.12429852485656738, }, +[1408] = { city_madrid, 1974, MONTH_jan, 0.12622825622558595, }, +[1409] = { city_madrid, 1975, MONTH_jan, 0.10509173393249512, }, +[1410] = { city_madrid, 1976, MONTH_jan, 0.07937400817871093, }, +[1411] = { city_madrid, 1977, MONTH_jan, 0.14476511001586914, }, +[1412] = { city_madrid, 1978, MONTH_jan, 0.14644488334655761, }, +[1413] = { city_madrid, 1979, MONTH_jan, 0.15632555961608888, }, +[1414] = { city_madrid, 1980, MONTH_jan, 0.09981171607971191, }, +[1415] = { city_madrid, 1981, MONTH_jan, 0.07407119750976564, }, +[1416] = { city_madrid, 1982, MONTH_jan, 0.08885108947753906, }, +[1417] = { city_madrid, 1983, MONTH_jan, 0.08936359405517579, }, +[1418] = { city_madrid, 1984, MONTH_jan, 0.10203864097595217, }, +[1419] = { city_madrid, 1985, MONTH_jan, 0.10242602348327637, }, +[1420] = { city_madrid, 1986, MONTH_jan, 0.08501705169677734, }, +[1421] = { city_madrid, 1987, MONTH_jan, 0.08477232933044433, }, +[1422] = { city_madrid, 1988, MONTH_jan, 0.10430665016174316, }, +[1423] = { city_madrid, 1989, MONTH_jan, 0.055330204963684085, }, +[1424] = { city_madrid, 1990, MONTH_jan, 0.07198870182037354, }, +[1425] = { city_madrid, 1991, MONTH_jan, 0.07452907562255859, }, +[1426] = { city_madrid, 1992, MONTH_jan, 0.05013250350952148, }, +[1427] = { city_madrid, 1993, MONTH_jan, 0.0662508773803711, }, +[1428] = { city_madrid, 1994, MONTH_jan, 0.07313819408416748, }, +[1429] = { city_madrid, 1995, MONTH_jan, 0.05938282489776611, }, +[1430] = { city_madrid, 1996, MONTH_jan, 0.09653098106384275, }, +[1431] = { city_madrid, 1997, MONTH_jan, 0.08211402893066407, }, +[1432] = { city_madrid, 1998, MONTH_jan, 0.07815210342407226, }, +[1433] = { city_madrid, 1999, MONTH_jan, 0.05629496574401856, }, +[1434] = { city_madrid, 2000, MONTH_jan, 0.07008230686187744, }, +[1435] = { city_madrid, 2001, MONTH_jan, 0.09167547225952148, }, +[1436] = { city_madrid, 2002, MONTH_jan, 0.0644627046585083, }, +[1437] = { city_madrid, 2003, MONTH_jan, 0.09758903503417969, }, +[1438] = { city_madrid, 2004, MONTH_jan, 0.0844090461730957, }, +[1439] = { city_madrid, 2005, MONTH_jan, 0.06923494338989258, }, +[1440] = { city_madrid, 2006, MONTH_jan, 0.08360922813415528, }, +[1441] = { city_madrid, 2007, MONTH_jan, 0.09064817428588867, }, +[1442] = { city_madrid, 2008, MONTH_jan, 0.09948370933532717, }, +[1443] = { city_madrid, 2009, MONTH_jan, 0.12662100791931152, }, +[1444] = { city_madrid, 2010, MONTH_jan, 0.16742803573608397, }, +[1445] = { city_madrid, 2011, MONTH_jan, 0.15473434448242188, }, +[1446] = { city_madrid, 2012, MONTH_jan, 0.15889772415161132, }, +[1447] = { city_madrid, 2013, MONTH_jan, 0.19901302337646484, }, +[1448] = { city_madrid, 2014, MONTH_jan, 0.2008855438232422, }, +[1449] = { city_madrid, 2015, MONTH_jan, 0.17507902145385743, }, +[1450] = { city_madrid, 2016, MONTH_jan, 0.18609848022460937, }, +[1451] = { city_madrid, 2017, MONTH_jan, 0.15682350158691405, }, +[1452] = { city_madrid, 2018, MONTH_jan, 0.18230533599853516, }, +[1453] = { city_madrid, 2019, MONTH_jan, 0.17375850677490234, }, +[1454] = { city_madrid, 2020, MONTH_jan, 0.22102653503417968, }, +[1455] = { city_madrid, 2021, MONTH_jan, 0.22341663360595704, }, +[1456] = { city_bangkok, 1965, MONTH_jan, 0.08098695755004882, }, +[1457] = { city_bangkok, 1966, MONTH_jan, 0.08597766876220703, }, +[1458] = { city_bangkok, 1967, MONTH_jan, 0.09705655097961426, }, +[1459] = { city_bangkok, 1968, MONTH_jan, 0.07769661903381347, }, +[1460] = { city_bangkok, 1969, MONTH_jan, 0.054768366813659666, }, +[1461] = { city_bangkok, 1970, MONTH_jan, 0.07854705810546875, }, +[1462] = { city_bangkok, 1971, MONTH_jan, 0.08126887321472168, }, +[1463] = { city_bangkok, 1972, MONTH_jan, 0.056506228446960446, }, +[1464] = { city_bangkok, 1973, MONTH_jan, 0.05797545909881592, }, +[1465] = { city_bangkok, 1974, MONTH_jan, 0.07285396575927734, }, +[1466] = { city_bangkok, 1975, MONTH_jan, 0.09127364158630373, }, +[1467] = { city_bangkok, 1976, MONTH_jan, 0.09248512268066406, }, +[1468] = { city_bangkok, 1977, MONTH_jan, 0.07547190666198732, }, +[1469] = { city_bangkok, 1978, MONTH_jan, 0.045728025436401365, }, +[1470] = { city_bangkok, 1979, MONTH_jan, 0.06653911590576173, }, +[1471] = { city_bangkok, 1980, MONTH_jan, 0.02589577913284302, }, +[1472] = { city_bangkok, 1981, MONTH_jan, 0.06015193939208984, }, +[1473] = { city_bangkok, 1982, MONTH_jan, 0.07570967674255372, }, +[1474] = { city_bangkok, 1983, MONTH_jan, 0.06589135646820068, }, +[1475] = { city_bangkok, 1984, MONTH_jan, 0.06626251220703125, }, +[1476] = { city_bangkok, 1985, MONTH_jan, 0.05735532283782959, }, +[1477] = { city_bangkok, 1986, MONTH_jan, 0.08074996948242187, }, +[1478] = { city_bangkok, 1987, MONTH_jan, 0.05194031715393067, }, +[1479] = { city_bangkok, 1988, MONTH_jan, 0.04262178421020508, }, +[1480] = { city_bangkok, 1989, MONTH_jan, 0.05435298919677734, }, +[1481] = { city_bangkok, 1990, MONTH_jan, 0.04073401927947998, }, +[1482] = { city_bangkok, 1991, MONTH_jan, 0.03400254249572754, }, +[1483] = { city_bangkok, 1992, MONTH_jan, 0.028629646301269532, }, +[1484] = { city_bangkok, 1993, MONTH_jan, 0.021971902847290038, }, +[1485] = { city_bangkok, 1994, MONTH_jan, 0.02397928237915039, }, +[1486] = { city_bangkok, 1995, MONTH_jan, 0.032421882152557376, }, +[1487] = { city_bangkok, 1996, MONTH_jan, 0.031586606502532956, }, +[1488] = { city_bangkok, 1997, MONTH_jan, 0.02977715253829956, }, +[1489] = { city_bangkok, 1998, MONTH_jan, 0.02375905752182007, }, +[1490] = { city_bangkok, 1999, MONTH_jan, 0.01608154773712158, }, +[1491] = { city_bangkok, 2000, MONTH_jan, 0.025746095180511474, }, +[1492] = { city_bangkok, 2001, MONTH_jan, 0.025714476108551026, }, +[1493] = { city_bangkok, 2002, MONTH_jan, 0.02818033695220947, }, +[1494] = { city_bangkok, 2003, MONTH_jan, 0.027227082252502442, }, +[1495] = { city_bangkok, 2004, MONTH_jan, 0.02313349723815918, }, +[1496] = { city_bangkok, 2005, MONTH_jan, 0.0227521014213562, }, +[1497] = { city_bangkok, 2006, MONTH_jan, 0.029778263568878173, }, +[1498] = { city_bangkok, 2007, MONTH_jan, 0.029363691806793213, }, +[1499] = { city_bangkok, 2008, MONTH_jan, 0.029482808113098145, }, +[1500] = { city_bangkok, 2009, MONTH_jan, 0.030501224994659425, }, +[1501] = { city_bangkok, 2010, MONTH_jan, 0.028064701557159424, }, +[1502] = { city_bangkok, 2011, MONTH_jan, 0.03457339763641357, }, +[1503] = { city_bangkok, 2012, MONTH_jan, 0.03770574569702149, }, +[1504] = { city_bangkok, 2013, MONTH_jan, 0.0385915493965149, }, +[1505] = { city_bangkok, 2014, MONTH_jan, 0.04258995532989502, }, +[1506] = { city_bangkok, 2015, MONTH_jan, 0.04190981388092041, }, +[1507] = { city_bangkok, 2016, MONTH_jan, 0.045999755859375, }, +[1508] = { city_bangkok, 2017, MONTH_jan, 0.05306326389312744, }, +[1509] = { city_bangkok, 2018, MONTH_jan, 0.06380221366882324, }, +[1510] = { city_bangkok, 2019, MONTH_jan, 0.06956219673156738, }, +[1511] = { city_bangkok, 2020, MONTH_jan, 0.0699142074584961, }, +[1512] = { city_bangkok, 2021, MONTH_jan, 0.07113617897033692, }, +[1513] = { city_ankara, 1965, MONTH_jan, 0.07396099090576172, }, +[1514] = { city_ankara, 1966, MONTH_jan, 0.06960969448089599, }, +[1515] = { city_ankara, 1967, MONTH_jan, 0.06997379779815674, }, +[1516] = { city_ankara, 1968, MONTH_jan, 0.0787749719619751, }, +[1517] = { city_ankara, 1969, MONTH_jan, 0.07791776180267335, }, +[1518] = { city_ankara, 1970, MONTH_jan, 0.06475101470947266, }, +[1519] = { city_ankara, 1971, MONTH_jan, 0.05071615219116211, }, +[1520] = { city_ankara, 1972, MONTH_jan, 0.05530313968658447, }, +[1521] = { city_ankara, 1973, MONTH_jan, 0.04050086498260498, }, +[1522] = { city_ankara, 1974, MONTH_jan, 0.05047706604003906, }, +[1523] = { city_ankara, 1975, MONTH_jan, 0.07770755290985107, }, +[1524] = { city_ankara, 1976, MONTH_jan, 0.09604342460632324, }, +[1525] = { city_ankara, 1977, MONTH_jan, 0.09040463447570801, }, +[1526] = { city_ankara, 1978, MONTH_jan, 0.0920789909362793, }, +[1527] = { city_ankara, 1979, MONTH_jan, 0.10752221107482911, }, +[1528] = { city_ankara, 1980, MONTH_jan, 0.11387236595153809, }, +[1529] = { city_ankara, 1981, MONTH_jan, 0.1250270175933838, }, +[1530] = { city_ankara, 1982, MONTH_jan, 0.12745107650756837, }, +[1531] = { city_ankara, 1983, MONTH_jan, 0.09873126983642579, }, +[1532] = { city_ankara, 1984, MONTH_jan, 0.11116494178771973, }, +[1533] = { city_ankara, 1985, MONTH_jan, 0.09229307174682616, }, +[1534] = { city_ankara, 1986, MONTH_jan, 0.08374287605285645, }, +[1535] = { city_ankara, 1987, MONTH_jan, 0.11513276100158691, }, +[1536] = { city_ankara, 1988, MONTH_jan, 0.16268531799316407, }, +[1537] = { city_ankara, 1989, MONTH_jan, 0.10282753944396973, }, +[1538] = { city_ankara, 1990, MONTH_jan, 0.12219701766967772, }, +[1539] = { city_ankara, 1991, MONTH_jan, 0.11752680778503417, }, +[1540] = { city_ankara, 1992, MONTH_jan, 0.1307958698272705, }, +[1541] = { city_ankara, 1993, MONTH_jan, 0.15372352600097655, }, +[1542] = { city_ankara, 1994, MONTH_jan, 0.14304976463317873, }, +[1543] = { city_ankara, 1995, MONTH_jan, 0.14924197196960448, }, +[1544] = { city_ankara, 1996, MONTH_jan, 0.15543943405151367, }, +[1545] = { city_ankara, 1997, MONTH_jan, 0.14665958404541016, }, +[1546] = { city_ankara, 1998, MONTH_jan, 0.15141606330871582, }, +[1547] = { city_ankara, 1999, MONTH_jan, 0.12753751754760742, }, +[1548] = { city_ankara, 2000, MONTH_jan, 0.10657172203063965, }, +[1549] = { city_ankara, 2001, MONTH_jan, 0.09108513832092284, }, +[1550] = { city_ankara, 2002, MONTH_jan, 0.11535796165466308, }, +[1551] = { city_ankara, 2003, MONTH_jan, 0.11330117225646973, }, +[1552] = { city_ankara, 2004, MONTH_jan, 0.1369169235229492, }, +[1553] = { city_ankara, 2005, MONTH_jan, 0.11418582916259766, }, +[1554] = { city_ankara, 2006, MONTH_jan, 0.11456920623779297, }, +[1555] = { city_ankara, 2007, MONTH_jan, 0.08779489517211914, }, +[1556] = { city_ankara, 2008, MONTH_jan, 0.08211599349975586, }, +[1557] = { city_ankara, 2009, MONTH_jan, 0.08923343658447265, }, +[1558] = { city_ankara, 2010, MONTH_jan, 0.12280028343200683, }, +[1559] = { city_ankara, 2011, MONTH_jan, 0.11913782119750976, }, +[1560] = { city_ankara, 2012, MONTH_jan, 0.1252276611328125, }, +[1561] = { city_ankara, 2013, MONTH_jan, 0.1331322193145752, }, +[1562] = { city_ankara, 2014, MONTH_jan, 0.09769227027893067, }, +[1563] = { city_ankara, 2015, MONTH_jan, 0.1406381320953369, }, +[1564] = { city_ankara, 2016, MONTH_jan, 0.14479534149169923, }, +[1565] = { city_ankara, 2017, MONTH_jan, 0.13170472145080567, }, +[1566] = { city_ankara, 2018, MONTH_jan, 0.1484662437438965, }, +[1567] = { city_ankara, 2019, MONTH_jan, 0.1925493621826172, }, +[1568] = { city_ankara, 2020, MONTH_jan, 0.19150110244750976, }, +[1569] = { city_ankara, 2021, MONTH_jan, 0.16517044067382813, }, +[1570] = { city_kyiv, 1985, MONTH_jan, 0.011391943693161011, }, +[1571] = { city_kyiv, 1986, MONTH_jan, 0.01128100037574768, }, +[1572] = { city_kyiv, 1987, MONTH_jan, 0.009946019649505616, }, +[1573] = { city_kyiv, 1988, MONTH_jan, 0.012357125282287598, }, +[1574] = { city_kyiv, 1989, MONTH_jan, 0.010963214635848999, }, +[1575] = { city_kyiv, 1990, MONTH_jan, 0.009731683731079101, }, +[1576] = { city_kyiv, 1991, MONTH_jan, 0.01156305193901062, }, +[1577] = { city_kyiv, 1992, MONTH_jan, 0.00921140432357788, }, +[1578] = { city_kyiv, 1993, MONTH_jan, 0.014715107679367062, }, +[1579] = { city_kyiv, 1994, MONTH_jan, 0.018900632858276367, }, +[1580] = { city_kyiv, 1995, MONTH_jan, 0.015910707712173462, }, +[1581] = { city_kyiv, 1996, MONTH_jan, 0.014804906845092771, }, +[1582] = { city_kyiv, 1997, MONTH_jan, 0.017526177167892457, }, +[1583] = { city_kyiv, 1998, MONTH_jan, 0.02900869369506836, }, +[1584] = { city_kyiv, 1999, MONTH_jan, 0.026803247928619385, }, +[1585] = { city_kyiv, 2000, MONTH_jan, 0.021038007736206055, }, +[1586] = { city_kyiv, 2001, MONTH_jan, 0.022646660804748534, }, +[1587] = { city_kyiv, 2002, MONTH_jan, 0.018132338523864745, }, +[1588] = { city_kyiv, 2003, MONTH_jan, 0.01688597321510315, }, +[1589] = { city_kyiv, 2004, MONTH_jan, 0.021416072845458985, }, +[1590] = { city_kyiv, 2005, MONTH_jan, 0.022117321491241456, }, +[1591] = { city_kyiv, 2006, MONTH_jan, 0.022632830142974857, }, +[1592] = { city_kyiv, 2007, MONTH_jan, 0.018360310792922975, }, +[1593] = { city_kyiv, 2008, MONTH_jan, 0.02132999897003174, }, +[1594] = { city_kyiv, 2009, MONTH_jan, 0.025476245880126952, }, +[1595] = { city_kyiv, 2010, MONTH_jan, 0.02610059976577759, }, +[1596] = { city_kyiv, 2011, MONTH_jan, 0.020985288619995116, }, +[1597] = { city_kyiv, 2012, MONTH_jan, 0.021388649940490723, }, +[1598] = { city_kyiv, 2013, MONTH_jan, 0.03011183738708496, }, +[1599] = { city_kyiv, 2014, MONTH_jan, 0.022846858501434326, }, +[1600] = { city_kyiv, 2015, MONTH_jan, 0.01913326621055603, }, +[1601] = { city_kyiv, 2016, MONTH_jan, 0.02366657018661499, }, +[1602] = { city_kyiv, 2017, MONTH_jan, 0.02975400447845459, }, +[1603] = { city_kyiv, 2018, MONTH_jan, 0.03421227693557739, }, +[1604] = { city_kyiv, 2019, MONTH_jan, 0.03290361166000366, }, +[1605] = { city_kyiv, 2020, MONTH_jan, 0.048960785865783694, }, +[1606] = { city_kyiv, 2021, MONTH_jan, 0.06100841522216797, }, +[1607] = { city_dubai, 1965, MONTH_jan, 0, }, +[1608] = { city_dubai, 1966, MONTH_jan, 0, }, +[1609] = { city_dubai, 1967, MONTH_jan, 0, }, +[1610] = { city_dubai, 1968, MONTH_jan, 0, }, +[1611] = { city_dubai, 1969, MONTH_jan, 0, }, +[1612] = { city_dubai, 1970, MONTH_jan, 0, }, +[1613] = { city_dubai, 1971, MONTH_jan, 0, }, +[1614] = { city_dubai, 1972, MONTH_jan, 0, }, +[1615] = { city_dubai, 1973, MONTH_jan, 0, }, +[1616] = { city_dubai, 1974, MONTH_jan, 0, }, +[1617] = { city_dubai, 1975, MONTH_jan, 0, }, +[1618] = { city_dubai, 1976, MONTH_jan, 0, }, +[1619] = { city_dubai, 1977, MONTH_jan, 0, }, +[1620] = { city_dubai, 1978, MONTH_jan, 0, }, +[1621] = { city_dubai, 1979, MONTH_jan, 0, }, +[1622] = { city_dubai, 1980, MONTH_jan, 0, }, +[1623] = { city_dubai, 1981, MONTH_jan, 0, }, +[1624] = { city_dubai, 1982, MONTH_jan, 0, }, +[1625] = { city_dubai, 1983, MONTH_jan, 0, }, +[1626] = { city_dubai, 1984, MONTH_jan, 0, }, +[1627] = { city_dubai, 1985, MONTH_jan, 0, }, +[1628] = { city_dubai, 1986, MONTH_jan, 0, }, +[1629] = { city_dubai, 1987, MONTH_jan, 0, }, +[1630] = { city_dubai, 1988, MONTH_jan, 0, }, +[1631] = { city_dubai, 1989, MONTH_jan, 0, }, +[1632] = { city_dubai, 1990, MONTH_jan, 0, }, +[1633] = { city_dubai, 1991, MONTH_jan, 0, }, +[1634] = { city_dubai, 1992, MONTH_jan, 0, }, +[1635] = { city_dubai, 1993, MONTH_jan, 0, }, +[1636] = { city_dubai, 1994, MONTH_jan, 0, }, +[1637] = { city_dubai, 1995, MONTH_jan, 0, }, +[1638] = { city_dubai, 1996, MONTH_jan, 0, }, +[1639] = { city_dubai, 1997, MONTH_jan, 0, }, +[1640] = { city_dubai, 1998, MONTH_jan, 0, }, +[1641] = { city_dubai, 1999, MONTH_jan, 0, }, +[1642] = { city_dubai, 2000, MONTH_jan, 0, }, +[1643] = { city_dubai, 2001, MONTH_jan, 0, }, +[1644] = { city_dubai, 2002, MONTH_jan, 0, }, +[1645] = { city_dubai, 2003, MONTH_jan, 0, }, +[1646] = { city_dubai, 2004, MONTH_jan, 0, }, +[1647] = { city_dubai, 2005, MONTH_jan, 0, }, +[1648] = { city_dubai, 2006, MONTH_jan, 0, }, +[1649] = { city_dubai, 2007, MONTH_jan, 0, }, +[1650] = { city_dubai, 2008, MONTH_jan, 0, }, +[1651] = { city_dubai, 2009, MONTH_jan, 1.91772636026144e-5, }, +[1652] = { city_dubai, 2010, MONTH_jan, 5.25837112218141e-5, }, +[1653] = { city_dubai, 2011, MONTH_jan, 5.59225212782621e-5, }, +[1654] = { city_dubai, 2012, MONTH_jan, 6.18843780830502e-5, }, +[1655] = { city_dubai, 2013, MONTH_jan, 2.0930014550685878e-4, }, +[1656] = { city_dubai, 2014, MONTH_jan, 7.691703736782074e-4, }, +[1657] = { city_dubai, 2015, MONTH_jan, 6.952883303165436e-4, }, +[1658] = { city_dubai, 2016, MONTH_jan, 6.702232360839843e-4, }, +[1659] = { city_dubai, 2017, MONTH_jan, 0.0015412747859954834, }, +[1660] = { city_dubai, 2018, MONTH_jan, 0.0027376759052276612, }, +[1661] = { city_dubai, 2019, MONTH_jan, 0.007918253540992737, }, +[1662] = { city_dubai, 2020, MONTH_jan, 0.010150353908538818, }, +[1663] = { city_san_francisco, 1965, MONTH_jan, 0.043688697814941405, }, +[1664] = { city_denver, 1965, MONTH_jan, 0.043688697814941405, }, +[1665] = { city_washington, 1965, MONTH_jan, 0.043688697814941405, }, +[1666] = { city_chicago, 1965, MONTH_jan, 0.043688697814941405, }, +[1667] = { city_san_francisco, 1966, MONTH_jan, 0.041714019775390625, }, +[1668] = { city_denver, 1966, MONTH_jan, 0.041714019775390625, }, +[1669] = { city_washington, 1966, MONTH_jan, 0.041714019775390625, }, +[1670] = { city_chicago, 1966, MONTH_jan, 0.041714019775390625, }, +[1671] = { city_san_francisco, 1967, MONTH_jan, 0.04542215824127197, }, +[1672] = { city_denver, 1967, MONTH_jan, 0.04542215824127197, }, +[1673] = { city_washington, 1967, MONTH_jan, 0.04542215824127197, }, +[1674] = { city_chicago, 1967, MONTH_jan, 0.04542215824127197, }, +[1675] = { city_san_francisco, 1968, MONTH_jan, 0.04330973625183106, }, +[1676] = { city_denver, 1968, MONTH_jan, 0.04330973625183106, }, +[1677] = { city_washington, 1968, MONTH_jan, 0.04330973625183106, }, +[1678] = { city_chicago, 1968, MONTH_jan, 0.04330973625183106, }, +[1679] = { city_san_francisco, 1969, MONTH_jan, 0.04598878383636475, }, +[1680] = { city_denver, 1969, MONTH_jan, 0.04598878383636475, }, +[1681] = { city_washington, 1969, MONTH_jan, 0.04598878383636475, }, +[1682] = { city_chicago, 1969, MONTH_jan, 0.04598878383636475, }, +[1683] = { city_san_francisco, 1970, MONTH_jan, 0.044008030891418456, }, +[1684] = { city_denver, 1970, MONTH_jan, 0.044008030891418456, }, +[1685] = { city_washington, 1970, MONTH_jan, 0.044008030891418456, }, +[1686] = { city_chicago, 1970, MONTH_jan, 0.044008030891418456, }, +[1687] = { city_san_francisco, 1971, MONTH_jan, 0.046144747734069826, }, +[1688] = { city_denver, 1971, MONTH_jan, 0.046144747734069826, }, +[1689] = { city_washington, 1971, MONTH_jan, 0.046144747734069826, }, +[1690] = { city_chicago, 1971, MONTH_jan, 0.046144747734069826, }, +[1691] = { city_san_francisco, 1972, MONTH_jan, 0.045260472297668455, }, +[1692] = { city_denver, 1972, MONTH_jan, 0.045260472297668455, }, +[1693] = { city_washington, 1972, MONTH_jan, 0.045260472297668455, }, +[1694] = { city_chicago, 1972, MONTH_jan, 0.045260472297668455, }, +[1695] = { city_san_francisco, 1973, MONTH_jan, 0.043547596931457516, }, +[1696] = { city_denver, 1973, MONTH_jan, 0.043547596931457516, }, +[1697] = { city_washington, 1973, MONTH_jan, 0.043547596931457516, }, +[1698] = { city_chicago, 1973, MONTH_jan, 0.043547596931457516, }, +[1699] = { city_san_francisco, 1974, MONTH_jan, 0.04902864933013916, }, +[1700] = { city_denver, 1974, MONTH_jan, 0.04902864933013916, }, +[1701] = { city_washington, 1974, MONTH_jan, 0.04902864933013916, }, +[1702] = { city_chicago, 1974, MONTH_jan, 0.04902864933013916, }, +[1703] = { city_san_francisco, 1975, MONTH_jan, 0.050069751739501955, }, +[1704] = { city_denver, 1975, MONTH_jan, 0.050069751739501955, }, +[1705] = { city_washington, 1975, MONTH_jan, 0.050069751739501955, }, +[1706] = { city_chicago, 1975, MONTH_jan, 0.050069751739501955, }, +[1707] = { city_san_francisco, 1976, MONTH_jan, 0.045527076721191405, }, +[1708] = { city_denver, 1976, MONTH_jan, 0.045527076721191405, }, +[1709] = { city_washington, 1976, MONTH_jan, 0.045527076721191405, }, +[1710] = { city_chicago, 1976, MONTH_jan, 0.045527076721191405, }, +[1711] = { city_san_francisco, 1977, MONTH_jan, 0.03549314022064209, }, +[1712] = { city_denver, 1977, MONTH_jan, 0.03549314022064209, }, +[1713] = { city_washington, 1977, MONTH_jan, 0.03549314022064209, }, +[1714] = { city_chicago, 1977, MONTH_jan, 0.03549314022064209, }, +[1715] = { city_san_francisco, 1978, MONTH_jan, 0.043275704383850096, }, +[1716] = { city_denver, 1978, MONTH_jan, 0.043275704383850096, }, +[1717] = { city_washington, 1978, MONTH_jan, 0.043275704383850096, }, +[1718] = { city_chicago, 1978, MONTH_jan, 0.043275704383850096, }, +[1719] = { city_san_francisco, 1979, MONTH_jan, 0.0429140567779541, }, +[1720] = { city_denver, 1979, MONTH_jan, 0.0429140567779541, }, +[1721] = { city_washington, 1979, MONTH_jan, 0.0429140567779541, }, +[1722] = { city_chicago, 1979, MONTH_jan, 0.0429140567779541, }, +[1723] = { city_san_francisco, 1980, MONTH_jan, 0.044192209243774414, }, +[1724] = { city_denver, 1980, MONTH_jan, 0.044192209243774414, }, +[1725] = { city_washington, 1980, MONTH_jan, 0.044192209243774414, }, +[1726] = { city_chicago, 1980, MONTH_jan, 0.044192209243774414, }, +[1727] = { city_san_francisco, 1981, MONTH_jan, 0.04336748600006104, }, +[1728] = { city_denver, 1981, MONTH_jan, 0.04336748600006104, }, +[1729] = { city_washington, 1981, MONTH_jan, 0.04336748600006104, }, +[1730] = { city_chicago, 1981, MONTH_jan, 0.04336748600006104, }, +[1731] = { city_san_francisco, 1982, MONTH_jan, 0.05256711483001709, }, +[1732] = { city_denver, 1982, MONTH_jan, 0.05256711483001709, }, +[1733] = { city_washington, 1982, MONTH_jan, 0.05256711483001709, }, +[1734] = { city_chicago, 1982, MONTH_jan, 0.05256711483001709, }, +[1735] = { city_san_francisco, 1983, MONTH_jan, 0.056848154067993165, }, +[1736] = { city_denver, 1983, MONTH_jan, 0.056848154067993165, }, +[1737] = { city_washington, 1983, MONTH_jan, 0.056848154067993165, }, +[1738] = { city_chicago, 1983, MONTH_jan, 0.056848154067993165, }, +[1739] = { city_san_francisco, 1984, MONTH_jan, 0.05334360599517822, }, +[1740] = { city_denver, 1984, MONTH_jan, 0.05334360599517822, }, +[1741] = { city_washington, 1984, MONTH_jan, 0.05334360599517822, }, +[1742] = { city_chicago, 1984, MONTH_jan, 0.05334360599517822, }, +[1743] = { city_san_francisco, 1985, MONTH_jan, 0.04765776157379151, }, +[1744] = { city_denver, 1985, MONTH_jan, 0.04765776157379151, }, +[1745] = { city_washington, 1985, MONTH_jan, 0.04765776157379151, }, +[1746] = { city_chicago, 1985, MONTH_jan, 0.04765776157379151, }, +[1747] = { city_san_francisco, 1986, MONTH_jan, 0.048984041213989256, }, +[1748] = { city_denver, 1986, MONTH_jan, 0.048984041213989256, }, +[1749] = { city_washington, 1986, MONTH_jan, 0.048984041213989256, }, +[1750] = { city_chicago, 1986, MONTH_jan, 0.048984041213989256, }, +[1751] = { city_san_francisco, 1987, MONTH_jan, 0.04214753627777099, }, +[1752] = { city_denver, 1987, MONTH_jan, 0.04214753627777099, }, +[1753] = { city_washington, 1987, MONTH_jan, 0.04214753627777099, }, +[1754] = { city_chicago, 1987, MONTH_jan, 0.04214753627777099, }, +[1755] = { city_san_francisco, 1988, MONTH_jan, 0.03664999723434448, }, +[1756] = { city_denver, 1988, MONTH_jan, 0.03664999723434448, }, +[1757] = { city_washington, 1988, MONTH_jan, 0.03664999723434448, }, +[1758] = { city_chicago, 1988, MONTH_jan, 0.03664999723434448, }, +[1759] = { city_san_francisco, 1989, MONTH_jan, 0.043015427589416504, }, +[1760] = { city_denver, 1989, MONTH_jan, 0.043015427589416504, }, +[1761] = { city_washington, 1989, MONTH_jan, 0.043015427589416504, }, +[1762] = { city_chicago, 1989, MONTH_jan, 0.043015427589416504, }, +[1763] = { city_san_francisco, 1990, MONTH_jan, 0.047246766090393064, }, +[1764] = { city_denver, 1990, MONTH_jan, 0.047246766090393064, }, +[1765] = { city_washington, 1990, MONTH_jan, 0.047246766090393064, }, +[1766] = { city_chicago, 1990, MONTH_jan, 0.047246766090393064, }, +[1767] = { city_san_francisco, 1991, MONTH_jan, 0.0472428560256958, }, +[1768] = { city_denver, 1991, MONTH_jan, 0.0472428560256958, }, +[1769] = { city_washington, 1991, MONTH_jan, 0.0472428560256958, }, +[1770] = { city_chicago, 1991, MONTH_jan, 0.0472428560256958, }, +[1771] = { city_san_francisco, 1992, MONTH_jan, 0.042612309455871585, }, +[1772] = { city_denver, 1992, MONTH_jan, 0.042612309455871585, }, +[1773] = { city_washington, 1992, MONTH_jan, 0.042612309455871585, }, +[1774] = { city_chicago, 1992, MONTH_jan, 0.042612309455871585, }, +[1775] = { city_san_francisco, 1993, MONTH_jan, 0.045714097023010256, }, +[1776] = { city_denver, 1993, MONTH_jan, 0.045714097023010256, }, +[1777] = { city_washington, 1993, MONTH_jan, 0.045714097023010256, }, +[1778] = { city_chicago, 1993, MONTH_jan, 0.045714097023010256, }, +[1779] = { city_san_francisco, 1994, MONTH_jan, 0.0425481653213501, }, +[1780] = { city_denver, 1994, MONTH_jan, 0.0425481653213501, }, +[1781] = { city_washington, 1994, MONTH_jan, 0.0425481653213501, }, +[1782] = { city_chicago, 1994, MONTH_jan, 0.0425481653213501, }, +[1783] = { city_san_francisco, 1995, MONTH_jan, 0.04762141227722168, }, +[1784] = { city_denver, 1995, MONTH_jan, 0.04762141227722168, }, +[1785] = { city_washington, 1995, MONTH_jan, 0.04762141227722168, }, +[1786] = { city_chicago, 1995, MONTH_jan, 0.04762141227722168, }, +[1787] = { city_san_francisco, 1996, MONTH_jan, 0.050185713768005374, }, +[1788] = { city_denver, 1996, MONTH_jan, 0.050185713768005374, }, +[1789] = { city_washington, 1996, MONTH_jan, 0.050185713768005374, }, +[1790] = { city_chicago, 1996, MONTH_jan, 0.050185713768005374, }, +[1791] = { city_san_francisco, 1997, MONTH_jan, 0.051152210235595706, }, +[1792] = { city_denver, 1997, MONTH_jan, 0.051152210235595706, }, +[1793] = { city_washington, 1997, MONTH_jan, 0.051152210235595706, }, +[1794] = { city_chicago, 1997, MONTH_jan, 0.051152210235595706, }, +[1795] = { city_san_francisco, 1998, MONTH_jan, 0.046957569122314455, }, +[1796] = { city_denver, 1998, MONTH_jan, 0.046957569122314455, }, +[1797] = { city_washington, 1998, MONTH_jan, 0.046957569122314455, }, +[1798] = { city_chicago, 1998, MONTH_jan, 0.046957569122314455, }, +[1799] = { city_san_francisco, 1999, MONTH_jan, 0.04583451747894287, }, +[1800] = { city_denver, 1999, MONTH_jan, 0.04583451747894287, }, +[1801] = { city_washington, 1999, MONTH_jan, 0.04583451747894287, }, +[1802] = { city_chicago, 1999, MONTH_jan, 0.04583451747894287, }, +[1803] = { city_san_francisco, 2000, MONTH_jan, 0.0402735710144043, }, +[1804] = { city_denver, 2000, MONTH_jan, 0.0402735710144043, }, +[1805] = { city_washington, 2000, MONTH_jan, 0.0402735710144043, }, +[1806] = { city_chicago, 2000, MONTH_jan, 0.0402735710144043, }, +[1807] = { city_san_francisco, 2001, MONTH_jan, 0.034213709831237796, }, +[1808] = { city_denver, 2001, MONTH_jan, 0.034213709831237796, }, +[1809] = { city_washington, 2001, MONTH_jan, 0.034213709831237796, }, +[1810] = { city_chicago, 2001, MONTH_jan, 0.034213709831237796, }, +[1811] = { city_san_francisco, 2002, MONTH_jan, 0.040155067443847656, }, +[1812] = { city_denver, 2002, MONTH_jan, 0.040155067443847656, }, +[1813] = { city_washington, 2002, MONTH_jan, 0.040155067443847656, }, +[1814] = { city_chicago, 2002, MONTH_jan, 0.040155067443847656, }, +[1815] = { city_san_francisco, 2003, MONTH_jan, 0.041800403594970705, }, +[1816] = { city_denver, 2003, MONTH_jan, 0.041800403594970705, }, +[1817] = { city_washington, 2003, MONTH_jan, 0.041800403594970705, }, +[1818] = { city_chicago, 2003, MONTH_jan, 0.041800403594970705, }, +[1819] = { city_san_francisco, 2004, MONTH_jan, 0.04101511478424072, }, +[1820] = { city_denver, 2004, MONTH_jan, 0.04101511478424072, }, +[1821] = { city_washington, 2004, MONTH_jan, 0.04101511478424072, }, +[1822] = { city_chicago, 2004, MONTH_jan, 0.04101511478424072, }, +[1823] = { city_san_francisco, 2005, MONTH_jan, 0.04219231128692627, }, +[1824] = { city_denver, 2005, MONTH_jan, 0.04219231128692627, }, +[1825] = { city_washington, 2005, MONTH_jan, 0.04219231128692627, }, +[1826] = { city_chicago, 2005, MONTH_jan, 0.04219231128692627, }, +[1827] = { city_san_francisco, 2006, MONTH_jan, 0.04678860664367676, }, +[1828] = { city_denver, 2006, MONTH_jan, 0.04678860664367676, }, +[1829] = { city_washington, 2006, MONTH_jan, 0.04678860664367676, }, +[1830] = { city_chicago, 2006, MONTH_jan, 0.04678860664367676, }, +[1831] = { city_san_francisco, 2007, MONTH_jan, 0.04373008728027344, }, +[1832] = { city_denver, 2007, MONTH_jan, 0.04373008728027344, }, +[1833] = { city_washington, 2007, MONTH_jan, 0.04373008728027344, }, +[1834] = { city_chicago, 2007, MONTH_jan, 0.04373008728027344, }, +[1835] = { city_san_francisco, 2008, MONTH_jan, 0.050045504570007324, }, +[1836] = { city_denver, 2008, MONTH_jan, 0.050045504570007324, }, +[1837] = { city_washington, 2008, MONTH_jan, 0.050045504570007324, }, +[1838] = { city_chicago, 2008, MONTH_jan, 0.050045504570007324, }, +[1839] = { city_san_francisco, 2009, MONTH_jan, 0.0580000638961792, }, +[1840] = { city_denver, 2009, MONTH_jan, 0.0580000638961792, }, +[1841] = { city_washington, 2009, MONTH_jan, 0.0580000638961792, }, +[1842] = { city_chicago, 2009, MONTH_jan, 0.0580000638961792, }, +[1843] = { city_san_francisco, 2010, MONTH_jan, 0.05840554714202881, }, +[1844] = { city_denver, 2010, MONTH_jan, 0.05840554714202881, }, +[1845] = { city_washington, 2010, MONTH_jan, 0.05840554714202881, }, +[1846] = { city_chicago, 2010, MONTH_jan, 0.05840554714202881, }, +[1847] = { city_san_francisco, 2011, MONTH_jan, 0.06897319316864013, }, +[1848] = { city_denver, 2011, MONTH_jan, 0.06897319316864013, }, +[1849] = { city_washington, 2011, MONTH_jan, 0.06897319316864013, }, +[1850] = { city_chicago, 2011, MONTH_jan, 0.06897319316864013, }, +[1851] = { city_san_francisco, 2012, MONTH_jan, 0.06886333942413331, }, +[1852] = { city_denver, 2012, MONTH_jan, 0.06886333942413331, }, +[1853] = { city_washington, 2012, MONTH_jan, 0.06886333942413331, }, +[1854] = { city_chicago, 2012, MONTH_jan, 0.06886333942413331, }, +[1855] = { city_san_francisco, 2013, MONTH_jan, 0.07134616374969482, }, +[1856] = { city_denver, 2013, MONTH_jan, 0.07134616374969482, }, +[1857] = { city_washington, 2013, MONTH_jan, 0.07134616374969482, }, +[1858] = { city_chicago, 2013, MONTH_jan, 0.07134616374969482, }, +[1859] = { city_san_francisco, 2014, MONTH_jan, 0.07262890815734863, }, +[1860] = { city_denver, 2014, MONTH_jan, 0.07262890815734863, }, +[1861] = { city_washington, 2014, MONTH_jan, 0.07262890815734863, }, +[1862] = { city_chicago, 2014, MONTH_jan, 0.07262890815734863, }, +[1863] = { city_san_francisco, 2015, MONTH_jan, 0.07468742847442628, }, +[1864] = { city_denver, 2015, MONTH_jan, 0.07468742847442628, }, +[1865] = { city_washington, 2015, MONTH_jan, 0.07468742847442628, }, +[1866] = { city_chicago, 2015, MONTH_jan, 0.07468742847442628, }, +[1867] = { city_san_francisco, 2016, MONTH_jan, 0.08285085678100586, }, +[1868] = { city_denver, 2016, MONTH_jan, 0.08285085678100586, }, +[1869] = { city_washington, 2016, MONTH_jan, 0.08285085678100586, }, +[1870] = { city_chicago, 2016, MONTH_jan, 0.08285085678100586, }, +[1871] = { city_san_francisco, 2017, MONTH_jan, 0.09082049369812012, }, +[1872] = { city_denver, 2017, MONTH_jan, 0.09082049369812012, }, +[1873] = { city_washington, 2017, MONTH_jan, 0.09082049369812012, }, +[1874] = { city_chicago, 2017, MONTH_jan, 0.09082049369812012, }, +[1875] = { city_san_francisco, 2018, MONTH_jan, 0.0896493911743164, }, +[1876] = { city_denver, 2018, MONTH_jan, 0.0896493911743164, }, +[1877] = { city_washington, 2018, MONTH_jan, 0.0896493911743164, }, +[1878] = { city_chicago, 2018, MONTH_jan, 0.0896493911743164, }, +[1879] = { city_san_francisco, 2019, MONTH_jan, 0.09315262794494628, }, +[1880] = { city_denver, 2019, MONTH_jan, 0.09315262794494628, }, +[1881] = { city_washington, 2019, MONTH_jan, 0.09315262794494628, }, +[1882] = { city_chicago, 2019, MONTH_jan, 0.09315262794494628, }, +[1883] = { city_san_francisco, 2020, MONTH_jan, 0.10532232284545899, }, +[1884] = { city_denver, 2020, MONTH_jan, 0.10532232284545899, }, +[1885] = { city_washington, 2020, MONTH_jan, 0.10532232284545899, }, +[1886] = { city_chicago, 2020, MONTH_jan, 0.10532232284545899, }, +[1887] = { city_san_francisco, 2021, MONTH_jan, 0.10655990600585938, }, +[1888] = { city_denver, 2021, MONTH_jan, 0.10655990600585938, }, +[1889] = { city_washington, 2021, MONTH_jan, 0.10655990600585938, }, +[1890] = { city_chicago, 2021, MONTH_jan, 0.10655990600585938, }, +[1891] = { city_hanoi, 1965, MONTH_jan, 0.034132664203643796, }, +[1892] = { city_hanoi, 1966, MONTH_jan, 0.02240062952041626, }, +[1893] = { city_hanoi, 1967, MONTH_jan, 0.017923457622528075, }, +[1894] = { city_hanoi, 1968, MONTH_jan, 0.01929360270500183, }, +[1895] = { city_hanoi, 1969, MONTH_jan, 0.01837692379951477, }, +[1896] = { city_hanoi, 1970, MONTH_jan, 0.019573317766189577, }, +[1897] = { city_hanoi, 1971, MONTH_jan, 0.022463304996490477, }, +[1898] = { city_hanoi, 1972, MONTH_jan, 0.01592976570129394, }, +[1899] = { city_hanoi, 1973, MONTH_jan, 0.015021532773971558, }, +[1900] = { city_hanoi, 1974, MONTH_jan, 0.020197300910949706, }, +[1901] = { city_hanoi, 1975, MONTH_jan, 0.02163102149963379, }, +[1902] = { city_hanoi, 1976, MONTH_jan, 0.041627111434936526, }, +[1903] = { city_hanoi, 1977, MONTH_jan, 0.04191826820373535, }, +[1904] = { city_hanoi, 1978, MONTH_jan, 0.05387956142425537, }, +[1905] = { city_hanoi, 1979, MONTH_jan, 0.062493300437927245, }, +[1906] = { city_hanoi, 1980, MONTH_jan, 0.08125602722167968, }, +[1907] = { city_hanoi, 1981, MONTH_jan, 0.08210463523864746, }, +[1908] = { city_hanoi, 1982, MONTH_jan, 0.07957214832305909, }, +[1909] = { city_hanoi, 1983, MONTH_jan, 0.059674644470214845, }, +[1910] = { city_hanoi, 1984, MONTH_jan, 0.07733730316162109, }, +[1911] = { city_hanoi, 1985, MONTH_jan, 0.07084222316741944, }, +[1912] = { city_hanoi, 1986, MONTH_jan, 0.062252769470214846, }, +[1913] = { city_hanoi, 1987, MONTH_jan, 0.05438616275787354, }, +[1914] = { city_hanoi, 1988, MONTH_jan, 0.07041000366210938, }, +[1915] = { city_hanoi, 1989, MONTH_jan, 0.15831216812133786, }, +[1916] = { city_hanoi, 1990, MONTH_jan, 0.20584053039550781, }, +[1917] = { city_hanoi, 1991, MONTH_jan, 0.2379098892211914, }, +[1918] = { city_hanoi, 1992, MONTH_jan, 0.24912485122680664, }, +[1919] = { city_hanoi, 1993, MONTH_jan, 0.24039852142333984, }, +[1920] = { city_hanoi, 1994, MONTH_jan, 0.2497269630432129, }, +[1921] = { city_hanoi, 1995, MONTH_jan, 0.24608880996704102, }, +[1922] = { city_hanoi, 1996, MONTH_jan, 0.24358139038085938, }, +[1923] = { city_hanoi, 1997, MONTH_jan, 0.20527612686157226, }, +[1924] = { city_hanoi, 1998, MONTH_jan, 0.1806495475769043, }, +[1925] = { city_hanoi, 1999, MONTH_jan, 0.2165902328491211, }, +[1926] = { city_hanoi, 2000, MONTH_jan, 0.20092161178588866, }, +[1927] = { city_hanoi, 2001, MONTH_jan, 0.22102148056030274, }, +[1928] = { city_hanoi, 2002, MONTH_jan, 0.20062660217285155, }, +[1929] = { city_hanoi, 2003, MONTH_jan, 0.19297657012939454, }, +[1930] = { city_hanoi, 2004, MONTH_jan, 0.14763954162597656, }, +[1931] = { city_hanoi, 2005, MONTH_jan, 0.1284674835205078, }, +[1932] = { city_hanoi, 2006, MONTH_jan, 0.16607240676879884, }, +[1933] = { city_hanoi, 2007, MONTH_jan, 0.17202272415161132, }, +[1934] = { city_hanoi, 2008, MONTH_jan, 0.16009517669677734, }, +[1935] = { city_hanoi, 2009, MONTH_jan, 0.17948020935058595, }, +[1936] = { city_hanoi, 2010, MONTH_jan, 0.14711740493774414, }, +[1937] = { city_hanoi, 2011, MONTH_jan, 0.1902745246887207, }, +[1938] = { city_hanoi, 2012, MONTH_jan, 0.2338884544372558, }, +[1939] = { city_hanoi, 2013, MONTH_jan, 0.23877511978149418, }, +[1940] = { city_hanoi, 2014, MONTH_jan, 0.23073970794677734, }, +[1941] = { city_hanoi, 2015, MONTH_jan, 0.18584493637084962, }, +[1942] = { city_hanoi, 2016, MONTH_jan, 0.19181915283203124, }, +[1943] = { city_hanoi, 2017, MONTH_jan, 0.24208347320556642, }, +[1944] = { city_hanoi, 2018, MONTH_jan, 0.20761816024780275, }, +[1945] = { city_hanoi, 2019, MONTH_jan, 0.15891139030456544, }, +[1946] = { city_hanoi, 2020, MONTH_jan, 0.19136663436889648, }, +[1947] = { city_hanoi, 2021, MONTH_jan, 0.2273440742492676, }, +}; +global u32 question_21_len = sizeof(question_21_data) / sizeof(question_21_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_3.h b/run_tree/data/incenter_data/c/question_3.h new file mode 100644 index 0000000..3b4fb11 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_3.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_3_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.601593625498008, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.6060606060606061, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.5254237288135594, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.6507936507936508, }, +[4] = { city_paris, 2022, MONTH_jan, 0.569806492883416, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.6120930232558139, }, +[6] = { city_denver, 2022, MONTH_jan, 0.6120930232558139, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.7948003714020427, }, +[8] = { city_harare, 2022, MONTH_jan, 0.5714285714285714, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.6158536585365854, }, +[10] = { city_washington, 2022, MONTH_jan, 0.6120930232558139, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.5555555555555556, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.5142857142857142, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.6158536585365854, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.6169354838709677, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.5819672131147541, }, +[16] = { city_lima, 2022, MONTH_jan, 0.425, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.6363636363636364, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.8333333333333334, }, +[19] = { city_managua, 2022, MONTH_jan, 0.6774193548387096, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.464638783269962, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.6190476190476191, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.5254237288135594, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.5176882661996497, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.5714285714285714, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.5993009868421053, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.5, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.5, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.6011644832605532, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.6774193548387096, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.6111111111111112, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.5714285714285714, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.5142857142857142, }, +[33] = { city_quito, 2022, MONTH_jan, 0.4827586206896552, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.45, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.5254237288135594, }, +[36] = { city_accra, 2022, MONTH_jan, 0.5714285714285714, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.6352941176470588, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.7062314540059347, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.7062314540059347, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.7107438016528925, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.7948003714020427, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.6120930232558139, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.59375, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.5, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.6507936507936508, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.4838709677419355, }, +}; +global u32 question_3_len = sizeof(question_3_data) / sizeof(question_3_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_4.h b/run_tree/data/incenter_data/c/question_4.h new file mode 100644 index 0000000..81c2134 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_4.h @@ -0,0 +1,1366 @@ +static Incenter_Data_Row question_4_data[] = { +[0] = { city_abuja, 2020, MONTH_jan, 0, }, +[1] = { city_abuja, 2020, MONTH_feb, 0, }, +[2] = { city_abuja, 2020, MONTH_mar, 0.012232415902140673, }, +[3] = { city_abuja, 2020, MONTH_apr, 0.14984709480122324, }, +[4] = { city_abuja, 2020, MONTH_may, 0.672782874617737, }, +[5] = { city_abuja, 2020, MONTH_jun, 0.9174311926605505, }, +[6] = { city_abuja, 2020, MONTH_jul, 0.9327217125382263, }, +[7] = { city_abuja, 2020, MONTH_aug, 0.41284403669724773, }, +[8] = { city_abuja, 2020, MONTH_sep, 0.2996941896024465, }, +[9] = { city_abuja, 2020, MONTH_oct, 0.10091743119266056, }, +[10] = { city_abuja, 2020, MONTH_nov, 0.08868501529051988, }, +[11] = { city_abuja, 2020, MONTH_dec, 0.3211009174311927, }, +[12] = { city_abuja, 2021, MONTH_jan, 0.9174311926605505, }, +[13] = { city_abuja, 2021, MONTH_feb, 1, }, +[14] = { city_abuja, 2021, MONTH_mar, 0.4617737003058104, }, +[15] = { city_abuja, 2021, MONTH_apr, 0.021406727828746176, }, +[16] = { city_abuja, 2021, MONTH_may, 0.024464831804281346, }, +[17] = { city_abuja, 2021, MONTH_jun, 0.14984709480122324, }, +[18] = { city_abuja, 2021, MONTH_jul, 0.08868501529051988, }, +[19] = { city_abuja, 2021, MONTH_aug, 0.9357798165137615, }, +[20] = { city_abuja, 2021, MONTH_sep, 0.7553516819571865, }, +[21] = { city_abuja, 2021, MONTH_oct, 0.5902140672782875, }, +[22] = { city_abuja, 2021, MONTH_nov, 0.24770642201834864, }, +[23] = { city_abuja, 2021, MONTH_dec, 0.1651376146788991, }, +[24] = { city_abuja, 2022, MONTH_jan, 0.3211009174311927, }, +[25] = { city_abuja, 2022, MONTH_feb, 0.021406727828746176, }, +[26] = { city_abuja, 2022, MONTH_mar, 0, }, +[27] = { city_abuja, 2022, MONTH_apr, 0.0030581039755351682, }, +[28] = { city_abuja, 2022, MONTH_may, 0, }, +[29] = { city_accra, 2020, MONTH_jan, 0, }, +[30] = { city_accra, 2020, MONTH_feb, 0, }, +[31] = { city_accra, 2020, MONTH_mar, 0.017467248908296942, }, +[32] = { city_accra, 2020, MONTH_apr, 0.05240174672489083, }, +[33] = { city_accra, 2020, MONTH_may, 0.08296943231441048, }, +[34] = { city_accra, 2020, MONTH_jun, 0.33624454148471616, }, +[35] = { city_accra, 2020, MONTH_jul, 0.27510917030567683, }, +[36] = { city_accra, 2020, MONTH_aug, 0.4410480349344978, }, +[37] = { city_accra, 2020, MONTH_sep, 0.1091703056768559, }, +[38] = { city_accra, 2020, MONTH_oct, 0.08296943231441048, }, +[39] = { city_accra, 2020, MONTH_nov, 0.021834061135371178, }, +[40] = { city_accra, 2020, MONTH_dec, 0.043668122270742356, }, +[41] = { city_accra, 2021, MONTH_jan, 0.388646288209607, }, +[42] = { city_accra, 2021, MONTH_feb, 0.8165938864628821, }, +[43] = { city_accra, 2021, MONTH_mar, 0.5807860262008734, }, +[44] = { city_accra, 2021, MONTH_apr, 0.15283842794759825, }, +[45] = { city_accra, 2021, MONTH_may, 0.026200873362445413, }, +[46] = { city_accra, 2021, MONTH_jun, 0.048034934497816595, }, +[47] = { city_accra, 2021, MONTH_jul, 0.11790393013100436, }, +[48] = { city_accra, 2021, MONTH_aug, 1, }, +[49] = { city_accra, 2021, MONTH_sep, 0.4585152838427948, }, +[50] = { city_accra, 2021, MONTH_oct, 0.13537117903930132, }, +[51] = { city_accra, 2021, MONTH_nov, 0.16593886462882096, }, +[52] = { city_accra, 2021, MONTH_dec, 0.34934497816593885, }, +[53] = { city_accra, 2022, MONTH_jan, 0.4279475982532751, }, +[54] = { city_accra, 2022, MONTH_feb, 0.16593886462882096, }, +[55] = { city_accra, 2022, MONTH_mar, 0.013100436681222707, }, +[56] = { city_accra, 2022, MONTH_apr, 0, }, +[57] = { city_accra, 2022, MONTH_may, 0, }, +[58] = { city_addis_ababa, 2020, MONTH_jan, 0, }, +[59] = { city_addis_ababa, 2020, MONTH_feb, 0, }, +[60] = { city_addis_ababa, 2020, MONTH_mar, 0, }, +[61] = { city_addis_ababa, 2020, MONTH_apr, 0.026172300981461286, }, +[62] = { city_addis_ababa, 2020, MONTH_may, 0.004362050163576881, }, +[63] = { city_addis_ababa, 2020, MONTH_jun, 0.10032715376226826, }, +[64] = { city_addis_ababa, 2020, MONTH_jul, 0.1723009814612868, }, +[65] = { city_addis_ababa, 2020, MONTH_aug, 0.5627044711014176, }, +[66] = { city_addis_ababa, 2020, MONTH_sep, 0.4340239912758997, }, +[67] = { city_addis_ababa, 2020, MONTH_oct, 0.2966194111232279, }, +[68] = { city_addis_ababa, 2020, MONTH_nov, 0.257360959651036, }, +[69] = { city_addis_ababa, 2020, MONTH_dec, 0.23773173391494, }, +[70] = { city_addis_ababa, 2021, MONTH_jan, 0.18865866957470012, }, +[71] = { city_addis_ababa, 2021, MONTH_feb, 0.28680479825517996, }, +[72] = { city_addis_ababa, 2021, MONTH_mar, 0.5310796074154853, }, +[73] = { city_addis_ababa, 2021, MONTH_apr, 0.8909487459105779, }, +[74] = { city_addis_ababa, 2021, MONTH_may, 0.5419847328244275, }, +[75] = { city_addis_ababa, 2021, MONTH_jun, 0.17993456924754633, }, +[76] = { city_addis_ababa, 2021, MONTH_jul, 0.06870229007633588, }, +[77] = { city_addis_ababa, 2021, MONTH_aug, 0.302071973827699, }, +[78] = { city_addis_ababa, 2021, MONTH_sep, 0.9531079607415486, }, +[79] = { city_addis_ababa, 2021, MONTH_oct, 1, }, +[80] = { city_addis_ababa, 2021, MONTH_nov, 0.3260632497273719, }, +[81] = { city_addis_ababa, 2021, MONTH_dec, 0.19193020719738277, }, +[82] = { city_addis_ababa, 2022, MONTH_jan, 0.4416575790621592, }, +[83] = { city_addis_ababa, 2022, MONTH_feb, 0.1406761177753544, }, +[84] = { city_addis_ababa, 2022, MONTH_mar, 0.03489640130861505, }, +[85] = { city_addis_ababa, 2022, MONTH_apr, 0.019629225736095966, }, +[86] = { city_addis_ababa, 2022, MONTH_may, 0.003271537622682661, }, +[87] = { city_amsterdam, 2020, MONTH_jan, 0, }, +[88] = { city_amsterdam, 2020, MONTH_feb, 0, }, +[89] = { city_amsterdam, 2020, MONTH_mar, 0.22048475371383894, }, +[90] = { city_amsterdam, 2020, MONTH_apr, 1, }, +[91] = { city_amsterdam, 2020, MONTH_may, 0.32212666145426117, }, +[92] = { city_amsterdam, 2020, MONTH_jun, 0.041959864477456345, }, +[93] = { city_amsterdam, 2020, MONTH_jul, 0.01667969768047954, }, +[94] = { city_amsterdam, 2020, MONTH_aug, 0.019546520719311962, }, +[95] = { city_amsterdam, 2020, MONTH_sep, 0.04508730779254626, }, +[96] = { city_amsterdam, 2020, MONTH_oct, 0.24811050299713316, }, +[97] = { city_amsterdam, 2020, MONTH_nov, 0.5173312483711233, }, +[98] = { city_amsterdam, 2020, MONTH_dec, 0.5129007036747459, }, +[99] = { city_amsterdam, 2021, MONTH_jan, 0.689080010424811, }, +[100] = { city_amsterdam, 2021, MONTH_feb, 0.4162105811832161, }, +[101] = { city_amsterdam, 2021, MONTH_mar, 0.2509773260359656, }, +[102] = { city_amsterdam, 2021, MONTH_apr, 0.16080271045087308, }, +[103] = { city_amsterdam, 2021, MONTH_may, 0.1308313786812614, }, +[104] = { city_amsterdam, 2021, MONTH_jun, 0.03205629397967162, }, +[105] = { city_amsterdam, 2021, MONTH_jul, 0.019807140995569454, }, +[106] = { city_amsterdam, 2021, MONTH_aug, 0.046390409173833726, }, +[107] = { city_amsterdam, 2021, MONTH_sep, 0.04430544696377378, }, +[108] = { city_amsterdam, 2021, MONTH_oct, 0.05968204326296586, }, +[109] = { city_amsterdam, 2021, MONTH_nov, 0.24758926244461818, }, +[110] = { city_amsterdam, 2021, MONTH_dec, 0.40109460516028145, }, +[111] = { city_amsterdam, 2022, MONTH_jan, 0.09747198332030232, }, +[112] = { city_amsterdam, 2022, MONTH_feb, 0.07453739900964294, }, +[113] = { city_amsterdam, 2022, MONTH_mar, 0.10685431326557206, }, +[114] = { city_amsterdam, 2022, MONTH_apr, 0.07479801928590045, }, +[115] = { city_amsterdam, 2022, MONTH_may, 0.019807140995569454, }, +[116] = { city_ankara, 2020, MONTH_jan, 0, }, +[117] = { city_ankara, 2020, MONTH_feb, 0, }, +[118] = { city_ankara, 2020, MONTH_mar, 0.020114942528735632, }, +[119] = { city_ankara, 2020, MONTH_apr, 0.3487787356321839, }, +[120] = { city_ankara, 2020, MONTH_may, 0.17169540229885058, }, +[121] = { city_ankara, 2020, MONTH_jun, 0.07183908045977011, }, +[122] = { city_ankara, 2020, MONTH_jul, 0.06693007662835249, }, +[123] = { city_ankara, 2020, MONTH_aug, 0.07806513409961686, }, +[124] = { city_ankara, 2020, MONTH_sep, 0.21599616858237547, }, +[125] = { city_ankara, 2020, MONTH_oct, 0.24509099616858238, }, +[126] = { city_ankara, 2020, MONTH_nov, 0.4048132183908046, }, +[127] = { city_ankara, 2020, MONTH_dec, 0.8481800766283525, }, +[128] = { city_ankara, 2021, MONTH_jan, 0.6253591954022989, }, +[129] = { city_ankara, 2021, MONTH_feb, 0.3158524904214559, }, +[130] = { city_ankara, 2021, MONTH_mar, 0.3450670498084291, }, +[131] = { city_ankara, 2021, MONTH_apr, 1, }, +[132] = { city_ankara, 2021, MONTH_may, 0.9181034482758621, }, +[133] = { city_ankara, 2021, MONTH_jun, 0.273227969348659, }, +[134] = { city_ankara, 2021, MONTH_jul, 0.1875, }, +[135] = { city_ankara, 2021, MONTH_aug, 0.6232040229885057, }, +[136] = { city_ankara, 2021, MONTH_sep, 0.8836206896551724, }, +[137] = { city_ankara, 2021, MONTH_oct, 0.7868773946360154, }, +[138] = { city_ankara, 2021, MONTH_nov, 0.7453304597701149, }, +[139] = { city_ankara, 2021, MONTH_dec, 0.6660680076628352, }, +[140] = { city_ankara, 2022, MONTH_jan, 0.6029693486590039, }, +[141] = { city_ankara, 2022, MONTH_feb, 0.8378831417624522, }, +[142] = { city_ankara, 2022, MONTH_mar, 0.4483955938697318, }, +[143] = { city_ankara, 2022, MONTH_apr, 0.09375, }, +[144] = { city_ankara, 2022, MONTH_may, 0.024066091954022987, }, +[145] = { city_baghdad, 2020, MONTH_jan, 0, }, +[146] = { city_baghdad, 2020, MONTH_feb, 0, }, +[147] = { city_baghdad, 2020, MONTH_mar, 0.016242937853107344, }, +[148] = { city_baghdad, 2020, MONTH_apr, 0.016242937853107344, }, +[149] = { city_baghdad, 2020, MONTH_may, 0.03637005649717514, }, +[150] = { city_baghdad, 2020, MONTH_jun, 0.5805084745762712, }, +[151] = { city_baghdad, 2020, MONTH_jul, 1, }, +[152] = { city_baghdad, 2020, MONTH_aug, 0.807909604519774, }, +[153] = { city_baghdad, 2020, MONTH_sep, 0.763771186440678, }, +[154] = { city_baghdad, 2020, MONTH_oct, 0.614406779661017, }, +[155] = { city_baghdad, 2020, MONTH_nov, 0.4809322033898305, }, +[156] = { city_baghdad, 2020, MONTH_dec, 0.2062146892655367, }, +[157] = { city_baghdad, 2021, MONTH_jan, 0.08227401129943503, }, +[158] = { city_baghdad, 2021, MONTH_feb, 0.12076271186440678, }, +[159] = { city_baghdad, 2021, MONTH_mar, 0.3188559322033898, }, +[160] = { city_baghdad, 2021, MONTH_apr, 0.4050141242937853, }, +[161] = { city_baghdad, 2021, MONTH_may, 0.3241525423728814, }, +[162] = { city_baghdad, 2021, MONTH_jun, 0.2842514124293785, }, +[163] = { city_baghdad, 2021, MONTH_jul, 0.5081214689265536, }, +[164] = { city_baghdad, 2021, MONTH_aug, 0.7658898305084746, }, +[165] = { city_baghdad, 2021, MONTH_sep, 0.5144774011299436, }, +[166] = { city_baghdad, 2021, MONTH_oct, 0.3237994350282486, }, +[167] = { city_baghdad, 2021, MONTH_nov, 0.23622881355932204, }, +[168] = { city_baghdad, 2021, MONTH_dec, 0.12252824858757062, }, +[169] = { city_baghdad, 2022, MONTH_jan, 0.07838983050847458, }, +[170] = { city_baghdad, 2022, MONTH_feb, 0.21151129943502825, }, +[171] = { city_baghdad, 2022, MONTH_mar, 0.06638418079096045, }, +[172] = { city_baghdad, 2022, MONTH_apr, 0.01694915254237288, }, +[173] = { city_baghdad, 2022, MONTH_may, 0.002824858757062147, }, +[174] = { city_bangkok, 2020, MONTH_jan, 0, }, +[175] = { city_bangkok, 2020, MONTH_feb, 0, }, +[176] = { city_bangkok, 2020, MONTH_mar, 0.0014854426619132501, }, +[177] = { city_bangkok, 2020, MONTH_apr, 0.006535947712418301, }, +[178] = { city_bangkok, 2020, MONTH_may, 4.45632798573975e-4, }, +[179] = { city_bangkok, 2020, MONTH_jun, 1.4854426619132502e-4, }, +[180] = { city_bangkok, 2020, MONTH_jul, 0, }, +[181] = { city_bangkok, 2020, MONTH_aug, 0, }, +[182] = { city_bangkok, 2020, MONTH_sep, 1.4854426619132502e-4, }, +[183] = { city_bangkok, 2020, MONTH_oct, 0, }, +[184] = { city_bangkok, 2020, MONTH_nov, 1.4854426619132502e-4, }, +[185] = { city_bangkok, 2020, MONTH_dec, 1.4854426619132502e-4, }, +[186] = { city_bangkok, 2021, MONTH_jan, 0.0023767082590612004, }, +[187] = { city_bangkok, 2021, MONTH_feb, 8.9126559714795e-4, }, +[188] = { city_bangkok, 2021, MONTH_mar, 0.0016339869281045752, }, +[189] = { city_bangkok, 2021, MONTH_apr, 0.016191325014854426, }, +[190] = { city_bangkok, 2021, MONTH_may, 0.12299465240641712, }, +[191] = { city_bangkok, 2021, MONTH_jun, 0.1473559120617944, }, +[192] = { city_bangkok, 2021, MONTH_jul, 0.4209744503862151, }, +[193] = { city_bangkok, 2021, MONTH_aug, 1, }, +[194] = { city_bangkok, 2021, MONTH_sep, 0.7632204396910279, }, +[195] = { city_bangkok, 2021, MONTH_oct, 0.3680926916221034, }, +[196] = { city_bangkok, 2021, MONTH_nov, 0.232620320855615, }, +[197] = { city_bangkok, 2021, MONTH_dec, 0.13770053475935828, }, +[198] = { city_bangkok, 2022, MONTH_jan, 0.07055852644087938, }, +[199] = { city_bangkok, 2022, MONTH_feb, 0.11289364230540701, }, +[200] = { city_bangkok, 2022, MONTH_mar, 0.3263517528223411, }, +[201] = { city_bangkok, 2022, MONTH_apr, 0.5044563279857398, }, +[202] = { city_bangkok, 2022, MONTH_may, 0.22177658942364825, }, +[203] = { city_beijing, 2020, MONTH_jan, 0, }, +[204] = { city_beijing, 2020, MONTH_feb, 0.3723932472691162, }, +[205] = { city_beijing, 2020, MONTH_mar, 0.06752730883813307, }, +[206] = { city_beijing, 2020, MONTH_apr, 0.1885373811888211, }, +[207] = { city_beijing, 2020, MONTH_may, 2.837281883955171e-4, }, +[208] = { city_beijing, 2020, MONTH_jun, 4.2559228259327563e-4, }, +[209] = { city_beijing, 2020, MONTH_jul, 0.0025535536955596538, }, +[210] = { city_beijing, 2020, MONTH_aug, 0.00893743793445879, }, +[211] = { city_beijing, 2020, MONTH_sep, 0.0024116896013618955, }, +[212] = { city_beijing, 2020, MONTH_oct, 0, }, +[213] = { city_beijing, 2020, MONTH_nov, 5.674563767910342e-4, }, +[214] = { city_beijing, 2020, MONTH_dec, 0.005390835579514825, }, +[215] = { city_beijing, 2021, MONTH_jan, 0.004965243296921549, }, +[216] = { city_beijing, 2021, MONTH_feb, 0.002837281883955171, }, +[217] = { city_beijing, 2021, MONTH_mar, 0.0011349127535820683, }, +[218] = { city_beijing, 2021, MONTH_apr, 8.511845651865513e-4, }, +[219] = { city_beijing, 2021, MONTH_may, 0.013902681231380337, }, +[220] = { city_beijing, 2021, MONTH_jun, 0.07589729039580083, }, +[221] = { city_beijing, 2021, MONTH_jul, 0.02057029365867499, }, +[222] = { city_beijing, 2021, MONTH_aug, 0.006667612427294652, }, +[223] = { city_beijing, 2021, MONTH_sep, 0.0012767768477798269, }, +[224] = { city_beijing, 2021, MONTH_oct, 7.093204709887927e-4, }, +[225] = { city_beijing, 2021, MONTH_nov, 1.4186409419775854e-4, }, +[226] = { city_beijing, 2021, MONTH_dec, 2.837281883955171e-4, }, +[227] = { city_beijing, 2022, MONTH_jan, 1.4186409419775854e-4, }, +[228] = { city_beijing, 2022, MONTH_feb, 0.06355511420059583, }, +[229] = { city_beijing, 2022, MONTH_mar, 1, }, +[230] = { city_beijing, 2022, MONTH_apr, 0.2816002269825507, }, +[231] = { city_beijing, 2022, MONTH_may, 0.22513831749184282, }, +[232] = { city_belgrade, 2020, MONTH_jan, 0, }, +[233] = { city_belgrade, 2020, MONTH_feb, 0, }, +[234] = { city_belgrade, 2020, MONTH_mar, 0.007441327990841442, }, +[235] = { city_belgrade, 2020, MONTH_apr, 0.09158557527189468, }, +[236] = { city_belgrade, 2020, MONTH_may, 0.03949627933600458, }, +[237] = { city_belgrade, 2020, MONTH_jun, 0.018317115054378934, }, +[238] = { city_belgrade, 2020, MONTH_jul, 0.16657126502575845, }, +[239] = { city_belgrade, 2020, MONTH_aug, 0.0835718374356039, }, +[240] = { city_belgrade, 2020, MONTH_sep, 0.021751574127074985, }, +[241] = { city_belgrade, 2020, MONTH_oct, 0.03720663995420721, }, +[242] = { city_belgrade, 2020, MONTH_nov, 0.42072123640526615, }, +[243] = { city_belgrade, 2020, MONTH_dec, 0.9238694905552376, }, +[244] = { city_belgrade, 2021, MONTH_jan, 0.47910704064109905, }, +[245] = { city_belgrade, 2021, MONTH_feb, 0.2455638236977676, }, +[246] = { city_belgrade, 2021, MONTH_mar, 0.4813966800228964, }, +[247] = { city_belgrade, 2021, MONTH_apr, 0.6107613050944476, }, +[248] = { city_belgrade, 2021, MONTH_may, 0.2959358900973097, }, +[249] = { city_belgrade, 2021, MONTH_jun, 0.10818546078992558, }, +[250] = { city_belgrade, 2021, MONTH_jul, 0.03949627933600458, }, +[251] = { city_belgrade, 2021, MONTH_aug, 0.09502003434459072, }, +[252] = { city_belgrade, 2021, MONTH_sep, 0.5203205495134516, }, +[253] = { city_belgrade, 2021, MONTH_oct, 0.9748139668002289, }, +[254] = { city_belgrade, 2021, MONTH_nov, 1, }, +[255] = { city_belgrade, 2021, MONTH_dec, 0.6016027475672582, }, +[256] = { city_belgrade, 2022, MONTH_jan, 0.5048654836863194, }, +[257] = { city_belgrade, 2022, MONTH_feb, 0.9324556382369776, }, +[258] = { city_belgrade, 2022, MONTH_mar, 0.3371493989696623, }, +[259] = { city_belgrade, 2022, MONTH_apr, 0.11219232970807098, }, +[260] = { city_belgrade, 2022, MONTH_may, 0.05495134516313681, }, +[261] = { city_berlin, 2020, MONTH_jan, 0, }, +[262] = { city_berlin, 2020, MONTH_feb, 3.875217981011432e-5, }, +[263] = { city_berlin, 2020, MONTH_mar, 0.08913001356326293, }, +[264] = { city_berlin, 2020, MONTH_apr, 0.23445068785119164, }, +[265] = { city_berlin, 2020, MONTH_may, 0.029722921914357683, }, +[266] = { city_berlin, 2020, MONTH_jun, 0.0056965704320868045, }, +[267] = { city_berlin, 2020, MONTH_jul, 0.005076535555124976, }, +[268] = { city_berlin, 2020, MONTH_aug, 0.004999031195504747, }, +[269] = { city_berlin, 2020, MONTH_sep, 0.012749467157527611, }, +[270] = { city_berlin, 2020, MONTH_oct, 0.11893043983724085, }, +[271] = { city_berlin, 2020, MONTH_nov, 0.44944778143770586, }, +[272] = { city_berlin, 2020, MONTH_dec, 1, }, +[273] = { city_berlin, 2021, MONTH_jan, 0.7780662662274753, }, +[274] = { city_berlin, 2021, MONTH_feb, 0.2610734353807402, }, +[275] = { city_berlin, 2021, MONTH_mar, 0.21472582832784345, }, +[276] = { city_berlin, 2021, MONTH_apr, 0.26177097461732224, }, +[277] = { city_berlin, 2021, MONTH_may, 0.10831234256926953, }, +[278] = { city_berlin, 2021, MONTH_jun, 0.011393140864173609, }, +[279] = { city_berlin, 2021, MONTH_jul, 0.0063553574888587485, }, +[280] = { city_berlin, 2021, MONTH_aug, 0.033946909513660146, }, +[281] = { city_berlin, 2021, MONTH_sep, 0.06859135826390235, }, +[282] = { city_berlin, 2021, MONTH_oct, 0.13466382484014724, }, +[283] = { city_berlin, 2021, MONTH_nov, 0.3957372602208874, }, +[284] = { city_berlin, 2021, MONTH_dec, 0.346444487502422, }, +[285] = { city_berlin, 2022, MONTH_jan, 0.14357682619647355, }, +[286] = { city_berlin, 2022, MONTH_feb, 0.24545630691726408, }, +[287] = { city_berlin, 2022, MONTH_mar, 0.2939740360395272, }, +[288] = { city_berlin, 2022, MONTH_apr, 0.1602402635148227, }, +[289] = { city_berlin, 2022, MONTH_may, 0.05619066072466576, }, +[290] = { city_bogota, 2020, MONTH_jan, 0, }, +[291] = { city_bogota, 2020, MONTH_feb, 0, }, +[292] = { city_bogota, 2020, MONTH_mar, 5.688605722737357e-4, }, +[293] = { city_bogota, 2020, MONTH_apr, 0.014733488821889755, }, +[294] = { city_bogota, 2020, MONTH_may, 0.033221457420786166, }, +[295] = { city_bogota, 2020, MONTH_jun, 0.12816428693327264, }, +[296] = { city_bogota, 2020, MONTH_jul, 0.3611126912793674, }, +[297] = { city_bogota, 2020, MONTH_aug, 0.54667500995506, }, +[298] = { city_bogota, 2020, MONTH_sep, 0.374139598384436, }, +[299] = { city_bogota, 2020, MONTH_oct, 0.3006428124466693, }, +[300] = { city_bogota, 2020, MONTH_nov, 0.31145116331987027, }, +[301] = { city_bogota, 2020, MONTH_dec, 0.35377438989703625, }, +[302] = { city_bogota, 2021, MONTH_jan, 0.6066329142727117, }, +[303] = { city_bogota, 2021, MONTH_feb, 0.3546276807554468, }, +[304] = { city_bogota, 2021, MONTH_mar, 0.2025712497866773, }, +[305] = { city_bogota, 2021, MONTH_apr, 0.5487229080152455, }, +[306] = { city_bogota, 2021, MONTH_may, 0.8545423516696058, }, +[307] = { city_bogota, 2021, MONTH_jun, 1, }, +[308] = { city_bogota, 2021, MONTH_jul, 0.8419136469651288, }, +[309] = { city_bogota, 2021, MONTH_aug, 0.26651117811024516, }, +[310] = { city_bogota, 2021, MONTH_sep, 0.08009556857614199, }, +[311] = { city_bogota, 2021, MONTH_oct, 0.05722737357073781, }, +[312] = { city_bogota, 2021, MONTH_nov, 0.06894590135957676, }, +[313] = { city_bogota, 2021, MONTH_dec, 0.08129017577791683, }, +[314] = { city_bogota, 2022, MONTH_jan, 0.22561010296376358, }, +[315] = { city_bogota, 2022, MONTH_feb, 0.27111894874566245, }, +[316] = { city_bogota, 2022, MONTH_mar, 0.05671539905569145, }, +[317] = { city_bogota, 2022, MONTH_apr, 0.011035895102110473, }, +[318] = { city_bogota, 2022, MONTH_may, 0.003697593719779282, }, +[319] = { city_brasilia, 2020, MONTH_jan, 0, }, +[320] = { city_brasilia, 2020, MONTH_feb, 0, }, +[321] = { city_brasilia, 2020, MONTH_mar, 0.0016129223543922485, }, +[322] = { city_brasilia, 2020, MONTH_apr, 0.05788730891021004, }, +[323] = { city_brasilia, 2020, MONTH_may, 0.27112513193942056, }, +[324] = { city_brasilia, 2020, MONTH_jun, 0.35275560668413997, }, +[325] = { city_brasilia, 2020, MONTH_jul, 0.38558332048529986, }, +[326] = { city_brasilia, 2020, MONTH_aug, 0.3596816850294714, }, +[327] = { city_brasilia, 2020, MONTH_sep, 0.2561225820989338, }, +[328] = { city_brasilia, 2020, MONTH_oct, 0.20055977893475965, }, +[329] = { city_brasilia, 2020, MONTH_nov, 0.16119735765367235, }, +[330] = { city_brasilia, 2020, MONTH_dec, 0.23861763066450029, }, +[331] = { city_brasilia, 2021, MONTH_jan, 0.35561379997390863, }, +[332] = { city_brasilia, 2021, MONTH_feb, 0.35779598904161575, }, +[333] = { city_brasilia, 2021, MONTH_mar, 0.7238107662567156, }, +[334] = { city_brasilia, 2021, MONTH_apr, 1, }, +[335] = { city_brasilia, 2021, MONTH_may, 0.7456445166569812, }, +[336] = { city_brasilia, 2021, MONTH_jun, 0.6289804195970066, }, +[337] = { city_brasilia, 2021, MONTH_jul, 0.4791921156560206, }, +[338] = { city_brasilia, 2021, MONTH_aug, 0.2942515921678388, }, +[339] = { city_brasilia, 2021, MONTH_sep, 0.19139221290575079, }, +[340] = { city_brasilia, 2021, MONTH_oct, 0.14250643389983278, }, +[341] = { city_brasilia, 2021, MONTH_nov, 0.0808358732907174, }, +[342] = { city_brasilia, 2021, MONTH_dec, 0.053831283577841296, }, +[343] = { city_brasilia, 2022, MONTH_jan, 0.09140288665662544, }, +[344] = { city_brasilia, 2022, MONTH_feb, 0.2655273425918239, }, +[345] = { city_brasilia, 2022, MONTH_mar, 0.1224872211482584, }, +[346] = { city_brasilia, 2022, MONTH_apr, 0.04724913720513763, }, +[347] = { city_brasilia, 2022, MONTH_may, 0.03828318647042778, }, +[348] = { city_brisbane, 2020, MONTH_jan, 0, }, +[349] = { city_brisbane, 2020, MONTH_feb, 0, }, +[350] = { city_brisbane, 2020, MONTH_mar, 0.009825327510917031, }, +[351] = { city_brisbane, 2020, MONTH_apr, 0.039301310043668124, }, +[352] = { city_brisbane, 2020, MONTH_may, 0.006550218340611353, }, +[353] = { city_brisbane, 2020, MONTH_jun, 0.001091703056768559, }, +[354] = { city_brisbane, 2020, MONTH_jul, 0.04639737991266375, }, +[355] = { city_brisbane, 2020, MONTH_aug, 0.23034934497816595, }, +[356] = { city_brisbane, 2020, MONTH_sep, 0.14792576419213974, }, +[357] = { city_brisbane, 2020, MONTH_oct, 0.013646288209606987, }, +[358] = { city_brisbane, 2020, MONTH_nov, 0, }, +[359] = { city_brisbane, 2020, MONTH_dec, 0.001091703056768559, }, +[360] = { city_brisbane, 2021, MONTH_jan, 0, }, +[361] = { city_brisbane, 2021, MONTH_feb, 0, }, +[362] = { city_brisbane, 2021, MONTH_mar, 0, }, +[363] = { city_brisbane, 2021, MONTH_apr, 5.458515283842794e-4, }, +[364] = { city_brisbane, 2021, MONTH_may, 0, }, +[365] = { city_brisbane, 2021, MONTH_jun, 0, }, +[366] = { city_brisbane, 2021, MONTH_jul, 0.007096069868995633, }, +[367] = { city_brisbane, 2021, MONTH_aug, 0.04312227074235808, }, +[368] = { city_brisbane, 2021, MONTH_sep, 0.15065502183406113, }, +[369] = { city_brisbane, 2021, MONTH_oct, 0.2423580786026201, }, +[370] = { city_brisbane, 2021, MONTH_nov, 0.15010917030567686, }, +[371] = { city_brisbane, 2021, MONTH_dec, 0.125, }, +[372] = { city_brisbane, 2022, MONTH_jan, 0.8133187772925764, }, +[373] = { city_brisbane, 2022, MONTH_feb, 0.7876637554585153, }, +[374] = { city_brisbane, 2022, MONTH_mar, 0.4383187772925764, }, +[375] = { city_brisbane, 2022, MONTH_apr, 0.6697598253275109, }, +[376] = { city_brisbane, 2022, MONTH_may, 0.6986899563318777, }, +[377] = { city_bucharest, 2020, MONTH_jan, 0, }, +[378] = { city_bucharest, 2020, MONTH_feb, 0, }, +[379] = { city_bucharest, 2020, MONTH_mar, 0.006214743283296682, }, +[380] = { city_bucharest, 2020, MONTH_apr, 0.06004398126015872, }, +[381] = { city_bucharest, 2020, MONTH_may, 0.05411607228224496, }, +[382] = { city_bucharest, 2020, MONTH_jun, 0.03585428817286548, }, +[383] = { city_bucharest, 2020, MONTH_jul, 0.06405966153551965, }, +[384] = { city_bucharest, 2020, MONTH_aug, 0.12180896835261497, }, +[385] = { city_bucharest, 2020, MONTH_sep, 0.1160722822449565, }, +[386] = { city_bucharest, 2020, MONTH_oct, 0.19839372788985563, }, +[387] = { city_bucharest, 2020, MONTH_nov, 0.4136150683621761, }, +[388] = { city_bucharest, 2020, MONTH_dec, 0.4209771488670045, }, +[389] = { city_bucharest, 2021, MONTH_jan, 0.2550913089205469, }, +[390] = { city_bucharest, 2021, MONTH_feb, 0.19342193326321827, }, +[391] = { city_bucharest, 2021, MONTH_mar, 0.29849890046849603, }, +[392] = { city_bucharest, 2021, MONTH_apr, 0.4361793670522995, }, +[393] = { city_bucharest, 2021, MONTH_may, 0.22038435796921313, }, +[394] = { city_bucharest, 2021, MONTH_jun, 0.3182904675399178, }, +[395] = { city_bucharest, 2021, MONTH_jul, 0.06434649584090257, }, +[396] = { city_bucharest, 2021, MONTH_aug, 0.02495458456831437, }, +[397] = { city_bucharest, 2021, MONTH_sep, 0.2223921981068936, }, +[398] = { city_bucharest, 2021, MONTH_oct, 1, }, +[399] = { city_bucharest, 2021, MONTH_nov, 0.8660483793861746, }, +[400] = { city_bucharest, 2021, MONTH_dec, 0.22296586671765944, }, +[401] = { city_bucharest, 2022, MONTH_jan, 0.1214265226121044, }, +[402] = { city_bucharest, 2022, MONTH_feb, 0.3221149249450234, }, +[403] = { city_bucharest, 2022, MONTH_mar, 0.1568983650444593, }, +[404] = { city_bucharest, 2022, MONTH_apr, 0.046275934601778375, }, +[405] = { city_bucharest, 2022, MONTH_may, 0.019122287025528255, }, +[406] = { city_cairo, 2020, MONTH_jan, 0, }, +[407] = { city_cairo, 2020, MONTH_feb, 0, }, +[408] = { city_cairo, 2020, MONTH_mar, 0.02092904543134252, }, +[409] = { city_cairo, 2020, MONTH_apr, 0.17304747320061256, }, +[410] = { city_cairo, 2020, MONTH_may, 0.2720775906074528, }, +[411] = { city_cairo, 2020, MONTH_jun, 1, }, +[412] = { city_cairo, 2020, MONTH_jul, 0.9709035222052067, }, +[413] = { city_cairo, 2020, MONTH_aug, 0.31904032669729454, }, +[414] = { city_cairo, 2020, MONTH_sep, 0.2628892291985707, }, +[415] = { city_cairo, 2020, MONTH_oct, 0.1755997958141909, }, +[416] = { city_cairo, 2020, MONTH_nov, 0.19295558958652373, }, +[417] = { city_cairo, 2020, MONTH_dec, 0.47983665135273096, }, +[418] = { city_cairo, 2021, MONTH_jan, 0.8611536498213375, }, +[419] = { city_cairo, 2021, MONTH_feb, 0.7023991832567636, }, +[420] = { city_cairo, 2021, MONTH_mar, 0.6722817764165391, }, +[421] = { city_cairo, 2021, MONTH_apr, 0.6748340990301174, }, +[422] = { city_cairo, 2021, MONTH_may, 0.9030117406840225, }, +[423] = { city_cairo, 2021, MONTH_jun, 0.5620214395099541, }, +[424] = { city_cairo, 2021, MONTH_jul, 0.18887187340479836, }, +[425] = { city_cairo, 2021, MONTH_aug, 0.1066870852475753, }, +[426] = { city_cairo, 2021, MONTH_sep, 0.2894333843797856, }, +[427] = { city_cairo, 2021, MONTH_oct, 0.6625829504849413, }, +[428] = { city_cairo, 2021, MONTH_nov, 0.9290454313425217, }, +[429] = { city_cairo, 2021, MONTH_dec, 0.6712608473711077, }, +[430] = { city_cairo, 2022, MONTH_jan, 0.4476773864216437, }, +[431] = { city_cairo, 2022, MONTH_feb, 0.733027054619704, }, +[432] = { city_cairo, 2022, MONTH_mar, 0.19244512506380806, }, +[433] = { city_cairo, 2022, MONTH_apr, 0.09647779479326186, }, +[434] = { city_cairo, 2022, MONTH_may, 0.05717202654415518, }, +[435] = { city_chengdu, 2020, MONTH_jan, 0, }, +[436] = { city_chengdu, 2020, MONTH_feb, 0.3723932472691162, }, +[437] = { city_chengdu, 2020, MONTH_mar, 0.06752730883813307, }, +[438] = { city_chengdu, 2020, MONTH_apr, 0.1885373811888211, }, +[439] = { city_chengdu, 2020, MONTH_may, 2.837281883955171e-4, }, +[440] = { city_chengdu, 2020, MONTH_jun, 4.2559228259327563e-4, }, +[441] = { city_chengdu, 2020, MONTH_jul, 0.0025535536955596538, }, +[442] = { city_chengdu, 2020, MONTH_aug, 0.00893743793445879, }, +[443] = { city_chengdu, 2020, MONTH_sep, 0.0024116896013618955, }, +[444] = { city_chengdu, 2020, MONTH_oct, 0, }, +[445] = { city_chengdu, 2020, MONTH_nov, 5.674563767910342e-4, }, +[446] = { city_chengdu, 2020, MONTH_dec, 0.005390835579514825, }, +[447] = { city_chengdu, 2021, MONTH_jan, 0.004965243296921549, }, +[448] = { city_chengdu, 2021, MONTH_feb, 0.002837281883955171, }, +[449] = { city_chengdu, 2021, MONTH_mar, 0.0011349127535820683, }, +[450] = { city_chengdu, 2021, MONTH_apr, 8.511845651865513e-4, }, +[451] = { city_chengdu, 2021, MONTH_may, 0.013902681231380337, }, +[452] = { city_chengdu, 2021, MONTH_jun, 0.07589729039580083, }, +[453] = { city_chengdu, 2021, MONTH_jul, 0.02057029365867499, }, +[454] = { city_chengdu, 2021, MONTH_aug, 0.006667612427294652, }, +[455] = { city_chengdu, 2021, MONTH_sep, 0.0012767768477798269, }, +[456] = { city_chengdu, 2021, MONTH_oct, 7.093204709887927e-4, }, +[457] = { city_chengdu, 2021, MONTH_nov, 1.4186409419775854e-4, }, +[458] = { city_chengdu, 2021, MONTH_dec, 2.837281883955171e-4, }, +[459] = { city_chengdu, 2022, MONTH_jan, 1.4186409419775854e-4, }, +[460] = { city_chengdu, 2022, MONTH_feb, 0.06355511420059583, }, +[461] = { city_chengdu, 2022, MONTH_mar, 1, }, +[462] = { city_chengdu, 2022, MONTH_apr, 0.2816002269825507, }, +[463] = { city_chengdu, 2022, MONTH_may, 0.22513831749184282, }, +[464] = { city_dhaka, 2020, MONTH_jan, 0, }, +[465] = { city_dhaka, 2020, MONTH_feb, 0, }, +[466] = { city_dhaka, 2020, MONTH_mar, 8.087997411840828e-4, }, +[467] = { city_dhaka, 2020, MONTH_apr, 0.0263668715626011, }, +[468] = { city_dhaka, 2020, MONTH_may, 0.07796829505014559, }, +[469] = { city_dhaka, 2020, MONTH_jun, 0.19362665803946943, }, +[470] = { city_dhaka, 2020, MONTH_jul, 0.20446457457133613, }, +[471] = { city_dhaka, 2020, MONTH_aug, 0.18925913943707537, }, +[472] = { city_dhaka, 2020, MONTH_sep, 0.15690714978971207, }, +[473] = { city_dhaka, 2020, MONTH_oct, 0.10870268521514073, }, +[474] = { city_dhaka, 2020, MONTH_nov, 0.11662892267874474, }, +[475] = { city_dhaka, 2020, MONTH_dec, 0.14801035263668716, }, +[476] = { city_dhaka, 2021, MONTH_jan, 0.0918796505985118, }, +[477] = { city_dhaka, 2021, MONTH_feb, 0.045454545454545456, }, +[478] = { city_dhaka, 2021, MONTH_mar, 0.10320284697508897, }, +[479] = { city_dhaka, 2021, MONTH_apr, 0.38887091556130704, }, +[480] = { city_dhaka, 2021, MONTH_may, 0.18909737948883856, }, +[481] = { city_dhaka, 2021, MONTH_jun, 0.3047557424781624, }, +[482] = { city_dhaka, 2021, MONTH_jul, 1, }, +[483] = { city_dhaka, 2021, MONTH_aug, 0.8912973147848593, }, +[484] = { city_dhaka, 2021, MONTH_sep, 0.21271433193141379, }, +[485] = { city_dhaka, 2021, MONTH_oct, 0.05791006146878033, }, +[486] = { city_dhaka, 2021, MONTH_nov, 0.018278874150760273, }, +[487] = { city_dhaka, 2021, MONTH_dec, 0.014720155289550308, }, +[488] = { city_dhaka, 2022, MONTH_jan, 0.05208670333225494, }, +[489] = { city_dhaka, 2022, MONTH_feb, 0.10401164671627305, }, +[490] = { city_dhaka, 2022, MONTH_mar, 0.013749595600129408, }, +[491] = { city_dhaka, 2022, MONTH_apr, 8.087997411840828e-4, }, +[492] = { city_dhaka, 2022, MONTH_may, 6.470397929472663e-4, }, +[493] = { city_dubai, 2020, MONTH_jan, 0, }, +[494] = { city_dubai, 2020, MONTH_feb, 0, }, +[495] = { city_dubai, 2020, MONTH_mar, 0.016, }, +[496] = { city_dubai, 2020, MONTH_apr, 0.24533333333333332, }, +[497] = { city_dubai, 2020, MONTH_may, 0.43733333333333335, }, +[498] = { city_dubai, 2020, MONTH_jun, 0.13866666666666666, }, +[499] = { city_dubai, 2020, MONTH_jul, 0.09333333333333334, }, +[500] = { city_dubai, 2020, MONTH_aug, 0.088, }, +[501] = { city_dubai, 2020, MONTH_sep, 0.09066666666666667, }, +[502] = { city_dubai, 2020, MONTH_oct, 0.19733333333333333, }, +[503] = { city_dubai, 2020, MONTH_nov, 0.21333333333333335, }, +[504] = { city_dubai, 2020, MONTH_dec, 0.25333333333333335, }, +[505] = { city_dubai, 2021, MONTH_jan, 0.4613333333333333, }, +[506] = { city_dubai, 2021, MONTH_feb, 1, }, +[507] = { city_dubai, 2021, MONTH_mar, 0.744, }, +[508] = { city_dubai, 2021, MONTH_apr, 0.24533333333333332, }, +[509] = { city_dubai, 2021, MONTH_may, 0.248, }, +[510] = { city_dubai, 2021, MONTH_jun, 0.3466666666666667, }, +[511] = { city_dubai, 2021, MONTH_jul, 0.3626666666666667, }, +[512] = { city_dubai, 2021, MONTH_aug, 0.256, }, +[513] = { city_dubai, 2021, MONTH_sep, 0.14933333333333335, }, +[514] = { city_dubai, 2021, MONTH_oct, 0.10933333333333334, }, +[515] = { city_dubai, 2021, MONTH_nov, 0.02666666666666667, }, +[516] = { city_dubai, 2021, MONTH_dec, 0.042666666666666665, }, +[517] = { city_dubai, 2022, MONTH_jan, 0.208, }, +[518] = { city_dubai, 2022, MONTH_feb, 0.16266666666666665, }, +[519] = { city_dubai, 2022, MONTH_mar, 0.0026666666666666666, }, +[520] = { city_dubai, 2022, MONTH_apr, 0, }, +[521] = { city_dubai, 2022, MONTH_may, 0.008, }, +[522] = { city_guatemala_city, 2020, MONTH_jan, 0, }, +[523] = { city_guatemala_city, 2020, MONTH_feb, 0, }, +[524] = { city_guatemala_city, 2020, MONTH_mar, 6.101281269066504e-4, }, +[525] = { city_guatemala_city, 2020, MONTH_apr, 0.009151921903599756, }, +[526] = { city_guatemala_city, 2020, MONTH_may, 0.04514948139109213, }, +[527] = { city_guatemala_city, 2020, MONTH_jun, 0.3886516168395363, }, +[528] = { city_guatemala_city, 2020, MONTH_jul, 0.6955460646735815, }, +[529] = { city_guatemala_city, 2020, MONTH_aug, 0.5326418547895058, }, +[530] = { city_guatemala_city, 2020, MONTH_sep, 0.3038438071995119, }, +[531] = { city_guatemala_city, 2020, MONTH_oct, 0.2904209884075656, }, +[532] = { city_guatemala_city, 2020, MONTH_nov, 0.27577791336180596, }, +[533] = { city_guatemala_city, 2020, MONTH_dec, 0.3886516168395363, }, +[534] = { city_guatemala_city, 2021, MONTH_jan, 0.49725442342892007, }, +[535] = { city_guatemala_city, 2021, MONTH_feb, 0.4612568639414277, }, +[536] = { city_guatemala_city, 2021, MONTH_mar, 0.27394752898108604, }, +[537] = { city_guatemala_city, 2021, MONTH_apr, 0.41305674191580233, }, +[538] = { city_guatemala_city, 2021, MONTH_may, 0.3886516168395363, }, +[539] = { city_guatemala_city, 2021, MONTH_jun, 0.6162294081757169, }, +[540] = { city_guatemala_city, 2021, MONTH_jul, 0.6717510677242221, }, +[541] = { city_guatemala_city, 2021, MONTH_aug, 0.9993898718730934, }, +[542] = { city_guatemala_city, 2021, MONTH_sep, 1, }, +[543] = { city_guatemala_city, 2021, MONTH_oct, 0.9121415497254424, }, +[544] = { city_guatemala_city, 2021, MONTH_nov, 0.5539963392312386, }, +[545] = { city_guatemala_city, 2021, MONTH_dec, 0.10616229408175717, }, +[546] = { city_guatemala_city, 2022, MONTH_jan, 0.16534472239170225, }, +[547] = { city_guatemala_city, 2022, MONTH_feb, 0.3587553386211104, }, +[548] = { city_guatemala_city, 2022, MONTH_mar, 0.20378279438682123, }, +[549] = { city_guatemala_city, 2022, MONTH_apr, 0.1525320317266626, }, +[550] = { city_guatemala_city, 2022, MONTH_may, 0.348993288590604, }, +[551] = { city_hanoi, 2020, MONTH_jan, 0, }, +[552] = { city_hanoi, 2020, MONTH_feb, 0, }, +[553] = { city_hanoi, 2020, MONTH_mar, 0, }, +[554] = { city_hanoi, 2020, MONTH_apr, 0, }, +[555] = { city_hanoi, 2020, MONTH_may, 0, }, +[556] = { city_hanoi, 2020, MONTH_jun, 0, }, +[557] = { city_hanoi, 2020, MONTH_jul, 0, }, +[558] = { city_hanoi, 2020, MONTH_aug, 0.0032313440371604563, }, +[559] = { city_hanoi, 2020, MONTH_sep, 3.029385034837928e-4, }, +[560] = { city_hanoi, 2020, MONTH_oct, 0, }, +[561] = { city_hanoi, 2020, MONTH_nov, 0, }, +[562] = { city_hanoi, 2020, MONTH_dec, 0, }, +[563] = { city_hanoi, 2021, MONTH_jan, 0, }, +[564] = { city_hanoi, 2021, MONTH_feb, 0, }, +[565] = { city_hanoi, 2021, MONTH_mar, 0, }, +[566] = { city_hanoi, 2021, MONTH_apr, 0, }, +[567] = { city_hanoi, 2021, MONTH_may, 0.0012117540139351712, }, +[568] = { city_hanoi, 2021, MONTH_jun, 0.003736241542966778, }, +[569] = { city_hanoi, 2021, MONTH_jul, 0.10875492275068162, }, +[570] = { city_hanoi, 2021, MONTH_aug, 1, }, +[571] = { city_hanoi, 2021, MONTH_sep, 0.8112693123295971, }, +[572] = { city_hanoi, 2021, MONTH_oct, 0.2960718974048268, }, +[573] = { city_hanoi, 2021, MONTH_nov, 0.30546299101282437, }, +[574] = { city_hanoi, 2021, MONTH_dec, 0.7182671917600727, }, +[575] = { city_hanoi, 2022, MONTH_jan, 0.5553872563869534, }, +[576] = { city_hanoi, 2022, MONTH_feb, 0.2500252448752903, }, +[577] = { city_hanoi, 2022, MONTH_mar, 0.23326264768252045, }, +[578] = { city_hanoi, 2022, MONTH_apr, 0.05897202867817833, }, +[579] = { city_hanoi, 2022, MONTH_may, 0.004039180046450571, }, +[580] = { city_harare, 2020, MONTH_jan, 0, }, +[581] = { city_harare, 2020, MONTH_feb, 0, }, +[582] = { city_harare, 2020, MONTH_mar, 0.003470213996529786, }, +[583] = { city_harare, 2020, MONTH_apr, 0.001156737998843262, }, +[584] = { city_harare, 2020, MONTH_may, 0, }, +[585] = { city_harare, 2020, MONTH_jun, 0.001735106998264893, }, +[586] = { city_harare, 2020, MONTH_jul, 0.026604973973395025, }, +[587] = { city_harare, 2020, MONTH_aug, 0.08155002891844997, }, +[588] = { city_harare, 2020, MONTH_sep, 0.017929438982070563, }, +[589] = { city_harare, 2020, MONTH_oct, 0.008097165991902834, }, +[590] = { city_harare, 2020, MONTH_nov, 0.019086176980913822, }, +[591] = { city_harare, 2020, MONTH_dec, 0.048582995951417005, }, +[592] = { city_harare, 2021, MONTH_jan, 0.4817813765182186, }, +[593] = { city_harare, 2021, MONTH_feb, 0.15615962984384038, }, +[594] = { city_harare, 2021, MONTH_mar, 0.0335454019664546, }, +[595] = { city_harare, 2021, MONTH_apr, 0.026604973973395025, }, +[596] = { city_harare, 2021, MONTH_may, 0.015615962984384037, }, +[597] = { city_harare, 2021, MONTH_jun, 0.09658762290341237, }, +[598] = { city_harare, 2021, MONTH_jul, 1, }, +[599] = { city_harare, 2021, MONTH_aug, 0.5355696934644303, }, +[600] = { city_harare, 2021, MONTH_sep, 0.1156737998843262, }, +[601] = { city_harare, 2021, MONTH_oct, 0.035280508964719494, }, +[602] = { city_harare, 2021, MONTH_nov, 0.0167727009832273, }, +[603] = { city_harare, 2021, MONTH_dec, 0.1683053788316946, }, +[604] = { city_harare, 2022, MONTH_jan, 0.19664545980335454, }, +[605] = { city_harare, 2022, MONTH_feb, 0.03296703296703297, }, +[606] = { city_harare, 2022, MONTH_mar, 0.026604973973395025, }, +[607] = { city_harare, 2022, MONTH_apr, 0.0167727009832273, }, +[608] = { city_harare, 2022, MONTH_may, 0.019664545980335454, }, +[609] = { city_islamabad, 2020, MONTH_jan, 0, }, +[610] = { city_islamabad, 2020, MONTH_feb, 0, }, +[611] = { city_islamabad, 2020, MONTH_mar, 0.007521058965102286, }, +[612] = { city_islamabad, 2020, MONTH_apr, 0.09657039711191336, }, +[613] = { city_islamabad, 2020, MONTH_may, 0.34205776173285196, }, +[614] = { city_islamabad, 2020, MONTH_jun, 0.848676293622142, }, +[615] = { city_islamabad, 2020, MONTH_jul, 0.4954873646209386, }, +[616] = { city_islamabad, 2020, MONTH_aug, 0.10318892900120337, }, +[617] = { city_islamabad, 2020, MONTH_sep, 0.05565583634175692, }, +[618] = { city_islamabad, 2020, MONTH_oct, 0.0950661853188929, }, +[619] = { city_islamabad, 2020, MONTH_nov, 0.35800240673886885, }, +[620] = { city_islamabad, 2020, MONTH_dec, 0.6203369434416366, }, +[621] = { city_islamabad, 2021, MONTH_jan, 0.4741275571600481, }, +[622] = { city_islamabad, 2021, MONTH_feb, 0.36522262334536704, }, +[623] = { city_islamabad, 2021, MONTH_mar, 0.45697954271961494, }, +[624] = { city_islamabad, 2021, MONTH_apr, 1, }, +[625] = { city_islamabad, 2021, MONTH_may, 0.9193742478941035, }, +[626] = { city_islamabad, 2021, MONTH_jun, 0.4566787003610108, }, +[627] = { city_islamabad, 2021, MONTH_jul, 0.3131768953068592, }, +[628] = { city_islamabad, 2021, MONTH_aug, 0.7145006016847172, }, +[629] = { city_islamabad, 2021, MONTH_sep, 0.6077015643802648, }, +[630] = { city_islamabad, 2021, MONTH_oct, 0.2253309265944645, }, +[631] = { city_islamabad, 2021, MONTH_nov, 0.08393501805054152, }, +[632] = { city_islamabad, 2021, MONTH_dec, 0.06107099879663057, }, +[633] = { city_islamabad, 2022, MONTH_jan, 0.0983754512635379, }, +[634] = { city_islamabad, 2022, MONTH_feb, 0.2782791817087846, }, +[635] = { city_islamabad, 2022, MONTH_mar, 0.052948255114320095, }, +[636] = { city_islamabad, 2022, MONTH_apr, 0.006016847172081829, }, +[637] = { city_islamabad, 2022, MONTH_may, 0.0030084235860409147, }, +[638] = { city_jakarta, 2020, MONTH_jan, 0, }, +[639] = { city_jakarta, 2020, MONTH_feb, 0, }, +[640] = { city_jakarta, 2020, MONTH_mar, 0.003495784495167592, }, +[641] = { city_jakarta, 2020, MONTH_apr, 0.016862019329631914, }, +[642] = { city_jakarta, 2020, MONTH_may, 0.02110322845979848, }, +[643] = { city_jakarta, 2020, MONTH_jun, 0.032464528069093154, }, +[644] = { city_jakarta, 2020, MONTH_jul, 0.057963191445609706, }, +[645] = { city_jakarta, 2020, MONTH_aug, 0.05876002467612585, }, +[646] = { city_jakarta, 2020, MONTH_sep, 0.08541538145177874, }, +[647] = { city_jakarta, 2020, MONTH_oct, 0.0804287476866132, }, +[648] = { city_jakarta, 2020, MONTH_nov, 0.07906641990540818, }, +[649] = { city_jakarta, 2020, MONTH_dec, 0.13348241826033314, }, +[650] = { city_jakarta, 2021, MONTH_jan, 0.20203578038247996, }, +[651] = { city_jakarta, 2021, MONTH_feb, 0.15854410857495374, }, +[652] = { city_jakarta, 2021, MONTH_mar, 0.12060456508328192, }, +[653] = { city_jakarta, 2021, MONTH_apr, 0.11985914044828296, }, +[654] = { city_jakarta, 2021, MONTH_may, 0.12998663376516553, }, +[655] = { city_jakarta, 2021, MONTH_jun, 0.20339810816368498, }, +[656] = { city_jakarta, 2021, MONTH_jul, 0.9157927205428747, }, +[657] = { city_jakarta, 2021, MONTH_aug, 1, }, +[658] = { city_jakarta, 2021, MONTH_sep, 0.22917951881554596, }, +[659] = { city_jakarta, 2021, MONTH_oct, 0.037682500514085955, }, +[660] = { city_jakarta, 2021, MONTH_nov, 0.010924326547398725, }, +[661] = { city_jakarta, 2021, MONTH_dec, 0.006785934608266502, }, +[662] = { city_jakarta, 2022, MONTH_jan, 0.0058091712934402635, }, +[663] = { city_jakarta, 2022, MONTH_feb, 0.10320275550071972, }, +[664] = { city_jakarta, 2022, MONTH_mar, 0.17360682706148467, }, +[665] = { city_jakarta, 2022, MONTH_apr, 0.030022619782027554, }, +[666] = { city_jakarta, 2022, MONTH_may, 0.008585235451367468, }, +[667] = { city_kyiv, 2020, MONTH_jan, 0, }, +[668] = { city_kyiv, 2020, MONTH_feb, 0, }, +[669] = { city_kyiv, 2020, MONTH_mar, 7.124849282034418e-4, }, +[670] = { city_kyiv, 2020, MONTH_apr, 0.013592020168804122, }, +[671] = { city_kyiv, 2020, MONTH_may, 0.024498520223610654, }, +[672] = { city_kyiv, 2020, MONTH_jun, 0.02471774635536556, }, +[673] = { city_kyiv, 2020, MONTH_jul, 0.029266688589279843, }, +[674] = { city_kyiv, 2020, MONTH_aug, 0.04735284445905952, }, +[675] = { city_kyiv, 2020, MONTH_sep, 0.08615586977967774, }, +[676] = { city_kyiv, 2020, MONTH_oct, 0.16809163652307355, }, +[677] = { city_kyiv, 2020, MONTH_nov, 0.2812123205086046, }, +[678] = { city_kyiv, 2020, MONTH_dec, 0.3401293434177354, }, +[679] = { city_kyiv, 2021, MONTH_jan, 0.22876246848624357, }, +[680] = { city_kyiv, 2021, MONTH_feb, 0.17949139537432862, }, +[681] = { city_kyiv, 2021, MONTH_mar, 0.37504110489970405, }, +[682] = { city_kyiv, 2021, MONTH_apr, 0.6171215608900581, }, +[683] = { city_kyiv, 2021, MONTH_may, 0.35355694398772336, }, +[684] = { city_kyiv, 2021, MONTH_jun, 0.09887098542146223, }, +[685] = { city_kyiv, 2021, MONTH_jul, 0.03315795242792941, }, +[686] = { city_kyiv, 2021, MONTH_aug, 0.046256713800284996, }, +[687] = { city_kyiv, 2021, MONTH_sep, 0.13619423435273484, }, +[688] = { city_kyiv, 2021, MONTH_oct, 0.6278088348131097, }, +[689] = { city_kyiv, 2021, MONTH_nov, 1, }, +[690] = { city_kyiv, 2021, MONTH_dec, 0.5439000328839197, }, +[691] = { city_kyiv, 2022, MONTH_jan, 0.23588731776827798, }, +[692] = { city_kyiv, 2022, MONTH_feb, 0.3148635317329826, }, +[693] = { city_kyiv, 2022, MONTH_mar, 0.11010632467390113, }, +[694] = { city_kyiv, 2022, MONTH_apr, 0.024662939822426833, }, +[695] = { city_kyiv, 2022, MONTH_may, 0.00887865833607366, }, +[696] = { city_la_paz, 2020, MONTH_jan, 0, }, +[697] = { city_la_paz, 2020, MONTH_feb, 0, }, +[698] = { city_la_paz, 2020, MONTH_mar, 0.001688048615800135, }, +[699] = { city_la_paz, 2020, MONTH_apr, 0.01688048615800135, }, +[700] = { city_la_paz, 2020, MONTH_may, 0.08271438217420661, }, +[701] = { city_la_paz, 2020, MONTH_jun, 0.24105334233625927, }, +[702] = { city_la_paz, 2020, MONTH_jul, 0.6056718433490884, }, +[703] = { city_la_paz, 2020, MONTH_aug, 0.7191087103308575, }, +[704] = { city_la_paz, 2020, MONTH_sep, 1, }, +[705] = { city_la_paz, 2020, MONTH_oct, 0.27177582714382176, }, +[706] = { city_la_paz, 2020, MONTH_nov, 0.08237677245104659, }, +[707] = { city_la_paz, 2020, MONTH_dec, 0.06279540850776502, }, +[708] = { city_la_paz, 2021, MONTH_jan, 0.3683322079675895, }, +[709] = { city_la_paz, 2021, MONTH_feb, 0.4669142471303174, }, +[710] = { city_la_paz, 2021, MONTH_mar, 0.20324105334233625, }, +[711] = { city_la_paz, 2021, MONTH_apr, 0.23936529372045914, }, +[712] = { city_la_paz, 2021, MONTH_may, 0.5114787305874409, }, +[713] = { city_la_paz, 2021, MONTH_jun, 0.7413909520594193, }, +[714] = { city_la_paz, 2021, MONTH_jul, 0.38926401080351114, }, +[715] = { city_la_paz, 2021, MONTH_aug, 0.21168129642133693, }, +[716] = { city_la_paz, 2021, MONTH_sep, 0.10297096556380823, }, +[717] = { city_la_paz, 2021, MONTH_oct, 0.07022282241728561, }, +[718] = { city_la_paz, 2021, MONTH_nov, 0.0800135043889264, }, +[719] = { city_la_paz, 2021, MONTH_dec, 0.1650911546252532, }, +[720] = { city_la_paz, 2022, MONTH_jan, 0.4189736664415935, }, +[721] = { city_la_paz, 2022, MONTH_feb, 0.1826468602295746, }, +[722] = { city_la_paz, 2022, MONTH_mar, 0.15597569209993248, }, +[723] = { city_la_paz, 2022, MONTH_apr, 0.0054017555705604325, }, +[724] = { city_la_paz, 2022, MONTH_may, 0.012491559756921, }, +[725] = { city_lima, 2020, MONTH_jan, 0, }, +[726] = { city_lima, 2020, MONTH_feb, 0, }, +[727] = { city_lima, 2020, MONTH_mar, 0.0040497911160371726, }, +[728] = { city_lima, 2020, MONTH_apr, 0.17098644385710632, }, +[729] = { city_lima, 2020, MONTH_may, 0.6555119788558275, }, +[730] = { city_lima, 2020, MONTH_jun, 0.7456304885326968, }, +[731] = { city_lima, 2020, MONTH_jul, 0.7682240600221673, }, +[732] = { city_lima, 2020, MONTH_aug, 0.7700571233694262, }, +[733] = { city_lima, 2020, MONTH_sep, 0.3826839457754284, }, +[734] = { city_lima, 2020, MONTH_oct, 0.1922585045613437, }, +[735] = { city_lima, 2020, MONTH_nov, 0.1284849518288004, }, +[736] = { city_lima, 2020, MONTH_dec, 0.14945860687185608, }, +[737] = { city_lima, 2021, MONTH_jan, 0.41746951999317927, }, +[738] = { city_lima, 2021, MONTH_feb, 0.784423224486316, }, +[739] = { city_lima, 2021, MONTH_mar, 0.8913803393298662, }, +[740] = { city_lima, 2021, MONTH_apr, 1, }, +[741] = { city_lima, 2021, MONTH_may, 0.7605934009719498, }, +[742] = { city_lima, 2021, MONTH_jun, 0.3705772018074857, }, +[743] = { city_lima, 2021, MONTH_jul, 0.1726916190638588, }, +[744] = { city_lima, 2021, MONTH_aug, 0.08504561343678063, }, +[745] = { city_lima, 2021, MONTH_sep, 0.04774490578906983, }, +[746] = { city_lima, 2021, MONTH_oct, 0.03700230198652912, }, +[747] = { city_lima, 2021, MONTH_nov, 0.03883536533378805, }, +[748] = { city_lima, 2021, MONTH_dec, 0.06292096512916702, }, +[749] = { city_lima, 2022, MONTH_jan, 0.11778497740642851, }, +[750] = { city_lima, 2022, MONTH_feb, 0.21570466365419047, }, +[751] = { city_lima, 2022, MONTH_mar, 0.07553926165913548, }, +[752] = { city_lima, 2022, MONTH_apr, 0.026387586324494842, }, +[753] = { city_lima, 2022, MONTH_may, 0.01598601756330463, }, +[754] = { city_madrid, 2020, MONTH_jan, 0, }, +[755] = { city_madrid, 2020, MONTH_feb, 5.852744937375629e-5, }, +[756] = { city_madrid, 2020, MONTH_mar, 0.5019314058293339, }, +[757] = { city_madrid, 2020, MONTH_apr, 1, }, +[758] = { city_madrid, 2020, MONTH_may, 0.2004565141051153, }, +[759] = { city_madrid, 2020, MONTH_jun, 0.038745171485426666, }, +[760] = { city_madrid, 2020, MONTH_jul, 0.010827578134144915, }, +[761] = { city_madrid, 2020, MONTH_aug, 0.062214678684302936, }, +[762] = { city_madrid, 2020, MONTH_sep, 0.18307386164110967, }, +[763] = { city_madrid, 2020, MONTH_oct, 0.3029380779585626, }, +[764] = { city_madrid, 2020, MONTH_nov, 0.5457684654102775, }, +[765] = { city_madrid, 2020, MONTH_dec, 0.3399859534121503, }, +[766] = { city_madrid, 2021, MONTH_jan, 0.6453821842444106, }, +[767] = { city_madrid, 2021, MONTH_feb, 0.5533770338288657, }, +[768] = { city_madrid, 2021, MONTH_mar, 0.18658550860353507, }, +[769] = { city_madrid, 2021, MONTH_apr, 0.13666159428772093, }, +[770] = { city_madrid, 2021, MONTH_may, 0.08673767997190683, }, +[771] = { city_madrid, 2021, MONTH_jun, 0.03775020484607281, }, +[772] = { city_madrid, 2021, MONTH_jul, 0.059229778766241366, }, +[773] = { city_madrid, 2021, MONTH_aug, 0.1822544773498771, }, +[774] = { city_madrid, 2021, MONTH_sep, 0.093585391548636307, }, +[775] = { city_madrid, 2021, MONTH_oct, 0.03494088727613251, }, +[776] = { city_madrid, 2021, MONTH_nov, 0.03616996371298139, }, +[777] = { city_madrid, 2021, MONTH_dec, 0.1144796909750673, }, +[778] = { city_madrid, 2022, MONTH_jan, 0.32476881657497364, }, +[779] = { city_madrid, 2022, MONTH_feb, 0.27689336298724104, }, +[780] = { city_madrid, 2022, MONTH_mar, 0.10125248741659838, }, +[781] = { city_madrid, 2022, MONTH_apr, 0.08351867025635022, }, +[782] = { city_madrid, 2022, MONTH_may, 0.10722228725272152, }, +[783] = { city_managua, 2020, MONTH_jan, 0, }, +[784] = { city_managua, 2020, MONTH_feb, 0, }, +[785] = { city_managua, 2020, MONTH_mar, 0.023809523809523808, }, +[786] = { city_managua, 2020, MONTH_apr, 0.047619047619047616, }, +[787] = { city_managua, 2020, MONTH_may, 0.7619047619047619, }, +[788] = { city_managua, 2020, MONTH_jun, 0.9285714285714286, }, +[789] = { city_managua, 2020, MONTH_jul, 1, }, +[790] = { city_managua, 2020, MONTH_aug, 0.5, }, +[791] = { city_managua, 2020, MONTH_sep, 0.3333333333333333, }, +[792] = { city_managua, 2020, MONTH_oct, 0.11904761904761904, }, +[793] = { city_managua, 2020, MONTH_nov, 0.09523809523809523, }, +[794] = { city_managua, 2020, MONTH_dec, 0.11904761904761904, }, +[795] = { city_managua, 2021, MONTH_jan, 0.09523809523809523, }, +[796] = { city_managua, 2021, MONTH_feb, 0.09523809523809523, }, +[797] = { city_managua, 2021, MONTH_mar, 0.11904761904761904, }, +[798] = { city_managua, 2021, MONTH_apr, 0.09523809523809523, }, +[799] = { city_managua, 2021, MONTH_may, 0.09523809523809523, }, +[800] = { city_managua, 2021, MONTH_jun, 0.11904761904761904, }, +[801] = { city_managua, 2021, MONTH_jul, 0.09523809523809523, }, +[802] = { city_managua, 2021, MONTH_aug, 0.09523809523809523, }, +[803] = { city_managua, 2021, MONTH_sep, 0.11904761904761904, }, +[804] = { city_managua, 2021, MONTH_oct, 0.09523809523809523, }, +[805] = { city_managua, 2021, MONTH_nov, 0.09523809523809523, }, +[806] = { city_managua, 2021, MONTH_dec, 0.11904761904761904, }, +[807] = { city_managua, 2022, MONTH_jan, 0.07142857142857142, }, +[808] = { city_managua, 2022, MONTH_feb, 0.09523809523809523, }, +[809] = { city_managua, 2022, MONTH_mar, 0.14285714285714285, }, +[810] = { city_managua, 2022, MONTH_apr, 0.09523809523809523, }, +[811] = { city_managua, 2022, MONTH_may, 0.09523809523809523, }, +[812] = { city_mexico_city, 2020, MONTH_jan, 0, }, +[813] = { city_mexico_city, 2020, MONTH_feb, 0, }, +[814] = { city_mexico_city, 2020, MONTH_mar, 0.0013482679941920763, }, +[815] = { city_mexico_city, 2020, MONTH_apr, 0.1015608794855839, }, +[816] = { city_mexico_city, 2020, MONTH_may, 0.40523231694669154, }, +[817] = { city_mexico_city, 2020, MONTH_jun, 0.5275876374196224, }, +[818] = { city_mexico_city, 2020, MONTH_jul, 0.6168066791122174, }, +[819] = { city_mexico_city, 2020, MONTH_aug, 0.4998703588467123, }, +[820] = { city_mexico_city, 2020, MONTH_sep, 0.34160443891308856, }, +[821] = { city_mexico_city, 2020, MONTH_oct, 0.32690313213026345, }, +[822] = { city_mexico_city, 2020, MONTH_nov, 0.4108328147687202, }, +[823] = { city_mexico_city, 2020, MONTH_dec, 0.5958566687409251, }, +[824] = { city_mexico_city, 2021, MONTH_jan, 1, }, +[825] = { city_mexico_city, 2021, MONTH_feb, 0.6428386226923875, }, +[826] = { city_mexico_city, 2021, MONTH_mar, 0.3536869943995022, }, +[827] = { city_mexico_city, 2021, MONTH_apr, 0.20423667288944203, }, +[828] = { city_mexico_city, 2021, MONTH_may, 0.10806886538062642, }, +[829] = { city_mexico_city, 2021, MONTH_jun, 0.080196017423771, }, +[830] = { city_mexico_city, 2021, MONTH_jul, 0.20589607965152457, }, +[831] = { city_mexico_city, 2021, MONTH_aug, 0.5757104335200166, }, +[832] = { city_mexico_city, 2021, MONTH_sep, 0.4466397013067828, }, +[833] = { city_mexico_city, 2021, MONTH_oct, 0.22204936735117195, }, +[834] = { city_mexico_city, 2021, MONTH_nov, 0.11226923874714789, }, +[835] = { city_mexico_city, 2021, MONTH_dec, 0.09852727649865173, }, +[836] = { city_mexico_city, 2022, MONTH_jan, 0.2316946691557768, }, +[837] = { city_mexico_city, 2022, MONTH_feb, 0.27434660858743, }, +[838] = { city_mexico_city, 2022, MONTH_mar, 0.04877100186683261, }, +[839] = { city_mexico_city, 2022, MONTH_apr, 0.008893383115536196, }, +[840] = { city_mexico_city, 2022, MONTH_may, 0.004252229827836548, }, +[841] = { city_moscow, 2020, MONTH_jan, 0, }, +[842] = { city_moscow, 2020, MONTH_feb, 0, }, +[843] = { city_moscow, 2020, MONTH_mar, 4.6378393125085253e-4, }, +[844] = { city_moscow, 2020, MONTH_apr, 0.028809166552994134, }, +[845] = { city_moscow, 2020, MONTH_may, 0.09875869594871095, }, +[846] = { city_moscow, 2020, MONTH_jun, 0.1262310735233938, }, +[847] = { city_moscow, 2020, MONTH_jul, 0.12666757604692402, }, +[848] = { city_moscow, 2020, MONTH_aug, 0.08765516300641113, }, +[849] = { city_moscow, 2020, MONTH_sep, 0.09673987177738372, }, +[850] = { city_moscow, 2020, MONTH_oct, 0.1982812713135998, }, +[851] = { city_moscow, 2020, MONTH_nov, 0.32478515891419996, }, +[852] = { city_moscow, 2020, MONTH_dec, 0.4671668258082117, }, +[853] = { city_moscow, 2021, MONTH_jan, 0.4409493929886782, }, +[854] = { city_moscow, 2021, MONTH_feb, 0.3530214159050607, }, +[855] = { city_moscow, 2021, MONTH_mar, 0.3472377574682854, }, +[856] = { city_moscow, 2021, MONTH_apr, 0.3076797162733597, }, +[857] = { city_moscow, 2021, MONTH_may, 0.3102714500068203, }, +[858] = { city_moscow, 2021, MONTH_jun, 0.37410994407311415, }, +[859] = { city_moscow, 2021, MONTH_jul, 0.6369935888691857, }, +[860] = { city_moscow, 2021, MONTH_aug, 0.6727867957986632, }, +[861] = { city_moscow, 2021, MONTH_sep, 0.655599508934661, }, +[862] = { city_moscow, 2021, MONTH_oct, 0.8534442777247306, }, +[863] = { city_moscow, 2021, MONTH_nov, 1, }, +[864] = { city_moscow, 2021, MONTH_dec, 0.9184831537307325, }, +[865] = { city_moscow, 2022, MONTH_jan, 0.6135315782294366, }, +[866] = { city_moscow, 2022, MONTH_feb, 0.5541126722138863, }, +[867] = { city_moscow, 2022, MONTH_mar, 0.46547537852953214, }, +[868] = { city_moscow, 2022, MONTH_apr, 0.1953894420952121, }, +[869] = { city_moscow, 2022, MONTH_may, 0.0882007911608239, }, +[870] = { city_mumbai, 2020, MONTH_jan, 0, }, +[871] = { city_mumbai, 2020, MONTH_feb, 0, }, +[872] = { city_mumbai, 2020, MONTH_mar, 2.6496646518175043e-4, }, +[873] = { city_mumbai, 2020, MONTH_apr, 0.008627970522480748, }, +[874] = { city_mumbai, 2020, MONTH_may, 0.03386602633104248, }, +[875] = { city_mumbai, 2020, MONTH_jun, 0.09711848969114846, }, +[876] = { city_mumbai, 2020, MONTH_jul, 0.15611492920427258, }, +[877] = { city_mumbai, 2020, MONTH_aug, 0.23782396290469487, }, +[878] = { city_mumbai, 2020, MONTH_sep, 0.2734785128757142, }, +[879] = { city_mumbai, 2020, MONTH_oct, 0.1999171979796307, }, +[880] = { city_mumbai, 2020, MONTH_nov, 0.1283265711683365, }, +[881] = { city_mumbai, 2020, MONTH_dec, 0.09604206342634761, }, +[882] = { city_mumbai, 2021, MONTH_jan, 0.04583919847644283, }, +[883] = { city_mumbai, 2021, MONTH_feb, 0.02299412105655378, }, +[884] = { city_mumbai, 2021, MONTH_mar, 0.04485385443404819, }, +[885] = { city_mumbai, 2021, MONTH_apr, 0.37974662581766994, }, +[886] = { city_mumbai, 2021, MONTH_may, 1, }, +[887] = { city_mumbai, 2021, MONTH_jun, 0.5742651320692225, }, +[888] = { city_mumbai, 2021, MONTH_jul, 0.2099528028483895, }, +[889] = { city_mumbai, 2021, MONTH_aug, 0.1221329800447131, }, +[890] = { city_mumbai, 2021, MONTH_sep, 0.07867847975490602, }, +[891] = { city_mumbai, 2021, MONTH_oct, 0.0838287654218763, }, +[892] = { city_mumbai, 2021, MONTH_nov, 0.0893765007866192, }, +[893] = { city_mumbai, 2021, MONTH_dec, 0.10019044464684938, }, +[894] = { city_mumbai, 2022, MONTH_jan, 0.11567442245590792, }, +[895] = { city_mumbai, 2022, MONTH_feb, 0.15560983688001986, }, +[896] = { city_mumbai, 2022, MONTH_mar, 0.0603295520410698, }, +[897] = { city_mumbai, 2022, MONTH_apr, 0.02214126024675002, }, +[898] = { city_mumbai, 2022, MONTH_may, 0.006847727084540863, }, +[899] = { city_nairobi, 2020, MONTH_jan, 0, }, +[900] = { city_nairobi, 2020, MONTH_feb, 0, }, +[901] = { city_nairobi, 2020, MONTH_mar, 0.005037783375314861, }, +[902] = { city_nairobi, 2020, MONTH_apr, 0.012594458438287154, }, +[903] = { city_nairobi, 2020, MONTH_may, 0.061712846347607056, }, +[904] = { city_nairobi, 2020, MONTH_jun, 0.10201511335012595, }, +[905] = { city_nairobi, 2020, MONTH_jul, 0.22795969773299748, }, +[906] = { city_nairobi, 2020, MONTH_aug, 0.3136020151133501, }, +[907] = { city_nairobi, 2020, MONTH_sep, 0.16750629722921914, }, +[908] = { city_nairobi, 2020, MONTH_oct, 0.345088161209068, }, +[909] = { city_nairobi, 2020, MONTH_nov, 0.593198992443325, }, +[910] = { city_nairobi, 2020, MONTH_dec, 0.2707808564231738, }, +[911] = { city_nairobi, 2021, MONTH_jan, 0.11083123425692695, }, +[912] = { city_nairobi, 2021, MONTH_feb, 0.12468513853904283, }, +[913] = { city_nairobi, 2021, MONTH_mar, 0.3690176322418136, }, +[914] = { city_nairobi, 2021, MONTH_apr, 0.7052896725440806, }, +[915] = { city_nairobi, 2021, MONTH_may, 0.5667506297229219, }, +[916] = { city_nairobi, 2021, MONTH_jun, 0.5843828715365239, }, +[917] = { city_nairobi, 2021, MONTH_jul, 0.38413098236775817, }, +[918] = { city_nairobi, 2021, MONTH_aug, 1, }, +[919] = { city_nairobi, 2021, MONTH_sep, 0.5025188916876574, }, +[920] = { city_nairobi, 2021, MONTH_oct, 0.1977329974811083, }, +[921] = { city_nairobi, 2021, MONTH_nov, 0.07304785894206549, }, +[922] = { city_nairobi, 2021, MONTH_dec, 0.05289672544080604, }, +[923] = { city_nairobi, 2022, MONTH_jan, 0.25692695214105793, }, +[924] = { city_nairobi, 2022, MONTH_feb, 0.0743073047858942, }, +[925] = { city_nairobi, 2022, MONTH_mar, 0.011335012594458438, }, +[926] = { city_nairobi, 2022, MONTH_apr, 0.0012594458438287153, }, +[927] = { city_nairobi, 2022, MONTH_may, 0.0025188916876574307, }, +[928] = { city_new_delhi, 2020, MONTH_jan, 0, }, +[929] = { city_new_delhi, 2020, MONTH_feb, 0, }, +[930] = { city_new_delhi, 2020, MONTH_mar, 2.6496646518175043e-4, }, +[931] = { city_new_delhi, 2020, MONTH_apr, 0.008627970522480748, }, +[932] = { city_new_delhi, 2020, MONTH_may, 0.03386602633104248, }, +[933] = { city_new_delhi, 2020, MONTH_jun, 0.09711848969114846, }, +[934] = { city_new_delhi, 2020, MONTH_jul, 0.15611492920427258, }, +[935] = { city_new_delhi, 2020, MONTH_aug, 0.23782396290469487, }, +[936] = { city_new_delhi, 2020, MONTH_sep, 0.2734785128757142, }, +[937] = { city_new_delhi, 2020, MONTH_oct, 0.1999171979796307, }, +[938] = { city_new_delhi, 2020, MONTH_nov, 0.1283265711683365, }, +[939] = { city_new_delhi, 2020, MONTH_dec, 0.09604206342634761, }, +[940] = { city_new_delhi, 2021, MONTH_jan, 0.04583919847644283, }, +[941] = { city_new_delhi, 2021, MONTH_feb, 0.02299412105655378, }, +[942] = { city_new_delhi, 2021, MONTH_mar, 0.04485385443404819, }, +[943] = { city_new_delhi, 2021, MONTH_apr, 0.37974662581766994, }, +[944] = { city_new_delhi, 2021, MONTH_may, 1, }, +[945] = { city_new_delhi, 2021, MONTH_jun, 0.5742651320692225, }, +[946] = { city_new_delhi, 2021, MONTH_jul, 0.2099528028483895, }, +[947] = { city_new_delhi, 2021, MONTH_aug, 0.1221329800447131, }, +[948] = { city_new_delhi, 2021, MONTH_sep, 0.07867847975490602, }, +[949] = { city_new_delhi, 2021, MONTH_oct, 0.0838287654218763, }, +[950] = { city_new_delhi, 2021, MONTH_nov, 0.0893765007866192, }, +[951] = { city_new_delhi, 2021, MONTH_dec, 0.10019044464684938, }, +[952] = { city_new_delhi, 2022, MONTH_jan, 0.11567442245590792, }, +[953] = { city_new_delhi, 2022, MONTH_feb, 0.15560983688001986, }, +[954] = { city_new_delhi, 2022, MONTH_mar, 0.0603295520410698, }, +[955] = { city_new_delhi, 2022, MONTH_apr, 0.02214126024675002, }, +[956] = { city_new_delhi, 2022, MONTH_may, 0.006847727084540863, }, +[957] = { city_ottawa, 2020, MONTH_jan, 0, }, +[958] = { city_ottawa, 2020, MONTH_feb, 0, }, +[959] = { city_ottawa, 2020, MONTH_mar, 0.009571558796718322, }, +[960] = { city_ottawa, 2020, MONTH_apr, 0.6406107566089334, }, +[961] = { city_ottawa, 2020, MONTH_may, 0.9357338195077484, }, +[962] = { city_ottawa, 2020, MONTH_jun, 0.3484503190519599, }, +[963] = { city_ottawa, 2020, MONTH_jul, 0.08956244302643573, }, +[964] = { city_ottawa, 2020, MONTH_aug, 0.04421148587055606, }, +[965] = { city_ottawa, 2020, MONTH_sep, 0.037374658158614404, }, +[966] = { city_ottawa, 2020, MONTH_oct, 0.17889699179580676, }, +[967] = { city_ottawa, 2020, MONTH_nov, 0.43094804010938925, }, +[968] = { city_ottawa, 2020, MONTH_dec, 0.7654968094804011, }, +[969] = { city_ottawa, 2021, MONTH_jan, 1, }, +[970] = { city_ottawa, 2021, MONTH_feb, 0.4731084776663628, }, +[971] = { city_ottawa, 2021, MONTH_mar, 0.21923427529626252, }, +[972] = { city_ottawa, 2021, MONTH_apr, 0.270510483135825, }, +[973] = { city_ottawa, 2021, MONTH_may, 0.3076572470373747, }, +[974] = { city_ottawa, 2021, MONTH_jun, 0.17069279854147676, }, +[975] = { city_ottawa, 2021, MONTH_jul, 0.07338195077484047, }, +[976] = { city_ottawa, 2021, MONTH_aug, 0.0736098450319052, }, +[977] = { city_ottawa, 2021, MONTH_sep, 0.1927985414767548, }, +[978] = { city_ottawa, 2021, MONTH_oct, 0.2716499544211486, }, +[979] = { city_ottawa, 2021, MONTH_nov, 0.15633546034639928, }, +[980] = { city_ottawa, 2021, MONTH_dec, 0.13742023701002734, }, +[981] = { city_ottawa, 2022, MONTH_jan, 0.7474931631722881, }, +[982] = { city_ottawa, 2022, MONTH_feb, 0.6488149498632635, }, +[983] = { city_ottawa, 2022, MONTH_mar, 0.33887876025524155, }, +[984] = { city_ottawa, 2022, MONTH_apr, 0.3669097538742024, }, +[985] = { city_ottawa, 2022, MONTH_may, 0.4453053783044667, }, +[986] = { city_paris, 2020, MONTH_jan, 0, }, +[987] = { city_paris, 2020, MONTH_feb, 9.50705899130104e-5, }, +[988] = { city_paris, 2020, MONTH_mar, 0.1433189142938632, }, +[989] = { city_paris, 2020, MONTH_apr, 1, }, +[990] = { city_paris, 2020, MONTH_may, 0.22165708038218376, }, +[991] = { city_paris, 2020, MONTH_jun, 0.04815325379093977, }, +[992] = { city_paris, 2020, MONTH_jul, 0.019299329752341114, }, +[993] = { city_paris, 2020, MONTH_aug, 0.015734182630603222, }, +[994] = { city_paris, 2020, MONTH_sep, 0.05813566573180587, }, +[995] = { city_paris, 2020, MONTH_oct, 0.21737890383609831, }, +[996] = { city_paris, 2020, MONTH_nov, 0.7463992014070447, }, +[997] = { city_paris, 2020, MONTH_dec, 0.5722774159813662, }, +[998] = { city_paris, 2021, MONTH_jan, 0.5448495507914627, }, +[999] = { city_paris, 2021, MONTH_feb, 0.49341636164852404, }, +[1000] = { city_paris, 2021, MONTH_mar, 0.42235109568854873, }, +[1001] = { city_paris, 2021, MONTH_apr, 0.4173598897181157, }, +[1002] = { city_paris, 2021, MONTH_may, 0.23991063364548176, }, +[1003] = { city_paris, 2021, MONTH_jun, 0.07367970718258307, }, +[1004] = { city_paris, 2021, MONTH_jul, 0.03085040642677188, }, +[1005] = { city_paris, 2021, MONTH_aug, 0.08803536625944763, }, +[1006] = { city_paris, 2021, MONTH_sep, 0.08480296620240528, }, +[1007] = { city_paris, 2021, MONTH_oct, 0.03988211246850787, }, +[1008] = { city_paris, 2021, MONTH_nov, 0.06241384227789133, }, +[1009] = { city_paris, 2021, MONTH_dec, 0.20996339782288348, }, +[1010] = { city_paris, 2022, MONTH_jan, 0.32376289394875696, }, +[1011] = { city_paris, 2022, MONTH_feb, 0.3461995531682274, }, +[1012] = { city_paris, 2022, MONTH_mar, 0.18514997385558776, }, +[1013] = { city_paris, 2022, MONTH_apr, 0.1745496030802871, }, +[1014] = { city_paris, 2022, MONTH_may, 0.1104244901839616, }, +[1015] = { city_quito, 2020, MONTH_jan, 0, }, +[1016] = { city_quito, 2020, MONTH_feb, 0, }, +[1017] = { city_quito, 2020, MONTH_mar, 0.005972526378658172, }, +[1018] = { city_quito, 2020, MONTH_apr, 0.08192315349392792, }, +[1019] = { city_quito, 2020, MONTH_may, 0.24517220784391797, }, +[1020] = { city_quito, 2020, MONTH_jun, 0.11507067489548078, }, +[1021] = { city_quito, 2020, MONTH_jul, 0.11497113278916982, }, +[1022] = { city_quito, 2020, MONTH_aug, 0.08938881146725065, }, +[1023] = { city_quito, 2020, MONTH_sep, 0.4735217997212821, }, +[1024] = { city_quito, 2020, MONTH_oct, 0.1313955803304798, }, +[1025] = { city_quito, 2020, MONTH_nov, 0.0787378060919769, }, +[1026] = { city_quito, 2020, MONTH_dec, 0.059725263786581724, }, +[1027] = { city_quito, 2021, MONTH_jan, 0.08242086402548278, }, +[1028] = { city_quito, 2021, MONTH_feb, 0.08580529564005575, }, +[1029] = { city_quito, 2021, MONTH_mar, 0.1062114274338045, }, +[1030] = { city_quito, 2021, MONTH_apr, 0.17638861238303802, }, +[1031] = { city_quito, 2021, MONTH_may, 0.1983874178777623, }, +[1032] = { city_quito, 2021, MONTH_jun, 0.09954210631096955, }, +[1033] = { city_quito, 2021, MONTH_jul, 1, }, +[1034] = { city_quito, 2021, MONTH_aug, 0.0650009954210631, }, +[1035] = { city_quito, 2021, MONTH_sep, 0.05156281106908222, }, +[1036] = { city_quito, 2021, MONTH_oct, 0.02150109496316942, }, +[1037] = { city_quito, 2021, MONTH_nov, 0.025482779215608202, }, +[1038] = { city_quito, 2021, MONTH_dec, 0.04330081624527175, }, +[1039] = { city_quito, 2022, MONTH_jan, 0.0840135377264583, }, +[1040] = { city_quito, 2022, MONTH_feb, 0.07276527971331874, }, +[1041] = { city_quito, 2022, MONTH_mar, 0.017618952817041608, }, +[1042] = { city_quito, 2022, MONTH_apr, 0.016623531753931914, }, +[1043] = { city_quito, 2022, MONTH_may, 0.00437985267768266, }, +[1044] = { city_rabat, 2020, MONTH_jan, 0, }, +[1045] = { city_rabat, 2020, MONTH_feb, 0, }, +[1046] = { city_rabat, 2020, MONTH_mar, 0.011752136752136752, }, +[1047] = { city_rabat, 2020, MONTH_apr, 0.04807692307692308, }, +[1048] = { city_rabat, 2020, MONTH_may, 0.01282051282051282, }, +[1049] = { city_rabat, 2020, MONTH_jun, 0.007478632478632479, }, +[1050] = { city_rabat, 2020, MONTH_jul, 0.04309116809116809, }, +[1051] = { city_rabat, 2020, MONTH_aug, 0.2724358974358974, }, +[1052] = { city_rabat, 2020, MONTH_sep, 0.37072649572649574, }, +[1053] = { city_rabat, 2020, MONTH_oct, 0.5245726495726496, }, +[1054] = { city_rabat, 2020, MONTH_nov, 0.7706552706552706, }, +[1055] = { city_rabat, 2020, MONTH_dec, 0.5576923076923077, }, +[1056] = { city_rabat, 2021, MONTH_jan, 0.32193732193732194, }, +[1057] = { city_rabat, 2021, MONTH_feb, 0.1267806267806268, }, +[1058] = { city_rabat, 2021, MONTH_mar, 0.07051282051282051, }, +[1059] = { city_rabat, 2021, MONTH_apr, 0.07371794871794872, }, +[1060] = { city_rabat, 2021, MONTH_may, 0.0438034188034188, }, +[1061] = { city_rabat, 2021, MONTH_jun, 0.053062678062678066, }, +[1062] = { city_rabat, 2021, MONTH_jul, 0.15669515669515668, }, +[1063] = { city_rabat, 2021, MONTH_aug, 1, }, +[1064] = { city_rabat, 2021, MONTH_sep, 0.6082621082621082, }, +[1065] = { city_rabat, 2021, MONTH_oct, 0.1492165242165242, }, +[1066] = { city_rabat, 2021, MONTH_nov, 0.038461538461538464, }, +[1067] = { city_rabat, 2021, MONTH_dec, 0.024572649572649572, }, +[1068] = { city_rabat, 2022, MONTH_jan, 0.18447293447293447, }, +[1069] = { city_rabat, 2022, MONTH_feb, 0.21937321937321938, }, +[1070] = { city_rabat, 2022, MONTH_mar, 0.0292022792022792, }, +[1071] = { city_rabat, 2022, MONTH_apr, 0.003205128205128205, }, +[1072] = { city_rabat, 2022, MONTH_may, 0.002492877492877493, }, +[1073] = { city_seoul, 2020, MONTH_jan, 0, }, +[1074] = { city_seoul, 2020, MONTH_feb, 0.0019579050416054823, }, +[1075] = { city_seoul, 2020, MONTH_mar, 0.017865883504650026, }, +[1076] = { city_seoul, 2020, MONTH_apr, 0.010401370533529124, }, +[1077] = { city_seoul, 2020, MONTH_may, 0.0028144884973078806, }, +[1078] = { city_seoul, 2020, MONTH_jun, 0.0014684287812041115, }, +[1079] = { city_seoul, 2020, MONTH_jul, 0.00232501223690651, }, +[1080] = { city_seoul, 2020, MONTH_aug, 0.0028144884973078806, }, +[1081] = { city_seoul, 2020, MONTH_sep, 0.010890846793930495, }, +[1082] = { city_seoul, 2020, MONTH_oct, 0.006240822320117474, }, +[1083] = { city_seoul, 2020, MONTH_nov, 0.0075868820362212435, }, +[1084] = { city_seoul, 2020, MONTH_dec, 0.045766030347528144, }, +[1085] = { city_seoul, 2021, MONTH_jan, 0.06363191385217817, }, +[1086] = { city_seoul, 2021, MONTH_feb, 0.022393538913362702, }, +[1087] = { city_seoul, 2021, MONTH_mar, 0.01566324033284386, }, +[1088] = { city_seoul, 2021, MONTH_apr, 0.011869799314733235, }, +[1089] = { city_seoul, 2021, MONTH_may, 0.016030347528144886, }, +[1090] = { city_seoul, 2021, MONTH_jun, 0.007219774840920215, }, +[1091] = { city_seoul, 2021, MONTH_jul, 0.009422418012726383, }, +[1092] = { city_seoul, 2021, MONTH_aug, 0.0232501223690651, }, +[1093] = { city_seoul, 2021, MONTH_sep, 0.023984336759667158, }, +[1094] = { city_seoul, 2021, MONTH_oct, 0.04503181595692609, }, +[1095] = { city_seoul, 2021, MONTH_nov, 0.09483602545276554, }, +[1096] = { city_seoul, 2021, MONTH_dec, 0.23727361722956436, }, +[1097] = { city_seoul, 2022, MONTH_jan, 0.14586392559960842, }, +[1098] = { city_seoul, 2022, MONTH_feb, 0.15944689182574645, }, +[1099] = { city_seoul, 2022, MONTH_mar, 1, }, +[1100] = { city_seoul, 2022, MONTH_apr, 0.8032305433186491, }, +[1101] = { city_seoul, 2022, MONTH_may, 0.16911404796867352, }, +[1102] = { city_tehran, 2020, MONTH_jan, 0, }, +[1103] = { city_tehran, 2020, MONTH_feb, 0.00255845778544654, }, +[1104] = { city_tehran, 2020, MONTH_mar, 0.16986969714999703, }, +[1105] = { city_tehran, 2020, MONTH_apr, 0.18200749687630155, }, +[1106] = { city_tehran, 2020, MONTH_may, 0.10572975545903493, }, +[1107] = { city_tehran, 2020, MONTH_jun, 0.1746891176295591, }, +[1108] = { city_tehran, 2020, MONTH_jul, 0.3509847087523056, }, +[1109] = { city_tehran, 2020, MONTH_aug, 0.2911286963765098, }, +[1110] = { city_tehran, 2020, MONTH_sep, 0.2691735586362825, }, +[1111] = { city_tehran, 2020, MONTH_oct, 0.5052656631165586, }, +[1112] = { city_tehran, 2020, MONTH_nov, 0.7971083477122628, }, +[1113] = { city_tehran, 2020, MONTH_dec, 0.42958291188195397, }, +[1114] = { city_tehran, 2021, MONTH_jan, 0.1662402570357589, }, +[1115] = { city_tehran, 2021, MONTH_feb, 0.12441244719462129, }, +[1116] = { city_tehran, 2021, MONTH_mar, 0.1540429582911882, }, +[1117] = { city_tehran, 2021, MONTH_apr, 0.5225203784137562, }, +[1118] = { city_tehran, 2021, MONTH_may, 0.5109775688701137, }, +[1119] = { city_tehran, 2021, MONTH_jun, 0.24918188849883977, }, +[1120] = { city_tehran, 2021, MONTH_jul, 0.3699053965609567, }, +[1121] = { city_tehran, 2021, MONTH_aug, 1, }, +[1122] = { city_tehran, 2021, MONTH_sep, 0.7740227286249777, }, +[1123] = { city_tehran, 2021, MONTH_oct, 0.3549711429761409, }, +[1124] = { city_tehran, 2021, MONTH_nov, 0.213303980484322, }, +[1125] = { city_tehran, 2021, MONTH_dec, 0.11072767299339561, }, +[1126] = { city_tehran, 2022, MONTH_jan, 0.050693163562801215, }, +[1127] = { city_tehran, 2022, MONTH_feb, 0.25031236984589755, }, +[1128] = { city_tehran, 2022, MONTH_mar, 0.20985303742488248, }, +[1129] = { city_tehran, 2022, MONTH_apr, 0.05438210269530553, }, +[1130] = { city_tehran, 2022, MONTH_may, 0.014160766347355268, }, +[1131] = { city_tokyo, 2020, MONTH_jan, 0, }, +[1132] = { city_tokyo, 2020, MONTH_feb, 0.0010548523206751054, }, +[1133] = { city_tokyo, 2020, MONTH_mar, 0.010759493670886076, }, +[1134] = { city_tokyo, 2020, MONTH_apr, 0.07573839662447257, }, +[1135] = { city_tokyo, 2020, MONTH_may, 0.10042194092827005, }, +[1136] = { city_tokyo, 2020, MONTH_jun, 0.01751054852320675, }, +[1137] = { city_tokyo, 2020, MONTH_jul, 0.006751054852320675, }, +[1138] = { city_tokyo, 2020, MONTH_aug, 0.05759493670886076, }, +[1139] = { city_tokyo, 2020, MONTH_sep, 0.060126582278481014, }, +[1140] = { city_tokyo, 2020, MONTH_oct, 0.04029535864978903, }, +[1141] = { city_tokyo, 2020, MONTH_nov, 0.07679324894514768, }, +[1142] = { city_tokyo, 2020, MONTH_dec, 0.2732067510548523, }, +[1143] = { city_tokyo, 2021, MONTH_jan, 0.47257383966244726, }, +[1144] = { city_tokyo, 2021, MONTH_feb, 0.46540084388185654, }, +[1145] = { city_tokyo, 2021, MONTH_mar, 0.26434599156118144, }, +[1146] = { city_tokyo, 2021, MONTH_apr, 0.22805907172995782, }, +[1147] = { city_tokyo, 2021, MONTH_may, 0.5850210970464135, }, +[1148] = { city_tokyo, 2021, MONTH_jun, 0.3740506329113924, }, +[1149] = { city_tokyo, 2021, MONTH_jul, 0.09367088607594937, }, +[1150] = { city_tokyo, 2021, MONTH_aug, 0.17088607594936708, }, +[1151] = { city_tokyo, 2021, MONTH_sep, 0.33987341772151897, }, +[1152] = { city_tokyo, 2021, MONTH_oct, 0.13839662447257384, }, +[1153] = { city_tokyo, 2021, MONTH_nov, 0.02067510548523207, }, +[1154] = { city_tokyo, 2021, MONTH_dec, 0.007172995780590718, }, +[1155] = { city_tokyo, 2022, MONTH_jan, 0.07827004219409282, }, +[1156] = { city_tokyo, 2022, MONTH_feb, 0.950632911392405, }, +[1157] = { city_tokyo, 2022, MONTH_mar, 1, }, +[1158] = { city_tokyo, 2022, MONTH_apr, 0.32447257383966244, }, +[1159] = { city_tokyo, 2022, MONTH_may, 0.21814345991561182, }, +[1160] = { city_tunis, 2020, MONTH_jan, 0, }, +[1161] = { city_tunis, 2020, MONTH_feb, 0, }, +[1162] = { city_tunis, 2020, MONTH_mar, 0.001858352260995251, }, +[1163] = { city_tunis, 2020, MONTH_apr, 0.006400991121205864, }, +[1164] = { city_tunis, 2020, MONTH_may, 0.001651868676440223, }, +[1165] = { city_tunis, 2020, MONTH_jun, 4.1296716911005574e-4, }, +[1166] = { city_tunis, 2020, MONTH_jul, 0, }, +[1167] = { city_tunis, 2020, MONTH_aug, 0.005575056782985753, }, +[1168] = { city_tunis, 2020, MONTH_sep, 0.03881891389634524, }, +[1169] = { city_tunis, 2020, MONTH_oct, 0.21722073095188932, }, +[1170] = { city_tunis, 2020, MONTH_nov, 0.39273177782366303, }, +[1171] = { city_tunis, 2020, MONTH_dec, 0.2892835019615941, }, +[1172] = { city_tunis, 2021, MONTH_jan, 0.4253561841833574, }, +[1173] = { city_tunis, 2021, MONTH_feb, 0.26718975841420606, }, +[1174] = { city_tunis, 2021, MONTH_mar, 0.1680776378277927, }, +[1175] = { city_tunis, 2021, MONTH_apr, 0.38261408218046666, }, +[1176] = { city_tunis, 2021, MONTH_may, 0.40925046458806524, }, +[1177] = { city_tunis, 2021, MONTH_jun, 0.4583935577121619, }, +[1178] = { city_tunis, 2021, MONTH_jul, 1, }, +[1179] = { city_tunis, 2021, MONTH_aug, 0.7774106958496799, }, +[1180] = { city_tunis, 2021, MONTH_sep, 0.2925872393144745, }, +[1181] = { city_tunis, 2021, MONTH_oct, 0.07639892628536031, }, +[1182] = { city_tunis, 2021, MONTH_nov, 0.02622341523848854, }, +[1183] = { city_tunis, 2021, MONTH_dec, 0.041090233326450544, }, +[1184] = { city_tunis, 2022, MONTH_jan, 0.1459838942804047, }, +[1185] = { city_tunis, 2022, MONTH_feb, 0.31013834400165186, }, +[1186] = { city_tunis, 2022, MONTH_mar, 0.11356597150526533, }, +[1187] = { city_tunis, 2022, MONTH_apr, 0.04687177369399133, }, +[1188] = { city_tunis, 2022, MONTH_may, 0.016931653933512286, }, +[1189] = { city_ulaanbaatar, 2020, MONTH_jan, 0, }, +[1190] = { city_ulaanbaatar, 2020, MONTH_feb, 0, }, +[1191] = { city_ulaanbaatar, 2020, MONTH_mar, 0, }, +[1192] = { city_ulaanbaatar, 2020, MONTH_apr, 0, }, +[1193] = { city_ulaanbaatar, 2020, MONTH_may, 0, }, +[1194] = { city_ulaanbaatar, 2020, MONTH_jun, 0, }, +[1195] = { city_ulaanbaatar, 2020, MONTH_jul, 0, }, +[1196] = { city_ulaanbaatar, 2020, MONTH_aug, 0, }, +[1197] = { city_ulaanbaatar, 2020, MONTH_sep, 0, }, +[1198] = { city_ulaanbaatar, 2020, MONTH_oct, 0, }, +[1199] = { city_ulaanbaatar, 2020, MONTH_nov, 0, }, +[1200] = { city_ulaanbaatar, 2020, MONTH_dec, 0.002188183807439825, }, +[1201] = { city_ulaanbaatar, 2021, MONTH_jan, 0.002188183807439825, }, +[1202] = { city_ulaanbaatar, 2021, MONTH_feb, 0, }, +[1203] = { city_ulaanbaatar, 2021, MONTH_mar, 0.01312910284463895, }, +[1204] = { city_ulaanbaatar, 2021, MONTH_apr, 0.24070021881838075, }, +[1205] = { city_ulaanbaatar, 2021, MONTH_may, 0.29540481400437635, }, +[1206] = { city_ulaanbaatar, 2021, MONTH_jun, 0.5317286652078774, }, +[1207] = { city_ulaanbaatar, 2021, MONTH_jul, 0.474835886214442, }, +[1208] = { city_ulaanbaatar, 2021, MONTH_aug, 0.26914660831509846, }, +[1209] = { city_ulaanbaatar, 2021, MONTH_sep, 0.8052516411378556, }, +[1210] = { city_ulaanbaatar, 2021, MONTH_oct, 1, }, +[1211] = { city_ulaanbaatar, 2021, MONTH_nov, 0.5886214442013129, }, +[1212] = { city_ulaanbaatar, 2021, MONTH_dec, 0.12253829321663019, }, +[1213] = { city_ulaanbaatar, 2022, MONTH_jan, 0.10940919037199125, }, +[1214] = { city_ulaanbaatar, 2022, MONTH_feb, 0.13129102844638948, }, +[1215] = { city_ulaanbaatar, 2022, MONTH_mar, 0.0262582056892779, }, +[1216] = { city_ulaanbaatar, 2022, MONTH_apr, 0.00437636761487965, }, +[1217] = { city_ulaanbaatar, 2022, MONTH_may, 0.010940919037199124, }, +[1218] = { city_yerevan, 2020, MONTH_jan, 0, }, +[1219] = { city_yerevan, 2020, MONTH_feb, 0, }, +[1220] = { city_yerevan, 2020, MONTH_mar, 0.002421307506053269, }, +[1221] = { city_yerevan, 2020, MONTH_apr, 0.023405972558514933, }, +[1222] = { city_yerevan, 2020, MONTH_may, 0.07990314769975787, }, +[1223] = { city_yerevan, 2020, MONTH_jun, 0.25181598062953997, }, +[1224] = { city_yerevan, 2020, MONTH_jul, 0.23809523809523808, }, +[1225] = { city_yerevan, 2020, MONTH_aug, 0.11380145278450363, }, +[1226] = { city_yerevan, 2020, MONTH_sep, 0.0645682001614205, }, +[1227] = { city_yerevan, 2020, MONTH_oct, 0.3083131557707829, }, +[1228] = { city_yerevan, 2020, MONTH_nov, 0.6642453591606134, }, +[1229] = { city_yerevan, 2020, MONTH_dec, 0.5318805488297014, }, +[1230] = { city_yerevan, 2021, MONTH_jan, 0.20742534301856336, }, +[1231] = { city_yerevan, 2021, MONTH_feb, 0.0903954802259887, }, +[1232] = { city_yerevan, 2021, MONTH_mar, 0.26069410815173527, }, +[1233] = { city_yerevan, 2021, MONTH_apr, 0.47861178369652946, }, +[1234] = { city_yerevan, 2021, MONTH_may, 0.26634382566585957, }, +[1235] = { city_yerevan, 2021, MONTH_jun, 0.06133979015334948, }, +[1236] = { city_yerevan, 2021, MONTH_jul, 0.08071025020177562, }, +[1237] = { city_yerevan, 2021, MONTH_aug, 0.18563357546408393, }, +[1238] = { city_yerevan, 2021, MONTH_sep, 0.3833736884584342, }, +[1239] = { city_yerevan, 2021, MONTH_oct, 0.814366424535916, }, +[1240] = { city_yerevan, 2021, MONTH_nov, 1, }, +[1241] = { city_yerevan, 2021, MONTH_dec, 0.3268765133171913, }, +[1242] = { city_yerevan, 2022, MONTH_jan, 0.06537530266343826, }, +[1243] = { city_yerevan, 2022, MONTH_feb, 0.32929782082324455, }, +[1244] = { city_yerevan, 2022, MONTH_mar, 0.12267958030669895, }, +[1245] = { city_yerevan, 2022, MONTH_apr, 0.007263922518159807, }, +[1246] = { city_yerevan, 2022, MONTH_may, 0.002421307506053269, }, +[1247] = { city_chicago, 2020, MONTH_jan, 0, }, +[1248] = { city_chicago, 2020, MONTH_feb, 0, }, +[1249] = { city_chicago, 2020, MONTH_mar, 0.021555197421434327, }, +[1250] = { city_chicago, 2020, MONTH_apr, 0.4540692989524577, }, +[1251] = { city_chicago, 2020, MONTH_may, 0.6174456083803385, }, +[1252] = { city_chicago, 2020, MONTH_jun, 0.3444802578565673, }, +[1253] = { city_chicago, 2020, MONTH_jul, 0.11422240128928283, }, +[1254] = { city_chicago, 2020, MONTH_aug, 0.11180499597099114, }, +[1255] = { city_chicago, 2020, MONTH_sep, 0.13638195004029008, }, +[1256] = { city_chicago, 2020, MONTH_oct, 0.22058823529411764, }, +[1257] = { city_chicago, 2020, MONTH_nov, 0.6013295729250604, }, +[1258] = { city_chicago, 2020, MONTH_dec, 1, }, +[1259] = { city_chicago, 2021, MONTH_jan, 0.6573327961321515, }, +[1260] = { city_chicago, 2021, MONTH_feb, 0.3007655116841257, }, +[1261] = { city_chicago, 2021, MONTH_mar, 0.17002417405318293, }, +[1262] = { city_chicago, 2021, MONTH_apr, 0.1434327155519742, }, +[1263] = { city_chicago, 2021, MONTH_may, 0.18775181305398872, }, +[1264] = { city_chicago, 2021, MONTH_jun, 0.09085414987912974, }, +[1265] = { city_chicago, 2021, MONTH_jul, 0.048751007252215955, }, +[1266] = { city_chicago, 2021, MONTH_aug, 0.11764705882352941, }, +[1267] = { city_chicago, 2021, MONTH_sep, 0.2346897663174859, }, +[1268] = { city_chicago, 2021, MONTH_oct, 0.19238517324738114, }, +[1269] = { city_chicago, 2021, MONTH_nov, 0.1522965350523771, }, +[1270] = { city_chicago, 2021, MONTH_dec, 0.33058017727639, }, +[1271] = { city_chicago, 2022, MONTH_jan, 0.7427477840451249, }, +[1272] = { city_chicago, 2022, MONTH_feb, 0.4443996776792909, }, +[1273] = { city_chicago, 2022, MONTH_mar, 0.1524979854955681, }, +[1274] = { city_chicago, 2022, MONTH_apr, 0.04653505237711523, }, +[1275] = { city_chicago, 2022, MONTH_may, 0.021555197421434327, }, +[1276] = { city_denver, 2020, MONTH_jan, 0, }, +[1277] = { city_denver, 2020, MONTH_feb, 0, }, +[1278] = { city_denver, 2020, MONTH_mar, 0.03793293018141836, }, +[1279] = { city_denver, 2020, MONTH_apr, 0.3881253435953821, }, +[1280] = { city_denver, 2020, MONTH_may, 0.3683342495876855, }, +[1281] = { city_denver, 2020, MONTH_jun, 0.13468938977460143, }, +[1282] = { city_denver, 2020, MONTH_jul, 0.08301264431006047, }, +[1283] = { city_denver, 2020, MONTH_aug, 0.06102253985706432, }, +[1284] = { city_denver, 2020, MONTH_sep, 0.059923034634414514, }, +[1285] = { city_denver, 2020, MONTH_oct, 0.13633864760857614, }, +[1286] = { city_denver, 2020, MONTH_nov, 0.41286421110500277, }, +[1287] = { city_denver, 2020, MONTH_dec, 1, }, +[1288] = { city_denver, 2021, MONTH_jan, 0.45739417262231996, }, +[1289] = { city_denver, 2021, MONTH_feb, 0.18361737218251786, }, +[1290] = { city_denver, 2021, MONTH_mar, 0.07146783947223749, }, +[1291] = { city_denver, 2021, MONTH_apr, 0.14128642111050027, }, +[1292] = { city_denver, 2021, MONTH_may, 0.159978009895547, }, +[1293] = { city_denver, 2021, MONTH_jun, 0.12314458493677845, }, +[1294] = { city_denver, 2021, MONTH_jul, 0.08246289169873557, }, +[1295] = { city_denver, 2021, MONTH_aug, 0.12204507971412865, }, +[1296] = { city_denver, 2021, MONTH_sep, 0.22649807586586038, }, +[1297] = { city_denver, 2021, MONTH_oct, 0.35459043430456294, }, +[1298] = { city_denver, 2021, MONTH_nov, 0.5536008796041781, }, +[1299] = { city_denver, 2021, MONTH_dec, 0.6030786146234195, }, +[1300] = { city_denver, 2022, MONTH_jan, 0.4722374931280924, }, +[1301] = { city_denver, 2022, MONTH_feb, 0.3672347443650357, }, +[1302] = { city_denver, 2022, MONTH_mar, 0.09840571742715779, }, +[1303] = { city_denver, 2022, MONTH_apr, 0.09895547003848268, }, +[1304] = { city_denver, 2022, MONTH_may, 0.18526663001649257, }, +[1305] = { city_san_francisco, 2020, MONTH_jan, 0, }, +[1306] = { city_san_francisco, 2020, MONTH_feb, 0, }, +[1307] = { city_san_francisco, 2020, MONTH_mar, 0.012296999264853305, }, +[1308] = { city_san_francisco, 2020, MONTH_apr, 0.12517543273407739, }, +[1309] = { city_san_francisco, 2020, MONTH_may, 0.146026866270133, }, +[1310] = { city_san_francisco, 2020, MONTH_jun, 0.12303682416627681, }, +[1311] = { city_san_francisco, 2020, MONTH_jul, 0.20978413419768763, }, +[1312] = { city_san_francisco, 2020, MONTH_aug, 0.2538261043908307, }, +[1313] = { city_san_francisco, 2020, MONTH_sep, 0.19234110806656418, }, +[1314] = { city_san_francisco, 2020, MONTH_oct, 0.11782396578226291, }, +[1315] = { city_san_francisco, 2020, MONTH_nov, 0.1034551894673528, }, +[1316] = { city_san_francisco, 2020, MONTH_dec, 0.45151373387689636, }, +[1317] = { city_san_francisco, 2021, MONTH_jan, 1, }, +[1318] = { city_san_francisco, 2021, MONTH_feb, 0.7541936777384214, }, +[1319] = { city_san_francisco, 2021, MONTH_mar, 0.47096170554033284, }, +[1320] = { city_san_francisco, 2021, MONTH_apr, 0.16681146828844484, }, +[1321] = { city_san_francisco, 2021, MONTH_may, 0.09977945599144557, }, +[1322] = { city_san_francisco, 2021, MONTH_jun, 0.027601416828176167, }, +[1323] = { city_san_francisco, 2021, MONTH_jul, 0.05045779589654481, }, +[1324] = { city_san_francisco, 2021, MONTH_aug, 0.09663837465748847, }, +[1325] = { city_san_francisco, 2021, MONTH_sep, 0.22822963309496758, }, +[1326] = { city_san_francisco, 2021, MONTH_oct, 0.19153912985363897, }, +[1327] = { city_san_francisco, 2021, MONTH_nov, 0.16881641382075788, }, +[1328] = { city_san_francisco, 2021, MONTH_dec, 0.13626946467954287, }, +[1329] = { city_san_francisco, 2022, MONTH_jan, 0.23778654013232642, }, +[1330] = { city_san_francisco, 2022, MONTH_feb, 0.3540065494887389, }, +[1331] = { city_san_francisco, 2022, MONTH_mar, 0.23083606228697454, }, +[1332] = { city_san_francisco, 2022, MONTH_apr, 0.09363095635901891, }, +[1333] = { city_san_francisco, 2022, MONTH_may, 0.0360890195816347, }, +[1334] = { city_washington, 2020, MONTH_jan, 0, }, +[1335] = { city_washington, 2020, MONTH_feb, 0, }, +[1336] = { city_washington, 2020, MONTH_mar, 0.0371900826446281, }, +[1337] = { city_washington, 2020, MONTH_apr, 0.8884297520661157, }, +[1338] = { city_washington, 2020, MONTH_may, 1, }, +[1339] = { city_washington, 2020, MONTH_jun, 0.3512396694214876, }, +[1340] = { city_washington, 2020, MONTH_jul, 0.14049586776859505, }, +[1341] = { city_washington, 2020, MONTH_aug, 0.09090909090909091, }, +[1342] = { city_washington, 2020, MONTH_sep, 0.08264462809917356, }, +[1343] = { city_washington, 2020, MONTH_oct, 0.07851239669421488, }, +[1344] = { city_washington, 2020, MONTH_nov, 0.14049586776859505, }, +[1345] = { city_washington, 2020, MONTH_dec, 0.4380165289256198, }, +[1346] = { city_washington, 2021, MONTH_jan, 0.5247933884297521, }, +[1347] = { city_washington, 2021, MONTH_feb, 0.4297520661157025, }, +[1348] = { city_washington, 2021, MONTH_mar, 0.19421487603305784, }, +[1349] = { city_washington, 2021, MONTH_apr, 0.16942148760330578, }, +[1350] = { city_washington, 2021, MONTH_may, 0.1115702479338843, }, +[1351] = { city_washington, 2021, MONTH_jun, 0.0371900826446281, }, +[1352] = { city_washington, 2021, MONTH_jul, 0.03305785123966942, }, +[1353] = { city_washington, 2021, MONTH_aug, 0.045454545454545456, }, +[1354] = { city_washington, 2021, MONTH_sep, 0.05785123966942149, }, +[1355] = { city_washington, 2021, MONTH_oct, 0.06611570247933884, }, +[1356] = { city_washington, 2021, MONTH_nov, 0.024793388429752067, }, +[1357] = { city_washington, 2021, MONTH_dec, 0.06198347107438017, }, +[1358] = { city_washington, 2022, MONTH_jan, 0.32231404958677684, }, +[1359] = { city_washington, 2022, MONTH_feb, 0.11983471074380166, }, +[1360] = { city_washington, 2022, MONTH_mar, 0.05371900826446281, }, +[1361] = { city_washington, 2022, MONTH_apr, 0.0371900826446281, }, +[1362] = { city_washington, 2022, MONTH_may, 0, }, +}; +global u32 question_4_len = sizeof(question_4_data) / sizeof(question_4_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_5.h b/run_tree/data/incenter_data/c/question_5.h new file mode 100644 index 0000000..995972e --- /dev/null +++ b/run_tree/data/incenter_data/c/question_5.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_5_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.601593625498008, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.6060606060606061, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.5254237288135594, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.6507936507936508, }, +[4] = { city_paris, 2022, MONTH_jan, 0.569806492883416, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.6120930232558139, }, +[6] = { city_denver, 2022, MONTH_jan, 0.6120930232558139, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.7948003714020427, }, +[8] = { city_harare, 2022, MONTH_jan, 0.5714285714285714, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.6158536585365854, }, +[10] = { city_washington, 2022, MONTH_jan, 0.6120930232558139, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.5555555555555556, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.5142857142857142, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.6158536585365854, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.6169354838709677, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.5819672131147541, }, +[16] = { city_lima, 2022, MONTH_jan, 0.425, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.6363636363636364, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.8333333333333334, }, +[19] = { city_managua, 2022, MONTH_jan, 0.6774193548387096, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.464638783269962, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.6190476190476191, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.5254237288135594, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.5176882661996497, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.5714285714285714, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.5993009868421053, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.5, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.5, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.6011644832605532, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.6774193548387096, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.6111111111111112, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.5714285714285714, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.5142857142857142, }, +[33] = { city_quito, 2022, MONTH_jan, 0.4827586206896552, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.45, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.5254237288135594, }, +[36] = { city_accra, 2022, MONTH_jan, 0.5714285714285714, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.6352941176470588, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.7062314540059347, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.7062314540059347, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.7107438016528925, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.7948003714020427, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.6120930232558139, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.59375, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.5, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.6507936507936508, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.4838709677419355, }, +}; +global u32 question_5_len = sizeof(question_5_data) / sizeof(question_5_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_6.h b/run_tree/data/incenter_data/c/question_6.h new file mode 100644 index 0000000..ac29d6e --- /dev/null +++ b/run_tree/data/incenter_data/c/question_6.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_6_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.2964426877470356, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.3141891891891892, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.4745762711864407, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.4603174603174603, }, +[4] = { city_paris, 2022, MONTH_jan, 0.3169346452283817, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.3714551371455137, }, +[6] = { city_denver, 2022, MONTH_jan, 0.3714551371455137, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.5386046511627907, }, +[8] = { city_harare, 2022, MONTH_jan, 0.21428571428571427, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.4878048780487805, }, +[10] = { city_washington, 2022, MONTH_jan, 0.3714551371455137, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.5, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.4647887323943662, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.4878048780487805, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.3089430894308943, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.3442622950819672, }, +[16] = { city_lima, 2022, MONTH_jan, 0.225, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.3719298245614035, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.4117647058823529, }, +[19] = { city_managua, 2022, MONTH_jan, 0.375, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.2883156297420334, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.2926829268292683, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.4745762711864407, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.3334112422578006, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.21428571428571427, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.8559967084961942, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.3137254901960784, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.3137254901960784, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.36627906976744184, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.375, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.3335826477187734, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.21428571428571427, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.4647887323943662, }, +[33] = { city_quito, 2022, MONTH_jan, 0.27586206896551724, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.3111111111111111, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.4745762711864407, }, +[36] = { city_accra, 2022, MONTH_jan, 0.21428571428571427, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.3568075117370892, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.5705794947994056, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.5705794947994056, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.3159340659340659, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.5386046511627907, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.3714551371455137, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.3939393939393939, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.3137254901960784, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.4603174603174603, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.37209302325581395, }, +}; +global u32 question_6_len = sizeof(question_6_data) / sizeof(question_6_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_7.h b/run_tree/data/incenter_data/c/question_7.h new file mode 100644 index 0000000..8458133 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_7.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_7_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.9065934065934066, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.8987854251012146, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.8, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.8666666666666667, }, +[4] = { city_paris, 2022, MONTH_jan, 0.8818422046055115, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.9293150684931507, }, +[6] = { city_denver, 2022, MONTH_jan, 0.9293150684931507, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.9027283511269276, }, +[8] = { city_harare, 2022, MONTH_jan, 1 , }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.9253731343283582, }, +[10] = { city_washington, 2022, MONTH_jan, 0.9293150684931507, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.7692307692307693, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.9056603773584906, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.9253731343283582, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.9090909090909091, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.7934782608695652, }, +[16] = { city_lima, 2022, MONTH_jan, 0.9705882352941176, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.8928571428571429, }, +[18] = { city_abuja, 2022, MONTH_jan, 1 , }, +[19] = { city_managua, 2022, MONTH_jan, 0.9047619047619048, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.924908424908425, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.9714285714285714, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.8, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.9220470098185064, }, +[24] = { city_nairobi, 2022, MONTH_jan, 1, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.5873192436040044, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.925, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.925, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.8819938962360122, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.9047619047619048, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.9141824751580849, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 1, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.9056603773584906, }, +[33] = { city_quito, 2022, MONTH_jan, 0.9565217391304348, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.8592592592592593, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.8, }, +[36] = { city_accra, 2022, MONTH_jan, 1, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.8787878787878788, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.9236641221374046, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.9236641221374046, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.91701244813278, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.9027283511269276, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.9293150684931507, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.9090909090909091, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.925, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.8666666666666667, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.8149882903981265, }, +}; +global u32 question_7_len = sizeof(question_7_data) / sizeof(question_7_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_8.h b/run_tree/data/incenter_data/c/question_8.h new file mode 100644 index 0000000..c956c8e --- /dev/null +++ b/run_tree/data/incenter_data/c/question_8.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_8_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.9398907103825137, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.9061224489795918, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.8717948717948718, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 1, }, +[4] = { city_paris, 2022, MONTH_jan, 0.898988944533686, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.9071938495332235, }, +[6] = { city_denver, 2022, MONTH_jan, 0.9071938495332235, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.9175627240143369, }, +[8] = { city_harare, 2022, MONTH_jan, 1, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.8962962962962963, }, +[10] = { city_washington, 2022, MONTH_jan, 0.9071938495332235, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.9230769230769231, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.8846153846153846, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.8962962962962963, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.9179487179487179, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.8571428571428571, }, +[16] = { city_lima, 2022, MONTH_jan, 0.9411764705882353, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.8290155440414507, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.8571428571428571, }, +[19] = { city_managua, 2022, MONTH_jan, 0.9523809523809523, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.8682027649769585, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.9411764705882353, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.8717948717948718, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.8594192107222636, }, +[24] = { city_nairobi, 2022, MONTH_jan, 1, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.5911220165068035, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.975, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.975, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.9158215010141988, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.9523809523809523, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.9038112522686026, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 1, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.8846153846153846, }, +[33] = { city_quito, 2022, MONTH_jan, 1, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.8712121212121212, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.8717948717948718, }, +[36] = { city_accra, 2022, MONTH_jan, 1, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.8953168044077136, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.9504761904761905, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.9504761904761905, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.9159663865546218, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.9175627240143369, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.9071938495332235, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.9090909090909091, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.975, }, +[45] = { city_mumbai, 2022, MONTH_jan, 1, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.9479905437352246, }, +}; +global u32 question_8_len = sizeof(question_8_data) / sizeof(question_8_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/c/question_9.h b/run_tree/data/incenter_data/c/question_9.h new file mode 100644 index 0000000..1333084 --- /dev/null +++ b/run_tree/data/incenter_data/c/question_9.h @@ -0,0 +1,50 @@ +static Incenter_Data_Row question_9_data[] = { +[0] = { city_bucharest, 2022, MONTH_jan, 0.9276054097056484, }, +[1] = { city_brisbane, 2022, MONTH_jan, 0.9355913381454747, }, +[2] = { city_chengdu, 2022, MONTH_jan, 0.874793524942187, }, +[3] = { city_new_delhi, 2022, MONTH_jan, 0.947289156626506, }, +[4] = { city_paris, 2022, MONTH_jan, 0.9259986902423052, }, +[5] = { city_san_francisco, 2022, MONTH_jan, 0.9016393442622951, }, +[6] = { city_denver, 2022, MONTH_jan, 0.9326923076923077, }, +[7] = { city_ankara, 2022, MONTH_jan, 0.9283050145047659, }, +[8] = { city_harare, 2022, MONTH_jan, 0.966996699669967, }, +[9] = { city_hanoi, 2022, MONTH_jan, 0.9691666666666666, }, +[10] = { city_washington, 2022, MONTH_jan, 0.9068219633943427, }, +[11] = { city_bangkok, 2022, MONTH_jan, 0.9223040857334226, }, +[12] = { city_tunis, 2022, MONTH_jan, 0.9776490066225165, }, +[13] = { city_seoul, 2022, MONTH_jan, 0.9156626506024096, }, +[14] = { city_belgrade, 2022, MONTH_jan, 0.946360153256705, }, +[15] = { city_moscow, 2022, MONTH_jan, 0.8717379233759023, }, +[16] = { city_lima, 2022, MONTH_jan, 0.8871428571428571, }, +[17] = { city_islamabad, 2022, MONTH_jan, 0.947289156626506, }, +[18] = { city_abuja, 2022, MONTH_jan, 0.9919093851132686, }, +[19] = { city_managua, 2022, MONTH_jan, 0.84, }, +[20] = { city_amsterdam, 2022, MONTH_jan, 0.8231389284020862, }, +[21] = { city_rabat, 2022, MONTH_jan, 0.8991666666666667, }, +[22] = { city_ulaanbaatar, 2022, MONTH_jan, 0.8192918192918193, }, +[23] = { city_mexico_city, 2022, MONTH_jan, 0.9753015508328546, }, +[24] = { city_nairobi, 2022, MONTH_jan, 0.9818181818181818, }, +[25] = { city_tokyo, 2022, MONTH_jan, 0.9380134428678119, }, +[26] = { city_baghdad, 2022, MONTH_jan, 0.9808013355592654, }, +[27] = { city_tehran, 2022, MONTH_jan, 0.9425901201602136, }, +[28] = { city_jakarta, 2022, MONTH_jan, 0.98875, }, +[29] = { city_guatemala_city, 2022, MONTH_jan, 0.9072416598860863, }, +[30] = { city_berlin, 2022, MONTH_jan, 0.9259986902423052, }, +[31] = { city_addis_ababa, 2022, MONTH_jan, 0.9536585365853658, }, +[32] = { city_cairo, 2022, MONTH_jan, 0.9975, }, +[33] = { city_quito, 2022, MONTH_jan, 0.9073455759599333, }, +[34] = { city_bogota, 2022, MONTH_jan, 0.8782894736842105, }, +[35] = { city_beijing, 2022, MONTH_jan, 0.874793524942187, }, +[36] = { city_accra, 2022, MONTH_jan, 0.9818181818181818, }, +[37] = { city_ottawa, 2022, MONTH_jan, 0.8504230960676954, }, +[38] = { city_brasilia, 2022, MONTH_jan, 0.8677639046538025, }, +[39] = { city_la_paz, 2022, MONTH_jan, 0.8522286821705426, }, +[40] = { city_dhaka, 2022, MONTH_jan, 0.99, }, +[41] = { city_yerevan, 2022, MONTH_jan, 0.9705641864268193, }, +[42] = { city_chicago, 2022, MONTH_jan, 0.9385113268608414, }, +[43] = { city_kyiv, 2022, MONTH_jan, 0.8817120622568093, }, +[44] = { city_dubai, 2022, MONTH_jan, 0.9975, }, +[45] = { city_mumbai, 2022, MONTH_jan, 0.947289156626506, }, +[46] = { city_madrid, 2022, MONTH_jan, 0.9259986902423052, }, +}; +global u32 question_9_len = sizeof(question_9_data) / sizeof(question_9_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_data/csv/question_1.csv b/run_tree/data/incenter_data/csv/question_1.csv new file mode 100644 index 0000000..22b6766 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_1.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.7211155378486056 +city_brisbane,2022,MONTH_jan,0.6813559322033899 +city_chengdu,2022,MONTH_jan,0.5084745762711864 +city_new_delhi,2022,MONTH_jan,0.6507936507936508 +city_paris,2022,MONTH_jan,0.5611355457816873 +city_san_francisco,2022,MONTH_jan,0.7130232558139535 +city_denver,2022,MONTH_jan,0.7130232558139535 +city_ankara,2022,MONTH_jan,0.8550185873605948 +city_harare,2022,MONTH_jan,0.5 +city_hanoi,2022,MONTH_jan,0.3597560975609756 +city_washington,2022,MONTH_jan,0.7130232558139535 +city_bangkok,2022,MONTH_jan,0.5555555555555556 +city_tunis,2022,MONTH_jan,0.5942028985507246 +city_seoul,2022,MONTH_jan,0.3597560975609756 +city_belgrade,2022,MONTH_jan,0.632 +city_moscow,2022,MONTH_jan,0.5081967213114754 +city_lima,2022,MONTH_jan,0.5 +city_islamabad,2022,MONTH_jan,0.6526315789473685 +city_abuja,2022,MONTH_jan,0.8888888888888888 +city_managua,2022,MONTH_jan,0.6774193548387096 +city_amsterdam,2022,MONTH_jan,0.6104783599088838 +city_rabat,2022,MONTH_jan,0.4523809523809524 +city_ulaanbaatar,2022,MONTH_jan,0.5084745762711864 +city_mexico_city,2022,MONTH_jan,0.5747718230751229 +city_nairobi,2022,MONTH_jan,0.5 +city_tokyo,2022,MONTH_jan,0.3949372298826919 +city_baghdad,2022,MONTH_jan,0.7 +city_tehran,2022,MONTH_jan,0.7 +city_jakarta,2022,MONTH_jan,0.45276162790697677 +city_guatemala_city,2022,MONTH_jan,0.6774193548387096 +city_berlin,2022,MONTH_jan,0.6714178544636159 +city_addis_ababa,2022,MONTH_jan,0.5 +city_cairo,2022,MONTH_jan,0.5942028985507246 +city_quito,2022,MONTH_jan,0.48148148148148145 +city_bogota,2022,MONTH_jan,0.5698324022346368 +city_beijing,2022,MONTH_jan,0.5084745762711864 +city_accra,2022,MONTH_jan,0.5 +city_ottawa,2022,MONTH_jan,0.7213114754098361 +city_brasilia,2022,MONTH_jan,0.7555555555555555 +city_la_paz,2022,MONTH_jan,0.7555555555555555 +city_dhaka,2022,MONTH_jan,0.7348066298342542 +city_yerevan,2022,MONTH_jan,0.8550185873605948 +city_chicago,2022,MONTH_jan,0.7130232558139535 +city_kyiv,2022,MONTH_jan,0.46875 +city_dubai,2022,MONTH_jan,0.7 +city_mumbai,2022,MONTH_jan,0.6507936507936508 +city_madrid,2022,MONTH_jan,0.5716845878136201 diff --git a/run_tree/data/incenter_data/csv/question_10.csv b/run_tree/data/incenter_data/csv/question_10.csv new file mode 100644 index 0000000..716ff49 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_10.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.7907915993537964 +city_brisbane,2022,MONTH_jan,0.9196675900277008 +city_chengdu,2022,MONTH_jan,0.8922570016474465 +city_new_delhi,2022,MONTH_jan,0.8931259407927747 +city_paris,2022,MONTH_jan,0.8915187376725838 +city_san_francisco,2022,MONTH_jan,0.8767605633802817 +city_denver,2022,MONTH_jan,0.8822393822393823 +city_ankara,2022,MONTH_jan,0.8529289572081429 +city_harare,2022,MONTH_jan,0.5197693574958814 +city_hanoi,2022,MONTH_jan,0.9733333333333334 +city_washington,2022,MONTH_jan,0.885 +city_bangkok,2022,MONTH_jan,0.8386880856760375 +city_tunis,2022,MONTH_jan,0.7669983416252073 +city_seoul,2022,MONTH_jan,0.8907630522088353 +city_belgrade,2022,MONTH_jan,0.8032629558541267 +city_moscow,2022,MONTH_jan,0.8402501421262081 +city_lima,2022,MONTH_jan,0.8164874551971326 +city_islamabad,2022,MONTH_jan,0.8931259407927747 +city_abuja,2022,MONTH_jan,0.7283049472830495 +city_managua,2022,MONTH_jan,0.8558333333333333 +city_amsterdam,2022,MONTH_jan,0.9145383104125737 +city_rabat,2022,MONTH_jan,0.8283333333333334 +city_ulaanbaatar,2022,MONTH_jan,0.6910866910866911 +city_mexico_city,2022,MONTH_jan,0.9178632969557725 +city_nairobi,2022,MONTH_jan,0.8371907422186752 +city_tokyo,2022,MONTH_jan,0.9025679758308157 +city_baghdad,2022,MONTH_jan,0.7039864291772688 +city_tehran,2022,MONTH_jan,0.6967267869071476 +city_jakarta,2022,MONTH_jan,0.939043451078462 +city_guatemala_city,2022,MONTH_jan,0.9072416598860863 +city_berlin,2022,MONTH_jan,0.8915187376725838 +city_addis_ababa,2022,MONTH_jan,0.8747967479674796 +city_cairo,2022,MONTH_jan,0.7172643869891576 +city_quito,2022,MONTH_jan,0.8932203389830509 +city_bogota,2022,MONTH_jan,0.8940789473684211 +city_beijing,2022,MONTH_jan,0.8922570016474465 +city_accra,2022,MONTH_jan,0.8371907422186752 +city_ottawa,2022,MONTH_jan,0.8638626182180189 +city_brasilia,2022,MONTH_jan,0.9008595988538682 +city_la_paz,2022,MONTH_jan,0.7321688500727802 +city_dhaka,2022,MONTH_jan,0.9066666666666666 +city_yerevan,2022,MONTH_jan,0.8845836768342952 +city_chicago,2022,MONTH_jan,0.8559870550161812 +city_kyiv,2022,MONTH_jan,0.8059105431309904 +city_dubai,2022,MONTH_jan,0.7172643869891576 +city_mumbai,2022,MONTH_jan,0.8931259407927747 +city_madrid,2022,MONTH_jan,0.8915187376725838 diff --git a/run_tree/data/incenter_data/csv/question_11.csv b/run_tree/data/incenter_data/csv/question_11.csv new file mode 100644 index 0000000..2781b08 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_11.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.7527472527472527 +city_brisbane,2022,MONTH_jan,0.7346938775510204 +city_chengdu,2022,MONTH_jan,0.75 +city_new_delhi,2022,MONTH_jan,0.8222222222222222 +city_paris,2022,MONTH_jan,0.5690460306871248 +city_san_francisco,2022,MONTH_jan,0.7624035281146637 +city_denver,2022,MONTH_jan,0.7624035281146637 +city_ankara,2022,MONTH_jan,0.6437054631828979 +city_harare,2022,MONTH_jan,0.8 +city_hanoi,2022,MONTH_jan,0.8148148148148148 +city_washington,2022,MONTH_jan,0.7624035281146637 +city_bangkok,2022,MONTH_jan,0.5384615384615384 +city_tunis,2022,MONTH_jan,0.8431372549019608 +city_seoul,2022,MONTH_jan,0.8148148148148148 +city_belgrade,2022,MONTH_jan,0.6818181818181818 +city_moscow,2022,MONTH_jan,0.4065934065934066 +city_lima,2022,MONTH_jan,0.8235294117647058 +city_islamabad,2022,MONTH_jan,0.8105263157894737 +city_abuja,2022,MONTH_jan,0.7142857142857143 +city_managua,2022,MONTH_jan,0.8571428571428571 +city_amsterdam,2022,MONTH_jan,0.7003676470588235 +city_rabat,2022,MONTH_jan,0.7058823529411765 +city_ulaanbaatar,2022,MONTH_jan,0.75 +city_mexico_city,2022,MONTH_jan,0.7737030411449016 +city_nairobi,2022,MONTH_jan,0.8 +city_tokyo,2022,MONTH_jan,0.4397765363128492 +city_baghdad,2022,MONTH_jan,0.7 +city_tehran,2022,MONTH_jan,0.7 +city_jakarta,2022,MONTH_jan,0.8859470468431772 +city_guatemala_city,2022,MONTH_jan,0.8571428571428571 +city_berlin,2022,MONTH_jan,0.6584922797456857 +city_addis_ababa,2022,MONTH_jan,0.8 +city_cairo,2022,MONTH_jan,0.8431372549019608 +city_quito,2022,MONTH_jan,0.8181818181818182 +city_bogota,2022,MONTH_jan,0.7089552238805971 +city_beijing,2022,MONTH_jan,0.75 +city_accra,2022,MONTH_jan,0.8 +city_ottawa,2022,MONTH_jan,0.6509695290858726 +city_brasilia,2022,MONTH_jan,0.8969465648854962 +city_la_paz,2022,MONTH_jan,0.8969465648854962 +city_dhaka,2022,MONTH_jan,0.8523206751054853 +city_yerevan,2022,MONTH_jan,0.6437054631828979 +city_chicago,2022,MONTH_jan,0.7624035281146637 +city_kyiv,2022,MONTH_jan,0.8181818181818182 +city_dubai,2022,MONTH_jan,0.7 +city_mumbai,2022,MONTH_jan,0.8222222222222222 +city_madrid,2022,MONTH_jan,0.7440191387559809 diff --git a/run_tree/data/incenter_data/csv/question_12.csv b/run_tree/data/incenter_data/csv/question_12.csv new file mode 100644 index 0000000..4a537d1 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_12.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.4789180588703262 +city_brisbane,2022,MONTH_jan,0.827357970215113 +city_chengdu,2022,MONTH_jan,0.600926538716082 +city_new_delhi,2022,MONTH_jan,0.42355889724310775 +city_paris,2022,MONTH_jan,0.8413114754098361 +city_san_francisco,2022,MONTH_jan,0.6807511737089202 +city_denver,2022,MONTH_jan,0.6730769230769231 +city_ankara,2022,MONTH_jan,0.6662309368191721 +city_harare,2022,MONTH_jan,0.7267489711934156 +city_hanoi,2022,MONTH_jan,0.4633333333333333 +city_washington,2022,MONTH_jan,0.7408637873754153 +city_bangkok,2022,MONTH_jan,0.522 +city_tunis,2022,MONTH_jan,0.8239731768650461 +city_seoul,2022,MONTH_jan,0.5084337349397591 +city_belgrade,2022,MONTH_jan,0.6408518877057116 +city_moscow,2022,MONTH_jan,0.5629834254143646 +city_lima,2022,MONTH_jan,0.6192857142857143 +city_islamabad,2022,MONTH_jan,0.42355889724310775 +city_abuja,2022,MONTH_jan,0.6176232821341956 +city_managua,2022,MONTH_jan,0.7441666666666666 +city_amsterdam,2022,MONTH_jan,0.8019323671497585 +city_rabat,2022,MONTH_jan,0.5075 +city_ulaanbaatar,2022,MONTH_jan,0.4340659340659341 +city_mexico_city,2022,MONTH_jan,0.6657093624353819 +city_nairobi,2022,MONTH_jan,0.5442338072669827 +city_tokyo,2022,MONTH_jan,0.6260162601626016 +city_baghdad,2022,MONTH_jan,0.7216666666666667 +city_tehran,2022,MONTH_jan,0.40493662441627754 +city_jakarta,2022,MONTH_jan,0.470625 +city_guatemala_city,2022,MONTH_jan,0.7831558567279767 +city_berlin,2022,MONTH_jan,0.8413114754098361 +city_addis_ababa,2022,MONTH_jan,0.45934959349593496 +city_cairo,2022,MONTH_jan,0.7814845704753962 +city_quito,2022,MONTH_jan,0.6958333333333333 +city_bogota,2022,MONTH_jan,0.7730263157894737 +city_beijing,2022,MONTH_jan,0.600926538716082 +city_accra,2022,MONTH_jan,0.5442338072669827 +city_ottawa,2022,MONTH_jan,0.7073170731707317 +city_brasilia,2022,MONTH_jan,0.6152099886492622 +city_la_paz,2022,MONTH_jan,0.7289946576007771 +city_dhaka,2022,MONTH_jan,0.7075 +city_yerevan,2022,MONTH_jan,0.6059113300492611 +city_chicago,2022,MONTH_jan,0.6844660194174758 +city_kyiv,2022,MONTH_jan,0.4786656322730799 +city_dubai,2022,MONTH_jan,0.7814845704753962 +city_mumbai,2022,MONTH_jan,0.42355889724310775 +city_madrid,2022,MONTH_jan,0.8413114754098361 diff --git a/run_tree/data/incenter_data/csv/question_13.csv b/run_tree/data/incenter_data/csv/question_13.csv new file mode 100644 index 0000000..25094a4 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_13.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.08285385500575373 +city_brisbane,2022,MONTH_jan,0.09841628959276018 +city_chengdu,2022,MONTH_jan,0.08166666666666667 +city_new_delhi,2022,MONTH_jan,0.20042987641053198 +city_paris,2022,MONTH_jan,0.031207598371777476 +city_san_francisco,2022,MONTH_jan,0.1670616113744076 +city_denver,2022,MONTH_jan,0.15145631067961166 +city_ankara,2022,MONTH_jan,0.14479830148619957 +city_harare,2022,MONTH_jan,0.3549459684123026 +city_hanoi,2022,MONTH_jan,0.08166666666666667 +city_washington,2022,MONTH_jan,0.14214046822742474 +city_bangkok,2022,MONTH_jan,0.18401611820013433 +city_tunis,2022,MONTH_jan,0.28439597315436244 +city_seoul,2022,MONTH_jan,0.157429718875502 +city_belgrade,2022,MONTH_jan,0.0691333982473223 +city_moscow,2022,MONTH_jan,0.07294264339152119 +city_lima,2022,MONTH_jan,0.18324607329842932 +city_islamabad,2022,MONTH_jan,0.20042987641053198 +city_abuja,2022,MONTH_jan,0.18892508143322476 +city_managua,2022,MONTH_jan,0.11083333333333334 +city_amsterdam,2022,MONTH_jan,0.09620098039215687 +city_rabat,2022,MONTH_jan,0.5508333333333333 +city_ulaanbaatar,2022,MONTH_jan,0.2658924205378973 +city_mexico_city,2022,MONTH_jan,0.3469387755102041 +city_nairobi,2022,MONTH_jan,0.37571312143439284 +city_tokyo,2022,MONTH_jan,0.0972644376899696 +city_baghdad,2022,MONTH_jan,0.16893039049235994 +city_tehran,2022,MONTH_jan,0.07811447811447811 +city_jakarta,2022,MONTH_jan,0.0608640807316304 +city_guatemala_city,2022,MONTH_jan,0.322213181448332 +city_berlin,2022,MONTH_jan,0.031207598371777476 +city_addis_ababa,2022,MONTH_jan,0.15637860082304528 +city_cairo,2022,MONTH_jan,0.16893039049235994 +city_quito,2022,MONTH_jan,0.14830875975715524 +city_bogota,2022,MONTH_jan,0.13355263157894737 +city_beijing,2022,MONTH_jan,0.08166666666666667 +city_accra,2022,MONTH_jan,0.37571312143439284 +city_ottawa,2022,MONTH_jan,0.14758586361373818 +city_brasilia,2022,MONTH_jan,0.20054384772263767 +city_la_paz,2022,MONTH_jan,0.14959016393442623 +city_dhaka,2022,MONTH_jan,0.13162544169611307 +city_yerevan,2022,MONTH_jan,0.03935599284436494 +city_chicago,2022,MONTH_jan,0.1563517915309446 +city_kyiv,2022,MONTH_jan,0.055281342546890426 +city_dubai,2022,MONTH_jan,0.16893039049235994 +city_mumbai,2022,MONTH_jan,0.20042987641053198 +city_madrid,2022,MONTH_jan,0.031207598371777476 diff --git a/run_tree/data/incenter_data/csv/question_14.csv b/run_tree/data/incenter_data/csv/question_14.csv new file mode 100644 index 0000000..c5478e7 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_14.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.6968174204355109 +city_brisbane,2022,MONTH_jan,0.4254484304932735 +city_chengdu,2022,MONTH_jan,0.15694768410529825 +city_new_delhi,2022,MONTH_jan,0.37493632195618953 +city_paris,2022,MONTH_jan,0.31785003317850036 +city_san_francisco,2022,MONTH_jan,0.6515513126491647 +city_denver,2022,MONTH_jan,0.700587084148728 +city_ankara,2022,MONTH_jan,0.39265898420828 +city_harare,2022,MONTH_jan,0.76814011676397 +city_hanoi,2022,MONTH_jan,0.145 +city_washington,2022,MONTH_jan,0.6761744966442953 +city_bangkok,2022,MONTH_jan,0.529689608636977 +city_tunis,2022,MONTH_jan,0.7771236333052985 +city_seoul,2022,MONTH_jan,0.09799196787148594 +city_belgrade,2022,MONTH_jan,0.6625891946992865 +city_moscow,2022,MONTH_jan,0.5068903535050928 +city_lima,2022,MONTH_jan,0.7326086956521739 +city_islamabad,2022,MONTH_jan,0.37493632195618953 +city_abuja,2022,MONTH_jan,0.6726238830219334 +city_managua,2022,MONTH_jan,0.6166666666666667 +city_amsterdam,2022,MONTH_jan,0.37310308738880166 +city_rabat,2022,MONTH_jan,0.5525 +city_ulaanbaatar,2022,MONTH_jan,0.43933823529411764 +city_mexico_city,2022,MONTH_jan,0.6502890173410405 +city_nairobi,2022,MONTH_jan,0.5854632587859425 +city_tokyo,2022,MONTH_jan,0.4491803278688525 +city_baghdad,2022,MONTH_jan,0.74 +city_tehran,2022,MONTH_jan,0.48944860449285227 +city_jakarta,2022,MONTH_jan,0.3997445721583653 +city_guatemala_city,2022,MONTH_jan,0.7050538525269263 +city_berlin,2022,MONTH_jan,0.31785003317850036 +city_addis_ababa,2022,MONTH_jan,0.6325350949628407 +city_cairo,2022,MONTH_jan,0.74 +city_quito,2022,MONTH_jan,0.5373635600335852 +city_bogota,2022,MONTH_jan,0.7315789473684211 +city_beijing,2022,MONTH_jan,0.15694768410529825 +city_accra,2022,MONTH_jan,0.5854632587859425 +city_ottawa,2022,MONTH_jan,0.2929318068690891 +city_brasilia,2022,MONTH_jan,0.8714953271028038 +city_la_paz,2022,MONTH_jan,0.48205383848454636 +city_dhaka,2022,MONTH_jan,0.215 +city_yerevan,2022,MONTH_jan,0.7328308207705193 +city_chicago,2022,MONTH_jan,0.6830870279146142 +city_kyiv,2022,MONTH_jan,0.7300813008130081 +city_dubai,2022,MONTH_jan,0.74 +city_mumbai,2022,MONTH_jan,0.37493632195618953 +city_madrid,2022,MONTH_jan,0.31785003317850036 diff --git a/run_tree/data/incenter_data/csv/question_15.csv b/run_tree/data/incenter_data/csv/question_15.csv new file mode 100644 index 0000000..f690ecf --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_15.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.8681318681318682 +city_brisbane,2022,MONTH_jan,0.842741935483871 +city_chengdu,2022,MONTH_jan,0.75 +city_new_delhi,2022,MONTH_jan,0.8444444444444444 +city_paris,2022,MONTH_jan,0.7975257342525262 +city_san_francisco,2022,MONTH_jan,0.8898026315789473 +city_denver,2022,MONTH_jan,0.8898026315789473 +city_ankara,2022,MONTH_jan,0.8466111771700356 +city_harare,2022,MONTH_jan,1 +city_hanoi,2022,MONTH_jan,0.8507462686567164 +city_washington,2022,MONTH_jan,0.8898026315789473 +city_bangkok,2022,MONTH_jan,0.7692307692307693 +city_tunis,2022,MONTH_jan,0.8653846153846154 +city_seoul,2022,MONTH_jan,0.8507462686567164 +city_belgrade,2022,MONTH_jan,0.8838383838383839 +city_moscow,2022,MONTH_jan,0.7934782608695652 +city_lima,2022,MONTH_jan,0.9705882352941176 +city_islamabad,2022,MONTH_jan,0.8121827411167513 +city_abuja,2022,MONTH_jan,0.8571428571428571 +city_managua,2022,MONTH_jan,1 +city_amsterdam,2022,MONTH_jan,0.9004566210045662 +city_rabat,2022,MONTH_jan,0.7352941176470589 +city_ulaanbaatar,2022,MONTH_jan,0.75 +city_mexico_city,2022,MONTH_jan,0.8772086117297698 +city_nairobi,2022,MONTH_jan,1 +city_tokyo,2022,MONTH_jan,0.41568278012920473 +city_baghdad,2022,MONTH_jan,0.8 +city_tehran,2022,MONTH_jan,0.8 +city_jakarta,2022,MONTH_jan,0.8562753036437247 +city_guatemala_city,2022,MONTH_jan,1 +city_berlin,2022,MONTH_jan,0.8590785907859079 +city_addis_ababa,2022,MONTH_jan,1 +city_cairo,2022,MONTH_jan,0.8653846153846154 +city_quito,2022,MONTH_jan,0.8695652173913043 +city_bogota,2022,MONTH_jan,0.8656716417910447 +city_beijing,2022,MONTH_jan,0.75 +city_accra,2022,MONTH_jan,1 +city_ottawa,2022,MONTH_jan,0.8402203856749312 +city_brasilia,2022,MONTH_jan,0.8950381679389313 +city_la_paz,2022,MONTH_jan,0.8950381679389313 +city_dhaka,2022,MONTH_jan,0.9041666666666667 +city_yerevan,2022,MONTH_jan,0.8466111771700356 +city_chicago,2022,MONTH_jan,0.8898026315789473 +city_kyiv,2022,MONTH_jan,0.8636363636363636 +city_dubai,2022,MONTH_jan,0.8 +city_mumbai,2022,MONTH_jan,0.8444444444444444 +city_madrid,2022,MONTH_jan,0.8524590163934426 diff --git a/run_tree/data/incenter_data/csv/question_16.csv b/run_tree/data/incenter_data/csv/question_16.csv new file mode 100644 index 0000000..8964d0e --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_16.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.6252144082332761 +city_brisbane,2022,MONTH_jan,0.21300448430493274 +city_chengdu,2022,MONTH_jan,0.8102633355840648 +city_new_delhi,2022,MONTH_jan,0.7666836474783495 +city_paris,2022,MONTH_jan,0.1596806387225549 +city_san_francisco,2022,MONTH_jan,0.23954372623574144 +city_denver,2022,MONTH_jan,0.21940928270042195 +city_ankara,2022,MONTH_jan,0.8744531933508312 +city_harare,2022,MONTH_jan,0.9385004212299916 +city_hanoi,2022,MONTH_jan,0.8875 +city_washington,2022,MONTH_jan,0.2643884892086331 +city_bangkok,2022,MONTH_jan,0.6720647773279352 +city_tunis,2022,MONTH_jan,0.8076580587711487 +city_seoul,2022,MONTH_jan,0.8481927710843373 +city_belgrade,2022,MONTH_jan,0.763023493360572 +city_moscow,2022,MONTH_jan,0.738166566806471 +city_lima,2022,MONTH_jan,0.44288872512896094 +city_islamabad,2022,MONTH_jan,0.7666836474783495 +city_abuja,2022,MONTH_jan,0.9618196588139724 +city_managua,2022,MONTH_jan,0.4816666666666667 +city_amsterdam,2022,MONTH_jan,0.27867095391211144 +city_rabat,2022,MONTH_jan,0.91 +city_ulaanbaatar,2022,MONTH_jan,0.7175245098039216 +city_mexico_city,2022,MONTH_jan,0.3929398148148148 +city_nairobi,2022,MONTH_jan,0.8004926108374384 +city_tokyo,2022,MONTH_jan,0.5046491969568893 +city_baghdad,2022,MONTH_jan,0.9116666666666666 +city_tehran,2022,MONTH_jan,1 +city_jakarta,2022,MONTH_jan,0.9195402298850575 +city_guatemala_city,2022,MONTH_jan,0.6255178127589064 +city_berlin,2022,MONTH_jan,0.1596806387225549 +city_addis_ababa,2022,MONTH_jan,0.8911055694098088 +city_cairo,2022,MONTH_jan,0.9116666666666666 +city_quito,2022,MONTH_jan,0.4869857262804366 +city_bogota,2022,MONTH_jan,0.4 +city_beijing,2022,MONTH_jan,0.8102633355840648 +city_accra,2022,MONTH_jan,0.8004926108374384 +city_ottawa,2022,MONTH_jan,0.20034843205574912 +city_brasilia,2022,MONTH_jan,0.1588785046728972 +city_la_paz,2022,MONTH_jan,0.43232438606510565 +city_dhaka,2022,MONTH_jan,0.9798826487845766 +city_yerevan,2022,MONTH_jan,0.8872881355932203 +city_chicago,2022,MONTH_jan,0.2586805555555556 +city_kyiv,2022,MONTH_jan,0.7552447552447552 +city_dubai,2022,MONTH_jan,0.9116666666666666 +city_mumbai,2022,MONTH_jan,0.7666836474783495 +city_madrid,2022,MONTH_jan,0.1596806387225549 diff --git a/run_tree/data/incenter_data/csv/question_17.csv b/run_tree/data/incenter_data/csv/question_17.csv new file mode 100644 index 0000000..b6a7a65 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_17.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.3517305893358279 +city_brisbane,2022,MONTH_jan,0.7251693002257337 +city_chengdu,2022,MONTH_jan,0.6752336448598131 +city_new_delhi,2022,MONTH_jan,0.28718882817243474 +city_paris,2022,MONTH_jan,0.8590694538098449 +city_san_francisco,2022,MONTH_jan,0.7202881152460985 +city_denver,2022,MONTH_jan,0.7637795275590551 +city_ankara,2022,MONTH_jan,0.22046174739701221 +city_harare,2022,MONTH_jan,0.4797297297297297 +city_hanoi,2022,MONTH_jan,0.08583333333333333 +city_washington,2022,MONTH_jan,0.7687074829931972 +city_bangkok,2022,MONTH_jan,0.39174560216508797 +city_tunis,2022,MONTH_jan,0.18357933579335795 +city_seoul,2022,MONTH_jan,0.242570281124498 +city_belgrade,2022,MONTH_jan,0.23599137931034483 +city_moscow,2022,MONTH_jan,0.3582286847323199 +city_lima,2022,MONTH_jan,0.21016166281755197 +city_islamabad,2022,MONTH_jan,0.28718882817243474 +city_abuja,2022,MONTH_jan,0.4920502092050209 +city_managua,2022,MONTH_jan,0.3875 +city_amsterdam,2022,MONTH_jan,0.5708571428571428 +city_rabat,2022,MONTH_jan,0.28583333333333333 +city_ulaanbaatar,2022,MONTH_jan,0.5067401960784313 +city_mexico_city,2022,MONTH_jan,0.1445221445221445 +city_nairobi,2022,MONTH_jan,0.5110356536502547 +city_tokyo,2022,MONTH_jan,0.6290018832391714 +city_baghdad,2022,MONTH_jan,0.475736568457539 +city_tehran,2022,MONTH_jan,0.7332421340629275 +city_jakarta,2022,MONTH_jan,0.3570284982388729 +city_guatemala_city,2022,MONTH_jan,0.5788135593220339 +city_berlin,2022,MONTH_jan,0.8590694538098449 +city_addis_ababa,2022,MONTH_jan,0.17217981340118746 +city_cairo,2022,MONTH_jan,0.475736568457539 +city_quito,2022,MONTH_jan,0.4667235494880546 +city_bogota,2022,MONTH_jan,0.6217105263157895 +city_beijing,2022,MONTH_jan,0.6752336448598131 +city_accra,2022,MONTH_jan,0.5110356536502547 +city_ottawa,2022,MONTH_jan,0.7775012444001991 +city_brasilia,2022,MONTH_jan,0.5541561712846348 +city_la_paz,2022,MONTH_jan,0.5235414534288638 +city_dhaka,2022,MONTH_jan,0.34421364985163205 +city_yerevan,2022,MONTH_jan,0.365832614322692 +city_chicago,2022,MONTH_jan,0.760797342192691 +city_kyiv,2022,MONTH_jan,0.28751311647429173 +city_dubai,2022,MONTH_jan,0.475736568457539 +city_mumbai,2022,MONTH_jan,0.28718882817243474 +city_madrid,2022,MONTH_jan,0.8590694538098449 diff --git a/run_tree/data/incenter_data/csv/question_18.csv b/run_tree/data/incenter_data/csv/question_18.csv new file mode 100644 index 0000000..952767e --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_18.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.40350877192982454 +city_brisbane,2022,MONTH_jan,0.6732617297908423 +city_chengdu,2022,MONTH_jan,0.6871880199667221 +city_new_delhi,2022,MONTH_jan,0.4288 +city_paris,2022,MONTH_jan,0.6646090534979424 +city_san_francisco,2022,MONTH_jan,0.5142857142857142 +city_denver,2022,MONTH_jan,0.528957528957529 +city_ankara,2022,MONTH_jan,0.5759139784946237 +city_harare,2022,MONTH_jan,0.538971807628524 +city_hanoi,2022,MONTH_jan,0.7172643869891576 +city_washington,2022,MONTH_jan,0.5456081081081081 +city_bangkok,2022,MONTH_jan,0.5256756756756756 +city_tunis,2022,MONTH_jan,0.34995625546806647 +city_seoul,2022,MONTH_jan,0.5742971887550201 +city_belgrade,2022,MONTH_jan,0.46930280957336107 +city_moscow,2022,MONTH_jan,0.48936170212765956 +city_lima,2022,MONTH_jan,0.5945144551519644 +city_islamabad,2022,MONTH_jan,0.4288 +city_abuja,2022,MONTH_jan,0.41254125412541254 +city_managua,2022,MONTH_jan,0.6333333333333333 +city_amsterdam,2022,MONTH_jan,0.7243367935409458 +city_rabat,2022,MONTH_jan,0.5133333333333333 +city_ulaanbaatar,2022,MONTH_jan,0.5415140415140415 +city_mexico_city,2022,MONTH_jan,0.5577712609970674 +city_nairobi,2022,MONTH_jan,0.4683127572016461 +city_tokyo,2022,MONTH_jan,0.5072463768115942 +city_baghdad,2022,MONTH_jan,0.43166666666666664 +city_tehran,2022,MONTH_jan,0.6534320323014805 +city_jakarta,2022,MONTH_jan,0.733607855559075 +city_guatemala_city,2022,MONTH_jan,0.5899339933993399 +city_berlin,2022,MONTH_jan,0.6646090534979424 +city_addis_ababa,2022,MONTH_jan,0.46716541978387366 +city_cairo,2022,MONTH_jan,0.3588290840415486 +city_quito,2022,MONTH_jan,0.5719207579672696 +city_bogota,2022,MONTH_jan,0.6966887417218544 +city_beijing,2022,MONTH_jan,0.6871880199667221 +city_accra,2022,MONTH_jan,0.4683127572016461 +city_ottawa,2022,MONTH_jan,0.6124937779990045 +city_brasilia,2022,MONTH_jan,0.644878706199461 +city_la_paz,2022,MONTH_jan,0.7341961174713788 +city_dhaka,2022,MONTH_jan,0.4765694076038904 +city_yerevan,2022,MONTH_jan,0.5004262574595055 +city_chicago,2022,MONTH_jan,0.5481239804241436 +city_kyiv,2022,MONTH_jan,0.5114235500878734 +city_dubai,2022,MONTH_jan,0.3588290840415486 +city_mumbai,2022,MONTH_jan,0.4288 +city_madrid,2022,MONTH_jan,0.6646090534979424 diff --git a/run_tree/data/incenter_data/csv/question_19.csv b/run_tree/data/incenter_data/csv/question_19.csv new file mode 100644 index 0000000..9ffecf9 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_19.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.7082644628099174 +city_brisbane,2022,MONTH_jan,0.8521205357142857 +city_chengdu,2022,MONTH_jan,0.9380856760374833 +city_new_delhi,2022,MONTH_jan,0.7483477376715811 +city_paris,2022,MONTH_jan,0.8271523178807947 +city_san_francisco,2022,MONTH_jan,0.7714285714285715 +city_denver,2022,MONTH_jan,0.7393822393822393 +city_ankara,2022,MONTH_jan,0.735936188077246 +city_harare,2022,MONTH_jan,0.7394190871369295 +city_hanoi,2022,MONTH_jan,0.9416666666666667 +city_washington,2022,MONTH_jan,0.8 +city_bangkok,2022,MONTH_jan,0.7437457741717377 +city_tunis,2022,MONTH_jan,0.5396825396825397 +city_seoul,2022,MONTH_jan,0.9164658634538153 +city_belgrade,2022,MONTH_jan,0.6821782178217822 +city_moscow,2022,MONTH_jan,0.8499717992103779 +city_lima,2022,MONTH_jan,0.5747211895910781 +city_islamabad,2022,MONTH_jan,0.7483477376715811 +city_abuja,2022,MONTH_jan,0.6848534201954397 +city_managua,2022,MONTH_jan,0.55 +city_amsterdam,2022,MONTH_jan,0.8363922391190352 +city_rabat,2022,MONTH_jan,0.82 +city_ulaanbaatar,2022,MONTH_jan,0.7635919364691509 +city_mexico_city,2022,MONTH_jan,0.6364685516445471 +city_nairobi,2022,MONTH_jan,0.6780876494023904 +city_tokyo,2022,MONTH_jan,0.7748344370860927 +city_baghdad,2022,MONTH_jan,0.78 +city_tehran,2022,MONTH_jan,0.6942204301075269 +city_jakarta,2022,MONTH_jan,0.8313479623824451 +city_guatemala_city,2022,MONTH_jan,0.6363636363636364 +city_berlin,2022,MONTH_jan,0.8271523178807947 +city_addis_ababa,2022,MONTH_jan,0.7589134125636672 +city_cairo,2022,MONTH_jan,0.5408333333333334 +city_quito,2022,MONTH_jan,0.5179916317991632 +city_bogota,2022,MONTH_jan,0.5506578947368421 +city_beijing,2022,MONTH_jan,0.9380856760374833 +city_accra,2022,MONTH_jan,0.6780876494023904 +city_ottawa,2022,MONTH_jan,0.8128422100547537 +city_brasilia,2022,MONTH_jan,0.5583962812318419 +city_la_paz,2022,MONTH_jan,0.5051749630359783 +city_dhaka,2022,MONTH_jan,0.9416666666666667 +city_yerevan,2022,MONTH_jan,0.6306156405990017 +city_chicago,2022,MONTH_jan,0.7963875205254516 +city_kyiv,2022,MONTH_jan,0.830249396621078 +city_dubai,2022,MONTH_jan,0.5408333333333334 +city_mumbai,2022,MONTH_jan,0.7483477376715811 +city_madrid,2022,MONTH_jan,0.8271523178807947 diff --git a/run_tree/data/incenter_data/csv/question_2.csv b/run_tree/data/incenter_data/csv/question_2.csv new file mode 100644 index 0000000..bafb750 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_2.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.8087649402390438 +city_brisbane,2022,MONTH_jan,0.7064846416382252 +city_chengdu,2022,MONTH_jan,0.6440677966101694 +city_new_delhi,2022,MONTH_jan,0.7936507936507936 +city_paris,2022,MONTH_jan,0.6832853946947907 +city_san_francisco,2022,MONTH_jan,0.814797580269893 +city_denver,2022,MONTH_jan,0.814797580269893 +city_ankara,2022,MONTH_jan,0.870817843866171 +city_harare,2022,MONTH_jan,0.7857142857142857 +city_hanoi,2022,MONTH_jan,0.6257668711656442 +city_washington,2022,MONTH_jan,0.814797580269893 +city_bangkok,2022,MONTH_jan,0.47058823529411764 +city_tunis,2022,MONTH_jan,0.6571428571428571 +city_seoul,2022,MONTH_jan,0.6257668711656442 +city_belgrade,2022,MONTH_jan,0.8 +city_moscow,2022,MONTH_jan,0.8032786885245902 +city_lima,2022,MONTH_jan,0.8 +city_islamabad,2022,MONTH_jan,0.7448275862068966 +city_abuja,2022,MONTH_jan,0.9411764705882353 +city_managua,2022,MONTH_jan,0.8125 +city_amsterdam,2022,MONTH_jan,0.5527714502657555 +city_rabat,2022,MONTH_jan,0.7619047619047619 +city_ulaanbaatar,2022,MONTH_jan,0.6440677966101694 +city_mexico_city,2022,MONTH_jan,0.825 +city_nairobi,2022,MONTH_jan,0.7857142857142857 +city_tokyo,2022,MONTH_jan,0.665843621399177 +city_baghdad,2022,MONTH_jan,0.7058823529411765 +city_tehran,2022,MONTH_jan,0.7058823529411765 +city_jakarta,2022,MONTH_jan,0.7700145560407569 +city_guatemala_city,2022,MONTH_jan,0.8125 +city_berlin,2022,MONTH_jan,0.6601796407185628 +city_addis_ababa,2022,MONTH_jan,0.7857142857142857 +city_cairo,2022,MONTH_jan,0.6571428571428571 +city_quito,2022,MONTH_jan,0.7241379310344828 +city_bogota,2022,MONTH_jan,0.7722222222222223 +city_beijing,2022,MONTH_jan,0.6440677966101694 +city_accra,2022,MONTH_jan,0.7857142857142857 +city_ottawa,2022,MONTH_jan,0.7915690866510539 +city_brasilia,2022,MONTH_jan,0.8020833333333334 +city_la_paz,2022,MONTH_jan,0.8020833333333334 +city_dhaka,2022,MONTH_jan,0.8126721763085399 +city_yerevan,2022,MONTH_jan,0.870817843866171 +city_chicago,2022,MONTH_jan,0.814797580269893 +city_kyiv,2022,MONTH_jan,0.8125 +city_dubai,2022,MONTH_jan,0.7058823529411765 +city_mumbai,2022,MONTH_jan,0.7936507936507936 +city_madrid,2022,MONTH_jan,0.7365591397849462 diff --git a/run_tree/data/incenter_data/csv/question_20.csv b/run_tree/data/incenter_data/csv/question_20.csv new file mode 100644 index 0000000..3726a6d --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_20.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.008906882591093117 +city_brisbane,2022,MONTH_jan,0.06120157215047726 +city_chengdu,2022,MONTH_jan,0.014885874958650347 +city_new_delhi,2022,MONTH_jan,0.05456570155902005 +city_paris,2022,MONTH_jan,0.07147540983606557 +city_san_francisco,2022,MONTH_jan,0.06863905325443787 +city_denver,2022,MONTH_jan,0.06395348837209303 +city_ankara,2022,MONTH_jan,0.007591733445803458 +city_harare,2022,MONTH_jan,0.07966804979253111 +city_hanoi,2022,MONTH_jan,0.021666666666666667 +city_washington,2022,MONTH_jan,0.05852842809364549 +city_bangkok,2022,MONTH_jan,0.13266666666666665 +city_tunis,2022,MONTH_jan,0.009369676320272573 +city_seoul,2022,MONTH_jan,0.01606425702811245 +city_belgrade,2022,MONTH_jan,0.014691478942213516 +city_moscow,2022,MONTH_jan,0.0061624649859943975 +city_lima,2022,MONTH_jan,0.023038156947444204 +city_islamabad,2022,MONTH_jan,0.05456570155902005 +city_abuja,2022,MONTH_jan,0.09248554913294797 +city_managua,2022,MONTH_jan,0.11166666666666666 +city_amsterdam,2022,MONTH_jan,0.01694915254237288 +city_rabat,2022,MONTH_jan,0.041666666666666664 +city_ulaanbaatar,2022,MONTH_jan,0.11233211233211234 +city_mexico_city,2022,MONTH_jan,0.047756041426927506 +city_nairobi,2022,MONTH_jan,0.1770573566084788 +city_tokyo,2022,MONTH_jan,0.0037425149700598802 +city_baghdad,2022,MONTH_jan,0.037800687285223365 +city_tehran,2022,MONTH_jan,0.06412825651302605 +city_jakarta,2022,MONTH_jan,0.2173776662484316 +city_guatemala_city,2022,MONTH_jan,0.06795302013422819 +city_berlin,2022,MONTH_jan,0.07147540983606557 +city_addis_ababa,2022,MONTH_jan,0.11595394736842106 +city_cairo,2022,MONTH_jan,0.0016680567139282735 +city_quito,2022,MONTH_jan,0.05396290050590219 +city_bogota,2022,MONTH_jan,0.1118421052631579 +city_beijing,2022,MONTH_jan,0.014885874958650347 +city_accra,2022,MONTH_jan,0.1770573566084788 +city_ottawa,2022,MONTH_jan,0.05301144848183176 +city_brasilia,2022,MONTH_jan,0.017452006980802792 +city_la_paz,2022,MONTH_jan,0.08312958435207823 +city_dhaka,2022,MONTH_jan,0.03836317135549872 +city_yerevan,2022,MONTH_jan,0.02875924404272802 +city_chicago,2022,MONTH_jan,0.06188925081433225 +city_kyiv,2022,MONTH_jan,0.01675977653631285 +city_dubai,2022,MONTH_jan,0.0016680567139282735 +city_mumbai,2022,MONTH_jan,0.05456570155902005 +city_madrid,2022,MONTH_jan,0.07147540983606557 diff --git a/run_tree/data/incenter_data/csv/question_21.csv b/run_tree/data/incenter_data/csv/question_21.csv new file mode 100644 index 0000000..85c6a6f --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_21.csv @@ -0,0 +1,1949 @@ +city_data,year,month,prop +city_brisbane,1965,MONTH_jan,0.05562621593475342 +city_brisbane,1966,MONTH_jan,0.05071894645690918 +city_brisbane,1967,MONTH_jan,0.049495487213134765 +city_brisbane,1968,MONTH_jan,0.04865467548370361 +city_brisbane,1969,MONTH_jan,0.05086987972259521 +city_brisbane,1970,MONTH_jan,0.05421450614929199 +city_brisbane,1971,MONTH_jan,0.05822727203369141 +city_brisbane,1972,MONTH_jan,0.05599285125732422 +city_brisbane,1973,MONTH_jan,0.055886645317077634 +city_brisbane,1974,MONTH_jan,0.05955109596252441 +city_brisbane,1975,MONTH_jan,0.06297008037567138 +city_brisbane,1976,MONTH_jan,0.05793421268463135 +city_brisbane,1977,MONTH_jan,0.05269774913787842 +city_brisbane,1978,MONTH_jan,0.0550869607925415 +city_brisbane,1979,MONTH_jan,0.051658406257629394 +city_brisbane,1980,MONTH_jan,0.04862271785736084 +city_brisbane,1981,MONTH_jan,0.04930354595184326 +city_brisbane,1982,MONTH_jan,0.046367826461791994 +city_brisbane,1983,MONTH_jan,0.045344815254211426 +city_brisbane,1984,MONTH_jan,0.04718454360961914 +city_brisbane,1985,MONTH_jan,0.04863154888153076 +city_brisbane,1986,MONTH_jan,0.047985596656799315 +city_brisbane,1987,MONTH_jan,0.04532893180847168 +city_brisbane,1988,MONTH_jan,0.046416802406311033 +city_brisbane,1989,MONTH_jan,0.044199533462524414 +city_brisbane,1990,MONTH_jan,0.044593911170959476 +city_brisbane,1991,MONTH_jan,0.047400617599487306 +city_brisbane,1992,MONTH_jan,0.04731717109680176 +city_brisbane,1993,MONTH_jan,0.0475942850112915 +city_brisbane,1994,MONTH_jan,0.045271806716918946 +city_brisbane,1995,MONTH_jan,0.04239725112915039 +city_brisbane,1996,MONTH_jan,0.0423659086227417 +city_brisbane,1997,MONTH_jan,0.04145838737487793 +city_brisbane,1998,MONTH_jan,0.04037755966186524 +city_brisbane,1999,MONTH_jan,0.04008933544158935 +city_brisbane,2000,MONTH_jan,0.03988877773284912 +city_brisbane,2001,MONTH_jan,0.0387076210975647 +city_brisbane,2002,MONTH_jan,0.03931450366973877 +city_brisbane,2003,MONTH_jan,0.040149688720703125 +city_brisbane,2004,MONTH_jan,0.04036560535430908 +city_brisbane,2005,MONTH_jan,0.04313553333282471 +city_brisbane,2006,MONTH_jan,0.04233413219451904 +city_brisbane,2007,MONTH_jan,0.039767227172851555 +city_brisbane,2008,MONTH_jan,0.03681326389312744 +city_brisbane,2009,MONTH_jan,0.03920266151428222 +city_brisbane,2010,MONTH_jan,0.04312804698944092 +city_brisbane,2011,MONTH_jan,0.05698980808258056 +city_brisbane,2012,MONTH_jan,0.05700209140777588 +city_brisbane,2013,MONTH_jan,0.06525868892669678 +city_brisbane,2014,MONTH_jan,0.05979823112487793 +city_brisbane,2015,MONTH_jan,0.06290020942687988 +city_brisbane,2016,MONTH_jan,0.07189175605773926 +city_brisbane,2017,MONTH_jan,0.06750126838684083 +city_brisbane,2018,MONTH_jan,0.08300061225891113 +city_brisbane,2019,MONTH_jan,0.08880722045898437 +city_brisbane,2020,MONTH_jan,0.10789811134338381 +city_brisbane,2021,MONTH_jan,0.12933531761169434 +city_dhaka,1971,MONTH_jan,0.03859757661819458 +city_dhaka,1972,MONTH_jan,0.03406534433364868 +city_dhaka,1973,MONTH_jan,0.050243868827819824 +city_dhaka,1974,MONTH_jan,0.03463459491729736 +city_dhaka,1975,MONTH_jan,0.06043976306915283 +city_dhaka,1976,MONTH_jan,0.05868124008178711 +city_dhaka,1977,MONTH_jan,0.05079775810241699 +city_dhaka,1978,MONTH_jan,0.05536711692810058 +city_dhaka,1979,MONTH_jan,0.05825671672821045 +city_dhaka,1980,MONTH_jan,0.049608802795410155 +city_dhaka,1981,MONTH_jan,0.05016649723052979 +city_dhaka,1982,MONTH_jan,0.03805250644683838 +city_dhaka,1983,MONTH_jan,0.048706588745117185 +city_dhaka,1984,MONTH_jan,0.06105583190917969 +city_dhaka,1985,MONTH_jan,0.04526681423187256 +city_dhaka,1986,MONTH_jan,0.025327975749969478 +city_dhaka,1987,MONTH_jan,0.026365013122558595 +city_dhaka,1988,MONTH_jan,0.030908639430999755 +city_dhaka,1989,MONTH_jan,0.03907864093780518 +city_dhaka,1990,MONTH_jan,0.03539271354675293 +city_dhaka,1991,MONTH_jan,0.03477609157562256 +city_dhaka,1992,MONTH_jan,0.030288853645324708 +city_dhaka,1993,MONTH_jan,0.02104328870773315 +city_dhaka,1994,MONTH_jan,0.02761680603027344 +city_dhaka,1995,MONTH_jan,0.010269947052001951 +city_dhaka,1996,MONTH_jan,0.01947564125061035 +city_dhaka,1997,MONTH_jan,0.018034275770187375 +city_dhaka,1998,MONTH_jan,0.020371236801147462 +city_dhaka,1999,MONTH_jan,0.0193972909450531 +city_dhaka,2000,MONTH_jan,0.016270726919174194 +city_dhaka,2001,MONTH_jan,0.01875003218650818 +city_dhaka,2002,MONTH_jan,0.01362207531929016 +city_dhaka,2003,MONTH_jan,0.012784041166305542 +city_dhaka,2004,MONTH_jan,0.012296963930130005 +city_dhaka,2005,MONTH_jan,0.011353458166122437 +city_dhaka,2006,MONTH_jan,0.010463094711303711 +city_dhaka,2007,MONTH_jan,0.010207374095916748 +city_dhaka,2008,MONTH_jan,0.012218128442764282 +city_dhaka,2009,MONTH_jan,0.0051176011562347416 +city_dhaka,2010,MONTH_jan,0.008648931980133057 +city_dhaka,2011,MONTH_jan,0.009513694643974304 +city_dhaka,2012,MONTH_jan,0.008256486654281615 +city_dhaka,2013,MONTH_jan,0.007885019183158875 +city_dhaka,2014,MONTH_jan,0.0064616197347640994 +city_dhaka,2015,MONTH_jan,0.008184085488319398 +city_dhaka,2016,MONTH_jan,0.008060975074768066 +city_dhaka,2017,MONTH_jan,0.00894644320011139 +city_dhaka,2018,MONTH_jan,0.007471175193786621 +city_dhaka,2019,MONTH_jan,0.00675128698348999 +city_dhaka,2020,MONTH_jan,0.006580818295478821 +city_dhaka,2021,MONTH_jan,0.0065014690160751345 +city_brasilia,1965,MONTH_jan,0.2754872131347656 +city_brasilia,1966,MONTH_jan,0.27618213653564455 +city_brasilia,1967,MONTH_jan,0.27880290985107425 +city_brasilia,1968,MONTH_jan,0.2555575370788575 +city_brasilia,1969,MONTH_jan,0.2505621910095215 +city_brasilia,1970,MONTH_jan,0.2690108108520508 +city_brasilia,1971,MONTH_jan,0.26817771911621097 +city_brasilia,1972,MONTH_jan,0.2739073371887207 +city_brasilia,1973,MONTH_jan,0.2610169982910156 +city_brasilia,1974,MONTH_jan,0.2692813491821289 +city_brasilia,1975,MONTH_jan,0.279958610534668 +city_brasilia,1976,MONTH_jan,0.2916008758544922 +city_brasilia,1977,MONTH_jan,0.3108434295654297 +city_brasilia,1978,MONTH_jan,0.31529354095458983 +city_brasilia,1979,MONTH_jan,0.3338748931884766 +city_brasilia,1980,MONTH_jan,0.3618800735473633 +city_brasilia,1981,MONTH_jan,0.3750487899780273 +city_brasilia,1982,MONTH_jan,0.3909782028198242 +city_brasilia,1983,MONTH_jan,0.41867771148681643 +city_brasilia,1984,MONTH_jan,0.43218948364257814 +city_brasilia,1985,MONTH_jan,0.43929534912109375 +city_brasilia,1986,MONTH_jan,0.4321952438354492 +city_brasilia,1987,MONTH_jan,0.42777210235595703 +city_brasilia,1988,MONTH_jan,0.4401119613647461 +city_brasilia,1989,MONTH_jan,0.44574317932128904 +city_brasilia,1990,MONTH_jan,0.4527548599243164 +city_brasilia,1991,MONTH_jan,0.4586178970336914 +city_brasilia,1992,MONTH_jan,0.44902706146240234 +city_brasilia,1993,MONTH_jan,0.4515962982177734 +city_brasilia,1994,MONTH_jan,0.44565601348876954 +city_brasilia,1995,MONTH_jan,0.4434580993652344 +city_brasilia,1996,MONTH_jan,0.44081958770751956 +city_brasilia,1997,MONTH_jan,0.43489933013916016 +city_brasilia,1998,MONTH_jan,0.43571971893310546 +city_brasilia,1999,MONTH_jan,0.43143802642822265 +city_brasilia,2000,MONTH_jan,0.4328843307495117 +city_brasilia,2001,MONTH_jan,0.39111621856689455 +city_brasilia,2002,MONTH_jan,0.4075665283203125 +city_brasilia,2003,MONTH_jan,0.4228412628173828 +city_brasilia,2004,MONTH_jan,0.4228615570068359 +city_brasilia,2005,MONTH_jan,0.4314569854736328 +city_brasilia,2006,MONTH_jan,0.4304596328735352 +city_brasilia,2007,MONTH_jan,0.4438022613525391 +city_brasilia,2008,MONTH_jan,0.4336677551269531 +city_brasilia,2009,MONTH_jan,0.4630883026123047 +city_brasilia,2010,MONTH_jan,0.4424653625488281 +city_brasilia,2011,MONTH_jan,0.4391006088256836 +city_brasilia,2012,MONTH_jan,0.42066368103027346 +city_brasilia,2013,MONTH_jan,0.39836597442626953 +city_brasilia,2014,MONTH_jan,0.38852745056152344 +city_brasilia,2015,MONTH_jan,0.4060352325439453 +city_brasilia,2016,MONTH_jan,0.43538700103759764 +city_brasilia,2017,MONTH_jan,0.4328067779541016 +city_brasilia,2018,MONTH_jan,0.46080497741699217 +city_brasilia,2019,MONTH_jan,0.4730484390258789 +city_brasilia,2020,MONTH_jan,0.4947188186645508 +city_brasilia,2021,MONTH_jan,0.46219749450683595 +city_ottawa,1965,MONTH_jan,0.2513864898681641 +city_ottawa,1966,MONTH_jan,0.2619474792480469 +city_ottawa,1967,MONTH_jan,0.2561042594909668 +city_ottawa,1968,MONTH_jan,0.24474010467529297 +city_ottawa,1969,MONTH_jan,0.25521268844604494 +city_ottawa,1970,MONTH_jan,0.2502507591247558 +city_ottawa,1971,MONTH_jan,0.24927824020385747 +city_ottawa,1972,MONTH_jan,0.25893644332885746 +city_ottawa,1973,MONTH_jan,0.2555288314819336 +city_ottawa,1974,MONTH_jan,0.2681158256530762 +city_ottawa,1975,MONTH_jan,0.2615631484985352 +city_ottawa,1976,MONTH_jan,0.2633203506469727 +city_ottawa,1977,MONTH_jan,0.25808473587036135 +city_ottawa,1978,MONTH_jan,0.2705876922607422 +city_ottawa,1979,MONTH_jan,0.2729702377319336 +city_ottawa,1980,MONTH_jan,0.2753968620300293 +city_ottawa,1981,MONTH_jan,0.29403928756713865 +city_ottawa,1982,MONTH_jan,0.29416236877441404 +city_ottawa,1983,MONTH_jan,0.30499225616455083 +city_ottawa,1984,MONTH_jan,0.30855842590332033 +city_ottawa,1985,MONTH_jan,0.3161163330078125 +city_ottawa,1986,MONTH_jan,0.32045928955078123 +city_ottawa,1987,MONTH_jan,0.316495418548584 +city_ottawa,1988,MONTH_jan,0.29611337661743165 +city_ottawa,1989,MONTH_jan,0.2781739616394043 +city_ottawa,1990,MONTH_jan,0.29480998992919916 +city_ottawa,1991,MONTH_jan,0.30499427795410156 +city_ottawa,1992,MONTH_jan,0.30512109756469724 +city_ottawa,1993,MONTH_jan,0.3045089340209961 +city_ottawa,1994,MONTH_jan,0.2992730140686035 +city_ottawa,1995,MONTH_jan,0.2988811683654785 +city_ottawa,1996,MONTH_jan,0.3087930679321289 +city_ottawa,1997,MONTH_jan,0.3028490447998047 +city_ottawa,1998,MONTH_jan,0.29307371139526367 +city_ottawa,1999,MONTH_jan,0.29588794708251953 +city_ottawa,2000,MONTH_jan,0.297678165435791 +city_ottawa,2001,MONTH_jan,0.282014102935791 +city_ottawa,2002,MONTH_jan,0.2854655647277832 +city_ottawa,2003,MONTH_jan,0.2718001365661621 +city_ottawa,2004,MONTH_jan,0.2682792282104492 +city_ottawa,2005,MONTH_jan,0.2826547622680664 +city_ottawa,2006,MONTH_jan,0.2761646842956543 +city_ottawa,2007,MONTH_jan,0.2769431495666504 +city_ottawa,2008,MONTH_jan,0.2859009170532227 +city_ottawa,2009,MONTH_jan,0.2920944976806641 +city_ottawa,2010,MONTH_jan,0.27789688110351557 +city_ottawa,2011,MONTH_jan,0.2862636947631836 +city_ottawa,2012,MONTH_jan,0.2897691345214844 +city_ottawa,2013,MONTH_jan,0.2894182777404785 +city_ottawa,2014,MONTH_jan,0.2814776039123535 +city_ottawa,2015,MONTH_jan,0.2876414680480957 +city_ottawa,2016,MONTH_jan,0.29652599334716795 +city_ottawa,2017,MONTH_jan,0.2967363929748535 +city_ottawa,2018,MONTH_jan,0.28814517974853515 +city_ottawa,2019,MONTH_jan,0.2858637619018555 +city_ottawa,2020,MONTH_jan,0.3054215049743652 +city_ottawa,2021,MONTH_jan,0.29888439178466797 +city_chengdu,1965,MONTH_jan,0.042534070014953615 +city_beijing,1965,MONTH_jan,0.042534070014953615 +city_chengdu,1966,MONTH_jan,0.039831228256225586 +city_beijing,1966,MONTH_jan,0.039831228256225586 +city_chengdu,1967,MONTH_jan,0.038183979988098145 +city_beijing,1967,MONTH_jan,0.038183979988098145 +city_chengdu,1968,MONTH_jan,0.04458870887756348 +city_beijing,1968,MONTH_jan,0.04458870887756348 +city_chengdu,1969,MONTH_jan,0.03727402210235596 +city_beijing,1969,MONTH_jan,0.03727402210235596 +city_chengdu,1970,MONTH_jan,0.03009592294692993 +city_beijing,1970,MONTH_jan,0.03009592294692993 +city_chengdu,1971,MONTH_jan,0.030704047679901123 +city_beijing,1971,MONTH_jan,0.030704047679901123 +city_chengdu,1972,MONTH_jan,0.0322759747505188 +city_beijing,1972,MONTH_jan,0.0322759747505188 +city_chengdu,1973,MONTH_jan,0.03417015075683594 +city_beijing,1973,MONTH_jan,0.03417015075683594 +city_chengdu,1974,MONTH_jan,0.03749354600906372 +city_beijing,1974,MONTH_jan,0.03749354600906372 +city_chengdu,1975,MONTH_jan,0.035038237571716306 +city_beijing,1975,MONTH_jan,0.035038237571716306 +city_chengdu,1976,MONTH_jan,0.03372568368911743 +city_beijing,1976,MONTH_jan,0.03372568368911743 +city_chengdu,1977,MONTH_jan,0.03228713989257812 +city_beijing,1977,MONTH_jan,0.03228713989257812 +city_chengdu,1978,MONTH_jan,0.027594637870788575 +city_beijing,1978,MONTH_jan,0.027594637870788575 +city_chengdu,1979,MONTH_jan,0.03008899211883545 +city_beijing,1979,MONTH_jan,0.03008899211883545 +city_chengdu,1980,MONTH_jan,0.035661976337432864 +city_beijing,1980,MONTH_jan,0.035661976337432864 +city_chengdu,1981,MONTH_jan,0.040664968490600584 +city_beijing,1981,MONTH_jan,0.040664968490600584 +city_chengdu,1982,MONTH_jan,0.044212722778320314 +city_beijing,1982,MONTH_jan,0.044212722778320314 +city_chengdu,1983,MONTH_jan,0.048234906196594235 +city_beijing,1983,MONTH_jan,0.048234906196594235 +city_chengdu,1984,MONTH_jan,0.045154547691345213 +city_beijing,1984,MONTH_jan,0.045154547691345213 +city_chengdu,1985,MONTH_jan,0.04441830158233642 +city_beijing,1985,MONTH_jan,0.04441830158233642 +city_chengdu,1986,MONTH_jan,0.043385276794433596 +city_beijing,1986,MONTH_jan,0.043385276794433596 +city_chengdu,1987,MONTH_jan,0.04255547523498535 +city_beijing,1987,MONTH_jan,0.04255547523498535 +city_chengdu,1988,MONTH_jan,0.043230724334716794 +city_beijing,1988,MONTH_jan,0.043230724334716794 +city_chengdu,1989,MONTH_jan,0.044680271148681644 +city_beijing,1989,MONTH_jan,0.044680271148681644 +city_chengdu,1990,MONTH_jan,0.04723667621612549 +city_beijing,1990,MONTH_jan,0.04723667621612549 +city_chengdu,1991,MONTH_jan,0.04424777984619141 +city_beijing,1991,MONTH_jan,0.04424777984619141 +city_chengdu,1992,MONTH_jan,0.04412701606750488 +city_beijing,1992,MONTH_jan,0.04412701606750488 +city_chengdu,1993,MONTH_jan,0.04757860660552979 +city_beijing,1993,MONTH_jan,0.04757860660552979 +city_chengdu,1994,MONTH_jan,0.04952474117279053 +city_beijing,1994,MONTH_jan,0.04952474117279053 +city_chengdu,1995,MONTH_jan,0.05553820133209229 +city_beijing,1995,MONTH_jan,0.05553820133209229 +city_chengdu,1996,MONTH_jan,0.05143133163452149 +city_beijing,1996,MONTH_jan,0.05143133163452149 +city_chengdu,1997,MONTH_jan,0.05361733913421631 +city_beijing,1997,MONTH_jan,0.05361733913421631 +city_chengdu,1998,MONTH_jan,0.054277782440185544 +city_beijing,1998,MONTH_jan,0.054277782440185544 +city_chengdu,1999,MONTH_jan,0.05188285827636719 +city_beijing,1999,MONTH_jan,0.05188285827636719 +city_chengdu,2000,MONTH_jan,0.05656925201416016 +city_beijing,2000,MONTH_jan,0.05656925201416016 +city_chengdu,2001,MONTH_jan,0.06618624210357665 +city_beijing,2001,MONTH_jan,0.06618624210357665 +city_chengdu,2002,MONTH_jan,0.0628048849105835 +city_beijing,2002,MONTH_jan,0.0628048849105835 +city_chengdu,2003,MONTH_jan,0.05301109313964844 +city_beijing,2003,MONTH_jan,0.05301109313964844 +city_chengdu,2004,MONTH_jan,0.05600940227508545 +city_beijing,2004,MONTH_jan,0.05600940227508545 +city_chengdu,2005,MONTH_jan,0.05554481029510498 +city_beijing,2005,MONTH_jan,0.05554481029510498 +city_chengdu,2006,MONTH_jan,0.055779824256896975 +city_beijing,2006,MONTH_jan,0.055779824256896975 +city_chengdu,2007,MONTH_jan,0.0571853494644165 +city_beijing,2007,MONTH_jan,0.0571853494644165 +city_chengdu,2008,MONTH_jan,0.07268667221069336 +city_beijing,2008,MONTH_jan,0.07268667221069336 +city_chengdu,2009,MONTH_jan,0.06935531616210938 +city_beijing,2009,MONTH_jan,0.06935531616210938 +city_chengdu,2010,MONTH_jan,0.07615997791290283 +city_beijing,2010,MONTH_jan,0.07615997791290283 +city_chengdu,2011,MONTH_jan,0.07084204196929932 +city_beijing,2011,MONTH_jan,0.07084204196929932 +city_chengdu,2012,MONTH_jan,0.08522597312927246 +city_beijing,2012,MONTH_jan,0.08522597312927246 +city_chengdu,2013,MONTH_jan,0.08959421157836914 +city_beijing,2013,MONTH_jan,0.08959421157836914 +city_chengdu,2014,MONTH_jan,0.10197330474853515 +city_beijing,2014,MONTH_jan,0.10197330474853515 +city_chengdu,2015,MONTH_jan,0.10787498474121093 +city_beijing,2015,MONTH_jan,0.10787498474121093 +city_chengdu,2016,MONTH_jan,0.11530946731567385 +city_beijing,2016,MONTH_jan,0.11530946731567385 +city_chengdu,2017,MONTH_jan,0.12138820648193359 +city_beijing,2017,MONTH_jan,0.12138820648193359 +city_chengdu,2018,MONTH_jan,0.12807393074035645 +city_beijing,2018,MONTH_jan,0.12807393074035645 +city_chengdu,2019,MONTH_jan,0.1351595973968506 +city_beijing,2019,MONTH_jan,0.1351595973968506 +city_chengdu,2020,MONTH_jan,0.1424287223815918 +city_beijing,2020,MONTH_jan,0.1424287223815918 +city_chengdu,2021,MONTH_jan,0.14946244239807127 +city_beijing,2021,MONTH_jan,0.14946244239807127 +city_bogota,1965,MONTH_jan,0.11788208961486817 +city_bogota,1966,MONTH_jan,0.12017394065856933 +city_bogota,1967,MONTH_jan,0.12580106735229493 +city_bogota,1968,MONTH_jan,0.13300461769104005 +city_bogota,1969,MONTH_jan,0.1452613925933838 +city_bogota,1970,MONTH_jan,0.14817516326904298 +city_bogota,1971,MONTH_jan,0.15987798690795899 +city_bogota,1972,MONTH_jan,0.15767953872680665 +city_bogota,1973,MONTH_jan,0.17170427322387696 +city_bogota,1974,MONTH_jan,0.17395509719848634 +city_bogota,1975,MONTH_jan,0.19235607147216796 +city_bogota,1976,MONTH_jan,0.1940712547302246 +city_bogota,1977,MONTH_jan,0.1936701011657715 +city_bogota,1978,MONTH_jan,0.20862884521484376 +city_bogota,1979,MONTH_jan,0.2154510498046875 +city_bogota,1980,MONTH_jan,0.23044971466064454 +city_bogota,1981,MONTH_jan,0.2221888542175293 +city_bogota,1982,MONTH_jan,0.22697723388671875 +city_bogota,1983,MONTH_jan,0.2179018783569336 +city_bogota,1984,MONTH_jan,0.23639833450317382 +city_bogota,1985,MONTH_jan,0.2444196128845215 +city_bogota,1986,MONTH_jan,0.27276325225830084 +city_bogota,1987,MONTH_jan,0.2731085395812988 +city_bogota,1988,MONTH_jan,0.28748077392578125 +city_bogota,1989,MONTH_jan,0.29793998718261716 +city_bogota,1990,MONTH_jan,0.32640933990478516 +city_bogota,1991,MONTH_jan,0.3169980049133301 +city_bogota,1992,MONTH_jan,0.2460545539855957 +city_bogota,1993,MONTH_jan,0.27847396850585937 +city_bogota,1994,MONTH_jan,0.2980908203125 +city_bogota,1995,MONTH_jan,0.2933157730102539 +city_bogota,1996,MONTH_jan,0.31475914001464844 +city_bogota,1997,MONTH_jan,0.27334064483642573 +city_bogota,1998,MONTH_jan,0.26691463470458987 +city_bogota,1999,MONTH_jan,0.3137824821472168 +city_bogota,2000,MONTH_jan,0.29556066513061524 +city_bogota,2001,MONTH_jan,0.3060448455810547 +city_bogota,2002,MONTH_jan,0.32692554473876956 +city_bogota,2003,MONTH_jan,0.3338913345336914 +city_bogota,2004,MONTH_jan,0.3450545501708984 +city_bogota,2005,MONTH_jan,0.35053531646728514 +city_bogota,2006,MONTH_jan,0.34142719268798827 +city_bogota,2007,MONTH_jan,0.35182762145996094 +city_bogota,2008,MONTH_jan,0.33941410064697264 +city_bogota,2009,MONTH_jan,0.31377744674682617 +city_bogota,2010,MONTH_jan,0.30092037200927735 +city_bogota,2011,MONTH_jan,0.34515674591064455 +city_bogota,2012,MONTH_jan,0.3174613380432129 +city_bogota,2013,MONTH_jan,0.29385107040405273 +city_bogota,2014,MONTH_jan,0.2836468505859375 +city_bogota,2015,MONTH_jan,0.280216178894043 +city_bogota,2016,MONTH_jan,0.2770881271362305 +city_bogota,2017,MONTH_jan,0.3282905960083008 +city_bogota,2018,MONTH_jan,0.31999549865722654 +city_bogota,2019,MONTH_jan,0.29890342712402346 +city_bogota,2020,MONTH_jan,0.3077278709411621 +city_bogota,2021,MONTH_jan,0.33020408630371095 +city_quito,1965,MONTH_jan,0.0850521469116211 +city_quito,1966,MONTH_jan,0.0924820613861084 +city_quito,1967,MONTH_jan,0.09417126655578612 +city_quito,1968,MONTH_jan,0.08330953598022461 +city_quito,1969,MONTH_jan,0.08701672554016113 +city_quito,1970,MONTH_jan,0.08106535911560059 +city_quito,1971,MONTH_jan,0.08015813827514648 +city_quito,1972,MONTH_jan,0.07758965969085693 +city_quito,1973,MONTH_jan,0.07086233615875244 +city_quito,1974,MONTH_jan,0.06978053569793702 +city_quito,1975,MONTH_jan,0.08653943061828613 +city_quito,1976,MONTH_jan,0.07572480201721192 +city_quito,1977,MONTH_jan,0.05873260498046875 +city_quito,1978,MONTH_jan,0.07960052967071533 +city_quito,1979,MONTH_jan,0.0685176420211792 +city_quito,1980,MONTH_jan,0.06642500877380371 +city_quito,1981,MONTH_jan,0.05350114345550537 +city_quito,1982,MONTH_jan,0.0559368371963501 +city_quito,1983,MONTH_jan,0.10982114791870115 +city_quito,1984,MONTH_jan,0.18537538528442382 +city_quito,1985,MONTH_jan,0.15903298377990724 +city_quito,1986,MONTH_jan,0.18563940048217772 +city_quito,1987,MONTH_jan,0.2051675033569336 +city_quito,1988,MONTH_jan,0.18759294509887695 +city_quito,1989,MONTH_jan,0.1867353248596191 +city_quito,1990,MONTH_jan,0.18208444595336912 +city_quito,1991,MONTH_jan,0.16781824111938476 +city_quito,1992,MONTH_jan,0.1652834701538086 +city_quito,1993,MONTH_jan,0.18627613067626952 +city_quito,1994,MONTH_jan,0.19351001739501952 +city_quito,1995,MONTH_jan,0.160936336517334 +city_quito,1996,MONTH_jan,0.17381893157958983 +city_quito,1997,MONTH_jan,0.16071613311767577 +city_quito,1998,MONTH_jan,0.15920068740844728 +city_quito,1999,MONTH_jan,0.19251895904541017 +city_quito,2000,MONTH_jan,0.21613927841186523 +city_quito,2001,MONTH_jan,0.19692354202270507 +city_quito,2002,MONTH_jan,0.21095178604125978 +city_quito,2003,MONTH_jan,0.19533443450927734 +city_quito,2004,MONTH_jan,0.1873490524291992 +city_quito,2005,MONTH_jan,0.1659660530090332 +city_quito,2006,MONTH_jan,0.16251609802246095 +city_quito,2007,MONTH_jan,0.1955727195739746 +city_quito,2008,MONTH_jan,0.22617521286010744 +city_quito,2009,MONTH_jan,0.18929243087768555 +city_quito,2010,MONTH_jan,0.15936485290527344 +city_quito,2011,MONTH_jan,0.19198841094970703 +city_quito,2012,MONTH_jan,0.19840085983276368 +city_quito,2013,MONTH_jan,0.1737746238708496 +city_quito,2014,MONTH_jan,0.1727614212036133 +city_quito,2015,MONTH_jan,0.19640232086181642 +city_quito,2016,MONTH_jan,0.2362802505493164 +city_quito,2017,MONTH_jan,0.2833585739135743 +city_quito,2018,MONTH_jan,0.2738693428039551 +city_quito,2019,MONTH_jan,0.31769020080566407 +city_quito,2020,MONTH_jan,0.3603577423095703 +city_quito,2021,MONTH_jan,0.32354198455810546 +city_cairo,1965,MONTH_jan,0.055878944396972656 +city_cairo,1966,MONTH_jan,0.055950436592102054 +city_cairo,1967,MONTH_jan,0.07041625022888183 +city_cairo,1968,MONTH_jan,0.09956792831420898 +city_cairo,1969,MONTH_jan,0.16082429885864258 +city_cairo,1970,MONTH_jan,0.1516463565826416 +city_cairo,1971,MONTH_jan,0.1587799835205078 +city_cairo,1972,MONTH_jan,0.14635689735412596 +city_cairo,1973,MONTH_jan,0.15458051681518556 +city_cairo,1974,MONTH_jan,0.16143081665039063 +city_cairo,1975,MONTH_jan,0.16160579681396484 +city_cairo,1976,MONTH_jan,0.15923643112182614 +city_cairo,1977,MONTH_jan,0.16571006774902344 +city_cairo,1978,MONTH_jan,0.17237102508544921 +city_cairo,1979,MONTH_jan,0.15267534255981444 +city_cairo,1980,MONTH_jan,0.13694029808044433 +city_cairo,1981,MONTH_jan,0.12526339530944824 +city_cairo,1982,MONTH_jan,0.11533038139343262 +city_cairo,1983,MONTH_jan,0.09980415344238279 +city_cairo,1984,MONTH_jan,0.08979602813720704 +city_cairo,1985,MONTH_jan,0.08225811958312988 +city_cairo,1986,MONTH_jan,0.07888433456420899 +city_cairo,1987,MONTH_jan,0.0743703556060791 +city_cairo,1988,MONTH_jan,0.07214404582977295 +city_cairo,1989,MONTH_jan,0.07353952407836914 +city_cairo,1990,MONTH_jan,0.07520865440368653 +city_cairo,1991,MONTH_jan,0.07396338939666748 +city_cairo,1992,MONTH_jan,0.07380685806274415 +city_cairo,1993,MONTH_jan,0.07595428943634033 +city_cairo,1994,MONTH_jan,0.07676783084869385 +city_cairo,1995,MONTH_jan,0.07558946132659912 +city_cairo,1996,MONTH_jan,0.07361753940582276 +city_cairo,1997,MONTH_jan,0.07243848800659179 +city_cairo,1998,MONTH_jan,0.07154178619384766 +city_cairo,1999,MONTH_jan,0.07409151077270508 +city_cairo,2000,MONTH_jan,0.07416068077087402 +city_cairo,2001,MONTH_jan,0.07225909233093261 +city_cairo,2002,MONTH_jan,0.06795775890350342 +city_cairo,2003,MONTH_jan,0.059376978874206544 +city_cairo,2004,MONTH_jan,0.05634644031524658 +city_cairo,2005,MONTH_jan,0.05385705947875977 +city_cairo,2006,MONTH_jan,0.05172313690185547 +city_cairo,2007,MONTH_jan,0.053631553649902346 +city_cairo,2008,MONTH_jan,0.05414237022399902 +city_cairo,2009,MONTH_jan,0.04800594806671143 +city_cairo,2010,MONTH_jan,0.04461719036102295 +city_cairo,2011,MONTH_jan,0.04331544399261475 +city_cairo,2012,MONTH_jan,0.041802897453308105 +city_cairo,2013,MONTH_jan,0.04177184581756592 +city_cairo,2014,MONTH_jan,0.04181652545928955 +city_cairo,2015,MONTH_jan,0.043288531303405764 +city_cairo,2016,MONTH_jan,0.041314678192138674 +city_cairo,2017,MONTH_jan,0.038699905872344974 +city_cairo,2018,MONTH_jan,0.04055405616760254 +city_cairo,2019,MONTH_jan,0.05169897556304932 +city_cairo,2020,MONTH_jan,0.06564623832702637 +city_cairo,2021,MONTH_jan,0.06230570793151855 +city_paris,1965,MONTH_jan,0.10584983825683594 +city_paris,1966,MONTH_jan,0.1160239315032959 +city_paris,1967,MONTH_jan,0.09537199020385742 +city_paris,1968,MONTH_jan,0.10092880249023438 +city_paris,1969,MONTH_jan,0.09634167671203611 +city_paris,1970,MONTH_jan,0.09537435531616213 +city_paris,1971,MONTH_jan,0.07942842483520508 +city_paris,1972,MONTH_jan,0.07446317195892334 +city_paris,1973,MONTH_jan,0.06709061622619629 +city_paris,1974,MONTH_jan,0.08016220092773438 +city_paris,1975,MONTH_jan,0.09053054809570313 +city_paris,1976,MONTH_jan,0.06899677753448487 +city_paris,1977,MONTH_jan,0.1059511947631836 +city_paris,1978,MONTH_jan,0.09109526634216308 +city_paris,1979,MONTH_jan,0.08611678123474122 +city_paris,1980,MONTH_jan,0.09114398002624512 +city_paris,1981,MONTH_jan,0.09551752090454102 +city_paris,1982,MONTH_jan,0.09705157279968261 +city_paris,1983,MONTH_jan,0.09325616836547851 +city_paris,1984,MONTH_jan,0.08554503440856934 +city_paris,1985,MONTH_jan,0.07887791156768799 +city_paris,1986,MONTH_jan,0.07764792442321777 +city_paris,1987,MONTH_jan,0.0858464527130127 +city_paris,1988,MONTH_jan,0.09174312591552734 +city_paris,1989,MONTH_jan,0.055997366905212405 +city_paris,1990,MONTH_jan,0.06222640991210938 +city_paris,1991,MONTH_jan,0.0626654052734375 +city_paris,1992,MONTH_jan,0.07399243831634522 +city_paris,1993,MONTH_jan,0.06968883514404296 +city_paris,1994,MONTH_jan,0.08563506126403808 +city_paris,1995,MONTH_jan,0.07823903083801269 +city_paris,1996,MONTH_jan,0.06882894039154053 +city_paris,1997,MONTH_jan,0.0680388879776001 +city_paris,1998,MONTH_jan,0.06470213890075684 +city_paris,1999,MONTH_jan,0.07388863086700441 +city_paris,2000,MONTH_jan,0.06744560718536377 +city_paris,2001,MONTH_jan,0.07405366897583007 +city_paris,2002,MONTH_jan,0.06175621032714844 +city_paris,2003,MONTH_jan,0.059621820449829104 +city_paris,2004,MONTH_jan,0.05970314979553223 +city_paris,2005,MONTH_jan,0.05365334033966065 +city_paris,2006,MONTH_jan,0.059697318077087405 +city_paris,2007,MONTH_jan,0.06638713359832764 +city_paris,2008,MONTH_jan,0.07632267475128174 +city_paris,2009,MONTH_jan,0.0770644998550415 +city_paris,2010,MONTH_jan,0.08220292091369628 +city_paris,2011,MONTH_jan,0.0718551778793335 +city_paris,2012,MONTH_jan,0.0913736343383789 +city_paris,2013,MONTH_jan,0.10459434509277343 +city_paris,2014,MONTH_jan,0.1045927906036377 +city_paris,2015,MONTH_jan,0.10147398948669434 +city_paris,2016,MONTH_jan,0.1097524642944336 +city_paris,2017,MONTH_jan,0.10437264442443847 +city_paris,2018,MONTH_jan,0.12132494926452636 +city_paris,2019,MONTH_jan,0.12384904861450195 +city_paris,2020,MONTH_jan,0.1478874683380127 +city_paris,2021,MONTH_jan,0.13671010971069336 +city_berlin,1965,MONTH_jan,0.016145030260086058 +city_berlin,1966,MONTH_jan,0.01741612911224365 +city_berlin,1967,MONTH_jan,0.01658253788948059 +city_berlin,1968,MONTH_jan,0.01576139807701111 +city_berlin,1969,MONTH_jan,0.011857671737670899 +city_berlin,1970,MONTH_jan,0.015171291828155518 +city_berlin,1971,MONTH_jan,0.01179680585861206 +city_berlin,1972,MONTH_jan,0.011219959259033203 +city_berlin,1973,MONTH_jan,0.012137141227722168 +city_berlin,1974,MONTH_jan,0.014188613891601563 +city_berlin,1975,MONTH_jan,0.014353294372558594 +city_berlin,1976,MONTH_jan,0.011208523511886597 +city_berlin,1977,MONTH_jan,0.013967294692993164 +city_berlin,1978,MONTH_jan,0.01408961057662964 +city_berlin,1979,MONTH_jan,0.013454017639160156 +city_berlin,1980,MONTH_jan,0.01478190541267395 +city_berlin,1981,MONTH_jan,0.015739785432815553 +city_berlin,1982,MONTH_jan,0.01617851257324219 +city_berlin,1983,MONTH_jan,0.014992613792419434 +city_berlin,1984,MONTH_jan,0.0143718421459198 +city_berlin,1985,MONTH_jan,0.013216147422790528 +city_berlin,1986,MONTH_jan,0.014105298519134519 +city_berlin,1987,MONTH_jan,0.015094993114471435 +city_berlin,1988,MONTH_jan,0.015009332895278931 +city_berlin,1989,MONTH_jan,0.013991726636886597 +city_berlin,1990,MONTH_jan,0.013369400501251221 +city_berlin,1991,MONTH_jan,0.012709577083587647 +city_berlin,1992,MONTH_jan,0.015204551219940186 +city_berlin,1993,MONTH_jan,0.01583544135093689 +city_berlin,1994,MONTH_jan,0.01739633440971374 +city_berlin,1995,MONTH_jan,0.01889189839363098 +city_berlin,1996,MONTH_jan,0.016823945045471193 +city_berlin,1997,MONTH_jan,0.018035167455673216 +city_berlin,1998,MONTH_jan,0.019705649614334103 +city_berlin,1999,MONTH_jan,0.02227585792541504 +city_berlin,2000,MONTH_jan,0.028871116638183595 +city_berlin,2001,MONTH_jan,0.029411675930023192 +city_berlin,2002,MONTH_jan,0.03538631916046143 +city_berlin,2003,MONTH_jan,0.03641989707946778 +city_berlin,2004,MONTH_jan,0.04516597747802734 +city_berlin,2005,MONTH_jan,0.052084193229675294 +city_berlin,2006,MONTH_jan,0.060263047218322756 +city_berlin,2007,MONTH_jan,0.07653833389282226 +city_berlin,2008,MONTH_jan,0.07817628383636474 +city_berlin,2009,MONTH_jan,0.08454279899597168 +city_berlin,2010,MONTH_jan,0.08792469024658203 +city_berlin,2011,MONTH_jan,0.10566965103149414 +city_berlin,2012,MONTH_jan,0.11899699211120604 +city_berlin,2013,MONTH_jan,0.12063335418701172 +city_berlin,2014,MONTH_jan,0.13278846740722655 +city_berlin,2015,MONTH_jan,0.14823543548583984 +city_berlin,2016,MONTH_jan,0.14607312202453612 +city_berlin,2017,MONTH_jan,0.16196212768554688 +city_berlin,2018,MONTH_jan,0.17084951400756837 +city_berlin,2019,MONTH_jan,0.18768304824829102 +city_berlin,2020,MONTH_jan,0.21122827529907226 +city_berlin,2021,MONTH_jan,0.19453121185302735 +city_new_delhi,1965,MONTH_jan,0.09149455070495603 +city_mumbai,1965,MONTH_jan,0.09149455070495603 +city_new_delhi,1966,MONTH_jan,0.09270711898803713 +city_mumbai,1966,MONTH_jan,0.09270711898803713 +city_new_delhi,1967,MONTH_jan,0.10058605194091796 +city_mumbai,1967,MONTH_jan,0.10058605194091796 +city_new_delhi,1968,MONTH_jan,0.10857532501220703 +city_mumbai,1968,MONTH_jan,0.10857532501220703 +city_new_delhi,1969,MONTH_jan,0.10873967170715332 +city_mumbai,1969,MONTH_jan,0.10873967170715332 +city_new_delhi,1970,MONTH_jan,0.11784119606018066 +city_mumbai,1970,MONTH_jan,0.11784119606018066 +city_new_delhi,1971,MONTH_jan,0.1242677116394043 +city_mumbai,1971,MONTH_jan,0.1242677116394043 +city_new_delhi,1972,MONTH_jan,0.11463116645812989 +city_mumbai,1972,MONTH_jan,0.11463116645812989 +city_new_delhi,1973,MONTH_jan,0.11957463264465332 +city_mumbai,1973,MONTH_jan,0.11957463264465332 +city_new_delhi,1974,MONTH_jan,0.1086085319519043 +city_mumbai,1974,MONTH_jan,0.1086085319519043 +city_new_delhi,1975,MONTH_jan,0.12067704200744628 +city_mumbai,1975,MONTH_jan,0.12067704200744628 +city_new_delhi,1976,MONTH_jan,0.12036797523498535 +city_mumbai,1976,MONTH_jan,0.12036797523498535 +city_new_delhi,1977,MONTH_jan,0.12415875434875488 +city_mumbai,1977,MONTH_jan,0.12415875434875488 +city_new_delhi,1978,MONTH_jan,0.14818278312683103 +city_mumbai,1978,MONTH_jan,0.14818278312683103 +city_new_delhi,1979,MONTH_jan,0.13540278434753417 +city_mumbai,1979,MONTH_jan,0.13540278434753417 +city_new_delhi,1980,MONTH_jan,0.1345311737060547 +city_mumbai,1980,MONTH_jan,0.1345311737060547 +city_new_delhi,1981,MONTH_jan,0.12948171615600587 +city_mumbai,1981,MONTH_jan,0.12948171615600587 +city_new_delhi,1982,MONTH_jan,0.11035112380981443 +city_mumbai,1982,MONTH_jan,0.11035112380981443 +city_new_delhi,1983,MONTH_jan,0.10110920906066896 +city_mumbai,1983,MONTH_jan,0.10110920906066896 +city_new_delhi,1984,MONTH_jan,0.10576085090637209 +city_mumbai,1984,MONTH_jan,0.10576085090637209 +city_new_delhi,1985,MONTH_jan,0.09670783996582032 +city_mumbai,1985,MONTH_jan,0.09670783996582032 +city_new_delhi,1986,MONTH_jan,0.0916761875152588 +city_mumbai,1986,MONTH_jan,0.0916761875152588 +city_new_delhi,1987,MONTH_jan,0.08030695915222168 +city_mumbai,1987,MONTH_jan,0.08030695915222168 +city_new_delhi,1988,MONTH_jan,0.08229918479919433 +city_mumbai,1988,MONTH_jan,0.08229918479919433 +city_new_delhi,1989,MONTH_jan,0.08742303848266601 +city_mumbai,1989,MONTH_jan,0.08742303848266601 +city_new_delhi,1990,MONTH_jan,0.08542831420898438 +city_mumbai,1990,MONTH_jan,0.08542831420898438 +city_new_delhi,1991,MONTH_jan,0.09029864311218262 +city_mumbai,1991,MONTH_jan,0.09029864311218262 +city_new_delhi,1992,MONTH_jan,0.08140623092651367 +city_mumbai,1992,MONTH_jan,0.08140623092651367 +city_new_delhi,1993,MONTH_jan,0.08035937309265137 +city_mumbai,1993,MONTH_jan,0.08035937309265137 +city_new_delhi,1994,MONTH_jan,0.08667225837707519 +city_mumbai,1994,MONTH_jan,0.08667225837707519 +city_new_delhi,1995,MONTH_jan,0.07686767578125 +city_mumbai,1995,MONTH_jan,0.07686767578125 +city_new_delhi,1996,MONTH_jan,0.06789632797241212 +city_mumbai,1996,MONTH_jan,0.06789632797241212 +city_new_delhi,1997,MONTH_jan,0.06570899486541748 +city_mumbai,1997,MONTH_jan,0.06570899486541748 +city_new_delhi,1998,MONTH_jan,0.07381818294525147 +city_mumbai,1998,MONTH_jan,0.07381818294525147 +city_new_delhi,1999,MONTH_jan,0.0712459659576416 +city_mumbai,1999,MONTH_jan,0.0712459659576416 +city_new_delhi,2000,MONTH_jan,0.06376289367675782 +city_mumbai,2000,MONTH_jan,0.06376289367675782 +city_new_delhi,2001,MONTH_jan,0.0599252462387085 +city_mumbai,2001,MONTH_jan,0.0599252462387085 +city_new_delhi,2002,MONTH_jan,0.057318320274353025 +city_mumbai,2002,MONTH_jan,0.057318320274353025 +city_new_delhi,2003,MONTH_jan,0.05624061584472656 +city_mumbai,2003,MONTH_jan,0.05624061584472656 +city_new_delhi,2004,MONTH_jan,0.07460848808288574 +city_mumbai,2004,MONTH_jan,0.07460848808288574 +city_new_delhi,2005,MONTH_jan,0.06894316673278808 +city_mumbai,2005,MONTH_jan,0.06894316673278808 +city_new_delhi,2006,MONTH_jan,0.07706239700317383 +city_mumbai,2006,MONTH_jan,0.07706239700317383 +city_new_delhi,2007,MONTH_jan,0.07855644702911377 +city_mumbai,2007,MONTH_jan,0.07855644702911377 +city_new_delhi,2008,MONTH_jan,0.07257065296173096 +city_mumbai,2008,MONTH_jan,0.07257065296173096 +city_new_delhi,2009,MONTH_jan,0.06473570346832275 +city_mumbai,2009,MONTH_jan,0.06473570346832275 +city_new_delhi,2010,MONTH_jan,0.0658367109298706 +city_mumbai,2010,MONTH_jan,0.0658367109298706 +city_new_delhi,2011,MONTH_jan,0.075013427734375 +city_mumbai,2011,MONTH_jan,0.075013427734375 +city_new_delhi,2012,MONTH_jan,0.06727289199829102 +city_mumbai,2012,MONTH_jan,0.06727289199829102 +city_new_delhi,2013,MONTH_jan,0.07329665184020996 +city_mumbai,2013,MONTH_jan,0.07329665184020996 +city_new_delhi,2014,MONTH_jan,0.07344336032867432 +city_mumbai,2014,MONTH_jan,0.07344336032867432 +city_new_delhi,2015,MONTH_jan,0.07184645652770996 +city_mumbai,2015,MONTH_jan,0.07184645652770996 +city_new_delhi,2016,MONTH_jan,0.07011397361755371 +city_mumbai,2016,MONTH_jan,0.07011397361755371 +city_new_delhi,2017,MONTH_jan,0.07511875152587891 +city_mumbai,2017,MONTH_jan,0.07511875152587891 +city_new_delhi,2018,MONTH_jan,0.07912805557250976 +city_mumbai,2018,MONTH_jan,0.07912805557250976 +city_new_delhi,2019,MONTH_jan,0.08849618911743164 +city_mumbai,2019,MONTH_jan,0.08849618911743164 +city_new_delhi,2020,MONTH_jan,0.09730036735534668 +city_mumbai,2020,MONTH_jan,0.09730036735534668 +city_new_delhi,2021,MONTH_jan,0.09310850143432615 +city_mumbai,2021,MONTH_jan,0.09310850143432615 +city_jakarta,1965,MONTH_jan,0.06385928153991699 +city_jakarta,1966,MONTH_jan,0.08364607810974121 +city_jakarta,1967,MONTH_jan,0.09505834579467771 +city_jakarta,1968,MONTH_jan,0.1101013946533203 +city_jakarta,1969,MONTH_jan,0.10201886177062988 +city_jakarta,1970,MONTH_jan,0.11570672035217283 +city_jakarta,1971,MONTH_jan,0.04001150131225586 +city_jakarta,1972,MONTH_jan,0.03373836040496826 +city_jakarta,1973,MONTH_jan,0.037743794918060306 +city_jakarta,1974,MONTH_jan,0.039022941589355466 +city_jakarta,1975,MONTH_jan,0.03342118501663208 +city_jakarta,1976,MONTH_jan,0.018672399520874024 +city_jakarta,1977,MONTH_jan,0.023478298187255858 +city_jakarta,1978,MONTH_jan,0.014906297922134399 +city_jakarta,1979,MONTH_jan,0.014562846422195437 +city_jakarta,1980,MONTH_jan,0.012272299528121948 +city_jakarta,1981,MONTH_jan,0.011406815052032471 +city_jakarta,1982,MONTH_jan,0.012204515933990481 +city_jakarta,1983,MONTH_jan,0.017323704957962035 +city_jakarta,1984,MONTH_jan,0.017180938720703125 +city_jakarta,1985,MONTH_jan,0.01980858683586121 +city_jakarta,1986,MONTH_jan,0.02986825704574585 +city_jakarta,1987,MONTH_jan,0.029112305641174317 +city_jakarta,1988,MONTH_jan,0.0302899694442749 +city_jakarta,1989,MONTH_jan,0.03408119440078736 +city_jakarta,1990,MONTH_jan,0.03731863260269165 +city_jakarta,1991,MONTH_jan,0.03812469959259033 +city_jakarta,1992,MONTH_jan,0.044085426330566405 +city_jakarta,1993,MONTH_jan,0.03847653388977051 +city_jakarta,1994,MONTH_jan,0.03521223306655884 +city_jakarta,1995,MONTH_jan,0.035392696857452395 +city_jakarta,1996,MONTH_jan,0.03508815288543701 +city_jakarta,1997,MONTH_jan,0.02477278470993042 +city_jakarta,1998,MONTH_jan,0.04014904499053955 +city_jakarta,1999,MONTH_jan,0.03852458000183105 +city_jakarta,2000,MONTH_jan,0.03733640432357788 +city_jakarta,2001,MONTH_jan,0.04112386703491211 +city_jakarta,2002,MONTH_jan,0.03683813571929931 +city_jakarta,2003,MONTH_jan,0.03221094608306885 +city_jakarta,2004,MONTH_jan,0.034259636402130124 +city_jakarta,2005,MONTH_jan,0.035274262428283694 +city_jakarta,2006,MONTH_jan,0.03220308542251587 +city_jakarta,2007,MONTH_jan,0.03370551109313965 +city_jakarta,2008,MONTH_jan,0.03586532115936279 +city_jakarta,2009,MONTH_jan,0.03655174016952514 +city_jakarta,2010,MONTH_jan,0.043262209892272946 +city_jakarta,2011,MONTH_jan,0.03388597726821899 +city_jakarta,2012,MONTH_jan,0.034713633060455315 +city_jakarta,2013,MONTH_jan,0.0433060359954834 +city_jakarta,2014,MONTH_jan,0.044786324501037596 +city_jakarta,2015,MONTH_jan,0.037929575443267825 +city_jakarta,2016,MONTH_jan,0.05479020118713379 +city_jakarta,2017,MONTH_jan,0.05283773899078369 +city_jakarta,2018,MONTH_jan,0.07393457889556884 +city_jakarta,2019,MONTH_jan,0.07870308876037597 +city_jakarta,2020,MONTH_jan,0.09860146522521973 +city_jakarta,2021,MONTH_jan,0.10385714530944824 +city_tehran,1965,MONTH_jan,0.052250761985778806 +city_tehran,1966,MONTH_jan,0.05151486396789551 +city_tehran,1967,MONTH_jan,0.050412230491638184 +city_tehran,1968,MONTH_jan,0.04931734085083008 +city_tehran,1969,MONTH_jan,0.04837111473083496 +city_tehran,1970,MONTH_jan,0.04415298461914063 +city_tehran,1971,MONTH_jan,0.04332554340362549 +city_tehran,1972,MONTH_jan,0.0501894760131836 +city_tehran,1973,MONTH_jan,0.03557704448699951 +city_tehran,1974,MONTH_jan,0.03455620527267456 +city_tehran,1975,MONTH_jan,0.031140482425689696 +city_tehran,1976,MONTH_jan,0.0309524917602539 +city_tehran,1977,MONTH_jan,0.02825014591217041 +city_tehran,1978,MONTH_jan,0.04526003360748291 +city_tehran,1979,MONTH_jan,0.036342711448669435 +city_tehran,1980,MONTH_jan,0.04064725875854492 +city_tehran,1981,MONTH_jan,0.044219164848327636 +city_tehran,1982,MONTH_jan,0.04111237049102783 +city_tehran,1983,MONTH_jan,0.033884649276733396 +city_tehran,1984,MONTH_jan,0.029317567348480223 +city_tehran,1985,MONTH_jan,0.027088303565979004 +city_tehran,1986,MONTH_jan,0.03455609560012817 +city_tehran,1987,MONTH_jan,0.03573478698730469 +city_tehran,1988,MONTH_jan,0.036968004703521726 +city_tehran,1989,MONTH_jan,0.027610442638397216 +city_tehran,1990,MONTH_jan,0.026902496814727783 +city_tehran,1991,MONTH_jan,0.018835831880569455 +city_tehran,1992,MONTH_jan,0.02795917510986328 +city_tehran,1993,MONTH_jan,0.034577884674072266 +city_tehran,1994,MONTH_jan,0.020214617252349857 +city_tehran,1995,MONTH_jan,0.023263061046600343 +city_tehran,1996,MONTH_jan,0.022645998001098632 +city_tehran,1997,MONTH_jan,0.014810699224472045 +city_tehran,1998,MONTH_jan,0.017921339273452762 +city_tehran,1999,MONTH_jan,0.011498689651489258 +city_tehran,2000,MONTH_jan,0.00808289110660553 +city_tehran,2001,MONTH_jan,0.008181908130645753 +city_tehran,2002,MONTH_jan,0.014433478116989135 +city_tehran,2003,MONTH_jan,0.016837654113769532 +city_tehran,2004,MONTH_jan,0.01884332299232483 +city_tehran,2005,MONTH_jan,0.021426386833190918 +city_tehran,2006,MONTH_jan,0.025007379055023194 +city_tehran,2007,MONTH_jan,0.022706358432769774 +city_tehran,2008,MONTH_jan,0.009235934615135192 +city_tehran,2009,MONTH_jan,0.008136967420578003 +city_tehran,2010,MONTH_jan,0.011950724124908448 +city_tehran,2011,MONTH_jan,0.011898080110549929 +city_tehran,2012,MONTH_jan,0.013722978830337525 +city_tehran,2013,MONTH_jan,0.01525709867477417 +city_tehran,2014,MONTH_jan,0.014402105808258056 +city_tehran,2015,MONTH_jan,0.013088065385818479 +city_tehran,2016,MONTH_jan,0.014465060234069824 +city_tehran,2017,MONTH_jan,0.015620874166488647 +city_tehran,2018,MONTH_jan,0.009227302074432371 +city_tehran,2019,MONTH_jan,0.028368299007415772 +city_tehran,2020,MONTH_jan,0.019643505811691286 +city_tehran,2021,MONTH_jan,0.012903937101364137 +city_baghdad,1965,MONTH_jan,0.009088937044143675 +city_baghdad,1966,MONTH_jan,0.010816304683685305 +city_baghdad,1967,MONTH_jan,0.012241523265838623 +city_baghdad,1968,MONTH_jan,0.013923404216766355 +city_baghdad,1969,MONTH_jan,0.013289313316345218 +city_baghdad,1970,MONTH_jan,0.01301562786102295 +city_baghdad,1971,MONTH_jan,0.013798673152923584 +city_baghdad,1972,MONTH_jan,0.011780089139938355 +city_baghdad,1973,MONTH_jan,0.01737240195274353 +city_baghdad,1974,MONTH_jan,0.02446626663208008 +city_baghdad,1975,MONTH_jan,0.02579850673675537 +city_baghdad,1976,MONTH_jan,0.020427801609039307 +city_baghdad,1977,MONTH_jan,0.02406090497970581 +city_baghdad,1978,MONTH_jan,0.03056793212890625 +city_baghdad,1979,MONTH_jan,0.03528018236160278 +city_baghdad,1980,MONTH_jan,0.020129208564758302 +city_baghdad,1981,MONTH_jan,0.019036805629730223 +city_baghdad,1982,MONTH_jan,0.01808008313179016 +city_baghdad,1983,MONTH_jan,0.01574033737182617 +city_baghdad,1984,MONTH_jan,0.014442424774169921 +city_baghdad,1985,MONTH_jan,0.012590632438659669 +city_baghdad,1986,MONTH_jan,0.010752139091491699 +city_baghdad,1987,MONTH_jan,0.03949446678161621 +city_baghdad,1988,MONTH_jan,0.03410572290420532 +city_baghdad,1989,MONTH_jan,0.030038673877716065 +city_baghdad,1990,MONTH_jan,0.0578435230255127 +city_baghdad,1991,MONTH_jan,0.0428729248046875 +city_baghdad,1992,MONTH_jan,0.06584853172302246 +city_baghdad,1993,MONTH_jan,0.058610520362854 +city_baghdad,1994,MONTH_jan,0.05243114471435547 +city_baghdad,1995,MONTH_jan,0.05992914199829102 +city_baghdad,1996,MONTH_jan,0.054542551040649416 +city_baghdad,1997,MONTH_jan,0.046753549575805665 +city_baghdad,1998,MONTH_jan,0.05869803905487061 +city_baghdad,1999,MONTH_jan,0.04700111389160156 +city_baghdad,2000,MONTH_jan,0.029294536113739018 +city_baghdad,2001,MONTH_jan,0.03016484260559082 +city_baghdad,2002,MONTH_jan,0.03885046482086182 +city_baghdad,2003,MONTH_jan,0.04535982608795166 +city_baghdad,2004,MONTH_jan,0.05081915855407715 +city_baghdad,2005,MONTH_jan,0.04544925212860108 +city_baghdad,2006,MONTH_jan,0.0473859977722168 +city_baghdad,2007,MONTH_jan,0.042728943824768065 +city_baghdad,2008,MONTH_jan,0.02381868362426758 +city_baghdad,2009,MONTH_jan,0.023280267715454103 +city_baghdad,2010,MONTH_jan,0.026375570297241212 +city_baghdad,2011,MONTH_jan,0.023962152004241944 +city_baghdad,2012,MONTH_jan,0.02823270320892334 +city_baghdad,2013,MONTH_jan,0.026760001182556153 +city_baghdad,2014,MONTH_jan,0.01738718867301941 +city_baghdad,2015,MONTH_jan,0.016102989912033083 +city_baghdad,2016,MONTH_jan,0.01836539387702942 +city_baghdad,2017,MONTH_jan,0.011253452301025391 +city_baghdad,2018,MONTH_jan,0.009119535088539124 +city_baghdad,2019,MONTH_jan,0.022772881984710693 +city_baghdad,2020,MONTH_jan,0.016468850374221803 +city_baghdad,2021,MONTH_jan,0.015024909973144531 +city_tokyo,1965,MONTH_jan,0.12335086822509765 +city_tokyo,1966,MONTH_jan,0.11651081085205078 +city_tokyo,1967,MONTH_jan,0.08793859481811524 +city_tokyo,1968,MONTH_jan,0.08451984405517578 +city_tokyo,1969,MONTH_jan,0.0761188268661499 +city_tokyo,1970,MONTH_jan,0.06836434364318848 +city_tokyo,1971,MONTH_jan,0.07166181564331055 +city_tokyo,1972,MONTH_jan,0.06914736270904541 +city_tokyo,1973,MONTH_jan,0.04894681930541992 +city_tokyo,1974,MONTH_jan,0.060309801101684574 +city_tokyo,1975,MONTH_jan,0.06373206615447997 +city_tokyo,1976,MONTH_jan,0.06161350250244141 +city_tokyo,1977,MONTH_jan,0.05355945110321045 +city_tokyo,1978,MONTH_jan,0.049568381309509274 +city_tokyo,1979,MONTH_jan,0.055059475898742674 +city_tokyo,1980,MONTH_jan,0.06194887161254883 +city_tokyo,1981,MONTH_jan,0.062369403839111326 +city_tokyo,1982,MONTH_jan,0.06735273361206055 +city_tokyo,1983,MONTH_jan,0.06926650524139405 +city_tokyo,1984,MONTH_jan,0.05621933937072754 +city_tokyo,1985,MONTH_jan,0.06361672401428223 +city_tokyo,1986,MONTH_jan,0.06296619892120361 +city_tokyo,1987,MONTH_jan,0.058519330024719235 +city_tokyo,1988,MONTH_jan,0.06523026466369629 +city_tokyo,1989,MONTH_jan,0.06458432197570801 +city_tokyo,1990,MONTH_jan,0.05605645179748535 +city_tokyo,1991,MONTH_jan,0.059171295166015624 +city_tokyo,1992,MONTH_jan,0.050801749229431155 +city_tokyo,1993,MONTH_jan,0.05666120529174805 +city_tokyo,1994,MONTH_jan,0.04097033977508545 +city_tokyo,1995,MONTH_jan,0.04652009010314941 +city_tokyo,1996,MONTH_jan,0.045326762199401856 +city_tokyo,1997,MONTH_jan,0.04951632499694824 +city_tokyo,1998,MONTH_jan,0.05170876026153565 +city_tokyo,1999,MONTH_jan,0.048562874794006346 +city_tokyo,2000,MONTH_jan,0.0482745361328125 +city_tokyo,2001,MONTH_jan,0.047163658142089844 +city_tokyo,2002,MONTH_jan,0.04702637195587158 +city_tokyo,2003,MONTH_jan,0.05332041263580322 +city_tokyo,2004,MONTH_jan,0.052576699256896973 +city_tokyo,2005,MONTH_jan,0.04790322780609131 +city_tokyo,2006,MONTH_jan,0.053090085983276365 +city_tokyo,2007,MONTH_jan,0.04761953353881836 +city_tokyo,2008,MONTH_jan,0.04830859184265137 +city_tokyo,2009,MONTH_jan,0.05021396160125732 +city_tokyo,2010,MONTH_jan,0.05684884071350098 +city_tokyo,2011,MONTH_jan,0.057331571578979494 +city_tokyo,2012,MONTH_jan,0.05650204658508301 +city_tokyo,2013,MONTH_jan,0.061299676895141604 +city_tokyo,2014,MONTH_jan,0.06935917377471924 +city_tokyo,2015,MONTH_jan,0.0806879711151123 +city_tokyo,2016,MONTH_jan,0.07975860595703126 +city_tokyo,2017,MONTH_jan,0.08634003639221191 +city_tokyo,2018,MONTH_jan,0.09322304725646972 +city_tokyo,2019,MONTH_jan,0.09565926551818847 +city_tokyo,2020,MONTH_jan,0.11155339241027833 +city_tokyo,2021,MONTH_jan,0.11428995132446287 +city_mexico_city,1965,MONTH_jan,0.08934722900390625 +city_mexico_city,1966,MONTH_jan,0.09633110046386721 +city_mexico_city,1967,MONTH_jan,0.1029133129119873 +city_mexico_city,1968,MONTH_jan,0.1084283447265625 +city_mexico_city,1969,MONTH_jan,0.10475299835205078 +city_mexico_city,1970,MONTH_jan,0.1098171329498291 +city_mexico_city,1971,MONTH_jan,0.10142724990844729 +city_mexico_city,1972,MONTH_jan,0.09780027389526368 +city_mexico_city,1973,MONTH_jan,0.09648298263549805 +city_mexico_city,1974,MONTH_jan,0.09094654083251952 +city_mexico_city,1975,MONTH_jan,0.07784452438354492 +city_mexico_city,1976,MONTH_jan,0.08308449745178223 +city_mexico_city,1977,MONTH_jan,0.08738277435302734 +city_mexico_city,1978,MONTH_jan,0.0659796380996704 +city_mexico_city,1979,MONTH_jan,0.06747371673583985 +city_mexico_city,1980,MONTH_jan,0.058035578727722165 +city_mexico_city,1981,MONTH_jan,0.07537362575531006 +city_mexico_city,1982,MONTH_jan,0.06843096733093262 +city_mexico_city,1983,MONTH_jan,0.06308685779571534 +city_mexico_city,1984,MONTH_jan,0.0683129644393921 +city_mexico_city,1985,MONTH_jan,0.07820509910583497 +city_mexico_city,1986,MONTH_jan,0.0659659194946289 +city_mexico_city,1987,MONTH_jan,0.06118594646453857 +city_mexico_city,1988,MONTH_jan,0.06784612655639649 +city_mexico_city,1989,MONTH_jan,0.07293380260467529 +city_mexico_city,1990,MONTH_jan,0.06830843448638917 +city_mexico_city,1991,MONTH_jan,0.06324604988098144 +city_mexico_city,1992,MONTH_jan,0.0725102186203003 +city_mexico_city,1993,MONTH_jan,0.07209392070770264 +city_mexico_city,1994,MONTH_jan,0.05448117256164551 +city_mexico_city,1995,MONTH_jan,0.07110982418060302 +city_mexico_city,1996,MONTH_jan,0.0760121488571167 +city_mexico_city,1997,MONTH_jan,0.06423584938049316 +city_mexico_city,1998,MONTH_jan,0.05862017154693604 +city_mexico_city,1999,MONTH_jan,0.07305535793304443 +city_mexico_city,2000,MONTH_jan,0.0715089750289917 +city_mexico_city,2001,MONTH_jan,0.06339307308197022 +city_mexico_city,2002,MONTH_jan,0.05449038505554199 +city_mexico_city,2003,MONTH_jan,0.046524553298950194 +city_mexico_city,2004,MONTH_jan,0.053032422065734865 +city_mexico_city,2005,MONTH_jan,0.05473337173461914 +city_mexico_city,2006,MONTH_jan,0.055860862731933594 +city_mexico_city,2007,MONTH_jan,0.052095470428466795 +city_mexico_city,2008,MONTH_jan,0.06696115970611573 +city_mexico_city,2009,MONTH_jan,0.04956578254699707 +city_mexico_city,2010,MONTH_jan,0.06283123970031738 +city_mexico_city,2011,MONTH_jan,0.058868541717529296 +city_mexico_city,2012,MONTH_jan,0.054620795249938965 +city_mexico_city,2013,MONTH_jan,0.05060070037841797 +city_mexico_city,2014,MONTH_jan,0.06727101802825927 +city_mexico_city,2015,MONTH_jan,0.060522632598876955 +city_mexico_city,2016,MONTH_jan,0.06131492614746094 +city_mexico_city,2017,MONTH_jan,0.06372722148895264 +city_mexico_city,2018,MONTH_jan,0.06939361095428467 +city_mexico_city,2019,MONTH_jan,0.0705077075958252 +city_mexico_city,2020,MONTH_jan,0.09475372314453123 +city_mexico_city,2021,MONTH_jan,0.1051475429534912 +city_rabat,1965,MONTH_jan,0.2022709846496582 +city_rabat,1966,MONTH_jan,0.1334361457824707 +city_rabat,1967,MONTH_jan,0.11197633743286133 +city_rabat,1968,MONTH_jan,0.11839537620544434 +city_rabat,1969,MONTH_jan,0.13958054542541504 +city_rabat,1970,MONTH_jan,0.13115361213684082 +city_rabat,1971,MONTH_jan,0.1392387866973877 +city_rabat,1972,MONTH_jan,0.13526378631591796 +city_rabat,1973,MONTH_jan,0.09094624519348145 +city_rabat,1974,MONTH_jan,0.09542439460754397 +city_rabat,1975,MONTH_jan,0.0713439130783081 +city_rabat,1976,MONTH_jan,0.06466088294982911 +city_rabat,1977,MONTH_jan,0.07884840011596679 +city_rabat,1978,MONTH_jan,0.0770575761795044 +city_rabat,1979,MONTH_jan,0.0771904230117798 +city_rabat,1980,MONTH_jan,0.07371124744415283 +city_rabat,1981,MONTH_jan,0.05136460304260254 +city_rabat,1982,MONTH_jan,0.027842175960540772 +city_rabat,1983,MONTH_jan,0.02280400514602661 +city_rabat,1984,MONTH_jan,0.01712327241897583 +city_rabat,1985,MONTH_jan,0.02200667381286621 +city_rabat,1986,MONTH_jan,0.028153402805328367 +city_rabat,1987,MONTH_jan,0.03506812572479248 +city_rabat,1988,MONTH_jan,0.037663094997406006 +city_rabat,1989,MONTH_jan,0.04231739044189453 +city_rabat,1990,MONTH_jan,0.04359245777130127 +city_rabat,1991,MONTH_jan,0.04325900077819824 +city_rabat,1992,MONTH_jan,0.030396227836608888 +city_rabat,1993,MONTH_jan,0.013822969198226929 +city_rabat,1994,MONTH_jan,0.023779470920562745 +city_rabat,1995,MONTH_jan,0.01763482928276062 +city_rabat,1996,MONTH_jan,0.05402516841888428 +city_rabat,1997,MONTH_jan,0.05531386375427246 +city_rabat,1998,MONTH_jan,0.04600728511810303 +city_rabat,1999,MONTH_jan,0.020588018894195557 +city_rabat,2000,MONTH_jan,0.019685844182968138 +city_rabat,2001,MONTH_jan,0.024725899696350098 +city_rabat,2002,MONTH_jan,0.02324991226196289 +city_rabat,2003,MONTH_jan,0.03657069444656372 +city_rabat,2004,MONTH_jan,0.03473497629165649 +city_rabat,2005,MONTH_jan,0.020816917419433593 +city_rabat,2006,MONTH_jan,0.020182490348815918 +city_rabat,2007,MONTH_jan,0.02050191640853882 +city_rabat,2008,MONTH_jan,0.018975967168807985 +city_rabat,2009,MONTH_jan,0.04711688995361328 +city_rabat,2010,MONTH_jan,0.05887355327606201 +city_rabat,2011,MONTH_jan,0.0364383602142334 +city_rabat,2012,MONTH_jan,0.031137833595275877 +city_rabat,2013,MONTH_jan,0.05110578060150146 +city_rabat,2014,MONTH_jan,0.04458736419677734 +city_rabat,2015,MONTH_jan,0.053888487815856936 +city_rabat,2016,MONTH_jan,0.05595184803009033 +city_rabat,2017,MONTH_jan,0.05286826610565185 +city_rabat,2018,MONTH_jan,0.0710693359375 +city_rabat,2019,MONTH_jan,0.07547047138214111 +city_rabat,2020,MONTH_jan,0.07633952140808105 +city_rabat,2021,MONTH_jan,0.0763616943359375 +city_amsterdam,1965,MONTH_jan,0 +city_amsterdam,1966,MONTH_jan,0 +city_amsterdam,1967,MONTH_jan,0 +city_amsterdam,1968,MONTH_jan,0 +city_amsterdam,1969,MONTH_jan,0 +city_amsterdam,1970,MONTH_jan,0 +city_amsterdam,1971,MONTH_jan,0 +city_amsterdam,1972,MONTH_jan,0 +city_amsterdam,1973,MONTH_jan,0 +city_amsterdam,1974,MONTH_jan,0 +city_amsterdam,1975,MONTH_jan,0.0031152141094207765 +city_amsterdam,1976,MONTH_jan,0.0031017714738845823 +city_amsterdam,1977,MONTH_jan,0.0031403565406799318 +city_amsterdam,1978,MONTH_jan,0.004299201965332031 +city_amsterdam,1979,MONTH_jan,0.0038009288907051085 +city_amsterdam,1980,MONTH_jan,0.0037478047609329226 +city_amsterdam,1981,MONTH_jan,0.004187572598457336 +city_amsterdam,1982,MONTH_jan,0.0011066412925720215 +city_amsterdam,1983,MONTH_jan,9.600715339183807e-4 +city_amsterdam,1984,MONTH_jan,6.805820390582081e-5 +city_amsterdam,1985,MONTH_jan,0.0017216096818447114 +city_amsterdam,1986,MONTH_jan,0.002057678997516632 +city_amsterdam,1987,MONTH_jan,0.002552417516708374 +city_amsterdam,1988,MONTH_jan,0.003074186444282532 +city_amsterdam,1989,MONTH_jan,0.003433368802070618 +city_amsterdam,1990,MONTH_jan,0.0028062096238136293 +city_amsterdam,1991,MONTH_jan,0.003191479742527008 +city_amsterdam,1992,MONTH_jan,0.0033999988436698913 +city_amsterdam,1993,MONTH_jan,0.0037428748607635496 +city_amsterdam,1994,MONTH_jan,0.00426658183336258 +city_amsterdam,1995,MONTH_jan,0.0045612013339996335 +city_amsterdam,1996,MONTH_jan,0.0056391310691833495 +city_amsterdam,1997,MONTH_jan,0.0063600361347198485 +city_amsterdam,1998,MONTH_jan,0.007268246412277222 +city_amsterdam,1999,MONTH_jan,0.007947908639907837 +city_amsterdam,2000,MONTH_jan,0.00925859272480011 +city_amsterdam,2001,MONTH_jan,0.009883764982223512 +city_amsterdam,2002,MONTH_jan,0.011863465309143067 +city_amsterdam,2003,MONTH_jan,0.011635091304779053 +city_amsterdam,2004,MONTH_jan,0.015031250715255734 +city_amsterdam,2005,MONTH_jan,0.020780501365661622 +city_amsterdam,2006,MONTH_jan,0.023150839805603028 +city_amsterdam,2007,MONTH_jan,0.024174244403839112 +city_amsterdam,2008,MONTH_jan,0.02913216352462769 +city_amsterdam,2009,MONTH_jan,0.034302778244018554 +city_amsterdam,2010,MONTH_jan,0.032134413719177246 +city_amsterdam,2011,MONTH_jan,0.03811289310455322 +city_amsterdam,2012,MONTH_jan,0.03963631391525269 +city_amsterdam,2013,MONTH_jan,0.03945788860321045 +city_amsterdam,2014,MONTH_jan,0.03978432416915893 +city_amsterdam,2015,MONTH_jan,0.04503983974456787 +city_amsterdam,2016,MONTH_jan,0.04676411151885986 +city_amsterdam,2017,MONTH_jan,0.05489981651306152 +city_amsterdam,2018,MONTH_jan,0.059912681579589844 +city_amsterdam,2019,MONTH_jan,0.07302987575531006 +city_amsterdam,2020,MONTH_jan,0.10758957862854004 +city_amsterdam,2021,MONTH_jan,0.12373795509338381 +city_islamabad,1965,MONTH_jan,0.07898932456970215 +city_islamabad,1966,MONTH_jan,0.07840171337127684 +city_islamabad,1967,MONTH_jan,0.0839201831817627 +city_islamabad,1968,MONTH_jan,0.08885177612304687 +city_islamabad,1969,MONTH_jan,0.09329750061035157 +city_islamabad,1970,MONTH_jan,0.08390380859375 +city_islamabad,1971,MONTH_jan,0.1171886157989502 +city_islamabad,1972,MONTH_jan,0.1325389575958252 +city_islamabad,1973,MONTH_jan,0.1308777618408203 +city_islamabad,1974,MONTH_jan,0.12144384384155271 +city_islamabad,1975,MONTH_jan,0.13310853958129884 +city_islamabad,1976,MONTH_jan,0.1423151779174805 +city_islamabad,1977,MONTH_jan,0.1562037467956543 +city_islamabad,1978,MONTH_jan,0.18110393524169918 +city_islamabad,1979,MONTH_jan,0.17961801528930665 +city_islamabad,1980,MONTH_jan,0.16982366561889647 +city_islamabad,1981,MONTH_jan,0.16494283676147461 +city_islamabad,1982,MONTH_jan,0.1682915496826172 +city_islamabad,1983,MONTH_jan,0.18234487533569335 +city_islamabad,1984,MONTH_jan,0.1785936164855957 +city_islamabad,1985,MONTH_jan,0.17652673721313478 +city_islamabad,1986,MONTH_jan,0.1592543983459473 +city_islamabad,1987,MONTH_jan,0.1866611099243164 +city_islamabad,1988,MONTH_jan,0.1841936492919922 +city_islamabad,1989,MONTH_jan,0.17649538040161133 +city_islamabad,1990,MONTH_jan,0.16537376403808593 +city_islamabad,1991,MONTH_jan,0.16701480865478516 +city_islamabad,1992,MONTH_jan,0.17344545364379882 +city_islamabad,1993,MONTH_jan,0.17234846115112304 +city_islamabad,1994,MONTH_jan,0.16347652435302734 +city_islamabad,1995,MONTH_jan,0.16378124237060546 +city_islamabad,1996,MONTH_jan,0.1676286506652832 +city_islamabad,1997,MONTH_jan,0.1289863395690918 +city_islamabad,1998,MONTH_jan,0.15707118988037108 +city_islamabad,1999,MONTH_jan,0.13423368453979492 +city_islamabad,2000,MONTH_jan,0.11344158172607421 +city_islamabad,2001,MONTH_jan,0.1141504955291748 +city_islamabad,2002,MONTH_jan,0.12188603401184082 +city_islamabad,2003,MONTH_jan,0.13333745002746583 +city_islamabad,2004,MONTH_jan,0.12676342964172363 +city_islamabad,2005,MONTH_jan,0.1359751033782959 +city_islamabad,2006,MONTH_jan,0.12633492469787597 +city_islamabad,2007,MONTH_jan,0.12365367889404297 +city_islamabad,2008,MONTH_jan,0.10553434371948242 +city_islamabad,2009,MONTH_jan,0.10885856628417968 +city_islamabad,2010,MONTH_jan,0.11174628257751465 +city_islamabad,2011,MONTH_jan,0.1141127872467041 +city_islamabad,2012,MONTH_jan,0.04317787647247315 +city_islamabad,2013,MONTH_jan,0.11522516250610351 +city_islamabad,2014,MONTH_jan,0.11496394157409667 +city_islamabad,2015,MONTH_jan,0.11174578666687011 +city_islamabad,2016,MONTH_jan,0.11086973190307615 +city_islamabad,2017,MONTH_jan,0.09674949645996093 +city_islamabad,2018,MONTH_jan,0.09416380882263184 +city_islamabad,2019,MONTH_jan,0.11015737533569336 +city_islamabad,2020,MONTH_jan,0.12021024703979492 +city_islamabad,2021,MONTH_jan,0.10622897148132324 +city_lima,1965,MONTH_jan,0.1374032688140869 +city_lima,1966,MONTH_jan,0.12172947883605956 +city_lima,1967,MONTH_jan,0.13394146919250488 +city_lima,1968,MONTH_jan,0.1411124134063721 +city_lima,1969,MONTH_jan,0.1524188995361328 +city_lima,1970,MONTH_jan,0.14120806694030763 +city_lima,1971,MONTH_jan,0.17272397994995117 +city_lima,1972,MONTH_jan,0.19887008666992187 +city_lima,1973,MONTH_jan,0.1857759666442871 +city_lima,1974,MONTH_jan,0.17592985153198243 +city_lima,1975,MONTH_jan,0.1786097526550293 +city_lima,1976,MONTH_jan,0.18501680374145507 +city_lima,1977,MONTH_jan,0.1907871437072754 +city_lima,1978,MONTH_jan,0.19592239379882812 +city_lima,1979,MONTH_jan,0.20157331466674805 +city_lima,1980,MONTH_jan,0.19488487243652344 +city_lima,1981,MONTH_jan,0.21093349456787108 +city_lima,1982,MONTH_jan,0.22348915100097655 +city_lima,1983,MONTH_jan,0.2438044166564942 +city_lima,1984,MONTH_jan,0.24780765533447266 +city_lima,1985,MONTH_jan,0.2695251083374023 +city_lima,1986,MONTH_jan,0.269285831451416 +city_lima,1987,MONTH_jan,0.2701639747619629 +city_lima,1988,MONTH_jan,0.2654584693908691 +city_lima,1989,MONTH_jan,0.2911813545227051 +city_lima,1990,MONTH_jan,0.2930202865600586 +city_lima,1991,MONTH_jan,0.32345062255859375 +city_lima,1992,MONTH_jan,0.2806740951538086 +city_lima,1993,MONTH_jan,0.3119631767272949 +city_lima,1994,MONTH_jan,0.309783992767334 +city_lima,1995,MONTH_jan,0.28913646697998047 +city_lima,1996,MONTH_jan,0.2877692604064942 +city_lima,1997,MONTH_jan,0.28343660354614253 +city_lima,1998,MONTH_jan,0.2941726493835449 +city_lima,1999,MONTH_jan,0.301059398651123 +city_lima,2000,MONTH_jan,0.3249596405029297 +city_lima,2001,MONTH_jan,0.3552646255493164 +city_lima,2002,MONTH_jan,0.3535195541381836 +city_lima,2003,MONTH_jan,0.3660024261474609 +city_lima,2004,MONTH_jan,0.3229750442504883 +city_lima,2005,MONTH_jan,0.3184630966186523 +city_lima,2006,MONTH_jan,0.34128055572509763 +city_lima,2007,MONTH_jan,0.3103961563110352 +city_lima,2008,MONTH_jan,0.28021553039550784 +city_lima,2009,MONTH_jan,0.2833369064331055 +city_lima,2010,MONTH_jan,0.25213640213012695 +city_lima,2011,MONTH_jan,0.24354307174682618 +city_lima,2012,MONTH_jan,0.2401105308532715 +city_lima,2013,MONTH_jan,0.24136716842651368 +city_lima,2014,MONTH_jan,0.23940710067749024 +city_lima,2015,MONTH_jan,0.24024496078491211 +city_lima,2016,MONTH_jan,0.2257667922973633 +city_lima,2017,MONTH_jan,0.2617181777954102 +city_lima,2018,MONTH_jan,0.26795402526855466 +city_lima,2019,MONTH_jan,0.2662133598327637 +city_lima,2020,MONTH_jan,0.30744228363037107 +city_lima,2021,MONTH_jan,0.27741008758544916 +city_bucharest,1965,MONTH_jan,0.01066218614578247 +city_bucharest,1966,MONTH_jan,0.0102953040599823 +city_bucharest,1967,MONTH_jan,0.01315669298171997 +city_bucharest,1968,MONTH_jan,0.01308521866798401 +city_bucharest,1969,MONTH_jan,0.01615439534187317 +city_bucharest,1970,MONTH_jan,0.01898038387298584 +city_bucharest,1971,MONTH_jan,0.028985319137573243 +city_bucharest,1972,MONTH_jan,0.0449291467666626 +city_bucharest,1973,MONTH_jan,0.04244083404541016 +city_bucharest,1974,MONTH_jan,0.04733458995819092 +city_bucharest,1975,MONTH_jan,0.04793048858642578 +city_bucharest,1976,MONTH_jan,0.03851948022842407 +city_bucharest,1977,MONTH_jan,0.041872053146362304 +city_bucharest,1978,MONTH_jan,0.04415801525115967 +city_bucharest,1979,MONTH_jan,0.04625902652740479 +city_bucharest,1980,MONTH_jan,0.05105916500091553 +city_bucharest,1981,MONTH_jan,0.051341099739074705 +city_bucharest,1982,MONTH_jan,0.04819664478302002 +city_bucharest,1983,MONTH_jan,0.041099562644958496 +city_bucharest,1984,MONTH_jan,0.04670980453491211 +city_bucharest,1985,MONTH_jan,0.052583565711975096 +city_bucharest,1986,MONTH_jan,0.0437827730178833 +city_bucharest,1987,MONTH_jan,0.04377776622772217 +city_bucharest,1988,MONTH_jan,0.05665992736816406 +city_bucharest,1989,MONTH_jan,0.05235843181610107 +city_bucharest,1990,MONTH_jan,0.04590248107910156 +city_bucharest,1991,MONTH_jan,0.06907992839813232 +city_bucharest,1992,MONTH_jan,0.06283785343170166 +city_bucharest,1993,MONTH_jan,0.07054651737213134 +city_bucharest,1994,MONTH_jan,0.07641243934631348 +city_bucharest,1995,MONTH_jan,0.08897040367126464 +city_bucharest,1996,MONTH_jan,0.08448899269104004 +city_bucharest,1997,MONTH_jan,0.09899968147277832 +city_bucharest,1998,MONTH_jan,0.11665589332580567 +city_bucharest,1999,MONTH_jan,0.12841182708740234 +city_bucharest,2000,MONTH_jan,0.10396162033081056 +city_bucharest,2001,MONTH_jan,0.10312889099121093 +city_bucharest,2002,MONTH_jan,0.10615109443664551 +city_bucharest,2003,MONTH_jan,0.08716782569885254 +city_bucharest,2004,MONTH_jan,0.10407816886901855 +city_bucharest,2005,MONTH_jan,0.1262943172454834 +city_bucharest,2006,MONTH_jan,0.11172654151916504 +city_bucharest,2007,MONTH_jan,0.10032530784606934 +city_bucharest,2008,MONTH_jan,0.10699505805969238 +city_bucharest,2009,MONTH_jan,0.10989452362060549 +city_bucharest,2010,MONTH_jan,0.14136738777160646 +city_bucharest,2011,MONTH_jan,0.11033339500427246 +city_bucharest,2012,MONTH_jan,0.1043911838531494 +city_bucharest,2013,MONTH_jan,0.14889094352722168 +city_bucharest,2014,MONTH_jan,0.17897146224975585 +city_bucharest,2015,MONTH_jan,0.1851751136779785 +city_bucharest,2016,MONTH_jan,0.18943086624145508 +city_bucharest,2017,MONTH_jan,0.16684114456176757 +city_bucharest,2018,MONTH_jan,0.17542226791381835 +city_bucharest,2019,MONTH_jan,0.16837947845458984 +city_bucharest,2020,MONTH_jan,0.17579639434814454 +city_bucharest,2021,MONTH_jan,0.1748103141784668 +city_moscow,1985,MONTH_jan,0.049429731369018556 +city_moscow,1986,MONTH_jan,0.04996936798095703 +city_moscow,1987,MONTH_jan,0.0478553295135498 +city_moscow,1988,MONTH_jan,0.046569442749023436 +city_moscow,1989,MONTH_jan,0.04605263233184814 +city_moscow,1990,MONTH_jan,0.04898304462432861 +city_moscow,1991,MONTH_jan,0.050031914710998535 +city_moscow,1992,MONTH_jan,0.05336780071258545 +city_moscow,1993,MONTH_jan,0.0578029727935791 +city_moscow,1994,MONTH_jan,0.06394296646118164 +city_moscow,1995,MONTH_jan,0.06769153594970703 +city_moscow,1996,MONTH_jan,0.06157421112060547 +city_moscow,1997,MONTH_jan,0.06642446517944336 +city_moscow,1998,MONTH_jan,0.06699800491333008 +city_moscow,1999,MONTH_jan,0.0669929838180542 +city_moscow,2000,MONTH_jan,0.06728621482849122 +city_moscow,2001,MONTH_jan,0.06975970268249512 +city_moscow,2002,MONTH_jan,0.06492728233337403 +city_moscow,2003,MONTH_jan,0.060753769874572754 +city_moscow,2004,MONTH_jan,0.06754271030426025 +city_moscow,2005,MONTH_jan,0.06603690147399903 +city_moscow,2006,MONTH_jan,0.06309632778167724 +city_moscow,2007,MONTH_jan,0.06371350765228272 +city_moscow,2008,MONTH_jan,0.05867445468902588 +city_moscow,2009,MONTH_jan,0.06485455513000488 +city_moscow,2010,MONTH_jan,0.059318561553955075 +city_moscow,2011,MONTH_jan,0.05585275650024414 +city_moscow,2012,MONTH_jan,0.0555089282989502 +city_moscow,2013,MONTH_jan,0.061906685829162596 +city_moscow,2014,MONTH_jan,0.0588721513748169 +city_moscow,2015,MONTH_jan,0.05773604393005371 +city_moscow,2016,MONTH_jan,0.06171404838562012 +city_moscow,2017,MONTH_jan,0.061212682723999025 +city_moscow,2018,MONTH_jan,0.06046762466430664 +city_moscow,2019,MONTH_jan,0.06201229095458984 +city_moscow,2020,MONTH_jan,0.07069781303405762 +city_moscow,2021,MONTH_jan,0.06620289325714111 +city_seoul,1965,MONTH_jan,0.028078150749206544 +city_seoul,1966,MONTH_jan,0.03209915399551391 +city_seoul,1967,MONTH_jan,0.027027177810668945 +city_seoul,1968,MONTH_jan,0.022995977401733397 +city_seoul,1969,MONTH_jan,0.029266607761383057 +city_seoul,1970,MONTH_jan,0.02155395030975342 +city_seoul,1971,MONTH_jan,0.021541755199432373 +city_seoul,1972,MONTH_jan,0.02153486490249634 +city_seoul,1973,MONTH_jan,0.016347564458847046 +city_seoul,1974,MONTH_jan,0.02332909107208252 +city_seoul,1975,MONTH_jan,0.0187353253364563 +city_seoul,1976,MONTH_jan,0.017800427675247192 +city_seoul,1977,MONTH_jan,0.012054132223129272 +city_seoul,1978,MONTH_jan,0.01396591067314148 +city_seoul,1979,MONTH_jan,0.01539095163345337 +city_seoul,1980,MONTH_jan,0.012506891489028931 +city_seoul,1981,MONTH_jan,0.01615981578826904 +city_seoul,1982,MONTH_jan,0.010666205883026122 +city_seoul,1983,MONTH_jan,0.013120517730712891 +city_seoul,1984,MONTH_jan,0.010462830066680908 +city_seoul,1985,MONTH_jan,0.015088706016540528 +city_seoul,1986,MONTH_jan,0.013128159046173095 +city_seoul,1987,MONTH_jan,0.015100772380828855 +city_seoul,1988,MONTH_jan,0.006779970526695251 +city_seoul,1989,MONTH_jan,0.009301869869232178 +city_seoul,1990,MONTH_jan,0.012995164394378662 +city_seoul,1991,MONTH_jan,0.008552601337432861 +city_seoul,1992,MONTH_jan,0.006740404963493347 +city_seoul,1993,MONTH_jan,0.008389674425125122 +city_seoul,1994,MONTH_jan,0.004319862127304077 +city_seoul,1995,MONTH_jan,0.0051026403903961185 +city_seoul,1996,MONTH_jan,0.004361970424652099 +city_seoul,1997,MONTH_jan,0.004026863574981689 +city_seoul,1998,MONTH_jan,0.006597698330879211 +city_seoul,1999,MONTH_jan,0.00593690276145935 +city_seoul,2000,MONTH_jan,0.005420218110084534 +city_seoul,2001,MONTH_jan,0.0031219828128814697 +city_seoul,2002,MONTH_jan,0.0041857692599296566 +city_seoul,2003,MONTH_jan,0.005985386967658997 +city_seoul,2004,MONTH_jan,0.005346380472183228 +city_seoul,2005,MONTH_jan,0.00453538864850998 +city_seoul,2006,MONTH_jan,0.004502668976783752 +city_seoul,2007,MONTH_jan,0.005043082237243653 +city_seoul,2008,MONTH_jan,0.005293462872505188 +city_seoul,2009,MONTH_jan,0.005700946450233459 +city_seoul,2010,MONTH_jan,0.009195590615272522 +city_seoul,2011,MONTH_jan,0.012539451122283935 +city_seoul,2012,MONTH_jan,0.01288482666015625 +city_seoul,2013,MONTH_jan,0.015155628919601441 +city_seoul,2014,MONTH_jan,0.017640750408172607 +city_seoul,2015,MONTH_jan,0.019041190147399904 +city_seoul,2016,MONTH_jan,0.020268120765686036 +city_seoul,2017,MONTH_jan,0.024301843643188478 +city_seoul,2018,MONTH_jan,0.02746018409729004 +city_seoul,2019,MONTH_jan,0.029800333976745606 +city_seoul,2020,MONTH_jan,0.03142855405807495 +city_seoul,2021,MONTH_jan,0.037249858379364016 +city_madrid,1965,MONTH_jan,0.17253438949584962 +city_madrid,1966,MONTH_jan,0.2111080551147461 +city_madrid,1967,MONTH_jan,0.16279375076293945 +city_madrid,1968,MONTH_jan,0.1665400505065918 +city_madrid,1969,MONTH_jan,0.18460060119628902 +city_madrid,1970,MONTH_jan,0.1555931854248047 +city_madrid,1971,MONTH_jan,0.16187814712524415 +city_madrid,1972,MONTH_jan,0.16690349578857422 +city_madrid,1973,MONTH_jan,0.12429852485656738 +city_madrid,1974,MONTH_jan,0.12622825622558595 +city_madrid,1975,MONTH_jan,0.10509173393249512 +city_madrid,1976,MONTH_jan,0.07937400817871093 +city_madrid,1977,MONTH_jan,0.14476511001586914 +city_madrid,1978,MONTH_jan,0.14644488334655761 +city_madrid,1979,MONTH_jan,0.15632555961608888 +city_madrid,1980,MONTH_jan,0.09981171607971191 +city_madrid,1981,MONTH_jan,0.07407119750976564 +city_madrid,1982,MONTH_jan,0.08885108947753906 +city_madrid,1983,MONTH_jan,0.08936359405517579 +city_madrid,1984,MONTH_jan,0.10203864097595217 +city_madrid,1985,MONTH_jan,0.10242602348327637 +city_madrid,1986,MONTH_jan,0.08501705169677734 +city_madrid,1987,MONTH_jan,0.08477232933044433 +city_madrid,1988,MONTH_jan,0.10430665016174316 +city_madrid,1989,MONTH_jan,0.055330204963684085 +city_madrid,1990,MONTH_jan,0.07198870182037354 +city_madrid,1991,MONTH_jan,0.07452907562255859 +city_madrid,1992,MONTH_jan,0.05013250350952148 +city_madrid,1993,MONTH_jan,0.0662508773803711 +city_madrid,1994,MONTH_jan,0.07313819408416748 +city_madrid,1995,MONTH_jan,0.05938282489776611 +city_madrid,1996,MONTH_jan,0.09653098106384275 +city_madrid,1997,MONTH_jan,0.08211402893066407 +city_madrid,1998,MONTH_jan,0.07815210342407226 +city_madrid,1999,MONTH_jan,0.05629496574401856 +city_madrid,2000,MONTH_jan,0.07008230686187744 +city_madrid,2001,MONTH_jan,0.09167547225952148 +city_madrid,2002,MONTH_jan,0.0644627046585083 +city_madrid,2003,MONTH_jan,0.09758903503417969 +city_madrid,2004,MONTH_jan,0.0844090461730957 +city_madrid,2005,MONTH_jan,0.06923494338989258 +city_madrid,2006,MONTH_jan,0.08360922813415528 +city_madrid,2007,MONTH_jan,0.09064817428588867 +city_madrid,2008,MONTH_jan,0.09948370933532717 +city_madrid,2009,MONTH_jan,0.12662100791931152 +city_madrid,2010,MONTH_jan,0.16742803573608397 +city_madrid,2011,MONTH_jan,0.15473434448242188 +city_madrid,2012,MONTH_jan,0.15889772415161132 +city_madrid,2013,MONTH_jan,0.19901302337646484 +city_madrid,2014,MONTH_jan,0.2008855438232422 +city_madrid,2015,MONTH_jan,0.17507902145385743 +city_madrid,2016,MONTH_jan,0.18609848022460937 +city_madrid,2017,MONTH_jan,0.15682350158691405 +city_madrid,2018,MONTH_jan,0.18230533599853516 +city_madrid,2019,MONTH_jan,0.17375850677490234 +city_madrid,2020,MONTH_jan,0.22102653503417968 +city_madrid,2021,MONTH_jan,0.22341663360595704 +city_bangkok,1965,MONTH_jan,0.08098695755004882 +city_bangkok,1966,MONTH_jan,0.08597766876220703 +city_bangkok,1967,MONTH_jan,0.09705655097961426 +city_bangkok,1968,MONTH_jan,0.07769661903381347 +city_bangkok,1969,MONTH_jan,0.054768366813659666 +city_bangkok,1970,MONTH_jan,0.07854705810546875 +city_bangkok,1971,MONTH_jan,0.08126887321472168 +city_bangkok,1972,MONTH_jan,0.056506228446960446 +city_bangkok,1973,MONTH_jan,0.05797545909881592 +city_bangkok,1974,MONTH_jan,0.07285396575927734 +city_bangkok,1975,MONTH_jan,0.09127364158630373 +city_bangkok,1976,MONTH_jan,0.09248512268066406 +city_bangkok,1977,MONTH_jan,0.07547190666198732 +city_bangkok,1978,MONTH_jan,0.045728025436401365 +city_bangkok,1979,MONTH_jan,0.06653911590576173 +city_bangkok,1980,MONTH_jan,0.02589577913284302 +city_bangkok,1981,MONTH_jan,0.06015193939208984 +city_bangkok,1982,MONTH_jan,0.07570967674255372 +city_bangkok,1983,MONTH_jan,0.06589135646820068 +city_bangkok,1984,MONTH_jan,0.06626251220703125 +city_bangkok,1985,MONTH_jan,0.05735532283782959 +city_bangkok,1986,MONTH_jan,0.08074996948242187 +city_bangkok,1987,MONTH_jan,0.05194031715393067 +city_bangkok,1988,MONTH_jan,0.04262178421020508 +city_bangkok,1989,MONTH_jan,0.05435298919677734 +city_bangkok,1990,MONTH_jan,0.04073401927947998 +city_bangkok,1991,MONTH_jan,0.03400254249572754 +city_bangkok,1992,MONTH_jan,0.028629646301269532 +city_bangkok,1993,MONTH_jan,0.021971902847290038 +city_bangkok,1994,MONTH_jan,0.02397928237915039 +city_bangkok,1995,MONTH_jan,0.032421882152557376 +city_bangkok,1996,MONTH_jan,0.031586606502532956 +city_bangkok,1997,MONTH_jan,0.02977715253829956 +city_bangkok,1998,MONTH_jan,0.02375905752182007 +city_bangkok,1999,MONTH_jan,0.01608154773712158 +city_bangkok,2000,MONTH_jan,0.025746095180511474 +city_bangkok,2001,MONTH_jan,0.025714476108551026 +city_bangkok,2002,MONTH_jan,0.02818033695220947 +city_bangkok,2003,MONTH_jan,0.027227082252502442 +city_bangkok,2004,MONTH_jan,0.02313349723815918 +city_bangkok,2005,MONTH_jan,0.0227521014213562 +city_bangkok,2006,MONTH_jan,0.029778263568878173 +city_bangkok,2007,MONTH_jan,0.029363691806793213 +city_bangkok,2008,MONTH_jan,0.029482808113098145 +city_bangkok,2009,MONTH_jan,0.030501224994659425 +city_bangkok,2010,MONTH_jan,0.028064701557159424 +city_bangkok,2011,MONTH_jan,0.03457339763641357 +city_bangkok,2012,MONTH_jan,0.03770574569702149 +city_bangkok,2013,MONTH_jan,0.0385915493965149 +city_bangkok,2014,MONTH_jan,0.04258995532989502 +city_bangkok,2015,MONTH_jan,0.04190981388092041 +city_bangkok,2016,MONTH_jan,0.045999755859375 +city_bangkok,2017,MONTH_jan,0.05306326389312744 +city_bangkok,2018,MONTH_jan,0.06380221366882324 +city_bangkok,2019,MONTH_jan,0.06956219673156738 +city_bangkok,2020,MONTH_jan,0.0699142074584961 +city_bangkok,2021,MONTH_jan,0.07113617897033692 +city_ankara,1965,MONTH_jan,0.07396099090576172 +city_ankara,1966,MONTH_jan,0.06960969448089599 +city_ankara,1967,MONTH_jan,0.06997379779815674 +city_ankara,1968,MONTH_jan,0.0787749719619751 +city_ankara,1969,MONTH_jan,0.07791776180267335 +city_ankara,1970,MONTH_jan,0.06475101470947266 +city_ankara,1971,MONTH_jan,0.05071615219116211 +city_ankara,1972,MONTH_jan,0.05530313968658447 +city_ankara,1973,MONTH_jan,0.04050086498260498 +city_ankara,1974,MONTH_jan,0.05047706604003906 +city_ankara,1975,MONTH_jan,0.07770755290985107 +city_ankara,1976,MONTH_jan,0.09604342460632324 +city_ankara,1977,MONTH_jan,0.09040463447570801 +city_ankara,1978,MONTH_jan,0.0920789909362793 +city_ankara,1979,MONTH_jan,0.10752221107482911 +city_ankara,1980,MONTH_jan,0.11387236595153809 +city_ankara,1981,MONTH_jan,0.1250270175933838 +city_ankara,1982,MONTH_jan,0.12745107650756837 +city_ankara,1983,MONTH_jan,0.09873126983642579 +city_ankara,1984,MONTH_jan,0.11116494178771973 +city_ankara,1985,MONTH_jan,0.09229307174682616 +city_ankara,1986,MONTH_jan,0.08374287605285645 +city_ankara,1987,MONTH_jan,0.11513276100158691 +city_ankara,1988,MONTH_jan,0.16268531799316407 +city_ankara,1989,MONTH_jan,0.10282753944396973 +city_ankara,1990,MONTH_jan,0.12219701766967772 +city_ankara,1991,MONTH_jan,0.11752680778503417 +city_ankara,1992,MONTH_jan,0.1307958698272705 +city_ankara,1993,MONTH_jan,0.15372352600097655 +city_ankara,1994,MONTH_jan,0.14304976463317873 +city_ankara,1995,MONTH_jan,0.14924197196960448 +city_ankara,1996,MONTH_jan,0.15543943405151367 +city_ankara,1997,MONTH_jan,0.14665958404541016 +city_ankara,1998,MONTH_jan,0.15141606330871582 +city_ankara,1999,MONTH_jan,0.12753751754760742 +city_ankara,2000,MONTH_jan,0.10657172203063965 +city_ankara,2001,MONTH_jan,0.09108513832092284 +city_ankara,2002,MONTH_jan,0.11535796165466308 +city_ankara,2003,MONTH_jan,0.11330117225646973 +city_ankara,2004,MONTH_jan,0.1369169235229492 +city_ankara,2005,MONTH_jan,0.11418582916259766 +city_ankara,2006,MONTH_jan,0.11456920623779297 +city_ankara,2007,MONTH_jan,0.08779489517211914 +city_ankara,2008,MONTH_jan,0.08211599349975586 +city_ankara,2009,MONTH_jan,0.08923343658447265 +city_ankara,2010,MONTH_jan,0.12280028343200683 +city_ankara,2011,MONTH_jan,0.11913782119750976 +city_ankara,2012,MONTH_jan,0.1252276611328125 +city_ankara,2013,MONTH_jan,0.1331322193145752 +city_ankara,2014,MONTH_jan,0.09769227027893067 +city_ankara,2015,MONTH_jan,0.1406381320953369 +city_ankara,2016,MONTH_jan,0.14479534149169923 +city_ankara,2017,MONTH_jan,0.13170472145080567 +city_ankara,2018,MONTH_jan,0.1484662437438965 +city_ankara,2019,MONTH_jan,0.1925493621826172 +city_ankara,2020,MONTH_jan,0.19150110244750976 +city_ankara,2021,MONTH_jan,0.16517044067382813 +city_kyiv,1985,MONTH_jan,0.011391943693161011 +city_kyiv,1986,MONTH_jan,0.01128100037574768 +city_kyiv,1987,MONTH_jan,0.009946019649505616 +city_kyiv,1988,MONTH_jan,0.012357125282287598 +city_kyiv,1989,MONTH_jan,0.010963214635848999 +city_kyiv,1990,MONTH_jan,0.009731683731079101 +city_kyiv,1991,MONTH_jan,0.01156305193901062 +city_kyiv,1992,MONTH_jan,0.00921140432357788 +city_kyiv,1993,MONTH_jan,0.014715107679367062 +city_kyiv,1994,MONTH_jan,0.018900632858276367 +city_kyiv,1995,MONTH_jan,0.015910707712173462 +city_kyiv,1996,MONTH_jan,0.014804906845092771 +city_kyiv,1997,MONTH_jan,0.017526177167892457 +city_kyiv,1998,MONTH_jan,0.02900869369506836 +city_kyiv,1999,MONTH_jan,0.026803247928619385 +city_kyiv,2000,MONTH_jan,0.021038007736206055 +city_kyiv,2001,MONTH_jan,0.022646660804748534 +city_kyiv,2002,MONTH_jan,0.018132338523864745 +city_kyiv,2003,MONTH_jan,0.01688597321510315 +city_kyiv,2004,MONTH_jan,0.021416072845458985 +city_kyiv,2005,MONTH_jan,0.022117321491241456 +city_kyiv,2006,MONTH_jan,0.022632830142974857 +city_kyiv,2007,MONTH_jan,0.018360310792922975 +city_kyiv,2008,MONTH_jan,0.02132999897003174 +city_kyiv,2009,MONTH_jan,0.025476245880126952 +city_kyiv,2010,MONTH_jan,0.02610059976577759 +city_kyiv,2011,MONTH_jan,0.020985288619995116 +city_kyiv,2012,MONTH_jan,0.021388649940490723 +city_kyiv,2013,MONTH_jan,0.03011183738708496 +city_kyiv,2014,MONTH_jan,0.022846858501434326 +city_kyiv,2015,MONTH_jan,0.01913326621055603 +city_kyiv,2016,MONTH_jan,0.02366657018661499 +city_kyiv,2017,MONTH_jan,0.02975400447845459 +city_kyiv,2018,MONTH_jan,0.03421227693557739 +city_kyiv,2019,MONTH_jan,0.03290361166000366 +city_kyiv,2020,MONTH_jan,0.048960785865783694 +city_kyiv,2021,MONTH_jan,0.06100841522216797 +city_dubai,1965,MONTH_jan,0 +city_dubai,1966,MONTH_jan,0 +city_dubai,1967,MONTH_jan,0 +city_dubai,1968,MONTH_jan,0 +city_dubai,1969,MONTH_jan,0 +city_dubai,1970,MONTH_jan,0 +city_dubai,1971,MONTH_jan,0 +city_dubai,1972,MONTH_jan,0 +city_dubai,1973,MONTH_jan,0 +city_dubai,1974,MONTH_jan,0 +city_dubai,1975,MONTH_jan,0 +city_dubai,1976,MONTH_jan,0 +city_dubai,1977,MONTH_jan,0 +city_dubai,1978,MONTH_jan,0 +city_dubai,1979,MONTH_jan,0 +city_dubai,1980,MONTH_jan,0 +city_dubai,1981,MONTH_jan,0 +city_dubai,1982,MONTH_jan,0 +city_dubai,1983,MONTH_jan,0 +city_dubai,1984,MONTH_jan,0 +city_dubai,1985,MONTH_jan,0 +city_dubai,1986,MONTH_jan,0 +city_dubai,1987,MONTH_jan,0 +city_dubai,1988,MONTH_jan,0 +city_dubai,1989,MONTH_jan,0 +city_dubai,1990,MONTH_jan,0 +city_dubai,1991,MONTH_jan,0 +city_dubai,1992,MONTH_jan,0 +city_dubai,1993,MONTH_jan,0 +city_dubai,1994,MONTH_jan,0 +city_dubai,1995,MONTH_jan,0 +city_dubai,1996,MONTH_jan,0 +city_dubai,1997,MONTH_jan,0 +city_dubai,1998,MONTH_jan,0 +city_dubai,1999,MONTH_jan,0 +city_dubai,2000,MONTH_jan,0 +city_dubai,2001,MONTH_jan,0 +city_dubai,2002,MONTH_jan,0 +city_dubai,2003,MONTH_jan,0 +city_dubai,2004,MONTH_jan,0 +city_dubai,2005,MONTH_jan,0 +city_dubai,2006,MONTH_jan,0 +city_dubai,2007,MONTH_jan,0 +city_dubai,2008,MONTH_jan,0 +city_dubai,2009,MONTH_jan,1.91772636026144e-5 +city_dubai,2010,MONTH_jan,5.25837112218141e-5 +city_dubai,2011,MONTH_jan,5.59225212782621e-5 +city_dubai,2012,MONTH_jan,6.18843780830502e-5 +city_dubai,2013,MONTH_jan,2.0930014550685878e-4 +city_dubai,2014,MONTH_jan,7.691703736782074e-4 +city_dubai,2015,MONTH_jan,6.952883303165436e-4 +city_dubai,2016,MONTH_jan,6.702232360839843e-4 +city_dubai,2017,MONTH_jan,0.0015412747859954834 +city_dubai,2018,MONTH_jan,0.0027376759052276612 +city_dubai,2019,MONTH_jan,0.007918253540992737 +city_dubai,2020,MONTH_jan,0.010150353908538818 +city_san_francisco,1965,MONTH_jan,0.043688697814941405 +city_denver,1965,MONTH_jan,0.043688697814941405 +city_washington,1965,MONTH_jan,0.043688697814941405 +city_chicago,1965,MONTH_jan,0.043688697814941405 +city_san_francisco,1966,MONTH_jan,0.041714019775390625 +city_denver,1966,MONTH_jan,0.041714019775390625 +city_washington,1966,MONTH_jan,0.041714019775390625 +city_chicago,1966,MONTH_jan,0.041714019775390625 +city_san_francisco,1967,MONTH_jan,0.04542215824127197 +city_denver,1967,MONTH_jan,0.04542215824127197 +city_washington,1967,MONTH_jan,0.04542215824127197 +city_chicago,1967,MONTH_jan,0.04542215824127197 +city_san_francisco,1968,MONTH_jan,0.04330973625183106 +city_denver,1968,MONTH_jan,0.04330973625183106 +city_washington,1968,MONTH_jan,0.04330973625183106 +city_chicago,1968,MONTH_jan,0.04330973625183106 +city_san_francisco,1969,MONTH_jan,0.04598878383636475 +city_denver,1969,MONTH_jan,0.04598878383636475 +city_washington,1969,MONTH_jan,0.04598878383636475 +city_chicago,1969,MONTH_jan,0.04598878383636475 +city_san_francisco,1970,MONTH_jan,0.044008030891418456 +city_denver,1970,MONTH_jan,0.044008030891418456 +city_washington,1970,MONTH_jan,0.044008030891418456 +city_chicago,1970,MONTH_jan,0.044008030891418456 +city_san_francisco,1971,MONTH_jan,0.046144747734069826 +city_denver,1971,MONTH_jan,0.046144747734069826 +city_washington,1971,MONTH_jan,0.046144747734069826 +city_chicago,1971,MONTH_jan,0.046144747734069826 +city_san_francisco,1972,MONTH_jan,0.045260472297668455 +city_denver,1972,MONTH_jan,0.045260472297668455 +city_washington,1972,MONTH_jan,0.045260472297668455 +city_chicago,1972,MONTH_jan,0.045260472297668455 +city_san_francisco,1973,MONTH_jan,0.043547596931457516 +city_denver,1973,MONTH_jan,0.043547596931457516 +city_washington,1973,MONTH_jan,0.043547596931457516 +city_chicago,1973,MONTH_jan,0.043547596931457516 +city_san_francisco,1974,MONTH_jan,0.04902864933013916 +city_denver,1974,MONTH_jan,0.04902864933013916 +city_washington,1974,MONTH_jan,0.04902864933013916 +city_chicago,1974,MONTH_jan,0.04902864933013916 +city_san_francisco,1975,MONTH_jan,0.050069751739501955 +city_denver,1975,MONTH_jan,0.050069751739501955 +city_washington,1975,MONTH_jan,0.050069751739501955 +city_chicago,1975,MONTH_jan,0.050069751739501955 +city_san_francisco,1976,MONTH_jan,0.045527076721191405 +city_denver,1976,MONTH_jan,0.045527076721191405 +city_washington,1976,MONTH_jan,0.045527076721191405 +city_chicago,1976,MONTH_jan,0.045527076721191405 +city_san_francisco,1977,MONTH_jan,0.03549314022064209 +city_denver,1977,MONTH_jan,0.03549314022064209 +city_washington,1977,MONTH_jan,0.03549314022064209 +city_chicago,1977,MONTH_jan,0.03549314022064209 +city_san_francisco,1978,MONTH_jan,0.043275704383850096 +city_denver,1978,MONTH_jan,0.043275704383850096 +city_washington,1978,MONTH_jan,0.043275704383850096 +city_chicago,1978,MONTH_jan,0.043275704383850096 +city_san_francisco,1979,MONTH_jan,0.0429140567779541 +city_denver,1979,MONTH_jan,0.0429140567779541 +city_washington,1979,MONTH_jan,0.0429140567779541 +city_chicago,1979,MONTH_jan,0.0429140567779541 +city_san_francisco,1980,MONTH_jan,0.044192209243774414 +city_denver,1980,MONTH_jan,0.044192209243774414 +city_washington,1980,MONTH_jan,0.044192209243774414 +city_chicago,1980,MONTH_jan,0.044192209243774414 +city_san_francisco,1981,MONTH_jan,0.04336748600006104 +city_denver,1981,MONTH_jan,0.04336748600006104 +city_washington,1981,MONTH_jan,0.04336748600006104 +city_chicago,1981,MONTH_jan,0.04336748600006104 +city_san_francisco,1982,MONTH_jan,0.05256711483001709 +city_denver,1982,MONTH_jan,0.05256711483001709 +city_washington,1982,MONTH_jan,0.05256711483001709 +city_chicago,1982,MONTH_jan,0.05256711483001709 +city_san_francisco,1983,MONTH_jan,0.056848154067993165 +city_denver,1983,MONTH_jan,0.056848154067993165 +city_washington,1983,MONTH_jan,0.056848154067993165 +city_chicago,1983,MONTH_jan,0.056848154067993165 +city_san_francisco,1984,MONTH_jan,0.05334360599517822 +city_denver,1984,MONTH_jan,0.05334360599517822 +city_washington,1984,MONTH_jan,0.05334360599517822 +city_chicago,1984,MONTH_jan,0.05334360599517822 +city_san_francisco,1985,MONTH_jan,0.04765776157379151 +city_denver,1985,MONTH_jan,0.04765776157379151 +city_washington,1985,MONTH_jan,0.04765776157379151 +city_chicago,1985,MONTH_jan,0.04765776157379151 +city_san_francisco,1986,MONTH_jan,0.048984041213989256 +city_denver,1986,MONTH_jan,0.048984041213989256 +city_washington,1986,MONTH_jan,0.048984041213989256 +city_chicago,1986,MONTH_jan,0.048984041213989256 +city_san_francisco,1987,MONTH_jan,0.04214753627777099 +city_denver,1987,MONTH_jan,0.04214753627777099 +city_washington,1987,MONTH_jan,0.04214753627777099 +city_chicago,1987,MONTH_jan,0.04214753627777099 +city_san_francisco,1988,MONTH_jan,0.03664999723434448 +city_denver,1988,MONTH_jan,0.03664999723434448 +city_washington,1988,MONTH_jan,0.03664999723434448 +city_chicago,1988,MONTH_jan,0.03664999723434448 +city_san_francisco,1989,MONTH_jan,0.043015427589416504 +city_denver,1989,MONTH_jan,0.043015427589416504 +city_washington,1989,MONTH_jan,0.043015427589416504 +city_chicago,1989,MONTH_jan,0.043015427589416504 +city_san_francisco,1990,MONTH_jan,0.047246766090393064 +city_denver,1990,MONTH_jan,0.047246766090393064 +city_washington,1990,MONTH_jan,0.047246766090393064 +city_chicago,1990,MONTH_jan,0.047246766090393064 +city_san_francisco,1991,MONTH_jan,0.0472428560256958 +city_denver,1991,MONTH_jan,0.0472428560256958 +city_washington,1991,MONTH_jan,0.0472428560256958 +city_chicago,1991,MONTH_jan,0.0472428560256958 +city_san_francisco,1992,MONTH_jan,0.042612309455871585 +city_denver,1992,MONTH_jan,0.042612309455871585 +city_washington,1992,MONTH_jan,0.042612309455871585 +city_chicago,1992,MONTH_jan,0.042612309455871585 +city_san_francisco,1993,MONTH_jan,0.045714097023010256 +city_denver,1993,MONTH_jan,0.045714097023010256 +city_washington,1993,MONTH_jan,0.045714097023010256 +city_chicago,1993,MONTH_jan,0.045714097023010256 +city_san_francisco,1994,MONTH_jan,0.0425481653213501 +city_denver,1994,MONTH_jan,0.0425481653213501 +city_washington,1994,MONTH_jan,0.0425481653213501 +city_chicago,1994,MONTH_jan,0.0425481653213501 +city_san_francisco,1995,MONTH_jan,0.04762141227722168 +city_denver,1995,MONTH_jan,0.04762141227722168 +city_washington,1995,MONTH_jan,0.04762141227722168 +city_chicago,1995,MONTH_jan,0.04762141227722168 +city_san_francisco,1996,MONTH_jan,0.050185713768005374 +city_denver,1996,MONTH_jan,0.050185713768005374 +city_washington,1996,MONTH_jan,0.050185713768005374 +city_chicago,1996,MONTH_jan,0.050185713768005374 +city_san_francisco,1997,MONTH_jan,0.051152210235595706 +city_denver,1997,MONTH_jan,0.051152210235595706 +city_washington,1997,MONTH_jan,0.051152210235595706 +city_chicago,1997,MONTH_jan,0.051152210235595706 +city_san_francisco,1998,MONTH_jan,0.046957569122314455 +city_denver,1998,MONTH_jan,0.046957569122314455 +city_washington,1998,MONTH_jan,0.046957569122314455 +city_chicago,1998,MONTH_jan,0.046957569122314455 +city_san_francisco,1999,MONTH_jan,0.04583451747894287 +city_denver,1999,MONTH_jan,0.04583451747894287 +city_washington,1999,MONTH_jan,0.04583451747894287 +city_chicago,1999,MONTH_jan,0.04583451747894287 +city_san_francisco,2000,MONTH_jan,0.0402735710144043 +city_denver,2000,MONTH_jan,0.0402735710144043 +city_washington,2000,MONTH_jan,0.0402735710144043 +city_chicago,2000,MONTH_jan,0.0402735710144043 +city_san_francisco,2001,MONTH_jan,0.034213709831237796 +city_denver,2001,MONTH_jan,0.034213709831237796 +city_washington,2001,MONTH_jan,0.034213709831237796 +city_chicago,2001,MONTH_jan,0.034213709831237796 +city_san_francisco,2002,MONTH_jan,0.040155067443847656 +city_denver,2002,MONTH_jan,0.040155067443847656 +city_washington,2002,MONTH_jan,0.040155067443847656 +city_chicago,2002,MONTH_jan,0.040155067443847656 +city_san_francisco,2003,MONTH_jan,0.041800403594970705 +city_denver,2003,MONTH_jan,0.041800403594970705 +city_washington,2003,MONTH_jan,0.041800403594970705 +city_chicago,2003,MONTH_jan,0.041800403594970705 +city_san_francisco,2004,MONTH_jan,0.04101511478424072 +city_denver,2004,MONTH_jan,0.04101511478424072 +city_washington,2004,MONTH_jan,0.04101511478424072 +city_chicago,2004,MONTH_jan,0.04101511478424072 +city_san_francisco,2005,MONTH_jan,0.04219231128692627 +city_denver,2005,MONTH_jan,0.04219231128692627 +city_washington,2005,MONTH_jan,0.04219231128692627 +city_chicago,2005,MONTH_jan,0.04219231128692627 +city_san_francisco,2006,MONTH_jan,0.04678860664367676 +city_denver,2006,MONTH_jan,0.04678860664367676 +city_washington,2006,MONTH_jan,0.04678860664367676 +city_chicago,2006,MONTH_jan,0.04678860664367676 +city_san_francisco,2007,MONTH_jan,0.04373008728027344 +city_denver,2007,MONTH_jan,0.04373008728027344 +city_washington,2007,MONTH_jan,0.04373008728027344 +city_chicago,2007,MONTH_jan,0.04373008728027344 +city_san_francisco,2008,MONTH_jan,0.050045504570007324 +city_denver,2008,MONTH_jan,0.050045504570007324 +city_washington,2008,MONTH_jan,0.050045504570007324 +city_chicago,2008,MONTH_jan,0.050045504570007324 +city_san_francisco,2009,MONTH_jan,0.0580000638961792 +city_denver,2009,MONTH_jan,0.0580000638961792 +city_washington,2009,MONTH_jan,0.0580000638961792 +city_chicago,2009,MONTH_jan,0.0580000638961792 +city_san_francisco,2010,MONTH_jan,0.05840554714202881 +city_denver,2010,MONTH_jan,0.05840554714202881 +city_washington,2010,MONTH_jan,0.05840554714202881 +city_chicago,2010,MONTH_jan,0.05840554714202881 +city_san_francisco,2011,MONTH_jan,0.06897319316864013 +city_denver,2011,MONTH_jan,0.06897319316864013 +city_washington,2011,MONTH_jan,0.06897319316864013 +city_chicago,2011,MONTH_jan,0.06897319316864013 +city_san_francisco,2012,MONTH_jan,0.06886333942413331 +city_denver,2012,MONTH_jan,0.06886333942413331 +city_washington,2012,MONTH_jan,0.06886333942413331 +city_chicago,2012,MONTH_jan,0.06886333942413331 +city_san_francisco,2013,MONTH_jan,0.07134616374969482 +city_denver,2013,MONTH_jan,0.07134616374969482 +city_washington,2013,MONTH_jan,0.07134616374969482 +city_chicago,2013,MONTH_jan,0.07134616374969482 +city_san_francisco,2014,MONTH_jan,0.07262890815734863 +city_denver,2014,MONTH_jan,0.07262890815734863 +city_washington,2014,MONTH_jan,0.07262890815734863 +city_chicago,2014,MONTH_jan,0.07262890815734863 +city_san_francisco,2015,MONTH_jan,0.07468742847442628 +city_denver,2015,MONTH_jan,0.07468742847442628 +city_washington,2015,MONTH_jan,0.07468742847442628 +city_chicago,2015,MONTH_jan,0.07468742847442628 +city_san_francisco,2016,MONTH_jan,0.08285085678100586 +city_denver,2016,MONTH_jan,0.08285085678100586 +city_washington,2016,MONTH_jan,0.08285085678100586 +city_chicago,2016,MONTH_jan,0.08285085678100586 +city_san_francisco,2017,MONTH_jan,0.09082049369812012 +city_denver,2017,MONTH_jan,0.09082049369812012 +city_washington,2017,MONTH_jan,0.09082049369812012 +city_chicago,2017,MONTH_jan,0.09082049369812012 +city_san_francisco,2018,MONTH_jan,0.0896493911743164 +city_denver,2018,MONTH_jan,0.0896493911743164 +city_washington,2018,MONTH_jan,0.0896493911743164 +city_chicago,2018,MONTH_jan,0.0896493911743164 +city_san_francisco,2019,MONTH_jan,0.09315262794494628 +city_denver,2019,MONTH_jan,0.09315262794494628 +city_washington,2019,MONTH_jan,0.09315262794494628 +city_chicago,2019,MONTH_jan,0.09315262794494628 +city_san_francisco,2020,MONTH_jan,0.10532232284545899 +city_denver,2020,MONTH_jan,0.10532232284545899 +city_washington,2020,MONTH_jan,0.10532232284545899 +city_chicago,2020,MONTH_jan,0.10532232284545899 +city_san_francisco,2021,MONTH_jan,0.10655990600585938 +city_denver,2021,MONTH_jan,0.10655990600585938 +city_washington,2021,MONTH_jan,0.10655990600585938 +city_chicago,2021,MONTH_jan,0.10655990600585938 +city_hanoi,1965,MONTH_jan,0.034132664203643796 +city_hanoi,1966,MONTH_jan,0.02240062952041626 +city_hanoi,1967,MONTH_jan,0.017923457622528075 +city_hanoi,1968,MONTH_jan,0.01929360270500183 +city_hanoi,1969,MONTH_jan,0.01837692379951477 +city_hanoi,1970,MONTH_jan,0.019573317766189577 +city_hanoi,1971,MONTH_jan,0.022463304996490477 +city_hanoi,1972,MONTH_jan,0.01592976570129394 +city_hanoi,1973,MONTH_jan,0.015021532773971558 +city_hanoi,1974,MONTH_jan,0.020197300910949706 +city_hanoi,1975,MONTH_jan,0.02163102149963379 +city_hanoi,1976,MONTH_jan,0.041627111434936526 +city_hanoi,1977,MONTH_jan,0.04191826820373535 +city_hanoi,1978,MONTH_jan,0.05387956142425537 +city_hanoi,1979,MONTH_jan,0.062493300437927245 +city_hanoi,1980,MONTH_jan,0.08125602722167968 +city_hanoi,1981,MONTH_jan,0.08210463523864746 +city_hanoi,1982,MONTH_jan,0.07957214832305909 +city_hanoi,1983,MONTH_jan,0.059674644470214845 +city_hanoi,1984,MONTH_jan,0.07733730316162109 +city_hanoi,1985,MONTH_jan,0.07084222316741944 +city_hanoi,1986,MONTH_jan,0.062252769470214846 +city_hanoi,1987,MONTH_jan,0.05438616275787354 +city_hanoi,1988,MONTH_jan,0.07041000366210938 +city_hanoi,1989,MONTH_jan,0.15831216812133786 +city_hanoi,1990,MONTH_jan,0.20584053039550781 +city_hanoi,1991,MONTH_jan,0.2379098892211914 +city_hanoi,1992,MONTH_jan,0.24912485122680664 +city_hanoi,1993,MONTH_jan,0.24039852142333984 +city_hanoi,1994,MONTH_jan,0.2497269630432129 +city_hanoi,1995,MONTH_jan,0.24608880996704102 +city_hanoi,1996,MONTH_jan,0.24358139038085938 +city_hanoi,1997,MONTH_jan,0.20527612686157226 +city_hanoi,1998,MONTH_jan,0.1806495475769043 +city_hanoi,1999,MONTH_jan,0.2165902328491211 +city_hanoi,2000,MONTH_jan,0.20092161178588866 +city_hanoi,2001,MONTH_jan,0.22102148056030274 +city_hanoi,2002,MONTH_jan,0.20062660217285155 +city_hanoi,2003,MONTH_jan,0.19297657012939454 +city_hanoi,2004,MONTH_jan,0.14763954162597656 +city_hanoi,2005,MONTH_jan,0.1284674835205078 +city_hanoi,2006,MONTH_jan,0.16607240676879884 +city_hanoi,2007,MONTH_jan,0.17202272415161132 +city_hanoi,2008,MONTH_jan,0.16009517669677734 +city_hanoi,2009,MONTH_jan,0.17948020935058595 +city_hanoi,2010,MONTH_jan,0.14711740493774414 +city_hanoi,2011,MONTH_jan,0.1902745246887207 +city_hanoi,2012,MONTH_jan,0.2338884544372558 +city_hanoi,2013,MONTH_jan,0.23877511978149418 +city_hanoi,2014,MONTH_jan,0.23073970794677734 +city_hanoi,2015,MONTH_jan,0.18584493637084962 +city_hanoi,2016,MONTH_jan,0.19181915283203124 +city_hanoi,2017,MONTH_jan,0.24208347320556642 +city_hanoi,2018,MONTH_jan,0.20761816024780275 +city_hanoi,2019,MONTH_jan,0.15891139030456544 +city_hanoi,2020,MONTH_jan,0.19136663436889648 +city_hanoi,2021,MONTH_jan,0.2273440742492676 diff --git a/run_tree/data/incenter_data/csv/question_3.csv b/run_tree/data/incenter_data/csv/question_3.csv new file mode 100644 index 0000000..6d63a0a --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_3.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.601593625498008 +city_brisbane,2022,MONTH_jan,0.6060606060606061 +city_chengdu,2022,MONTH_jan,0.5254237288135594 +city_new_delhi,2022,MONTH_jan,0.6507936507936508 +city_paris,2022,MONTH_jan,0.569806492883416 +city_san_francisco,2022,MONTH_jan,0.6120930232558139 +city_denver,2022,MONTH_jan,0.6120930232558139 +city_ankara,2022,MONTH_jan,0.7948003714020427 +city_harare,2022,MONTH_jan,0.5714285714285714 +city_hanoi,2022,MONTH_jan,0.6158536585365854 +city_washington,2022,MONTH_jan,0.6120930232558139 +city_bangkok,2022,MONTH_jan,0.5555555555555556 +city_tunis,2022,MONTH_jan,0.5142857142857142 +city_seoul,2022,MONTH_jan,0.6158536585365854 +city_belgrade,2022,MONTH_jan,0.6169354838709677 +city_moscow,2022,MONTH_jan,0.5819672131147541 +city_lima,2022,MONTH_jan,0.425 +city_islamabad,2022,MONTH_jan,0.6363636363636364 +city_abuja,2022,MONTH_jan,0.8333333333333334 +city_managua,2022,MONTH_jan,0.6774193548387096 +city_amsterdam,2022,MONTH_jan,0.464638783269962 +city_rabat,2022,MONTH_jan,0.6190476190476191 +city_ulaanbaatar,2022,MONTH_jan,0.5254237288135594 +city_mexico_city,2022,MONTH_jan,0.5176882661996497 +city_nairobi,2022,MONTH_jan,0.5714285714285714 +city_tokyo,2022,MONTH_jan,0.5993009868421053 +city_baghdad,2022,MONTH_jan,0.5 +city_tehran,2022,MONTH_jan,0.5 +city_jakarta,2022,MONTH_jan,0.6011644832605532 +city_guatemala_city,2022,MONTH_jan,0.6774193548387096 +city_berlin,2022,MONTH_jan,0.6111111111111112 +city_addis_ababa,2022,MONTH_jan,0.5714285714285714 +city_cairo,2022,MONTH_jan,0.5142857142857142 +city_quito,2022,MONTH_jan,0.4827586206896552 +city_bogota,2022,MONTH_jan,0.45 +city_beijing,2022,MONTH_jan,0.5254237288135594 +city_accra,2022,MONTH_jan,0.5714285714285714 +city_ottawa,2022,MONTH_jan,0.6352941176470588 +city_brasilia,2022,MONTH_jan,0.7062314540059347 +city_la_paz,2022,MONTH_jan,0.7062314540059347 +city_dhaka,2022,MONTH_jan,0.7107438016528925 +city_yerevan,2022,MONTH_jan,0.7948003714020427 +city_chicago,2022,MONTH_jan,0.6120930232558139 +city_kyiv,2022,MONTH_jan,0.59375 +city_dubai,2022,MONTH_jan,0.5 +city_mumbai,2022,MONTH_jan,0.6507936507936508 +city_madrid,2022,MONTH_jan,0.4838709677419355 diff --git a/run_tree/data/incenter_data/csv/question_4.csv b/run_tree/data/incenter_data/csv/question_4.csv new file mode 100644 index 0000000..18511d9 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_4.csv @@ -0,0 +1,1364 @@ +city_data,year,month,prop +city_abuja,2020,MONTH_jan,0 +city_abuja,2020,MONTH_feb,0 +city_abuja,2020,MONTH_mar,0.012232415902140673 +city_abuja,2020,MONTH_apr,0.14984709480122324 +city_abuja,2020,MONTH_may,0.672782874617737 +city_abuja,2020,MONTH_jun,0.9174311926605505 +city_abuja,2020,MONTH_jul,0.9327217125382263 +city_abuja,2020,MONTH_aug,0.41284403669724773 +city_abuja,2020,MONTH_sep,0.2996941896024465 +city_abuja,2020,MONTH_oct,0.10091743119266056 +city_abuja,2020,MONTH_nov,0.08868501529051988 +city_abuja,2020,MONTH_dec,0.3211009174311927 +city_abuja,2021,MONTH_jan,0.9174311926605505 +city_abuja,2021,MONTH_feb,1 +city_abuja,2021,MONTH_mar,0.4617737003058104 +city_abuja,2021,MONTH_apr,0.021406727828746176 +city_abuja,2021,MONTH_may,0.024464831804281346 +city_abuja,2021,MONTH_jun,0.14984709480122324 +city_abuja,2021,MONTH_jul,0.08868501529051988 +city_abuja,2021,MONTH_aug,0.9357798165137615 +city_abuja,2021,MONTH_sep,0.7553516819571865 +city_abuja,2021,MONTH_oct,0.5902140672782875 +city_abuja,2021,MONTH_nov,0.24770642201834864 +city_abuja,2021,MONTH_dec,0.1651376146788991 +city_abuja,2022,MONTH_jan,0.3211009174311927 +city_abuja,2022,MONTH_feb,0.021406727828746176 +city_abuja,2022,MONTH_mar,0 +city_abuja,2022,MONTH_apr,0.0030581039755351682 +city_abuja,2022,MONTH_may,0 +city_accra,2020,MONTH_jan,0 +city_accra,2020,MONTH_feb,0 +city_accra,2020,MONTH_mar,0.017467248908296942 +city_accra,2020,MONTH_apr,0.05240174672489083 +city_accra,2020,MONTH_may,0.08296943231441048 +city_accra,2020,MONTH_jun,0.33624454148471616 +city_accra,2020,MONTH_jul,0.27510917030567683 +city_accra,2020,MONTH_aug,0.4410480349344978 +city_accra,2020,MONTH_sep,0.1091703056768559 +city_accra,2020,MONTH_oct,0.08296943231441048 +city_accra,2020,MONTH_nov,0.021834061135371178 +city_accra,2020,MONTH_dec,0.043668122270742356 +city_accra,2021,MONTH_jan,0.388646288209607 +city_accra,2021,MONTH_feb,0.8165938864628821 +city_accra,2021,MONTH_mar,0.5807860262008734 +city_accra,2021,MONTH_apr,0.15283842794759825 +city_accra,2021,MONTH_may,0.026200873362445413 +city_accra,2021,MONTH_jun,0.048034934497816595 +city_accra,2021,MONTH_jul,0.11790393013100436 +city_accra,2021,MONTH_aug,1 +city_accra,2021,MONTH_sep,0.4585152838427948 +city_accra,2021,MONTH_oct,0.13537117903930132 +city_accra,2021,MONTH_nov,0.16593886462882096 +city_accra,2021,MONTH_dec,0.34934497816593885 +city_accra,2022,MONTH_jan,0.4279475982532751 +city_accra,2022,MONTH_feb,0.16593886462882096 +city_accra,2022,MONTH_mar,0.013100436681222707 +city_accra,2022,MONTH_apr,0 +city_accra,2022,MONTH_may,0 +city_addis_ababa,2020,MONTH_jan,0 +city_addis_ababa,2020,MONTH_feb,0 +city_addis_ababa,2020,MONTH_mar,0 +city_addis_ababa,2020,MONTH_apr,0.026172300981461286 +city_addis_ababa,2020,MONTH_may,0.004362050163576881 +city_addis_ababa,2020,MONTH_jun,0.10032715376226826 +city_addis_ababa,2020,MONTH_jul,0.1723009814612868 +city_addis_ababa,2020,MONTH_aug,0.5627044711014176 +city_addis_ababa,2020,MONTH_sep,0.4340239912758997 +city_addis_ababa,2020,MONTH_oct,0.2966194111232279 +city_addis_ababa,2020,MONTH_nov,0.257360959651036 +city_addis_ababa,2020,MONTH_dec,0.23773173391494 +city_addis_ababa,2021,MONTH_jan,0.18865866957470012 +city_addis_ababa,2021,MONTH_feb,0.28680479825517996 +city_addis_ababa,2021,MONTH_mar,0.5310796074154853 +city_addis_ababa,2021,MONTH_apr,0.8909487459105779 +city_addis_ababa,2021,MONTH_may,0.5419847328244275 +city_addis_ababa,2021,MONTH_jun,0.17993456924754633 +city_addis_ababa,2021,MONTH_jul,0.06870229007633588 +city_addis_ababa,2021,MONTH_aug,0.302071973827699 +city_addis_ababa,2021,MONTH_sep,0.9531079607415486 +city_addis_ababa,2021,MONTH_oct,1 +city_addis_ababa,2021,MONTH_nov,0.3260632497273719 +city_addis_ababa,2021,MONTH_dec,0.19193020719738277 +city_addis_ababa,2022,MONTH_jan,0.4416575790621592 +city_addis_ababa,2022,MONTH_feb,0.1406761177753544 +city_addis_ababa,2022,MONTH_mar,0.03489640130861505 +city_addis_ababa,2022,MONTH_apr,0.019629225736095966 +city_addis_ababa,2022,MONTH_may,0.003271537622682661 +city_amsterdam,2020,MONTH_jan,0 +city_amsterdam,2020,MONTH_feb,0 +city_amsterdam,2020,MONTH_mar,0.22048475371383894 +city_amsterdam,2020,MONTH_apr,1 +city_amsterdam,2020,MONTH_may,0.32212666145426117 +city_amsterdam,2020,MONTH_jun,0.041959864477456345 +city_amsterdam,2020,MONTH_jul,0.01667969768047954 +city_amsterdam,2020,MONTH_aug,0.019546520719311962 +city_amsterdam,2020,MONTH_sep,0.04508730779254626 +city_amsterdam,2020,MONTH_oct,0.24811050299713316 +city_amsterdam,2020,MONTH_nov,0.5173312483711233 +city_amsterdam,2020,MONTH_dec,0.5129007036747459 +city_amsterdam,2021,MONTH_jan,0.689080010424811 +city_amsterdam,2021,MONTH_feb,0.4162105811832161 +city_amsterdam,2021,MONTH_mar,0.2509773260359656 +city_amsterdam,2021,MONTH_apr,0.16080271045087308 +city_amsterdam,2021,MONTH_may,0.1308313786812614 +city_amsterdam,2021,MONTH_jun,0.03205629397967162 +city_amsterdam,2021,MONTH_jul,0.019807140995569454 +city_amsterdam,2021,MONTH_aug,0.046390409173833726 +city_amsterdam,2021,MONTH_sep,0.04430544696377378 +city_amsterdam,2021,MONTH_oct,0.05968204326296586 +city_amsterdam,2021,MONTH_nov,0.24758926244461818 +city_amsterdam,2021,MONTH_dec,0.40109460516028145 +city_amsterdam,2022,MONTH_jan,0.09747198332030232 +city_amsterdam,2022,MONTH_feb,0.07453739900964294 +city_amsterdam,2022,MONTH_mar,0.10685431326557206 +city_amsterdam,2022,MONTH_apr,0.07479801928590045 +city_amsterdam,2022,MONTH_may,0.019807140995569454 +city_ankara,2020,MONTH_jan,0 +city_ankara,2020,MONTH_feb,0 +city_ankara,2020,MONTH_mar,0.020114942528735632 +city_ankara,2020,MONTH_apr,0.3487787356321839 +city_ankara,2020,MONTH_may,0.17169540229885058 +city_ankara,2020,MONTH_jun,0.07183908045977011 +city_ankara,2020,MONTH_jul,0.06693007662835249 +city_ankara,2020,MONTH_aug,0.07806513409961686 +city_ankara,2020,MONTH_sep,0.21599616858237547 +city_ankara,2020,MONTH_oct,0.24509099616858238 +city_ankara,2020,MONTH_nov,0.4048132183908046 +city_ankara,2020,MONTH_dec,0.8481800766283525 +city_ankara,2021,MONTH_jan,0.6253591954022989 +city_ankara,2021,MONTH_feb,0.3158524904214559 +city_ankara,2021,MONTH_mar,0.3450670498084291 +city_ankara,2021,MONTH_apr,1 +city_ankara,2021,MONTH_may,0.9181034482758621 +city_ankara,2021,MONTH_jun,0.273227969348659 +city_ankara,2021,MONTH_jul,0.1875 +city_ankara,2021,MONTH_aug,0.6232040229885057 +city_ankara,2021,MONTH_sep,0.8836206896551724 +city_ankara,2021,MONTH_oct,0.7868773946360154 +city_ankara,2021,MONTH_nov,0.7453304597701149 +city_ankara,2021,MONTH_dec,0.6660680076628352 +city_ankara,2022,MONTH_jan,0.6029693486590039 +city_ankara,2022,MONTH_feb,0.8378831417624522 +city_ankara,2022,MONTH_mar,0.4483955938697318 +city_ankara,2022,MONTH_apr,0.09375 +city_ankara,2022,MONTH_may,0.024066091954022987 +city_baghdad,2020,MONTH_jan,0 +city_baghdad,2020,MONTH_feb,0 +city_baghdad,2020,MONTH_mar,0.016242937853107344 +city_baghdad,2020,MONTH_apr,0.016242937853107344 +city_baghdad,2020,MONTH_may,0.03637005649717514 +city_baghdad,2020,MONTH_jun,0.5805084745762712 +city_baghdad,2020,MONTH_jul,1 +city_baghdad,2020,MONTH_aug,0.807909604519774 +city_baghdad,2020,MONTH_sep,0.763771186440678 +city_baghdad,2020,MONTH_oct,0.614406779661017 +city_baghdad,2020,MONTH_nov,0.4809322033898305 +city_baghdad,2020,MONTH_dec,0.2062146892655367 +city_baghdad,2021,MONTH_jan,0.08227401129943503 +city_baghdad,2021,MONTH_feb,0.12076271186440678 +city_baghdad,2021,MONTH_mar,0.3188559322033898 +city_baghdad,2021,MONTH_apr,0.4050141242937853 +city_baghdad,2021,MONTH_may,0.3241525423728814 +city_baghdad,2021,MONTH_jun,0.2842514124293785 +city_baghdad,2021,MONTH_jul,0.5081214689265536 +city_baghdad,2021,MONTH_aug,0.7658898305084746 +city_baghdad,2021,MONTH_sep,0.5144774011299436 +city_baghdad,2021,MONTH_oct,0.3237994350282486 +city_baghdad,2021,MONTH_nov,0.23622881355932204 +city_baghdad,2021,MONTH_dec,0.12252824858757062 +city_baghdad,2022,MONTH_jan,0.07838983050847458 +city_baghdad,2022,MONTH_feb,0.21151129943502825 +city_baghdad,2022,MONTH_mar,0.06638418079096045 +city_baghdad,2022,MONTH_apr,0.01694915254237288 +city_baghdad,2022,MONTH_may,0.002824858757062147 +city_bangkok,2020,MONTH_jan,0 +city_bangkok,2020,MONTH_feb,0 +city_bangkok,2020,MONTH_mar,0.0014854426619132501 +city_bangkok,2020,MONTH_apr,0.006535947712418301 +city_bangkok,2020,MONTH_may,4.45632798573975e-4 +city_bangkok,2020,MONTH_jun,1.4854426619132502e-4 +city_bangkok,2020,MONTH_jul,0 +city_bangkok,2020,MONTH_aug,0 +city_bangkok,2020,MONTH_sep,1.4854426619132502e-4 +city_bangkok,2020,MONTH_oct,0 +city_bangkok,2020,MONTH_nov,1.4854426619132502e-4 +city_bangkok,2020,MONTH_dec,1.4854426619132502e-4 +city_bangkok,2021,MONTH_jan,0.0023767082590612004 +city_bangkok,2021,MONTH_feb,8.9126559714795e-4 +city_bangkok,2021,MONTH_mar,0.0016339869281045752 +city_bangkok,2021,MONTH_apr,0.016191325014854426 +city_bangkok,2021,MONTH_may,0.12299465240641712 +city_bangkok,2021,MONTH_jun,0.1473559120617944 +city_bangkok,2021,MONTH_jul,0.4209744503862151 +city_bangkok,2021,MONTH_aug,1 +city_bangkok,2021,MONTH_sep,0.7632204396910279 +city_bangkok,2021,MONTH_oct,0.3680926916221034 +city_bangkok,2021,MONTH_nov,0.232620320855615 +city_bangkok,2021,MONTH_dec,0.13770053475935828 +city_bangkok,2022,MONTH_jan,0.07055852644087938 +city_bangkok,2022,MONTH_feb,0.11289364230540701 +city_bangkok,2022,MONTH_mar,0.3263517528223411 +city_bangkok,2022,MONTH_apr,0.5044563279857398 +city_bangkok,2022,MONTH_may,0.22177658942364825 +city_beijing,2020,MONTH_jan,0 +city_beijing,2020,MONTH_feb,0.3723932472691162 +city_beijing,2020,MONTH_mar,0.06752730883813307 +city_beijing,2020,MONTH_apr,0.1885373811888211 +city_beijing,2020,MONTH_may,2.837281883955171e-4 +city_beijing,2020,MONTH_jun,4.2559228259327563e-4 +city_beijing,2020,MONTH_jul,0.0025535536955596538 +city_beijing,2020,MONTH_aug,0.00893743793445879 +city_beijing,2020,MONTH_sep,0.0024116896013618955 +city_beijing,2020,MONTH_oct,0 +city_beijing,2020,MONTH_nov,5.674563767910342e-4 +city_beijing,2020,MONTH_dec,0.005390835579514825 +city_beijing,2021,MONTH_jan,0.004965243296921549 +city_beijing,2021,MONTH_feb,0.002837281883955171 +city_beijing,2021,MONTH_mar,0.0011349127535820683 +city_beijing,2021,MONTH_apr,8.511845651865513e-4 +city_beijing,2021,MONTH_may,0.013902681231380337 +city_beijing,2021,MONTH_jun,0.07589729039580083 +city_beijing,2021,MONTH_jul,0.02057029365867499 +city_beijing,2021,MONTH_aug,0.006667612427294652 +city_beijing,2021,MONTH_sep,0.0012767768477798269 +city_beijing,2021,MONTH_oct,7.093204709887927e-4 +city_beijing,2021,MONTH_nov,1.4186409419775854e-4 +city_beijing,2021,MONTH_dec,2.837281883955171e-4 +city_beijing,2022,MONTH_jan,1.4186409419775854e-4 +city_beijing,2022,MONTH_feb,0.06355511420059583 +city_beijing,2022,MONTH_mar,1 +city_beijing,2022,MONTH_apr,0.2816002269825507 +city_beijing,2022,MONTH_may,0.22513831749184282 +city_belgrade,2020,MONTH_jan,0 +city_belgrade,2020,MONTH_feb,0 +city_belgrade,2020,MONTH_mar,0.007441327990841442 +city_belgrade,2020,MONTH_apr,0.09158557527189468 +city_belgrade,2020,MONTH_may,0.03949627933600458 +city_belgrade,2020,MONTH_jun,0.018317115054378934 +city_belgrade,2020,MONTH_jul,0.16657126502575845 +city_belgrade,2020,MONTH_aug,0.0835718374356039 +city_belgrade,2020,MONTH_sep,0.021751574127074985 +city_belgrade,2020,MONTH_oct,0.03720663995420721 +city_belgrade,2020,MONTH_nov,0.42072123640526615 +city_belgrade,2020,MONTH_dec,0.9238694905552376 +city_belgrade,2021,MONTH_jan,0.47910704064109905 +city_belgrade,2021,MONTH_feb,0.2455638236977676 +city_belgrade,2021,MONTH_mar,0.4813966800228964 +city_belgrade,2021,MONTH_apr,0.6107613050944476 +city_belgrade,2021,MONTH_may,0.2959358900973097 +city_belgrade,2021,MONTH_jun,0.10818546078992558 +city_belgrade,2021,MONTH_jul,0.03949627933600458 +city_belgrade,2021,MONTH_aug,0.09502003434459072 +city_belgrade,2021,MONTH_sep,0.5203205495134516 +city_belgrade,2021,MONTH_oct,0.9748139668002289 +city_belgrade,2021,MONTH_nov,1 +city_belgrade,2021,MONTH_dec,0.6016027475672582 +city_belgrade,2022,MONTH_jan,0.5048654836863194 +city_belgrade,2022,MONTH_feb,0.9324556382369776 +city_belgrade,2022,MONTH_mar,0.3371493989696623 +city_belgrade,2022,MONTH_apr,0.11219232970807098 +city_belgrade,2022,MONTH_may,0.05495134516313681 +city_berlin,2020,MONTH_jan,0 +city_berlin,2020,MONTH_feb,3.875217981011432e-5 +city_berlin,2020,MONTH_mar,0.08913001356326293 +city_berlin,2020,MONTH_apr,0.23445068785119164 +city_berlin,2020,MONTH_may,0.029722921914357683 +city_berlin,2020,MONTH_jun,0.0056965704320868045 +city_berlin,2020,MONTH_jul,0.005076535555124976 +city_berlin,2020,MONTH_aug,0.004999031195504747 +city_berlin,2020,MONTH_sep,0.012749467157527611 +city_berlin,2020,MONTH_oct,0.11893043983724085 +city_berlin,2020,MONTH_nov,0.44944778143770586 +city_berlin,2020,MONTH_dec,1 +city_berlin,2021,MONTH_jan,0.7780662662274753 +city_berlin,2021,MONTH_feb,0.2610734353807402 +city_berlin,2021,MONTH_mar,0.21472582832784345 +city_berlin,2021,MONTH_apr,0.26177097461732224 +city_berlin,2021,MONTH_may,0.10831234256926953 +city_berlin,2021,MONTH_jun,0.011393140864173609 +city_berlin,2021,MONTH_jul,0.0063553574888587485 +city_berlin,2021,MONTH_aug,0.033946909513660146 +city_berlin,2021,MONTH_sep,0.06859135826390235 +city_berlin,2021,MONTH_oct,0.13466382484014724 +city_berlin,2021,MONTH_nov,0.3957372602208874 +city_berlin,2021,MONTH_dec,0.346444487502422 +city_berlin,2022,MONTH_jan,0.14357682619647355 +city_berlin,2022,MONTH_feb,0.24545630691726408 +city_berlin,2022,MONTH_mar,0.2939740360395272 +city_berlin,2022,MONTH_apr,0.1602402635148227 +city_berlin,2022,MONTH_may,0.05619066072466576 +city_bogota,2020,MONTH_jan,0 +city_bogota,2020,MONTH_feb,0 +city_bogota,2020,MONTH_mar,5.688605722737357e-4 +city_bogota,2020,MONTH_apr,0.014733488821889755 +city_bogota,2020,MONTH_may,0.033221457420786166 +city_bogota,2020,MONTH_jun,0.12816428693327264 +city_bogota,2020,MONTH_jul,0.3611126912793674 +city_bogota,2020,MONTH_aug,0.54667500995506 +city_bogota,2020,MONTH_sep,0.374139598384436 +city_bogota,2020,MONTH_oct,0.3006428124466693 +city_bogota,2020,MONTH_nov,0.31145116331987027 +city_bogota,2020,MONTH_dec,0.35377438989703625 +city_bogota,2021,MONTH_jan,0.6066329142727117 +city_bogota,2021,MONTH_feb,0.3546276807554468 +city_bogota,2021,MONTH_mar,0.2025712497866773 +city_bogota,2021,MONTH_apr,0.5487229080152455 +city_bogota,2021,MONTH_may,0.8545423516696058 +city_bogota,2021,MONTH_jun,1 +city_bogota,2021,MONTH_jul,0.8419136469651288 +city_bogota,2021,MONTH_aug,0.26651117811024516 +city_bogota,2021,MONTH_sep,0.08009556857614199 +city_bogota,2021,MONTH_oct,0.05722737357073781 +city_bogota,2021,MONTH_nov,0.06894590135957676 +city_bogota,2021,MONTH_dec,0.08129017577791683 +city_bogota,2022,MONTH_jan,0.22561010296376358 +city_bogota,2022,MONTH_feb,0.27111894874566245 +city_bogota,2022,MONTH_mar,0.05671539905569145 +city_bogota,2022,MONTH_apr,0.011035895102110473 +city_bogota,2022,MONTH_may,0.003697593719779282 +city_brasilia,2020,MONTH_jan,0 +city_brasilia,2020,MONTH_feb,0 +city_brasilia,2020,MONTH_mar,0.0016129223543922485 +city_brasilia,2020,MONTH_apr,0.05788730891021004 +city_brasilia,2020,MONTH_may,0.27112513193942056 +city_brasilia,2020,MONTH_jun,0.35275560668413997 +city_brasilia,2020,MONTH_jul,0.38558332048529986 +city_brasilia,2020,MONTH_aug,0.3596816850294714 +city_brasilia,2020,MONTH_sep,0.2561225820989338 +city_brasilia,2020,MONTH_oct,0.20055977893475965 +city_brasilia,2020,MONTH_nov,0.16119735765367235 +city_brasilia,2020,MONTH_dec,0.23861763066450029 +city_brasilia,2021,MONTH_jan,0.35561379997390863 +city_brasilia,2021,MONTH_feb,0.35779598904161575 +city_brasilia,2021,MONTH_mar,0.7238107662567156 +city_brasilia,2021,MONTH_apr,1 +city_brasilia,2021,MONTH_may,0.7456445166569812 +city_brasilia,2021,MONTH_jun,0.6289804195970066 +city_brasilia,2021,MONTH_jul,0.4791921156560206 +city_brasilia,2021,MONTH_aug,0.2942515921678388 +city_brasilia,2021,MONTH_sep,0.19139221290575079 +city_brasilia,2021,MONTH_oct,0.14250643389983278 +city_brasilia,2021,MONTH_nov,0.0808358732907174 +city_brasilia,2021,MONTH_dec,0.053831283577841296 +city_brasilia,2022,MONTH_jan,0.09140288665662544 +city_brasilia,2022,MONTH_feb,0.2655273425918239 +city_brasilia,2022,MONTH_mar,0.1224872211482584 +city_brasilia,2022,MONTH_apr,0.04724913720513763 +city_brasilia,2022,MONTH_may,0.03828318647042778 +city_brisbane,2020,MONTH_jan,0 +city_brisbane,2020,MONTH_feb,0 +city_brisbane,2020,MONTH_mar,0.009825327510917031 +city_brisbane,2020,MONTH_apr,0.039301310043668124 +city_brisbane,2020,MONTH_may,0.006550218340611353 +city_brisbane,2020,MONTH_jun,0.001091703056768559 +city_brisbane,2020,MONTH_jul,0.04639737991266375 +city_brisbane,2020,MONTH_aug,0.23034934497816595 +city_brisbane,2020,MONTH_sep,0.14792576419213974 +city_brisbane,2020,MONTH_oct,0.013646288209606987 +city_brisbane,2020,MONTH_nov,0 +city_brisbane,2020,MONTH_dec,0.001091703056768559 +city_brisbane,2021,MONTH_jan,0 +city_brisbane,2021,MONTH_feb,0 +city_brisbane,2021,MONTH_mar,0 +city_brisbane,2021,MONTH_apr,5.458515283842794e-4 +city_brisbane,2021,MONTH_may,0 +city_brisbane,2021,MONTH_jun,0 +city_brisbane,2021,MONTH_jul,0.007096069868995633 +city_brisbane,2021,MONTH_aug,0.04312227074235808 +city_brisbane,2021,MONTH_sep,0.15065502183406113 +city_brisbane,2021,MONTH_oct,0.2423580786026201 +city_brisbane,2021,MONTH_nov,0.15010917030567686 +city_brisbane,2021,MONTH_dec,0.125 +city_brisbane,2022,MONTH_jan,0.8133187772925764 +city_brisbane,2022,MONTH_feb,0.7876637554585153 +city_brisbane,2022,MONTH_mar,0.4383187772925764 +city_brisbane,2022,MONTH_apr,0.6697598253275109 +city_brisbane,2022,MONTH_may,0.6986899563318777 +city_bucharest,2020,MONTH_jan,0 +city_bucharest,2020,MONTH_feb,0 +city_bucharest,2020,MONTH_mar,0.006214743283296682 +city_bucharest,2020,MONTH_apr,0.06004398126015872 +city_bucharest,2020,MONTH_may,0.05411607228224496 +city_bucharest,2020,MONTH_jun,0.03585428817286548 +city_bucharest,2020,MONTH_jul,0.06405966153551965 +city_bucharest,2020,MONTH_aug,0.12180896835261497 +city_bucharest,2020,MONTH_sep,0.1160722822449565 +city_bucharest,2020,MONTH_oct,0.19839372788985563 +city_bucharest,2020,MONTH_nov,0.4136150683621761 +city_bucharest,2020,MONTH_dec,0.4209771488670045 +city_bucharest,2021,MONTH_jan,0.2550913089205469 +city_bucharest,2021,MONTH_feb,0.19342193326321827 +city_bucharest,2021,MONTH_mar,0.29849890046849603 +city_bucharest,2021,MONTH_apr,0.4361793670522995 +city_bucharest,2021,MONTH_may,0.22038435796921313 +city_bucharest,2021,MONTH_jun,0.3182904675399178 +city_bucharest,2021,MONTH_jul,0.06434649584090257 +city_bucharest,2021,MONTH_aug,0.02495458456831437 +city_bucharest,2021,MONTH_sep,0.2223921981068936 +city_bucharest,2021,MONTH_oct,1 +city_bucharest,2021,MONTH_nov,0.8660483793861746 +city_bucharest,2021,MONTH_dec,0.22296586671765944 +city_bucharest,2022,MONTH_jan,0.1214265226121044 +city_bucharest,2022,MONTH_feb,0.3221149249450234 +city_bucharest,2022,MONTH_mar,0.1568983650444593 +city_bucharest,2022,MONTH_apr,0.046275934601778375 +city_bucharest,2022,MONTH_may,0.019122287025528255 +city_cairo,2020,MONTH_jan,0 +city_cairo,2020,MONTH_feb,0 +city_cairo,2020,MONTH_mar,0.02092904543134252 +city_cairo,2020,MONTH_apr,0.17304747320061256 +city_cairo,2020,MONTH_may,0.2720775906074528 +city_cairo,2020,MONTH_jun,1 +city_cairo,2020,MONTH_jul,0.9709035222052067 +city_cairo,2020,MONTH_aug,0.31904032669729454 +city_cairo,2020,MONTH_sep,0.2628892291985707 +city_cairo,2020,MONTH_oct,0.1755997958141909 +city_cairo,2020,MONTH_nov,0.19295558958652373 +city_cairo,2020,MONTH_dec,0.47983665135273096 +city_cairo,2021,MONTH_jan,0.8611536498213375 +city_cairo,2021,MONTH_feb,0.7023991832567636 +city_cairo,2021,MONTH_mar,0.6722817764165391 +city_cairo,2021,MONTH_apr,0.6748340990301174 +city_cairo,2021,MONTH_may,0.9030117406840225 +city_cairo,2021,MONTH_jun,0.5620214395099541 +city_cairo,2021,MONTH_jul,0.18887187340479836 +city_cairo,2021,MONTH_aug,0.1066870852475753 +city_cairo,2021,MONTH_sep,0.2894333843797856 +city_cairo,2021,MONTH_oct,0.6625829504849413 +city_cairo,2021,MONTH_nov,0.9290454313425217 +city_cairo,2021,MONTH_dec,0.6712608473711077 +city_cairo,2022,MONTH_jan,0.4476773864216437 +city_cairo,2022,MONTH_feb,0.733027054619704 +city_cairo,2022,MONTH_mar,0.19244512506380806 +city_cairo,2022,MONTH_apr,0.09647779479326186 +city_cairo,2022,MONTH_may,0.05717202654415518 +city_chengdu,2020,MONTH_jan,0 +city_chengdu,2020,MONTH_feb,0.3723932472691162 +city_chengdu,2020,MONTH_mar,0.06752730883813307 +city_chengdu,2020,MONTH_apr,0.1885373811888211 +city_chengdu,2020,MONTH_may,2.837281883955171e-4 +city_chengdu,2020,MONTH_jun,4.2559228259327563e-4 +city_chengdu,2020,MONTH_jul,0.0025535536955596538 +city_chengdu,2020,MONTH_aug,0.00893743793445879 +city_chengdu,2020,MONTH_sep,0.0024116896013618955 +city_chengdu,2020,MONTH_oct,0 +city_chengdu,2020,MONTH_nov,5.674563767910342e-4 +city_chengdu,2020,MONTH_dec,0.005390835579514825 +city_chengdu,2021,MONTH_jan,0.004965243296921549 +city_chengdu,2021,MONTH_feb,0.002837281883955171 +city_chengdu,2021,MONTH_mar,0.0011349127535820683 +city_chengdu,2021,MONTH_apr,8.511845651865513e-4 +city_chengdu,2021,MONTH_may,0.013902681231380337 +city_chengdu,2021,MONTH_jun,0.07589729039580083 +city_chengdu,2021,MONTH_jul,0.02057029365867499 +city_chengdu,2021,MONTH_aug,0.006667612427294652 +city_chengdu,2021,MONTH_sep,0.0012767768477798269 +city_chengdu,2021,MONTH_oct,7.093204709887927e-4 +city_chengdu,2021,MONTH_nov,1.4186409419775854e-4 +city_chengdu,2021,MONTH_dec,2.837281883955171e-4 +city_chengdu,2022,MONTH_jan,1.4186409419775854e-4 +city_chengdu,2022,MONTH_feb,0.06355511420059583 +city_chengdu,2022,MONTH_mar,1 +city_chengdu,2022,MONTH_apr,0.2816002269825507 +city_chengdu,2022,MONTH_may,0.22513831749184282 +city_dhaka,2020,MONTH_jan,0 +city_dhaka,2020,MONTH_feb,0 +city_dhaka,2020,MONTH_mar,8.087997411840828e-4 +city_dhaka,2020,MONTH_apr,0.0263668715626011 +city_dhaka,2020,MONTH_may,0.07796829505014559 +city_dhaka,2020,MONTH_jun,0.19362665803946943 +city_dhaka,2020,MONTH_jul,0.20446457457133613 +city_dhaka,2020,MONTH_aug,0.18925913943707537 +city_dhaka,2020,MONTH_sep,0.15690714978971207 +city_dhaka,2020,MONTH_oct,0.10870268521514073 +city_dhaka,2020,MONTH_nov,0.11662892267874474 +city_dhaka,2020,MONTH_dec,0.14801035263668716 +city_dhaka,2021,MONTH_jan,0.0918796505985118 +city_dhaka,2021,MONTH_feb,0.045454545454545456 +city_dhaka,2021,MONTH_mar,0.10320284697508897 +city_dhaka,2021,MONTH_apr,0.38887091556130704 +city_dhaka,2021,MONTH_may,0.18909737948883856 +city_dhaka,2021,MONTH_jun,0.3047557424781624 +city_dhaka,2021,MONTH_jul,1 +city_dhaka,2021,MONTH_aug,0.8912973147848593 +city_dhaka,2021,MONTH_sep,0.21271433193141379 +city_dhaka,2021,MONTH_oct,0.05791006146878033 +city_dhaka,2021,MONTH_nov,0.018278874150760273 +city_dhaka,2021,MONTH_dec,0.014720155289550308 +city_dhaka,2022,MONTH_jan,0.05208670333225494 +city_dhaka,2022,MONTH_feb,0.10401164671627305 +city_dhaka,2022,MONTH_mar,0.013749595600129408 +city_dhaka,2022,MONTH_apr,8.087997411840828e-4 +city_dhaka,2022,MONTH_may,6.470397929472663e-4 +city_dubai,2020,MONTH_jan,0 +city_dubai,2020,MONTH_feb,0 +city_dubai,2020,MONTH_mar,0.016 +city_dubai,2020,MONTH_apr,0.24533333333333332 +city_dubai,2020,MONTH_may,0.43733333333333335 +city_dubai,2020,MONTH_jun,0.13866666666666666 +city_dubai,2020,MONTH_jul,0.09333333333333334 +city_dubai,2020,MONTH_aug,0.088 +city_dubai,2020,MONTH_sep,0.09066666666666667 +city_dubai,2020,MONTH_oct,0.19733333333333333 +city_dubai,2020,MONTH_nov,0.21333333333333335 +city_dubai,2020,MONTH_dec,0.25333333333333335 +city_dubai,2021,MONTH_jan,0.4613333333333333 +city_dubai,2021,MONTH_feb,1 +city_dubai,2021,MONTH_mar,0.744 +city_dubai,2021,MONTH_apr,0.24533333333333332 +city_dubai,2021,MONTH_may,0.248 +city_dubai,2021,MONTH_jun,0.3466666666666667 +city_dubai,2021,MONTH_jul,0.3626666666666667 +city_dubai,2021,MONTH_aug,0.256 +city_dubai,2021,MONTH_sep,0.14933333333333335 +city_dubai,2021,MONTH_oct,0.10933333333333334 +city_dubai,2021,MONTH_nov,0.02666666666666667 +city_dubai,2021,MONTH_dec,0.042666666666666665 +city_dubai,2022,MONTH_jan,0.208 +city_dubai,2022,MONTH_feb,0.16266666666666665 +city_dubai,2022,MONTH_mar,0.0026666666666666666 +city_dubai,2022,MONTH_apr,0 +city_dubai,2022,MONTH_may,0.008 +city_guatemala_city,2020,MONTH_jan,0 +city_guatemala_city,2020,MONTH_feb,0 +city_guatemala_city,2020,MONTH_mar,6.101281269066504e-4 +city_guatemala_city,2020,MONTH_apr,0.009151921903599756 +city_guatemala_city,2020,MONTH_may,0.04514948139109213 +city_guatemala_city,2020,MONTH_jun,0.3886516168395363 +city_guatemala_city,2020,MONTH_jul,0.6955460646735815 +city_guatemala_city,2020,MONTH_aug,0.5326418547895058 +city_guatemala_city,2020,MONTH_sep,0.3038438071995119 +city_guatemala_city,2020,MONTH_oct,0.2904209884075656 +city_guatemala_city,2020,MONTH_nov,0.27577791336180596 +city_guatemala_city,2020,MONTH_dec,0.3886516168395363 +city_guatemala_city,2021,MONTH_jan,0.49725442342892007 +city_guatemala_city,2021,MONTH_feb,0.4612568639414277 +city_guatemala_city,2021,MONTH_mar,0.27394752898108604 +city_guatemala_city,2021,MONTH_apr,0.41305674191580233 +city_guatemala_city,2021,MONTH_may,0.3886516168395363 +city_guatemala_city,2021,MONTH_jun,0.6162294081757169 +city_guatemala_city,2021,MONTH_jul,0.6717510677242221 +city_guatemala_city,2021,MONTH_aug,0.9993898718730934 +city_guatemala_city,2021,MONTH_sep,1 +city_guatemala_city,2021,MONTH_oct,0.9121415497254424 +city_guatemala_city,2021,MONTH_nov,0.5539963392312386 +city_guatemala_city,2021,MONTH_dec,0.10616229408175717 +city_guatemala_city,2022,MONTH_jan,0.16534472239170225 +city_guatemala_city,2022,MONTH_feb,0.3587553386211104 +city_guatemala_city,2022,MONTH_mar,0.20378279438682123 +city_guatemala_city,2022,MONTH_apr,0.1525320317266626 +city_guatemala_city,2022,MONTH_may,0.348993288590604 +city_hanoi,2020,MONTH_jan,0 +city_hanoi,2020,MONTH_feb,0 +city_hanoi,2020,MONTH_mar,0 +city_hanoi,2020,MONTH_apr,0 +city_hanoi,2020,MONTH_may,0 +city_hanoi,2020,MONTH_jun,0 +city_hanoi,2020,MONTH_jul,0 +city_hanoi,2020,MONTH_aug,0.0032313440371604563 +city_hanoi,2020,MONTH_sep,3.029385034837928e-4 +city_hanoi,2020,MONTH_oct,0 +city_hanoi,2020,MONTH_nov,0 +city_hanoi,2020,MONTH_dec,0 +city_hanoi,2021,MONTH_jan,0 +city_hanoi,2021,MONTH_feb,0 +city_hanoi,2021,MONTH_mar,0 +city_hanoi,2021,MONTH_apr,0 +city_hanoi,2021,MONTH_may,0.0012117540139351712 +city_hanoi,2021,MONTH_jun,0.003736241542966778 +city_hanoi,2021,MONTH_jul,0.10875492275068162 +city_hanoi,2021,MONTH_aug,1 +city_hanoi,2021,MONTH_sep,0.8112693123295971 +city_hanoi,2021,MONTH_oct,0.2960718974048268 +city_hanoi,2021,MONTH_nov,0.30546299101282437 +city_hanoi,2021,MONTH_dec,0.7182671917600727 +city_hanoi,2022,MONTH_jan,0.5553872563869534 +city_hanoi,2022,MONTH_feb,0.2500252448752903 +city_hanoi,2022,MONTH_mar,0.23326264768252045 +city_hanoi,2022,MONTH_apr,0.05897202867817833 +city_hanoi,2022,MONTH_may,0.004039180046450571 +city_harare,2020,MONTH_jan,0 +city_harare,2020,MONTH_feb,0 +city_harare,2020,MONTH_mar,0.003470213996529786 +city_harare,2020,MONTH_apr,0.001156737998843262 +city_harare,2020,MONTH_may,0 +city_harare,2020,MONTH_jun,0.001735106998264893 +city_harare,2020,MONTH_jul,0.026604973973395025 +city_harare,2020,MONTH_aug,0.08155002891844997 +city_harare,2020,MONTH_sep,0.017929438982070563 +city_harare,2020,MONTH_oct,0.008097165991902834 +city_harare,2020,MONTH_nov,0.019086176980913822 +city_harare,2020,MONTH_dec,0.048582995951417005 +city_harare,2021,MONTH_jan,0.4817813765182186 +city_harare,2021,MONTH_feb,0.15615962984384038 +city_harare,2021,MONTH_mar,0.0335454019664546 +city_harare,2021,MONTH_apr,0.026604973973395025 +city_harare,2021,MONTH_may,0.015615962984384037 +city_harare,2021,MONTH_jun,0.09658762290341237 +city_harare,2021,MONTH_jul,1 +city_harare,2021,MONTH_aug,0.5355696934644303 +city_harare,2021,MONTH_sep,0.1156737998843262 +city_harare,2021,MONTH_oct,0.035280508964719494 +city_harare,2021,MONTH_nov,0.0167727009832273 +city_harare,2021,MONTH_dec,0.1683053788316946 +city_harare,2022,MONTH_jan,0.19664545980335454 +city_harare,2022,MONTH_feb,0.03296703296703297 +city_harare,2022,MONTH_mar,0.026604973973395025 +city_harare,2022,MONTH_apr,0.0167727009832273 +city_harare,2022,MONTH_may,0.019664545980335454 +city_islamabad,2020,MONTH_jan,0 +city_islamabad,2020,MONTH_feb,0 +city_islamabad,2020,MONTH_mar,0.007521058965102286 +city_islamabad,2020,MONTH_apr,0.09657039711191336 +city_islamabad,2020,MONTH_may,0.34205776173285196 +city_islamabad,2020,MONTH_jun,0.848676293622142 +city_islamabad,2020,MONTH_jul,0.4954873646209386 +city_islamabad,2020,MONTH_aug,0.10318892900120337 +city_islamabad,2020,MONTH_sep,0.05565583634175692 +city_islamabad,2020,MONTH_oct,0.0950661853188929 +city_islamabad,2020,MONTH_nov,0.35800240673886885 +city_islamabad,2020,MONTH_dec,0.6203369434416366 +city_islamabad,2021,MONTH_jan,0.4741275571600481 +city_islamabad,2021,MONTH_feb,0.36522262334536704 +city_islamabad,2021,MONTH_mar,0.45697954271961494 +city_islamabad,2021,MONTH_apr,1 +city_islamabad,2021,MONTH_may,0.9193742478941035 +city_islamabad,2021,MONTH_jun,0.4566787003610108 +city_islamabad,2021,MONTH_jul,0.3131768953068592 +city_islamabad,2021,MONTH_aug,0.7145006016847172 +city_islamabad,2021,MONTH_sep,0.6077015643802648 +city_islamabad,2021,MONTH_oct,0.2253309265944645 +city_islamabad,2021,MONTH_nov,0.08393501805054152 +city_islamabad,2021,MONTH_dec,0.06107099879663057 +city_islamabad,2022,MONTH_jan,0.0983754512635379 +city_islamabad,2022,MONTH_feb,0.2782791817087846 +city_islamabad,2022,MONTH_mar,0.052948255114320095 +city_islamabad,2022,MONTH_apr,0.006016847172081829 +city_islamabad,2022,MONTH_may,0.0030084235860409147 +city_jakarta,2020,MONTH_jan,0 +city_jakarta,2020,MONTH_feb,0 +city_jakarta,2020,MONTH_mar,0.003495784495167592 +city_jakarta,2020,MONTH_apr,0.016862019329631914 +city_jakarta,2020,MONTH_may,0.02110322845979848 +city_jakarta,2020,MONTH_jun,0.032464528069093154 +city_jakarta,2020,MONTH_jul,0.057963191445609706 +city_jakarta,2020,MONTH_aug,0.05876002467612585 +city_jakarta,2020,MONTH_sep,0.08541538145177874 +city_jakarta,2020,MONTH_oct,0.0804287476866132 +city_jakarta,2020,MONTH_nov,0.07906641990540818 +city_jakarta,2020,MONTH_dec,0.13348241826033314 +city_jakarta,2021,MONTH_jan,0.20203578038247996 +city_jakarta,2021,MONTH_feb,0.15854410857495374 +city_jakarta,2021,MONTH_mar,0.12060456508328192 +city_jakarta,2021,MONTH_apr,0.11985914044828296 +city_jakarta,2021,MONTH_may,0.12998663376516553 +city_jakarta,2021,MONTH_jun,0.20339810816368498 +city_jakarta,2021,MONTH_jul,0.9157927205428747 +city_jakarta,2021,MONTH_aug,1 +city_jakarta,2021,MONTH_sep,0.22917951881554596 +city_jakarta,2021,MONTH_oct,0.037682500514085955 +city_jakarta,2021,MONTH_nov,0.010924326547398725 +city_jakarta,2021,MONTH_dec,0.006785934608266502 +city_jakarta,2022,MONTH_jan,0.0058091712934402635 +city_jakarta,2022,MONTH_feb,0.10320275550071972 +city_jakarta,2022,MONTH_mar,0.17360682706148467 +city_jakarta,2022,MONTH_apr,0.030022619782027554 +city_jakarta,2022,MONTH_may,0.008585235451367468 +city_kyiv,2020,MONTH_jan,0 +city_kyiv,2020,MONTH_feb,0 +city_kyiv,2020,MONTH_mar,7.124849282034418e-4 +city_kyiv,2020,MONTH_apr,0.013592020168804122 +city_kyiv,2020,MONTH_may,0.024498520223610654 +city_kyiv,2020,MONTH_jun,0.02471774635536556 +city_kyiv,2020,MONTH_jul,0.029266688589279843 +city_kyiv,2020,MONTH_aug,0.04735284445905952 +city_kyiv,2020,MONTH_sep,0.08615586977967774 +city_kyiv,2020,MONTH_oct,0.16809163652307355 +city_kyiv,2020,MONTH_nov,0.2812123205086046 +city_kyiv,2020,MONTH_dec,0.3401293434177354 +city_kyiv,2021,MONTH_jan,0.22876246848624357 +city_kyiv,2021,MONTH_feb,0.17949139537432862 +city_kyiv,2021,MONTH_mar,0.37504110489970405 +city_kyiv,2021,MONTH_apr,0.6171215608900581 +city_kyiv,2021,MONTH_may,0.35355694398772336 +city_kyiv,2021,MONTH_jun,0.09887098542146223 +city_kyiv,2021,MONTH_jul,0.03315795242792941 +city_kyiv,2021,MONTH_aug,0.046256713800284996 +city_kyiv,2021,MONTH_sep,0.13619423435273484 +city_kyiv,2021,MONTH_oct,0.6278088348131097 +city_kyiv,2021,MONTH_nov,1 +city_kyiv,2021,MONTH_dec,0.5439000328839197 +city_kyiv,2022,MONTH_jan,0.23588731776827798 +city_kyiv,2022,MONTH_feb,0.3148635317329826 +city_kyiv,2022,MONTH_mar,0.11010632467390113 +city_kyiv,2022,MONTH_apr,0.024662939822426833 +city_kyiv,2022,MONTH_may,0.00887865833607366 +city_la_paz,2020,MONTH_jan,0 +city_la_paz,2020,MONTH_feb,0 +city_la_paz,2020,MONTH_mar,0.001688048615800135 +city_la_paz,2020,MONTH_apr,0.01688048615800135 +city_la_paz,2020,MONTH_may,0.08271438217420661 +city_la_paz,2020,MONTH_jun,0.24105334233625927 +city_la_paz,2020,MONTH_jul,0.6056718433490884 +city_la_paz,2020,MONTH_aug,0.7191087103308575 +city_la_paz,2020,MONTH_sep,1 +city_la_paz,2020,MONTH_oct,0.27177582714382176 +city_la_paz,2020,MONTH_nov,0.08237677245104659 +city_la_paz,2020,MONTH_dec,0.06279540850776502 +city_la_paz,2021,MONTH_jan,0.3683322079675895 +city_la_paz,2021,MONTH_feb,0.4669142471303174 +city_la_paz,2021,MONTH_mar,0.20324105334233625 +city_la_paz,2021,MONTH_apr,0.23936529372045914 +city_la_paz,2021,MONTH_may,0.5114787305874409 +city_la_paz,2021,MONTH_jun,0.7413909520594193 +city_la_paz,2021,MONTH_jul,0.38926401080351114 +city_la_paz,2021,MONTH_aug,0.21168129642133693 +city_la_paz,2021,MONTH_sep,0.10297096556380823 +city_la_paz,2021,MONTH_oct,0.07022282241728561 +city_la_paz,2021,MONTH_nov,0.0800135043889264 +city_la_paz,2021,MONTH_dec,0.1650911546252532 +city_la_paz,2022,MONTH_jan,0.4189736664415935 +city_la_paz,2022,MONTH_feb,0.1826468602295746 +city_la_paz,2022,MONTH_mar,0.15597569209993248 +city_la_paz,2022,MONTH_apr,0.0054017555705604325 +city_la_paz,2022,MONTH_may,0.012491559756921 +city_lima,2020,MONTH_jan,0 +city_lima,2020,MONTH_feb,0 +city_lima,2020,MONTH_mar,0.0040497911160371726 +city_lima,2020,MONTH_apr,0.17098644385710632 +city_lima,2020,MONTH_may,0.6555119788558275 +city_lima,2020,MONTH_jun,0.7456304885326968 +city_lima,2020,MONTH_jul,0.7682240600221673 +city_lima,2020,MONTH_aug,0.7700571233694262 +city_lima,2020,MONTH_sep,0.3826839457754284 +city_lima,2020,MONTH_oct,0.1922585045613437 +city_lima,2020,MONTH_nov,0.1284849518288004 +city_lima,2020,MONTH_dec,0.14945860687185608 +city_lima,2021,MONTH_jan,0.41746951999317927 +city_lima,2021,MONTH_feb,0.784423224486316 +city_lima,2021,MONTH_mar,0.8913803393298662 +city_lima,2021,MONTH_apr,1 +city_lima,2021,MONTH_may,0.7605934009719498 +city_lima,2021,MONTH_jun,0.3705772018074857 +city_lima,2021,MONTH_jul,0.1726916190638588 +city_lima,2021,MONTH_aug,0.08504561343678063 +city_lima,2021,MONTH_sep,0.04774490578906983 +city_lima,2021,MONTH_oct,0.03700230198652912 +city_lima,2021,MONTH_nov,0.03883536533378805 +city_lima,2021,MONTH_dec,0.06292096512916702 +city_lima,2022,MONTH_jan,0.11778497740642851 +city_lima,2022,MONTH_feb,0.21570466365419047 +city_lima,2022,MONTH_mar,0.07553926165913548 +city_lima,2022,MONTH_apr,0.026387586324494842 +city_lima,2022,MONTH_may,0.01598601756330463 +city_madrid,2020,MONTH_jan,0 +city_madrid,2020,MONTH_feb,5.852744937375629e-5 +city_madrid,2020,MONTH_mar,0.5019314058293339 +city_madrid,2020,MONTH_apr,1 +city_madrid,2020,MONTH_may,0.2004565141051153 +city_madrid,2020,MONTH_jun,0.038745171485426666 +city_madrid,2020,MONTH_jul,0.010827578134144915 +city_madrid,2020,MONTH_aug,0.062214678684302936 +city_madrid,2020,MONTH_sep,0.18307386164110967 +city_madrid,2020,MONTH_oct,0.3029380779585626 +city_madrid,2020,MONTH_nov,0.5457684654102775 +city_madrid,2020,MONTH_dec,0.3399859534121503 +city_madrid,2021,MONTH_jan,0.6453821842444106 +city_madrid,2021,MONTH_feb,0.5533770338288657 +city_madrid,2021,MONTH_mar,0.18658550860353507 +city_madrid,2021,MONTH_apr,0.13666159428772093 +city_madrid,2021,MONTH_may,0.08673767997190683 +city_madrid,2021,MONTH_jun,0.03775020484607281 +city_madrid,2021,MONTH_jul,0.059229778766241366 +city_madrid,2021,MONTH_aug,0.1822544773498771 +city_madrid,2021,MONTH_sep,0.093585391548636307 +city_madrid,2021,MONTH_oct,0.03494088727613251 +city_madrid,2021,MONTH_nov,0.03616996371298139 +city_madrid,2021,MONTH_dec,0.1144796909750673 +city_madrid,2022,MONTH_jan,0.32476881657497364 +city_madrid,2022,MONTH_feb,0.27689336298724104 +city_madrid,2022,MONTH_mar,0.10125248741659838 +city_madrid,2022,MONTH_apr,0.08351867025635022 +city_madrid,2022,MONTH_may,0.10722228725272152 +city_managua,2020,MONTH_jan,0 +city_managua,2020,MONTH_feb,0 +city_managua,2020,MONTH_mar,0.023809523809523808 +city_managua,2020,MONTH_apr,0.047619047619047616 +city_managua,2020,MONTH_may,0.7619047619047619 +city_managua,2020,MONTH_jun,0.9285714285714286 +city_managua,2020,MONTH_jul,1 +city_managua,2020,MONTH_aug,0.5 +city_managua,2020,MONTH_sep,0.3333333333333333 +city_managua,2020,MONTH_oct,0.11904761904761904 +city_managua,2020,MONTH_nov,0.09523809523809523 +city_managua,2020,MONTH_dec,0.11904761904761904 +city_managua,2021,MONTH_jan,0.09523809523809523 +city_managua,2021,MONTH_feb,0.09523809523809523 +city_managua,2021,MONTH_mar,0.11904761904761904 +city_managua,2021,MONTH_apr,0.09523809523809523 +city_managua,2021,MONTH_may,0.09523809523809523 +city_managua,2021,MONTH_jun,0.11904761904761904 +city_managua,2021,MONTH_jul,0.09523809523809523 +city_managua,2021,MONTH_aug,0.09523809523809523 +city_managua,2021,MONTH_sep,0.11904761904761904 +city_managua,2021,MONTH_oct,0.09523809523809523 +city_managua,2021,MONTH_nov,0.09523809523809523 +city_managua,2021,MONTH_dec,0.11904761904761904 +city_managua,2022,MONTH_jan,0.07142857142857142 +city_managua,2022,MONTH_feb,0.09523809523809523 +city_managua,2022,MONTH_mar,0.14285714285714285 +city_managua,2022,MONTH_apr,0.09523809523809523 +city_managua,2022,MONTH_may,0.09523809523809523 +city_mexico_city,2020,MONTH_jan,0 +city_mexico_city,2020,MONTH_feb,0 +city_mexico_city,2020,MONTH_mar,0.0013482679941920763 +city_mexico_city,2020,MONTH_apr,0.1015608794855839 +city_mexico_city,2020,MONTH_may,0.40523231694669154 +city_mexico_city,2020,MONTH_jun,0.5275876374196224 +city_mexico_city,2020,MONTH_jul,0.6168066791122174 +city_mexico_city,2020,MONTH_aug,0.4998703588467123 +city_mexico_city,2020,MONTH_sep,0.34160443891308856 +city_mexico_city,2020,MONTH_oct,0.32690313213026345 +city_mexico_city,2020,MONTH_nov,0.4108328147687202 +city_mexico_city,2020,MONTH_dec,0.5958566687409251 +city_mexico_city,2021,MONTH_jan,1 +city_mexico_city,2021,MONTH_feb,0.6428386226923875 +city_mexico_city,2021,MONTH_mar,0.3536869943995022 +city_mexico_city,2021,MONTH_apr,0.20423667288944203 +city_mexico_city,2021,MONTH_may,0.10806886538062642 +city_mexico_city,2021,MONTH_jun,0.080196017423771 +city_mexico_city,2021,MONTH_jul,0.20589607965152457 +city_mexico_city,2021,MONTH_aug,0.5757104335200166 +city_mexico_city,2021,MONTH_sep,0.4466397013067828 +city_mexico_city,2021,MONTH_oct,0.22204936735117195 +city_mexico_city,2021,MONTH_nov,0.11226923874714789 +city_mexico_city,2021,MONTH_dec,0.09852727649865173 +city_mexico_city,2022,MONTH_jan,0.2316946691557768 +city_mexico_city,2022,MONTH_feb,0.27434660858743 +city_mexico_city,2022,MONTH_mar,0.04877100186683261 +city_mexico_city,2022,MONTH_apr,0.008893383115536196 +city_mexico_city,2022,MONTH_may,0.004252229827836548 +city_moscow,2020,MONTH_jan,0 +city_moscow,2020,MONTH_feb,0 +city_moscow,2020,MONTH_mar,4.6378393125085253e-4 +city_moscow,2020,MONTH_apr,0.028809166552994134 +city_moscow,2020,MONTH_may,0.09875869594871095 +city_moscow,2020,MONTH_jun,0.1262310735233938 +city_moscow,2020,MONTH_jul,0.12666757604692402 +city_moscow,2020,MONTH_aug,0.08765516300641113 +city_moscow,2020,MONTH_sep,0.09673987177738372 +city_moscow,2020,MONTH_oct,0.1982812713135998 +city_moscow,2020,MONTH_nov,0.32478515891419996 +city_moscow,2020,MONTH_dec,0.4671668258082117 +city_moscow,2021,MONTH_jan,0.4409493929886782 +city_moscow,2021,MONTH_feb,0.3530214159050607 +city_moscow,2021,MONTH_mar,0.3472377574682854 +city_moscow,2021,MONTH_apr,0.3076797162733597 +city_moscow,2021,MONTH_may,0.3102714500068203 +city_moscow,2021,MONTH_jun,0.37410994407311415 +city_moscow,2021,MONTH_jul,0.6369935888691857 +city_moscow,2021,MONTH_aug,0.6727867957986632 +city_moscow,2021,MONTH_sep,0.655599508934661 +city_moscow,2021,MONTH_oct,0.8534442777247306 +city_moscow,2021,MONTH_nov,1 +city_moscow,2021,MONTH_dec,0.9184831537307325 +city_moscow,2022,MONTH_jan,0.6135315782294366 +city_moscow,2022,MONTH_feb,0.5541126722138863 +city_moscow,2022,MONTH_mar,0.46547537852953214 +city_moscow,2022,MONTH_apr,0.1953894420952121 +city_moscow,2022,MONTH_may,0.0882007911608239 +city_mumbai,2020,MONTH_jan,0 +city_mumbai,2020,MONTH_feb,0 +city_mumbai,2020,MONTH_mar,2.6496646518175043e-4 +city_mumbai,2020,MONTH_apr,0.008627970522480748 +city_mumbai,2020,MONTH_may,0.03386602633104248 +city_mumbai,2020,MONTH_jun,0.09711848969114846 +city_mumbai,2020,MONTH_jul,0.15611492920427258 +city_mumbai,2020,MONTH_aug,0.23782396290469487 +city_mumbai,2020,MONTH_sep,0.2734785128757142 +city_mumbai,2020,MONTH_oct,0.1999171979796307 +city_mumbai,2020,MONTH_nov,0.1283265711683365 +city_mumbai,2020,MONTH_dec,0.09604206342634761 +city_mumbai,2021,MONTH_jan,0.04583919847644283 +city_mumbai,2021,MONTH_feb,0.02299412105655378 +city_mumbai,2021,MONTH_mar,0.04485385443404819 +city_mumbai,2021,MONTH_apr,0.37974662581766994 +city_mumbai,2021,MONTH_may,1 +city_mumbai,2021,MONTH_jun,0.5742651320692225 +city_mumbai,2021,MONTH_jul,0.2099528028483895 +city_mumbai,2021,MONTH_aug,0.1221329800447131 +city_mumbai,2021,MONTH_sep,0.07867847975490602 +city_mumbai,2021,MONTH_oct,0.0838287654218763 +city_mumbai,2021,MONTH_nov,0.0893765007866192 +city_mumbai,2021,MONTH_dec,0.10019044464684938 +city_mumbai,2022,MONTH_jan,0.11567442245590792 +city_mumbai,2022,MONTH_feb,0.15560983688001986 +city_mumbai,2022,MONTH_mar,0.0603295520410698 +city_mumbai,2022,MONTH_apr,0.02214126024675002 +city_mumbai,2022,MONTH_may,0.006847727084540863 +city_nairobi,2020,MONTH_jan,0 +city_nairobi,2020,MONTH_feb,0 +city_nairobi,2020,MONTH_mar,0.005037783375314861 +city_nairobi,2020,MONTH_apr,0.012594458438287154 +city_nairobi,2020,MONTH_may,0.061712846347607056 +city_nairobi,2020,MONTH_jun,0.10201511335012595 +city_nairobi,2020,MONTH_jul,0.22795969773299748 +city_nairobi,2020,MONTH_aug,0.3136020151133501 +city_nairobi,2020,MONTH_sep,0.16750629722921914 +city_nairobi,2020,MONTH_oct,0.345088161209068 +city_nairobi,2020,MONTH_nov,0.593198992443325 +city_nairobi,2020,MONTH_dec,0.2707808564231738 +city_nairobi,2021,MONTH_jan,0.11083123425692695 +city_nairobi,2021,MONTH_feb,0.12468513853904283 +city_nairobi,2021,MONTH_mar,0.3690176322418136 +city_nairobi,2021,MONTH_apr,0.7052896725440806 +city_nairobi,2021,MONTH_may,0.5667506297229219 +city_nairobi,2021,MONTH_jun,0.5843828715365239 +city_nairobi,2021,MONTH_jul,0.38413098236775817 +city_nairobi,2021,MONTH_aug,1 +city_nairobi,2021,MONTH_sep,0.5025188916876574 +city_nairobi,2021,MONTH_oct,0.1977329974811083 +city_nairobi,2021,MONTH_nov,0.07304785894206549 +city_nairobi,2021,MONTH_dec,0.05289672544080604 +city_nairobi,2022,MONTH_jan,0.25692695214105793 +city_nairobi,2022,MONTH_feb,0.0743073047858942 +city_nairobi,2022,MONTH_mar,0.011335012594458438 +city_nairobi,2022,MONTH_apr,0.0012594458438287153 +city_nairobi,2022,MONTH_may,0.0025188916876574307 +city_new_delhi,2020,MONTH_jan,0 +city_new_delhi,2020,MONTH_feb,0 +city_new_delhi,2020,MONTH_mar,2.6496646518175043e-4 +city_new_delhi,2020,MONTH_apr,0.008627970522480748 +city_new_delhi,2020,MONTH_may,0.03386602633104248 +city_new_delhi,2020,MONTH_jun,0.09711848969114846 +city_new_delhi,2020,MONTH_jul,0.15611492920427258 +city_new_delhi,2020,MONTH_aug,0.23782396290469487 +city_new_delhi,2020,MONTH_sep,0.2734785128757142 +city_new_delhi,2020,MONTH_oct,0.1999171979796307 +city_new_delhi,2020,MONTH_nov,0.1283265711683365 +city_new_delhi,2020,MONTH_dec,0.09604206342634761 +city_new_delhi,2021,MONTH_jan,0.04583919847644283 +city_new_delhi,2021,MONTH_feb,0.02299412105655378 +city_new_delhi,2021,MONTH_mar,0.04485385443404819 +city_new_delhi,2021,MONTH_apr,0.37974662581766994 +city_new_delhi,2021,MONTH_may,1 +city_new_delhi,2021,MONTH_jun,0.5742651320692225 +city_new_delhi,2021,MONTH_jul,0.2099528028483895 +city_new_delhi,2021,MONTH_aug,0.1221329800447131 +city_new_delhi,2021,MONTH_sep,0.07867847975490602 +city_new_delhi,2021,MONTH_oct,0.0838287654218763 +city_new_delhi,2021,MONTH_nov,0.0893765007866192 +city_new_delhi,2021,MONTH_dec,0.10019044464684938 +city_new_delhi,2022,MONTH_jan,0.11567442245590792 +city_new_delhi,2022,MONTH_feb,0.15560983688001986 +city_new_delhi,2022,MONTH_mar,0.0603295520410698 +city_new_delhi,2022,MONTH_apr,0.02214126024675002 +city_new_delhi,2022,MONTH_may,0.006847727084540863 +city_ottawa,2020,MONTH_jan,0 +city_ottawa,2020,MONTH_feb,0 +city_ottawa,2020,MONTH_mar,0.009571558796718322 +city_ottawa,2020,MONTH_apr,0.6406107566089334 +city_ottawa,2020,MONTH_may,0.9357338195077484 +city_ottawa,2020,MONTH_jun,0.3484503190519599 +city_ottawa,2020,MONTH_jul,0.08956244302643573 +city_ottawa,2020,MONTH_aug,0.04421148587055606 +city_ottawa,2020,MONTH_sep,0.037374658158614404 +city_ottawa,2020,MONTH_oct,0.17889699179580676 +city_ottawa,2020,MONTH_nov,0.43094804010938925 +city_ottawa,2020,MONTH_dec,0.7654968094804011 +city_ottawa,2021,MONTH_jan,1 +city_ottawa,2021,MONTH_feb,0.4731084776663628 +city_ottawa,2021,MONTH_mar,0.21923427529626252 +city_ottawa,2021,MONTH_apr,0.270510483135825 +city_ottawa,2021,MONTH_may,0.3076572470373747 +city_ottawa,2021,MONTH_jun,0.17069279854147676 +city_ottawa,2021,MONTH_jul,0.07338195077484047 +city_ottawa,2021,MONTH_aug,0.0736098450319052 +city_ottawa,2021,MONTH_sep,0.1927985414767548 +city_ottawa,2021,MONTH_oct,0.2716499544211486 +city_ottawa,2021,MONTH_nov,0.15633546034639928 +city_ottawa,2021,MONTH_dec,0.13742023701002734 +city_ottawa,2022,MONTH_jan,0.7474931631722881 +city_ottawa,2022,MONTH_feb,0.6488149498632635 +city_ottawa,2022,MONTH_mar,0.33887876025524155 +city_ottawa,2022,MONTH_apr,0.3669097538742024 +city_ottawa,2022,MONTH_may,0.4453053783044667 +city_paris,2020,MONTH_jan,0 +city_paris,2020,MONTH_feb,9.50705899130104e-5 +city_paris,2020,MONTH_mar,0.1433189142938632 +city_paris,2020,MONTH_apr,1 +city_paris,2020,MONTH_may,0.22165708038218376 +city_paris,2020,MONTH_jun,0.04815325379093977 +city_paris,2020,MONTH_jul,0.019299329752341114 +city_paris,2020,MONTH_aug,0.015734182630603222 +city_paris,2020,MONTH_sep,0.05813566573180587 +city_paris,2020,MONTH_oct,0.21737890383609831 +city_paris,2020,MONTH_nov,0.7463992014070447 +city_paris,2020,MONTH_dec,0.5722774159813662 +city_paris,2021,MONTH_jan,0.5448495507914627 +city_paris,2021,MONTH_feb,0.49341636164852404 +city_paris,2021,MONTH_mar,0.42235109568854873 +city_paris,2021,MONTH_apr,0.4173598897181157 +city_paris,2021,MONTH_may,0.23991063364548176 +city_paris,2021,MONTH_jun,0.07367970718258307 +city_paris,2021,MONTH_jul,0.03085040642677188 +city_paris,2021,MONTH_aug,0.08803536625944763 +city_paris,2021,MONTH_sep,0.08480296620240528 +city_paris,2021,MONTH_oct,0.03988211246850787 +city_paris,2021,MONTH_nov,0.06241384227789133 +city_paris,2021,MONTH_dec,0.20996339782288348 +city_paris,2022,MONTH_jan,0.32376289394875696 +city_paris,2022,MONTH_feb,0.3461995531682274 +city_paris,2022,MONTH_mar,0.18514997385558776 +city_paris,2022,MONTH_apr,0.1745496030802871 +city_paris,2022,MONTH_may,0.1104244901839616 +city_quito,2020,MONTH_jan,0 +city_quito,2020,MONTH_feb,0 +city_quito,2020,MONTH_mar,0.005972526378658172 +city_quito,2020,MONTH_apr,0.08192315349392792 +city_quito,2020,MONTH_may,0.24517220784391797 +city_quito,2020,MONTH_jun,0.11507067489548078 +city_quito,2020,MONTH_jul,0.11497113278916982 +city_quito,2020,MONTH_aug,0.08938881146725065 +city_quito,2020,MONTH_sep,0.4735217997212821 +city_quito,2020,MONTH_oct,0.1313955803304798 +city_quito,2020,MONTH_nov,0.0787378060919769 +city_quito,2020,MONTH_dec,0.059725263786581724 +city_quito,2021,MONTH_jan,0.08242086402548278 +city_quito,2021,MONTH_feb,0.08580529564005575 +city_quito,2021,MONTH_mar,0.1062114274338045 +city_quito,2021,MONTH_apr,0.17638861238303802 +city_quito,2021,MONTH_may,0.1983874178777623 +city_quito,2021,MONTH_jun,0.09954210631096955 +city_quito,2021,MONTH_jul,1 +city_quito,2021,MONTH_aug,0.0650009954210631 +city_quito,2021,MONTH_sep,0.05156281106908222 +city_quito,2021,MONTH_oct,0.02150109496316942 +city_quito,2021,MONTH_nov,0.025482779215608202 +city_quito,2021,MONTH_dec,0.04330081624527175 +city_quito,2022,MONTH_jan,0.0840135377264583 +city_quito,2022,MONTH_feb,0.07276527971331874 +city_quito,2022,MONTH_mar,0.017618952817041608 +city_quito,2022,MONTH_apr,0.016623531753931914 +city_quito,2022,MONTH_may,0.00437985267768266 +city_rabat,2020,MONTH_jan,0 +city_rabat,2020,MONTH_feb,0 +city_rabat,2020,MONTH_mar,0.011752136752136752 +city_rabat,2020,MONTH_apr,0.04807692307692308 +city_rabat,2020,MONTH_may,0.01282051282051282 +city_rabat,2020,MONTH_jun,0.007478632478632479 +city_rabat,2020,MONTH_jul,0.04309116809116809 +city_rabat,2020,MONTH_aug,0.2724358974358974 +city_rabat,2020,MONTH_sep,0.37072649572649574 +city_rabat,2020,MONTH_oct,0.5245726495726496 +city_rabat,2020,MONTH_nov,0.7706552706552706 +city_rabat,2020,MONTH_dec,0.5576923076923077 +city_rabat,2021,MONTH_jan,0.32193732193732194 +city_rabat,2021,MONTH_feb,0.1267806267806268 +city_rabat,2021,MONTH_mar,0.07051282051282051 +city_rabat,2021,MONTH_apr,0.07371794871794872 +city_rabat,2021,MONTH_may,0.0438034188034188 +city_rabat,2021,MONTH_jun,0.053062678062678066 +city_rabat,2021,MONTH_jul,0.15669515669515668 +city_rabat,2021,MONTH_aug,1 +city_rabat,2021,MONTH_sep,0.6082621082621082 +city_rabat,2021,MONTH_oct,0.1492165242165242 +city_rabat,2021,MONTH_nov,0.038461538461538464 +city_rabat,2021,MONTH_dec,0.024572649572649572 +city_rabat,2022,MONTH_jan,0.18447293447293447 +city_rabat,2022,MONTH_feb,0.21937321937321938 +city_rabat,2022,MONTH_mar,0.0292022792022792 +city_rabat,2022,MONTH_apr,0.003205128205128205 +city_rabat,2022,MONTH_may,0.002492877492877493 +city_seoul,2020,MONTH_jan,0 +city_seoul,2020,MONTH_feb,0.0019579050416054823 +city_seoul,2020,MONTH_mar,0.017865883504650026 +city_seoul,2020,MONTH_apr,0.010401370533529124 +city_seoul,2020,MONTH_may,0.0028144884973078806 +city_seoul,2020,MONTH_jun,0.0014684287812041115 +city_seoul,2020,MONTH_jul,0.00232501223690651 +city_seoul,2020,MONTH_aug,0.0028144884973078806 +city_seoul,2020,MONTH_sep,0.010890846793930495 +city_seoul,2020,MONTH_oct,0.006240822320117474 +city_seoul,2020,MONTH_nov,0.0075868820362212435 +city_seoul,2020,MONTH_dec,0.045766030347528144 +city_seoul,2021,MONTH_jan,0.06363191385217817 +city_seoul,2021,MONTH_feb,0.022393538913362702 +city_seoul,2021,MONTH_mar,0.01566324033284386 +city_seoul,2021,MONTH_apr,0.011869799314733235 +city_seoul,2021,MONTH_may,0.016030347528144886 +city_seoul,2021,MONTH_jun,0.007219774840920215 +city_seoul,2021,MONTH_jul,0.009422418012726383 +city_seoul,2021,MONTH_aug,0.0232501223690651 +city_seoul,2021,MONTH_sep,0.023984336759667158 +city_seoul,2021,MONTH_oct,0.04503181595692609 +city_seoul,2021,MONTH_nov,0.09483602545276554 +city_seoul,2021,MONTH_dec,0.23727361722956436 +city_seoul,2022,MONTH_jan,0.14586392559960842 +city_seoul,2022,MONTH_feb,0.15944689182574645 +city_seoul,2022,MONTH_mar,1 +city_seoul,2022,MONTH_apr,0.8032305433186491 +city_seoul,2022,MONTH_may,0.16911404796867352 +city_tehran,2020,MONTH_jan,0 +city_tehran,2020,MONTH_feb,0.00255845778544654 +city_tehran,2020,MONTH_mar,0.16986969714999703 +city_tehran,2020,MONTH_apr,0.18200749687630155 +city_tehran,2020,MONTH_may,0.10572975545903493 +city_tehran,2020,MONTH_jun,0.1746891176295591 +city_tehran,2020,MONTH_jul,0.3509847087523056 +city_tehran,2020,MONTH_aug,0.2911286963765098 +city_tehran,2020,MONTH_sep,0.2691735586362825 +city_tehran,2020,MONTH_oct,0.5052656631165586 +city_tehran,2020,MONTH_nov,0.7971083477122628 +city_tehran,2020,MONTH_dec,0.42958291188195397 +city_tehran,2021,MONTH_jan,0.1662402570357589 +city_tehran,2021,MONTH_feb,0.12441244719462129 +city_tehran,2021,MONTH_mar,0.1540429582911882 +city_tehran,2021,MONTH_apr,0.5225203784137562 +city_tehran,2021,MONTH_may,0.5109775688701137 +city_tehran,2021,MONTH_jun,0.24918188849883977 +city_tehran,2021,MONTH_jul,0.3699053965609567 +city_tehran,2021,MONTH_aug,1 +city_tehran,2021,MONTH_sep,0.7740227286249777 +city_tehran,2021,MONTH_oct,0.3549711429761409 +city_tehran,2021,MONTH_nov,0.213303980484322 +city_tehran,2021,MONTH_dec,0.11072767299339561 +city_tehran,2022,MONTH_jan,0.050693163562801215 +city_tehran,2022,MONTH_feb,0.25031236984589755 +city_tehran,2022,MONTH_mar,0.20985303742488248 +city_tehran,2022,MONTH_apr,0.05438210269530553 +city_tehran,2022,MONTH_may,0.014160766347355268 +city_tokyo,2020,MONTH_jan,0 +city_tokyo,2020,MONTH_feb,0.0010548523206751054 +city_tokyo,2020,MONTH_mar,0.010759493670886076 +city_tokyo,2020,MONTH_apr,0.07573839662447257 +city_tokyo,2020,MONTH_may,0.10042194092827005 +city_tokyo,2020,MONTH_jun,0.01751054852320675 +city_tokyo,2020,MONTH_jul,0.006751054852320675 +city_tokyo,2020,MONTH_aug,0.05759493670886076 +city_tokyo,2020,MONTH_sep,0.060126582278481014 +city_tokyo,2020,MONTH_oct,0.04029535864978903 +city_tokyo,2020,MONTH_nov,0.07679324894514768 +city_tokyo,2020,MONTH_dec,0.2732067510548523 +city_tokyo,2021,MONTH_jan,0.47257383966244726 +city_tokyo,2021,MONTH_feb,0.46540084388185654 +city_tokyo,2021,MONTH_mar,0.26434599156118144 +city_tokyo,2021,MONTH_apr,0.22805907172995782 +city_tokyo,2021,MONTH_may,0.5850210970464135 +city_tokyo,2021,MONTH_jun,0.3740506329113924 +city_tokyo,2021,MONTH_jul,0.09367088607594937 +city_tokyo,2021,MONTH_aug,0.17088607594936708 +city_tokyo,2021,MONTH_sep,0.33987341772151897 +city_tokyo,2021,MONTH_oct,0.13839662447257384 +city_tokyo,2021,MONTH_nov,0.02067510548523207 +city_tokyo,2021,MONTH_dec,0.007172995780590718 +city_tokyo,2022,MONTH_jan,0.07827004219409282 +city_tokyo,2022,MONTH_feb,0.950632911392405 +city_tokyo,2022,MONTH_mar,1 +city_tokyo,2022,MONTH_apr,0.32447257383966244 +city_tokyo,2022,MONTH_may,0.21814345991561182 +city_tunis,2020,MONTH_jan,0 +city_tunis,2020,MONTH_feb,0 +city_tunis,2020,MONTH_mar,0.001858352260995251 +city_tunis,2020,MONTH_apr,0.006400991121205864 +city_tunis,2020,MONTH_may,0.001651868676440223 +city_tunis,2020,MONTH_jun,4.1296716911005574e-4 +city_tunis,2020,MONTH_jul,0 +city_tunis,2020,MONTH_aug,0.005575056782985753 +city_tunis,2020,MONTH_sep,0.03881891389634524 +city_tunis,2020,MONTH_oct,0.21722073095188932 +city_tunis,2020,MONTH_nov,0.39273177782366303 +city_tunis,2020,MONTH_dec,0.2892835019615941 +city_tunis,2021,MONTH_jan,0.4253561841833574 +city_tunis,2021,MONTH_feb,0.26718975841420606 +city_tunis,2021,MONTH_mar,0.1680776378277927 +city_tunis,2021,MONTH_apr,0.38261408218046666 +city_tunis,2021,MONTH_may,0.40925046458806524 +city_tunis,2021,MONTH_jun,0.4583935577121619 +city_tunis,2021,MONTH_jul,1 +city_tunis,2021,MONTH_aug,0.7774106958496799 +city_tunis,2021,MONTH_sep,0.2925872393144745 +city_tunis,2021,MONTH_oct,0.07639892628536031 +city_tunis,2021,MONTH_nov,0.02622341523848854 +city_tunis,2021,MONTH_dec,0.041090233326450544 +city_tunis,2022,MONTH_jan,0.1459838942804047 +city_tunis,2022,MONTH_feb,0.31013834400165186 +city_tunis,2022,MONTH_mar,0.11356597150526533 +city_tunis,2022,MONTH_apr,0.04687177369399133 +city_tunis,2022,MONTH_may,0.016931653933512286 +city_ulaanbaatar,2020,MONTH_jan,0 +city_ulaanbaatar,2020,MONTH_feb,0 +city_ulaanbaatar,2020,MONTH_mar,0 +city_ulaanbaatar,2020,MONTH_apr,0 +city_ulaanbaatar,2020,MONTH_may,0 +city_ulaanbaatar,2020,MONTH_jun,0 +city_ulaanbaatar,2020,MONTH_jul,0 +city_ulaanbaatar,2020,MONTH_aug,0 +city_ulaanbaatar,2020,MONTH_sep,0 +city_ulaanbaatar,2020,MONTH_oct,0 +city_ulaanbaatar,2020,MONTH_nov,0 +city_ulaanbaatar,2020,MONTH_dec,0.002188183807439825 +city_ulaanbaatar,2021,MONTH_jan,0.002188183807439825 +city_ulaanbaatar,2021,MONTH_feb,0 +city_ulaanbaatar,2021,MONTH_mar,0.01312910284463895 +city_ulaanbaatar,2021,MONTH_apr,0.24070021881838075 +city_ulaanbaatar,2021,MONTH_may,0.29540481400437635 +city_ulaanbaatar,2021,MONTH_jun,0.5317286652078774 +city_ulaanbaatar,2021,MONTH_jul,0.474835886214442 +city_ulaanbaatar,2021,MONTH_aug,0.26914660831509846 +city_ulaanbaatar,2021,MONTH_sep,0.8052516411378556 +city_ulaanbaatar,2021,MONTH_oct,1 +city_ulaanbaatar,2021,MONTH_nov,0.5886214442013129 +city_ulaanbaatar,2021,MONTH_dec,0.12253829321663019 +city_ulaanbaatar,2022,MONTH_jan,0.10940919037199125 +city_ulaanbaatar,2022,MONTH_feb,0.13129102844638948 +city_ulaanbaatar,2022,MONTH_mar,0.0262582056892779 +city_ulaanbaatar,2022,MONTH_apr,0.00437636761487965 +city_ulaanbaatar,2022,MONTH_may,0.010940919037199124 +city_yerevan,2020,MONTH_jan,0 +city_yerevan,2020,MONTH_feb,0 +city_yerevan,2020,MONTH_mar,0.002421307506053269 +city_yerevan,2020,MONTH_apr,0.023405972558514933 +city_yerevan,2020,MONTH_may,0.07990314769975787 +city_yerevan,2020,MONTH_jun,0.25181598062953997 +city_yerevan,2020,MONTH_jul,0.23809523809523808 +city_yerevan,2020,MONTH_aug,0.11380145278450363 +city_yerevan,2020,MONTH_sep,0.0645682001614205 +city_yerevan,2020,MONTH_oct,0.3083131557707829 +city_yerevan,2020,MONTH_nov,0.6642453591606134 +city_yerevan,2020,MONTH_dec,0.5318805488297014 +city_yerevan,2021,MONTH_jan,0.20742534301856336 +city_yerevan,2021,MONTH_feb,0.0903954802259887 +city_yerevan,2021,MONTH_mar,0.26069410815173527 +city_yerevan,2021,MONTH_apr,0.47861178369652946 +city_yerevan,2021,MONTH_may,0.26634382566585957 +city_yerevan,2021,MONTH_jun,0.06133979015334948 +city_yerevan,2021,MONTH_jul,0.08071025020177562 +city_yerevan,2021,MONTH_aug,0.18563357546408393 +city_yerevan,2021,MONTH_sep,0.3833736884584342 +city_yerevan,2021,MONTH_oct,0.814366424535916 +city_yerevan,2021,MONTH_nov,1 +city_yerevan,2021,MONTH_dec,0.3268765133171913 +city_yerevan,2022,MONTH_jan,0.06537530266343826 +city_yerevan,2022,MONTH_feb,0.32929782082324455 +city_yerevan,2022,MONTH_mar,0.12267958030669895 +city_yerevan,2022,MONTH_apr,0.007263922518159807 +city_yerevan,2022,MONTH_may,0.002421307506053269 +city_chicago,2020,MONTH_jan,0 +city_chicago,2020,MONTH_feb,0 +city_chicago,2020,MONTH_mar,0.021555197421434327 +city_chicago,2020,MONTH_apr,0.4540692989524577 +city_chicago,2020,MONTH_may,0.6174456083803385 +city_chicago,2020,MONTH_jun,0.3444802578565673 +city_chicago,2020,MONTH_jul,0.11422240128928283 +city_chicago,2020,MONTH_aug,0.11180499597099114 +city_chicago,2020,MONTH_sep,0.13638195004029008 +city_chicago,2020,MONTH_oct,0.22058823529411764 +city_chicago,2020,MONTH_nov,0.6013295729250604 +city_chicago,2020,MONTH_dec,1 +city_chicago,2021,MONTH_jan,0.6573327961321515 +city_chicago,2021,MONTH_feb,0.3007655116841257 +city_chicago,2021,MONTH_mar,0.17002417405318293 +city_chicago,2021,MONTH_apr,0.1434327155519742 +city_chicago,2021,MONTH_may,0.18775181305398872 +city_chicago,2021,MONTH_jun,0.09085414987912974 +city_chicago,2021,MONTH_jul,0.048751007252215955 +city_chicago,2021,MONTH_aug,0.11764705882352941 +city_chicago,2021,MONTH_sep,0.2346897663174859 +city_chicago,2021,MONTH_oct,0.19238517324738114 +city_chicago,2021,MONTH_nov,0.1522965350523771 +city_chicago,2021,MONTH_dec,0.33058017727639 +city_chicago,2022,MONTH_jan,0.7427477840451249 +city_chicago,2022,MONTH_feb,0.4443996776792909 +city_chicago,2022,MONTH_mar,0.1524979854955681 +city_chicago,2022,MONTH_apr,0.04653505237711523 +city_chicago,2022,MONTH_may,0.021555197421434327 +city_denver,2020,MONTH_jan,0 +city_denver,2020,MONTH_feb,0 +city_denver,2020,MONTH_mar,0.03793293018141836 +city_denver,2020,MONTH_apr,0.3881253435953821 +city_denver,2020,MONTH_may,0.3683342495876855 +city_denver,2020,MONTH_jun,0.13468938977460143 +city_denver,2020,MONTH_jul,0.08301264431006047 +city_denver,2020,MONTH_aug,0.06102253985706432 +city_denver,2020,MONTH_sep,0.059923034634414514 +city_denver,2020,MONTH_oct,0.13633864760857614 +city_denver,2020,MONTH_nov,0.41286421110500277 +city_denver,2020,MONTH_dec,1 +city_denver,2021,MONTH_jan,0.45739417262231996 +city_denver,2021,MONTH_feb,0.18361737218251786 +city_denver,2021,MONTH_mar,0.07146783947223749 +city_denver,2021,MONTH_apr,0.14128642111050027 +city_denver,2021,MONTH_may,0.159978009895547 +city_denver,2021,MONTH_jun,0.12314458493677845 +city_denver,2021,MONTH_jul,0.08246289169873557 +city_denver,2021,MONTH_aug,0.12204507971412865 +city_denver,2021,MONTH_sep,0.22649807586586038 +city_denver,2021,MONTH_oct,0.35459043430456294 +city_denver,2021,MONTH_nov,0.5536008796041781 +city_denver,2021,MONTH_dec,0.6030786146234195 +city_denver,2022,MONTH_jan,0.4722374931280924 +city_denver,2022,MONTH_feb,0.3672347443650357 +city_denver,2022,MONTH_mar,0.09840571742715779 +city_denver,2022,MONTH_apr,0.09895547003848268 +city_denver,2022,MONTH_may,0.18526663001649257 +city_san_francisco,2020,MONTH_jan,0 +city_san_francisco,2020,MONTH_feb,0 +city_san_francisco,2020,MONTH_mar,0.012296999264853305 +city_san_francisco,2020,MONTH_apr,0.12517543273407739 +city_san_francisco,2020,MONTH_may,0.146026866270133 +city_san_francisco,2020,MONTH_jun,0.12303682416627681 +city_san_francisco,2020,MONTH_jul,0.20978413419768763 +city_san_francisco,2020,MONTH_aug,0.2538261043908307 +city_san_francisco,2020,MONTH_sep,0.19234110806656418 +city_san_francisco,2020,MONTH_oct,0.11782396578226291 +city_san_francisco,2020,MONTH_nov,0.1034551894673528 +city_san_francisco,2020,MONTH_dec,0.45151373387689636 +city_san_francisco,2021,MONTH_jan,1 +city_san_francisco,2021,MONTH_feb,0.7541936777384214 +city_san_francisco,2021,MONTH_mar,0.47096170554033284 +city_san_francisco,2021,MONTH_apr,0.16681146828844484 +city_san_francisco,2021,MONTH_may,0.09977945599144557 +city_san_francisco,2021,MONTH_jun,0.027601416828176167 +city_san_francisco,2021,MONTH_jul,0.05045779589654481 +city_san_francisco,2021,MONTH_aug,0.09663837465748847 +city_san_francisco,2021,MONTH_sep,0.22822963309496758 +city_san_francisco,2021,MONTH_oct,0.19153912985363897 +city_san_francisco,2021,MONTH_nov,0.16881641382075788 +city_san_francisco,2021,MONTH_dec,0.13626946467954287 +city_san_francisco,2022,MONTH_jan,0.23778654013232642 +city_san_francisco,2022,MONTH_feb,0.3540065494887389 +city_san_francisco,2022,MONTH_mar,0.23083606228697454 +city_san_francisco,2022,MONTH_apr,0.09363095635901891 +city_san_francisco,2022,MONTH_may,0.0360890195816347 +city_washington,2020,MONTH_jan,0 +city_washington,2020,MONTH_feb,0 +city_washington,2020,MONTH_mar,0.0371900826446281 +city_washington,2020,MONTH_apr,0.8884297520661157 +city_washington,2020,MONTH_may,1 +city_washington,2020,MONTH_jun,0.3512396694214876 +city_washington,2020,MONTH_jul,0.14049586776859505 +city_washington,2020,MONTH_aug,0.09090909090909091 +city_washington,2020,MONTH_sep,0.08264462809917356 +city_washington,2020,MONTH_oct,0.07851239669421488 +city_washington,2020,MONTH_nov,0.14049586776859505 +city_washington,2020,MONTH_dec,0.4380165289256198 +city_washington,2021,MONTH_jan,0.5247933884297521 +city_washington,2021,MONTH_feb,0.4297520661157025 +city_washington,2021,MONTH_mar,0.19421487603305784 +city_washington,2021,MONTH_apr,0.16942148760330578 +city_washington,2021,MONTH_may,0.1115702479338843 +city_washington,2021,MONTH_jun,0.0371900826446281 +city_washington,2021,MONTH_jul,0.03305785123966942 +city_washington,2021,MONTH_aug,0.045454545454545456 +city_washington,2021,MONTH_sep,0.05785123966942149 +city_washington,2021,MONTH_oct,0.06611570247933884 +city_washington,2021,MONTH_nov,0.024793388429752067 +city_washington,2021,MONTH_dec,0.06198347107438017 +city_washington,2022,MONTH_jan,0.32231404958677684 +city_washington,2022,MONTH_feb,0.11983471074380166 +city_washington,2022,MONTH_mar,0.05371900826446281 +city_washington,2022,MONTH_apr,0.0371900826446281 +city_washington,2022,MONTH_may,0 diff --git a/run_tree/data/incenter_data/csv/question_5.csv b/run_tree/data/incenter_data/csv/question_5.csv new file mode 100644 index 0000000..6d63a0a --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_5.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.601593625498008 +city_brisbane,2022,MONTH_jan,0.6060606060606061 +city_chengdu,2022,MONTH_jan,0.5254237288135594 +city_new_delhi,2022,MONTH_jan,0.6507936507936508 +city_paris,2022,MONTH_jan,0.569806492883416 +city_san_francisco,2022,MONTH_jan,0.6120930232558139 +city_denver,2022,MONTH_jan,0.6120930232558139 +city_ankara,2022,MONTH_jan,0.7948003714020427 +city_harare,2022,MONTH_jan,0.5714285714285714 +city_hanoi,2022,MONTH_jan,0.6158536585365854 +city_washington,2022,MONTH_jan,0.6120930232558139 +city_bangkok,2022,MONTH_jan,0.5555555555555556 +city_tunis,2022,MONTH_jan,0.5142857142857142 +city_seoul,2022,MONTH_jan,0.6158536585365854 +city_belgrade,2022,MONTH_jan,0.6169354838709677 +city_moscow,2022,MONTH_jan,0.5819672131147541 +city_lima,2022,MONTH_jan,0.425 +city_islamabad,2022,MONTH_jan,0.6363636363636364 +city_abuja,2022,MONTH_jan,0.8333333333333334 +city_managua,2022,MONTH_jan,0.6774193548387096 +city_amsterdam,2022,MONTH_jan,0.464638783269962 +city_rabat,2022,MONTH_jan,0.6190476190476191 +city_ulaanbaatar,2022,MONTH_jan,0.5254237288135594 +city_mexico_city,2022,MONTH_jan,0.5176882661996497 +city_nairobi,2022,MONTH_jan,0.5714285714285714 +city_tokyo,2022,MONTH_jan,0.5993009868421053 +city_baghdad,2022,MONTH_jan,0.5 +city_tehran,2022,MONTH_jan,0.5 +city_jakarta,2022,MONTH_jan,0.6011644832605532 +city_guatemala_city,2022,MONTH_jan,0.6774193548387096 +city_berlin,2022,MONTH_jan,0.6111111111111112 +city_addis_ababa,2022,MONTH_jan,0.5714285714285714 +city_cairo,2022,MONTH_jan,0.5142857142857142 +city_quito,2022,MONTH_jan,0.4827586206896552 +city_bogota,2022,MONTH_jan,0.45 +city_beijing,2022,MONTH_jan,0.5254237288135594 +city_accra,2022,MONTH_jan,0.5714285714285714 +city_ottawa,2022,MONTH_jan,0.6352941176470588 +city_brasilia,2022,MONTH_jan,0.7062314540059347 +city_la_paz,2022,MONTH_jan,0.7062314540059347 +city_dhaka,2022,MONTH_jan,0.7107438016528925 +city_yerevan,2022,MONTH_jan,0.7948003714020427 +city_chicago,2022,MONTH_jan,0.6120930232558139 +city_kyiv,2022,MONTH_jan,0.59375 +city_dubai,2022,MONTH_jan,0.5 +city_mumbai,2022,MONTH_jan,0.6507936507936508 +city_madrid,2022,MONTH_jan,0.4838709677419355 diff --git a/run_tree/data/incenter_data/csv/question_6.csv b/run_tree/data/incenter_data/csv/question_6.csv new file mode 100644 index 0000000..6c7c9d3 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_6.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.2964426877470356 +city_brisbane,2022,MONTH_jan,0.3141891891891892 +city_chengdu,2022,MONTH_jan,0.4745762711864407 +city_new_delhi,2022,MONTH_jan,0.4603174603174603 +city_paris,2022,MONTH_jan,0.3169346452283817 +city_san_francisco,2022,MONTH_jan,0.3714551371455137 +city_denver,2022,MONTH_jan,0.3714551371455137 +city_ankara,2022,MONTH_jan,0.5386046511627907 +city_harare,2022,MONTH_jan,0.21428571428571427 +city_hanoi,2022,MONTH_jan,0.4878048780487805 +city_washington,2022,MONTH_jan,0.3714551371455137 +city_bangkok,2022,MONTH_jan,0.5 +city_tunis,2022,MONTH_jan,0.4647887323943662 +city_seoul,2022,MONTH_jan,0.4878048780487805 +city_belgrade,2022,MONTH_jan,0.3089430894308943 +city_moscow,2022,MONTH_jan,0.3442622950819672 +city_lima,2022,MONTH_jan,0.225 +city_islamabad,2022,MONTH_jan,0.3719298245614035 +city_abuja,2022,MONTH_jan,0.4117647058823529 +city_managua,2022,MONTH_jan,0.375 +city_amsterdam,2022,MONTH_jan,0.2883156297420334 +city_rabat,2022,MONTH_jan,0.2926829268292683 +city_ulaanbaatar,2022,MONTH_jan,0.4745762711864407 +city_mexico_city,2022,MONTH_jan,0.3334112422578006 +city_nairobi,2022,MONTH_jan,0.21428571428571427 +city_tokyo,2022,MONTH_jan,0.8559967084961942 +city_baghdad,2022,MONTH_jan,0.3137254901960784 +city_tehran,2022,MONTH_jan,0.3137254901960784 +city_jakarta,2022,MONTH_jan,0.36627906976744184 +city_guatemala_city,2022,MONTH_jan,0.375 +city_berlin,2022,MONTH_jan,0.3335826477187734 +city_addis_ababa,2022,MONTH_jan,0.21428571428571427 +city_cairo,2022,MONTH_jan,0.4647887323943662 +city_quito,2022,MONTH_jan,0.27586206896551724 +city_bogota,2022,MONTH_jan,0.3111111111111111 +city_beijing,2022,MONTH_jan,0.4745762711864407 +city_accra,2022,MONTH_jan,0.21428571428571427 +city_ottawa,2022,MONTH_jan,0.3568075117370892 +city_brasilia,2022,MONTH_jan,0.5705794947994056 +city_la_paz,2022,MONTH_jan,0.5705794947994056 +city_dhaka,2022,MONTH_jan,0.3159340659340659 +city_yerevan,2022,MONTH_jan,0.5386046511627907 +city_chicago,2022,MONTH_jan,0.3714551371455137 +city_kyiv,2022,MONTH_jan,0.3939393939393939 +city_dubai,2022,MONTH_jan,0.3137254901960784 +city_mumbai,2022,MONTH_jan,0.4603174603174603 +city_madrid,2022,MONTH_jan,0.37209302325581395 diff --git a/run_tree/data/incenter_data/csv/question_7.csv b/run_tree/data/incenter_data/csv/question_7.csv new file mode 100644 index 0000000..70d0c72 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_7.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.9065934065934066 +city_brisbane,2022,MONTH_jan,0.8987854251012146 +city_chengdu,2022,MONTH_jan,0.8 +city_new_delhi,2022,MONTH_jan,0.8666666666666667 +city_paris,2022,MONTH_jan,0.8818422046055115 +city_san_francisco,2022,MONTH_jan,0.9293150684931507 +city_denver,2022,MONTH_jan,0.9293150684931507 +city_ankara,2022,MONTH_jan,0.9027283511269276 +city_harare,2022,MONTH_jan,1 +city_hanoi,2022,MONTH_jan,0.9253731343283582 +city_washington,2022,MONTH_jan,0.9293150684931507 +city_bangkok,2022,MONTH_jan,0.7692307692307693 +city_tunis,2022,MONTH_jan,0.9056603773584906 +city_seoul,2022,MONTH_jan,0.9253731343283582 +city_belgrade,2022,MONTH_jan,0.9090909090909091 +city_moscow,2022,MONTH_jan,0.7934782608695652 +city_lima,2022,MONTH_jan,0.9705882352941176 +city_islamabad,2022,MONTH_jan,0.8928571428571429 +city_abuja,2022,MONTH_jan,1 +city_managua,2022,MONTH_jan,0.9047619047619048 +city_amsterdam,2022,MONTH_jan,0.924908424908425 +city_rabat,2022,MONTH_jan,0.9714285714285714 +city_ulaanbaatar,2022,MONTH_jan,0.8 +city_mexico_city,2022,MONTH_jan,0.9220470098185064 +city_nairobi,2022,MONTH_jan,1 +city_tokyo,2022,MONTH_jan,0.5873192436040044 +city_baghdad,2022,MONTH_jan,0.925 +city_tehran,2022,MONTH_jan,0.925 +city_jakarta,2022,MONTH_jan,0.8819938962360122 +city_guatemala_city,2022,MONTH_jan,0.9047619047619048 +city_berlin,2022,MONTH_jan,0.9141824751580849 +city_addis_ababa,2022,MONTH_jan,1 +city_cairo,2022,MONTH_jan,0.9056603773584906 +city_quito,2022,MONTH_jan,0.9565217391304348 +city_bogota,2022,MONTH_jan,0.8592592592592593 +city_beijing,2022,MONTH_jan,0.8 +city_accra,2022,MONTH_jan,1 +city_ottawa,2022,MONTH_jan,0.8787878787878788 +city_brasilia,2022,MONTH_jan,0.9236641221374046 +city_la_paz,2022,MONTH_jan,0.9236641221374046 +city_dhaka,2022,MONTH_jan,0.91701244813278 +city_yerevan,2022,MONTH_jan,0.9027283511269276 +city_chicago,2022,MONTH_jan,0.9293150684931507 +city_kyiv,2022,MONTH_jan,0.9090909090909091 +city_dubai,2022,MONTH_jan,0.925 +city_mumbai,2022,MONTH_jan,0.8666666666666667 +city_madrid,2022,MONTH_jan,0.8149882903981265 diff --git a/run_tree/data/incenter_data/csv/question_8.csv b/run_tree/data/incenter_data/csv/question_8.csv new file mode 100644 index 0000000..7bea2f8 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_8.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.9398907103825137 +city_brisbane,2022,MONTH_jan,0.9061224489795918 +city_chengdu,2022,MONTH_jan,0.8717948717948718 +city_new_delhi,2022,MONTH_jan,1 +city_paris,2022,MONTH_jan,0.898988944533686 +city_san_francisco,2022,MONTH_jan,0.9071938495332235 +city_denver,2022,MONTH_jan,0.9071938495332235 +city_ankara,2022,MONTH_jan,0.9175627240143369 +city_harare,2022,MONTH_jan,1 +city_hanoi,2022,MONTH_jan,0.8962962962962963 +city_washington,2022,MONTH_jan,0.9071938495332235 +city_bangkok,2022,MONTH_jan,0.9230769230769231 +city_tunis,2022,MONTH_jan,0.8846153846153846 +city_seoul,2022,MONTH_jan,0.8962962962962963 +city_belgrade,2022,MONTH_jan,0.9179487179487179 +city_moscow,2022,MONTH_jan,0.8571428571428571 +city_lima,2022,MONTH_jan,0.9411764705882353 +city_islamabad,2022,MONTH_jan,0.8290155440414507 +city_abuja,2022,MONTH_jan,0.8571428571428571 +city_managua,2022,MONTH_jan,0.9523809523809523 +city_amsterdam,2022,MONTH_jan,0.8682027649769585 +city_rabat,2022,MONTH_jan,0.9411764705882353 +city_ulaanbaatar,2022,MONTH_jan,0.8717948717948718 +city_mexico_city,2022,MONTH_jan,0.8594192107222636 +city_nairobi,2022,MONTH_jan,1 +city_tokyo,2022,MONTH_jan,0.5911220165068035 +city_baghdad,2022,MONTH_jan,0.975 +city_tehran,2022,MONTH_jan,0.975 +city_jakarta,2022,MONTH_jan,0.9158215010141988 +city_guatemala_city,2022,MONTH_jan,0.9523809523809523 +city_berlin,2022,MONTH_jan,0.9038112522686026 +city_addis_ababa,2022,MONTH_jan,1 +city_cairo,2022,MONTH_jan,0.8846153846153846 +city_quito,2022,MONTH_jan,1 +city_bogota,2022,MONTH_jan,0.8712121212121212 +city_beijing,2022,MONTH_jan,0.8717948717948718 +city_accra,2022,MONTH_jan,1 +city_ottawa,2022,MONTH_jan,0.8953168044077136 +city_brasilia,2022,MONTH_jan,0.9504761904761905 +city_la_paz,2022,MONTH_jan,0.9504761904761905 +city_dhaka,2022,MONTH_jan,0.9159663865546218 +city_yerevan,2022,MONTH_jan,0.9175627240143369 +city_chicago,2022,MONTH_jan,0.9071938495332235 +city_kyiv,2022,MONTH_jan,0.9090909090909091 +city_dubai,2022,MONTH_jan,0.975 +city_mumbai,2022,MONTH_jan,1 +city_madrid,2022,MONTH_jan,0.9479905437352246 diff --git a/run_tree/data/incenter_data/csv/question_9.csv b/run_tree/data/incenter_data/csv/question_9.csv new file mode 100644 index 0000000..a3f19d9 --- /dev/null +++ b/run_tree/data/incenter_data/csv/question_9.csv @@ -0,0 +1,48 @@ +city_data,year,month,prop +city_bucharest,2022,MONTH_jan,0.9276054097056484 +city_brisbane,2022,MONTH_jan,0.9355913381454747 +city_chengdu,2022,MONTH_jan,0.874793524942187 +city_new_delhi,2022,MONTH_jan,0.947289156626506 +city_paris,2022,MONTH_jan,0.9259986902423052 +city_san_francisco,2022,MONTH_jan,0.9016393442622951 +city_denver,2022,MONTH_jan,0.9326923076923077 +city_ankara,2022,MONTH_jan,0.9283050145047659 +city_harare,2022,MONTH_jan,0.966996699669967 +city_hanoi,2022,MONTH_jan,0.9691666666666666 +city_washington,2022,MONTH_jan,0.9068219633943427 +city_bangkok,2022,MONTH_jan,0.9223040857334226 +city_tunis,2022,MONTH_jan,0.9776490066225165 +city_seoul,2022,MONTH_jan,0.9156626506024096 +city_belgrade,2022,MONTH_jan,0.946360153256705 +city_moscow,2022,MONTH_jan,0.8717379233759023 +city_lima,2022,MONTH_jan,0.8871428571428571 +city_islamabad,2022,MONTH_jan,0.947289156626506 +city_abuja,2022,MONTH_jan,0.9919093851132686 +city_managua,2022,MONTH_jan,0.84 +city_amsterdam,2022,MONTH_jan,0.8231389284020862 +city_rabat,2022,MONTH_jan,0.8991666666666667 +city_ulaanbaatar,2022,MONTH_jan,0.8192918192918193 +city_mexico_city,2022,MONTH_jan,0.9753015508328546 +city_nairobi,2022,MONTH_jan,0.9818181818181818 +city_tokyo,2022,MONTH_jan,0.9380134428678119 +city_baghdad,2022,MONTH_jan,0.9808013355592654 +city_tehran,2022,MONTH_jan,0.9425901201602136 +city_jakarta,2022,MONTH_jan,0.98875 +city_guatemala_city,2022,MONTH_jan,0.9072416598860863 +city_berlin,2022,MONTH_jan,0.9259986902423052 +city_addis_ababa,2022,MONTH_jan,0.9536585365853658 +city_cairo,2022,MONTH_jan,0.9975 +city_quito,2022,MONTH_jan,0.9073455759599333 +city_bogota,2022,MONTH_jan,0.8782894736842105 +city_beijing,2022,MONTH_jan,0.874793524942187 +city_accra,2022,MONTH_jan,0.9818181818181818 +city_ottawa,2022,MONTH_jan,0.8504230960676954 +city_brasilia,2022,MONTH_jan,0.8677639046538025 +city_la_paz,2022,MONTH_jan,0.8522286821705426 +city_dhaka,2022,MONTH_jan,0.99 +city_yerevan,2022,MONTH_jan,0.9705641864268193 +city_chicago,2022,MONTH_jan,0.9385113268608414 +city_kyiv,2022,MONTH_jan,0.8817120622568093 +city_dubai,2022,MONTH_jan,0.9975 +city_mumbai,2022,MONTH_jan,0.947289156626506 +city_madrid,2022,MONTH_jan,0.9259986902423052 diff --git a/run_tree/data/incenter_test_data.c b/run_tree/data/incenter_test_data.c new file mode 100644 index 0000000..15a17af --- /dev/null +++ b/run_tree/data/incenter_test_data.c @@ -0,0 +1,551 @@ +typedef struct { + Incenter_City_Id city; + u32 year; + Incenter_Month_Id month; + r32 value_0; + r32 value_1; + r32 value_2; +} Incenter_Test_Data_Row; +static Incenter_Test_Data_Row test_data[] = { +[36] = { city_yerevan, 2019, MONTH_Feb, 0.222480434220212f, 0, 0 }, +[37] = { city_yerevan, 2019, MONTH_Apr, 0.4029543563896680f, 0, 0 }, +[38] = { city_yerevan, 2019, MONTH_Jun, 0.0084130412911773f, 0, 0 }, +[39] = { city_yerevan, 2019, MONTH_Oct, 0.4935333893524508f, 0, 0 }, +[40] = { city_yerevan, 2020, MONTH_Mar, 0.795608809243028f, 0, 0 }, +[41] = { city_yerevan, 2020, MONTH_May, 0.871852281333013f, 0, 0 }, +[42] = { city_yerevan, 2020, MONTH_Oct, 0.757850269654449f, 0, 0 }, +[43] = { city_yerevan, 2020, MONTH_Dec, 0.305973943715009f, 0, 0 }, +[44] = { city_yerevan, 2021, MONTH_Mar, 0.575105708333009f, 0, 0 }, +[45] = { city_yerevan, 2021, MONTH_May, 0.3241565018180455f, 0, 0 }, +[46] = { city_yerevan, 2021, MONTH_Oct, 0.1391937656411673f, 0, 0 }, +[47] = { city_yerevan, 2021, MONTH_Dec, 0.408290129008908f, 0, 0 }, +[60] = { city_dhaka, 2019, MONTH_Mar, 0.696487045082252f, 0, 0 }, +[61] = { city_dhaka, 2019, MONTH_May, 0.926874194615664f, 0, 0 }, +[62] = { city_dhaka, 2019, MONTH_Oct, 0.065784704818257f, 0, 0 }, +[63] = { city_dhaka, 2019, MONTH_Dec, 0.267978732515615f, 0, 0 }, +[64] = { city_dhaka, 2020, MONTH_Feb, 0.741594899662727f, 0, 0 }, +[65] = { city_dhaka, 2020, MONTH_Apr, 0.888792879778451f, 0, 0 }, +[66] = { city_dhaka, 2020, MONTH_Jun, 0.952616025778708f, 0, 0 }, +[67] = { city_dhaka, 2020, MONTH_Oct, 0.539424539962102f, 0, 0 }, +[68] = { city_dhaka, 2021, MONTH_Feb, 0.783291871057349f, 0, 0 }, +[69] = { city_dhaka, 2021, MONTH_Apr, 0.1670300347942025f, 0, 0 }, +[70] = { city_dhaka, 2021, MONTH_Jun, 0.916080035896739f, 0, 0 }, +[71] = { city_dhaka, 2021, MONTH_Oct, 0.04557651966926190f, 0, 0 }, +[72] = { city_sucre, 2019, MONTH_Feb, 0.905795384338579f, 0, 0 }, +[73] = { city_sucre, 2019, MONTH_Apr, 0.04894925227303792f, 0, 0 }, +[74] = { city_sucre, 2019, MONTH_Jun, 0.3974826752695833f, 0, 0 }, +[75] = { city_sucre, 2019, MONTH_Oct, 0.3240253361391306f, 0, 0 }, +[76] = { city_sucre, 2020, MONTH_Feb, 0.255506118683492f, 0, 0 }, +[77] = { city_sucre, 2020, MONTH_Apr, 0.683469845394748f, 0, 0 }, +[78] = { city_sucre, 2020, MONTH_Jun, 0.0860787488725892f, 0, 0 }, +[79] = { city_sucre, 2020, MONTH_Oct, 0.480200082551104f, 0, 0 }, +[80] = { city_sucre, 2021, MONTH_Apr, 0.933388110124702f, 0, 0 }, +[81] = { city_sucre, 2021, MONTH_Jul, 0.826055726458284f, 0, 0 }, +[82] = { city_sucre, 2021, MONTH_Sep, 0.655861858686346f, 0, 0 }, +[83] = { city_sucre, 2022, MONTH_Jan, 0.995135577230638f, 0, 0 }, +[84] = { city_brasilia, 2019, MONTH_Apr, 0.934349752963540f, 0, 0 }, +[85] = { city_brasilia, 2019, MONTH_Jul, 0.557085223032821f, 0, 0 }, +[86] = { city_brasilia, 2019, MONTH_Sep, 0.224253014743045f, 0, 0 }, +[87] = { city_brasilia, 2020, MONTH_Jan, 0.3792768359577919f, 0, 0 }, +[88] = { city_brasilia, 2020, MONTH_Feb, 0.134570768681787f, 0, 0 }, +[89] = { city_brasilia, 2020, MONTH_Apr, 0.2982662489386165f, 0, 0 }, +[90] = { city_brasilia, 2020, MONTH_Jun, 0.847116114015527f, 0, 0 }, +[91] = { city_brasilia, 2020, MONTH_Oct, 0.710668345133466f, 0, 0 }, +[92] = { city_brasilia, 2021, MONTH_Apr, 0.882130538520757f, 0, 0 }, +[93] = { city_brasilia, 2021, MONTH_Jul, 0.634126485396549f, 0, 0 }, +[94] = { city_brasilia, 2021, MONTH_Sep, 0.879304288498351f, 0, 0 }, +[95] = { city_brasilia, 2022, MONTH_Jan, 0.367836889045680f, 0, 0 }, +[96] = { city_ottawa, 2019, MONTH_Feb, 0.4644661026237456f, 0, 0 }, +[97] = { city_ottawa, 2019, MONTH_Apr, 0.27044176317875f, 0, 0 }, +[98] = { city_ottawa, 2019, MONTH_Jun, 0.78502064470336f, 0, 0 }, +[99] = { city_ottawa, 2019, MONTH_Oct, 0.439787889686537f, 0, 0 }, +[100] = { city_ottawa, 2020, MONTH_Mar, 0.625070053347673f, 0, 0 }, +[101] = { city_ottawa, 2020, MONTH_May, 0.854391809397701f, 0, 0 }, +[102] = { city_ottawa, 2020, MONTH_Oct, 0.1092476526609484f, 0, 0 }, +[103] = { city_ottawa, 2020, MONTH_Dec, 0.0698930895777035f, 0, 0 }, +[104] = { city_ottawa, 2021, MONTH_May, 0.0219222869517711f, 0, 0 }, +[105] = { city_ottawa, 2021, MONTH_Aug, 0.3118047013029038f, 0, 0 }, +[106] = { city_ottawa, 2021, MONTH_Nov, 0.800964131022624f, 0, 0 }, +[107] = { city_ottawa, 2021, MONTH_Dec, 0.893928203453701f, 0, 0 }, +[108] = { city_santiago, 2019, MONTH_Feb, 0.260406662278948f, 0, 0 }, +[109] = { city_santiago, 2019, MONTH_Apr, 0.0440821965051458f, 0, 0 }, +[110] = { city_santiago, 2019, MONTH_Jun, 0.03370085386772181f, 0, 0 }, +[111] = { city_santiago, 2019, MONTH_Oct, 0.0702001450638586f, 0, 0 }, +[112] = { city_santiago, 2020, MONTH_Mar, 0.66916706280028f, 0, 0 }, +[113] = { city_santiago, 2020, MONTH_May, 0.394667241732750f, 0, 0 }, +[114] = { city_santiago, 2020, MONTH_Oct, 0.9696170778040f, 0, 0 }, +[115] = { city_santiago, 2020, MONTH_Dec, 0.692669953953974f, 0, 0 }, +[116] = { city_santiago, 2021, MONTH_Feb, 0.885578817071499f, 0, 0 }, +[117] = { city_santiago, 2021, MONTH_Apr, 0.02248585274337977f, 0, 0 }, +[118] = { city_santiago, 2021, MONTH_Jun, 0.01661168283700642f, 0, 0 }, +[119] = { city_santiago, 2021, MONTH_Oct, 0.738806466943267f, 0, 0 }, +[120] = { city_beijing, 2019, MONTH_Mar, 0.398464980892838f, 0, 0 }, +[121] = { city_beijing, 2019, MONTH_May, 0.551648164638685f, 0, 0 }, +[122] = { city_beijing, 2019, MONTH_Oct, 0.021236210735964f, 0, 0 }, +[123] = { city_beijing, 2019, MONTH_Dec, 0.2339279354599085f, 0, 0 }, +[124] = { city_beijing, 2020, MONTH_Mar, 0.897658054227696f, 0, 0 }, +[125] = { city_beijing, 2020, MONTH_May, 0.512517872887249f, 0, 0 }, +[126] = { city_beijing, 2020, MONTH_Oct, 0.0988590392525249f, 0, 0 }, +[127] = { city_beijing, 2020, MONTH_Dec, 0.99615807233472f, 0, 0 }, +[128] = { city_beijing, 2021, MONTH_May, 0.391024451068782f, 0, 0 }, +[129] = { city_beijing, 2021, MONTH_Aug, 0.591905762173565f, 0, 0 }, +[130] = { city_beijing, 2021, MONTH_Nov, 0.2283096306364279f, 0, 0 }, +[131] = { city_beijing, 2021, MONTH_Dec, 0.821811925597835f, 0, 0 }, +[132] = { city_bogota, 2019, MONTH_Feb, 0.04055961855563494f, 0, 0 }, +[133] = { city_bogota, 2019, MONTH_Apr, 0.669754494655513f, 0, 0 }, +[134] = { city_bogota, 2019, MONTH_Jun, 0.701264834768624f, 0, 0 }, +[135] = { city_bogota, 2019, MONTH_Oct, 0.926643006799590f, 0, 0 }, +[136] = { city_bogota, 2020, MONTH_May, 0.926535096485845f, 0, 0 }, +[137] = { city_bogota, 2020, MONTH_Aug, 0.562271964832498f, 0, 0 }, +[138] = { city_bogota, 2020, MONTH_Nov, 0.1850507621318452f, 0, 0 }, +[139] = { city_bogota, 2020, MONTH_Dec, 0.1320097943504098f, 0, 0 }, +[140] = { city_bogota, 2021, MONTH_Apr, 0.2549272436870123f, 0, 0 }, +[141] = { city_bogota, 2021, MONTH_Jul, 0.655188137041105f, 0, 0 }, +[142] = { city_bogota, 2021, MONTH_Sep, 0.330150715675793f, 0, 0 }, +[143] = { city_bogota, 2022, MONTH_Jan, 0.931982538146994f, 0, 0 }, +[144] = { city_nicosia, 2019, MONTH_Feb, 0.811253678048109f, 0, 0 }, +[145] = { city_nicosia, 2019, MONTH_Apr, 0.712224222819743f, 0, 0 }, +[146] = { city_nicosia, 2019, MONTH_Jun, 0.399273172446563f, 0, 0 }, +[147] = { city_nicosia, 2019, MONTH_Oct, 0.056092503429609f, 0, 0 }, +[148] = { city_nicosia, 2020, MONTH_Mar, 0.60563587382731f, 0, 0 }, +[149] = { city_nicosia, 2020, MONTH_May, 0.815528514704807f, 0, 0 }, +[150] = { city_nicosia, 2020, MONTH_Oct, 0.728314034392938f, 0, 0 }, +[151] = { city_nicosia, 2020, MONTH_Dec, 0.159377338887028f, 0, 0 }, +[152] = { city_nicosia, 2021, MONTH_May, 0.533098572342027f, 0, 0 }, +[153] = { city_nicosia, 2021, MONTH_Aug, 0.4664341277469371f, 0, 0 }, +[154] = { city_nicosia, 2021, MONTH_Nov, 0.730237961803562f, 0, 0 }, +[155] = { city_nicosia, 2021, MONTH_Dec, 0.597177425986761f, 0, 0 }, +[156] = { city_quito, 2019, MONTH_May, 0.3900500941853586f, 0, 0 }, +[157] = { city_quito, 2019, MONTH_Aug, 0.902510252650640f, 0, 0 }, +[158] = { city_quito, 2019, MONTH_Nov, 0.50747923203348f, 0, 0 }, +[159] = { city_quito, 2019, MONTH_Dec, 0.504675362331222f, 0, 0 }, +[160] = { city_quito, 2020, MONTH_Mar, 0.893239434326622f, 0, 0 }, +[161] = { city_quito, 2020, MONTH_May, 0.1972236787064364f, 0, 0 }, +[162] = { city_quito, 2020, MONTH_Oct, 0.461624391667064f, 0, 0 }, +[163] = { city_quito, 2020, MONTH_Dec, 0.2292995261096597f, 0, 0 }, +[164] = { city_quito, 2021, MONTH_Apr, 0.67583955263968f, 0, 0 }, +[165] = { city_quito, 2021, MONTH_Jul, 0.752273762232872f, 0, 0 }, +[166] = { city_quito, 2021, MONTH_Sep, 0.754769476238442f, 0, 0 }, +[167] = { city_quito, 2022, MONTH_Jan, 0.522476871813856f, 0, 0 }, +[168] = { city_cairo, 2019, MONTH_Apr, 0.1225197816901859f, 0, 0 }, +[169] = { city_cairo, 2019, MONTH_Jul, 0.64021444184204f, 0, 0 }, +[170] = { city_cairo, 2019, MONTH_Sep, 0.1129228329032401f, 0, 0 }, +[171] = { city_cairo, 2020, MONTH_Jan, 0.44379330991469f, 0, 0 }, +[172] = { city_cairo, 2020, MONTH_May, 0.369533191151981f, 0, 0 }, +[173] = { city_cairo, 2020, MONTH_Aug, 0.087571921991018f, 0, 0 }, +[174] = { city_cairo, 2020, MONTH_Nov, 0.130023762282846f, 0, 0 }, +[175] = { city_cairo, 2020, MONTH_Dec, 0.619080240994548f, 0, 0 }, +[176] = { city_cairo, 2021, MONTH_May, 0.265431673532736f, 0, 0 }, +[177] = { city_cairo, 2021, MONTH_Aug, 0.0838086831407579f, 0, 0 }, +[178] = { city_cairo, 2021, MONTH_Nov, 0.002175360042457663f, 0, 0 }, +[179] = { city_cairo, 2021, MONTH_Dec, 0.342714385178964f, 0, 0 }, +[180] = { city_addis_ababa, 2019, MONTH_Feb, 0.527483000268353f, 0, 0 }, +[181] = { city_addis_ababa, 2019, MONTH_Apr, 0.02860178841412208f, 0, 0 }, +[182] = { city_addis_ababa, 2019, MONTH_Jun, 0.2240604563219019f, 0, 0 }, +[183] = { city_addis_ababa, 2019, MONTH_Oct, 0.157084009337969f, 0, 0 }, +[184] = { city_addis_ababa, 2020, MONTH_Apr, 0.469697598033293f, 0, 0 }, +[185] = { city_addis_ababa, 2020, MONTH_Jul, 0.701891216846054f, 0, 0 }, +[186] = { city_addis_ababa, 2020, MONTH_Sep, 0.670718895080620f, 0, 0 }, +[187] = { city_addis_ababa, 2021, MONTH_Jan, 0.2222353125566932f, 0, 0 }, +[188] = { city_addis_ababa, 2021, MONTH_Mar, 0.739784695704446f, 0, 0 }, +[189] = { city_addis_ababa, 2021, MONTH_May, 0.296333188085118f, 0, 0 }, +[190] = { city_addis_ababa, 2021, MONTH_Oct, 0.2272026794508933f, 0, 0 }, +[191] = { city_addis_ababa, 2021, MONTH_Dec, 0.97410047246957f, 0, 0 }, +[192] = { city_berlin, 2019, MONTH_May, 0.966330648602629f, 0, 0 }, +[193] = { city_berlin, 2019, MONTH_Aug, 0.0176205852695634f, 0, 0 }, +[194] = { city_berlin, 2019, MONTH_Nov, 0.584547668032789f, 0, 0 }, +[195] = { city_berlin, 2019, MONTH_Dec, 0.0526735938814365f, 0, 0 }, +[196] = { city_berlin, 2020, MONTH_Feb, 0.00291208011562660f, 0, 0 }, +[197] = { city_berlin, 2020, MONTH_Apr, 0.46161889811961f, 0, 0 }, +[198] = { city_berlin, 2020, MONTH_Jun, 0.918717731989696f, 0, 0 }, +[199] = { city_berlin, 2020, MONTH_Oct, 0.526922668293464f, 0, 0 }, +[200] = { city_berlin, 2021, MONTH_Feb, 0.407533147535702f, 0, 0 }, +[201] = { city_berlin, 2021, MONTH_Apr, 0.260631254569428f, 0, 0 }, +[202] = { city_berlin, 2021, MONTH_Jun, 0.850691099863162f, 0, 0 }, +[203] = { city_berlin, 2021, MONTH_Oct, 0.447745362619697f, 0, 0 }, +[204] = { city_athens, 2019, MONTH_Apr, 0.475810196278598f, 0, 0 }, +[205] = { city_athens, 2019, MONTH_Jul, 0.727351163708599f, 0, 0 }, +[206] = { city_athens, 2019, MONTH_Sep, 0.1173467409143746f, 0, 0 }, +[207] = { city_athens, 2020, MONTH_Jan, 0.701133914670033f, 0, 0 }, +[208] = { city_athens, 2020, MONTH_May, 0.502187471083579f, 0, 0 }, +[209] = { city_athens, 2020, MONTH_Aug, 0.722469653059002f, 0, 0 }, +[210] = { city_athens, 2020, MONTH_Nov, 0.0705704436871592f, 0, 0 }, +[211] = { city_athens, 2020, MONTH_Dec, 0.412202187265480f, 0, 0 }, +[212] = { city_athens, 2021, MONTH_Apr, 0.789529374678307f, 0, 0 }, +[213] = { city_athens, 2021, MONTH_Jul, 0.4263051767962031f, 0, 0 }, +[214] = { city_athens, 2021, MONTH_Sep, 0.422014815723197f, 0, 0 }, +[215] = { city_athens, 2022, MONTH_Jan, 0.0793089415950993f, 0, 0 }, +[216] = { city_guatemala_city, 2019, MONTH_Feb, 0.560605380854630f, 0, 0 }, +[217] = { city_guatemala_city, 2019, MONTH_Apr, 0.3382526681121018f, 0, 0 }, +[218] = { city_guatemala_city, 2019, MONTH_Jun, 0.395812130966940f, 0, 0 }, +[219] = { city_guatemala_city, 2019, MONTH_Oct, 0.812327694885220f, 0, 0 }, +[220] = { city_guatemala_city, 2020, MONTH_May, 0.654610646195839f, 0, 0 }, +[221] = { city_guatemala_city, 2020, MONTH_Aug, 0.365603885209179f, 0, 0 }, +[222] = { city_guatemala_city, 2020, MONTH_Nov, 0.299155503687062f, 0, 0 }, +[223] = { city_guatemala_city, 2020, MONTH_Dec, 0.184138836513171f, 0, 0 }, +[224] = { city_guatemala_city, 2021, MONTH_Mar, 0.704976319975955f, 0, 0 }, +[225] = { city_guatemala_city, 2021, MONTH_May, 0.0361929491443968f, 0, 0 }, +[226] = { city_guatemala_city, 2021, MONTH_Oct, 0.64197021948932f, 0, 0 }, +[227] = { city_guatemala_city, 2021, MONTH_Dec, 0.729014435225115f, 0, 0 }, +[228] = { city_jakarta, 2019, MONTH_May, 0.4873064888015896f, 0, 0 }, +[229] = { city_jakarta, 2019, MONTH_Aug, 0.1332481199937597f, 0, 0 }, +[230] = { city_jakarta, 2019, MONTH_Nov, 0.745745949826538f, 0, 0 }, +[231] = { city_jakarta, 2019, MONTH_Dec, 0.677061592008742f, 0, 0 }, +[232] = { city_jakarta, 2020, MONTH_Feb, 0.097222170637766f, 0, 0 }, +[233] = { city_jakarta, 2020, MONTH_Apr, 0.454813364724139f, 0, 0 }, +[234] = { city_jakarta, 2020, MONTH_Jun, 0.599030699042925f, 0, 0 }, +[235] = { city_jakarta, 2020, MONTH_Oct, 0.4625443588285278f, 0, 0 }, +[236] = { city_jakarta, 2021, MONTH_Feb, 0.487754108957089f, 0, 0 }, +[237] = { city_jakarta, 2021, MONTH_Apr, 0.317627211073128f, 0, 0 }, +[238] = { city_jakarta, 2021, MONTH_Jun, 0.4601649895962731f, 0, 0 }, +[239] = { city_jakarta, 2021, MONTH_Oct, 0.819518311504193f, 0, 0 }, +[240] = { city_tehran, 2019, MONTH_Apr, 0.301861333672369f, 0, 0 }, +[241] = { city_tehran, 2019, MONTH_Jul, 0.690444209645852f, 0, 0 }, +[242] = { city_tehran, 2019, MONTH_Sep, 0.4404145375380147f, 0, 0 }, +[243] = { city_tehran, 2020, MONTH_Jan, 0.512216673447640f, 0, 0 }, +[244] = { city_tehran, 2020, MONTH_Mar, 0.404877102071919f, 0, 0 }, +[245] = { city_tehran, 2020, MONTH_May, 0.0425131526773253f, 0, 0 }, +[246] = { city_tehran, 2020, MONTH_Oct, 0.2593536969506149f, 0, 0 }, +[247] = { city_tehran, 2020, MONTH_Dec, 0.783890028761998f, 0, 0 }, +[248] = { city_tehran, 2021, MONTH_Mar, 0.94926354604200f, 0, 0 }, +[249] = { city_tehran, 2021, MONTH_May, 0.0569072784620124f, 0, 0 }, +[250] = { city_tehran, 2021, MONTH_Oct, 0.577568094487137f, 0, 0 }, +[251] = { city_tehran, 2021, MONTH_Dec, 0.618906187850862f, 0, 0 }, +[252] = { city_baghdad, 2019, MONTH_Mar, 0.2041098782632676f, 0, 0 }, +[253] = { city_baghdad, 2019, MONTH_May, 0.418410741640879f, 0, 0 }, +[254] = { city_baghdad, 2019, MONTH_Oct, 0.4045113808247624f, 0, 0 }, +[255] = { city_baghdad, 2019, MONTH_Dec, 0.0935036317264107f, 0, 0 }, +[256] = { city_baghdad, 2020, MONTH_May, 0.881388063687282f, 0, 0 }, +[257] = { city_baghdad, 2020, MONTH_Aug, 0.542844838193968f, 0, 0 }, +[258] = { city_baghdad, 2020, MONTH_Nov, 0.919644994222689f, 0, 0 }, +[259] = { city_baghdad, 2020, MONTH_Dec, 0.4012535241874899f, 0, 0 }, +[260] = { city_baghdad, 2021, MONTH_Feb, 0.3336959972932559f, 0, 0 }, +[261] = { city_baghdad, 2021, MONTH_Apr, 0.1796197721242466f, 0, 0 }, +[262] = { city_baghdad, 2021, MONTH_Jun, 0.828742767016648f, 0, 0 }, +[263] = { city_baghdad, 2021, MONTH_Oct, 0.1843548012255065f, 0, 0 }, +[264] = { city_tokyo, 2019, MONTH_May, 0.155891108992637f, 0, 0 }, +[265] = { city_tokyo, 2019, MONTH_Aug, 0.710329744155827f, 0, 0 }, +[266] = { city_tokyo, 2019, MONTH_Nov, 0.767037295899860f, 0, 0 }, +[267] = { city_tokyo, 2019, MONTH_Dec, 0.3455214091470476f, 0, 0 }, +[268] = { city_tokyo, 2020, MONTH_Feb, 0.3474433981102914f, 0, 0 }, +[269] = { city_tokyo, 2020, MONTH_Apr, 0.945631216030701f, 0, 0 }, +[270] = { city_tokyo, 2020, MONTH_Jun, 0.696669631520124f, 0, 0 }, +[271] = { city_tokyo, 2020, MONTH_Oct, 0.722151370281128f, 0, 0 }, +[272] = { city_tokyo, 2021, MONTH_Apr, 0.124744692100837f, 0, 0 }, +[273] = { city_tokyo, 2021, MONTH_Jul, 0.780248733655871f, 0, 0 }, +[274] = { city_tokyo, 2021, MONTH_Sep, 0.802652502830138f, 0, 0 }, +[275] = { city_tokyo, 2022, MONTH_Jan, 0.1950030931830898f, 0, 0 }, +[276] = { city_amman, 2019, MONTH_Apr, 0.913564776301748f, 0, 0 }, +[277] = { city_amman, 2019, MONTH_Jul, 0.51995965182440f, 0, 0 }, +[278] = { city_amman, 2019, MONTH_Sep, 0.0734962371079785f, 0, 0 }, +[279] = { city_amman, 2020, MONTH_Jan, 0.820928052342723f, 0, 0 }, +[280] = { city_amman, 2020, MONTH_Feb, 0.858049473312560f, 0, 0 }, +[281] = { city_amman, 2020, MONTH_Apr, 0.472228820975274f, 0, 0 }, +[282] = { city_amman, 2020, MONTH_Jun, 0.859450329852867f, 0, 0 }, +[283] = { city_amman, 2020, MONTH_Oct, 0.734397157087221f, 0, 0 }, +[284] = { city_amman, 2021, MONTH_Feb, 0.471531691187588f, 0, 0 }, +[285] = { city_amman, 2021, MONTH_Apr, 0.74666411798262f, 0, 0 }, +[286] = { city_amman, 2021, MONTH_Jun, 0.0449755300464772f, 0, 0 }, +[287] = { city_amman, 2021, MONTH_Oct, 0.989728098238887f, 0, 0 }, +[288] = { city_nairobi, 2019, MONTH_May, 0.353258469908758f, 0, 0 }, +[289] = { city_nairobi, 2019, MONTH_Aug, 0.637265803224577f, 0, 0 }, +[290] = { city_nairobi, 2019, MONTH_Nov, 0.652963298166620f, 0, 0 }, +[291] = { city_nairobi, 2019, MONTH_Dec, 0.980136667400578f, 0, 0 }, +[292] = { city_nairobi, 2020, MONTH_May, 0.1123254499523785f, 0, 0 }, +[293] = { city_nairobi, 2020, MONTH_Aug, 0.636340674934326f, 0, 0 }, +[294] = { city_nairobi, 2020, MONTH_Nov, 0.457205051760276f, 0, 0 }, +[295] = { city_nairobi, 2020, MONTH_Dec, 0.501683805374266f, 0, 0 }, +[296] = { city_nairobi, 2021, MONTH_May, 0.287133545101559f, 0, 0 }, +[297] = { city_nairobi, 2021, MONTH_Aug, 0.613486374545206f, 0, 0 }, +[298] = { city_nairobi, 2021, MONTH_Nov, 0.664668792823215f, 0, 0 }, +[299] = { city_nairobi, 2021, MONTH_Dec, 0.460460310851094f, 0, 0 }, +[300] = { city_beirut, 2019, MONTH_May, 0.2065707928015757f, 0, 0 }, +[301] = { city_beirut, 2019, MONTH_Aug, 0.0806051251653264f, 0, 0 }, +[302] = { city_beirut, 2019, MONTH_Nov, 0.312175807704065f, 0, 0 }, +[303] = { city_beirut, 2019, MONTH_Dec, 0.570445032963265f, 0, 0 }, +[304] = { city_beirut, 2020, MONTH_May, 0.4971129813508322f, 0, 0 }, +[305] = { city_beirut, 2020, MONTH_Aug, 0.265179951577338f, 0, 0 }, +[306] = { city_beirut, 2020, MONTH_Nov, 0.3758296973795538f, 0, 0 }, +[307] = { city_beirut, 2020, MONTH_Dec, 0.2321419145383638f, 0, 0 }, +[308] = { city_beirut, 2021, MONTH_Feb, 0.976920552803965f, 0, 0 }, +[309] = { city_beirut, 2021, MONTH_Apr, 0.571447163905541f, 0, 0 }, +[310] = { city_beirut, 2021, MONTH_Jun, 0.786651053940900f, 0, 0 }, +[311] = { city_beirut, 2021, MONTH_Oct, 0.1096868650743059f, 0, 0 }, +[312] = { city_tripoli, 2019, MONTH_Apr, 0.345925686602871f, 0, 0 }, +[313] = { city_tripoli, 2019, MONTH_Jul, 0.876290377343576f, 0, 0 }, +[314] = { city_tripoli, 2019, MONTH_Sep, 0.790275244077456f, 0, 0 }, +[315] = { city_tripoli, 2020, MONTH_Jan, 0.3965589139790378f, 0, 0 }, +[316] = { city_tripoli, 2020, MONTH_Mar, 0.285348770715926f, 0, 0 }, +[317] = { city_tripoli, 2020, MONTH_May, 0.496333626012515f, 0, 0 }, +[318] = { city_tripoli, 2020, MONTH_Oct, 0.01792744471676621f, 0, 0 }, +[319] = { city_tripoli, 2020, MONTH_Dec, 0.4947927621449260f, 0, 0 }, +[320] = { city_tripoli, 2021, MONTH_May, 0.1308448333921825f, 0, 0 }, +[321] = { city_tripoli, 2021, MONTH_Aug, 0.397296712656376f, 0, 0 }, +[322] = { city_tripoli, 2021, MONTH_Nov, 0.4494511222856165f, 0, 0 }, +[323] = { city_tripoli, 2021, MONTH_Dec, 0.918909285370890f, 0, 0 }, +[324] = { city_kuala_lumpur, 2019, MONTH_Feb, 0.1675625833439882f, 0, 0 }, +[325] = { city_kuala_lumpur, 2019, MONTH_Apr, 0.729200169873379f, 0, 0 }, +[326] = { city_kuala_lumpur, 2019, MONTH_Jun, 0.515728121325297f, 0, 0 }, +[327] = { city_kuala_lumpur, 2019, MONTH_Oct, 0.801495874749624f, 0, 0 }, +[328] = { city_kuala_lumpur, 2020, MONTH_May, 0.860285410440025f, 0, 0 }, +[329] = { city_kuala_lumpur, 2020, MONTH_Aug, 0.4333367319964f, 0, 0 }, +[330] = { city_kuala_lumpur, 2020, MONTH_Nov, 0.373641801398257f, 0, 0 }, +[331] = { city_kuala_lumpur, 2020, MONTH_Dec, 0.993321214324000f, 0, 0 }, +[332] = { city_kuala_lumpur, 2021, MONTH_May, 0.955896960620464f, 0, 0 }, +[333] = { city_kuala_lumpur, 2021, MONTH_Aug, 0.847466374787605f, 0, 0 }, +[334] = { city_kuala_lumpur, 2021, MONTH_Nov, 0.725930991736956f, 0, 0 }, +[335] = { city_kuala_lumpur, 2021, MONTH_Dec, 0.0771676585796252f, 0, 0 }, +[336] = { city_male, 2019, MONTH_May, 0.1185919416224812f, 0, 0 }, +[337] = { city_male, 2019, MONTH_Aug, 0.1093303633227156f, 0, 0 }, +[338] = { city_male, 2019, MONTH_Nov, 0.351298531207944f, 0, 0 }, +[339] = { city_male, 2019, MONTH_Dec, 0.939014019805290f, 0, 0 }, +[340] = { city_male, 2020, MONTH_May, 0.905825718197400f, 0, 0 }, +[341] = { city_male, 2020, MONTH_Aug, 0.4774451158431509f, 0, 0 }, +[342] = { city_male, 2020, MONTH_Nov, 0.865861494206516f, 0, 0 }, +[343] = { city_male, 2020, MONTH_Dec, 0.3879887276689698f, 0, 0 }, +[344] = { city_male, 2021, MONTH_Feb, 0.762094702658892f, 0, 0 }, +[345] = { city_male, 2021, MONTH_Apr, 0.930703136536702f, 0, 0 }, +[346] = { city_male, 2021, MONTH_Jun, 0.413267471538170f, 0, 0 }, +[347] = { city_male, 2021, MONTH_Oct, 0.0715077259848261f, 0, 0 }, +[348] = { city_mexico_city, 2019, MONTH_Mar, 0.282689271758157f, 0, 0 }, +[349] = { city_mexico_city, 2019, MONTH_May, 0.692801392386349f, 0, 0 }, +[350] = { city_mexico_city, 2019, MONTH_Oct, 0.856300831164312f, 0, 0 }, +[351] = { city_mexico_city, 2019, MONTH_Dec, 0.62752648352262f, 0, 0 }, +[352] = { city_mexico_city, 2020, MONTH_Apr, 0.992877682455008f, 0, 0 }, +[353] = { city_mexico_city, 2020, MONTH_Jul, 0.3288944801257265f, 0, 0 }, +[354] = { city_mexico_city, 2020, MONTH_Sep, 0.567301662762395f, 0, 0 }, +[355] = { city_mexico_city, 2021, MONTH_Jan, 0.653652403202057f, 0, 0 }, +[356] = { city_mexico_city, 2021, MONTH_Feb, 0.3617368415256383f, 0, 0 }, +[357] = { city_mexico_city, 2021, MONTH_Apr, 0.1999051783032370f, 0, 0 }, +[358] = { city_mexico_city, 2021, MONTH_Jun, 0.2234520522974474f, 0, 0 }, +[359] = { city_mexico_city, 2021, MONTH_Oct, 0.2249265703960294f, 0, 0 }, +[360] = { city_ulan_bator, 2019, MONTH_Feb, 0.0973111569162685f, 0, 0 }, +[361] = { city_ulan_bator, 2019, MONTH_Apr, 0.717625035182259f, 0, 0 }, +[362] = { city_ulan_bator, 2019, MONTH_Jun, 0.68888115436561f, 0, 0 }, +[363] = { city_ulan_bator, 2019, MONTH_Oct, 0.317598068282712f, 0, 0 }, +[364] = { city_ulan_bator, 2020, MONTH_Mar, 0.532042281420785f, 0, 0 }, +[365] = { city_ulan_bator, 2020, MONTH_May, 0.937731820508145f, 0, 0 }, +[366] = { city_ulan_bator, 2020, MONTH_Oct, 0.1507514606104898f, 0, 0 }, +[367] = { city_ulan_bator, 2020, MONTH_Dec, 0.0210516496711773f, 0, 0 }, +[368] = { city_ulan_bator, 2021, MONTH_Feb, 0.695258364407790f, 0, 0 }, +[369] = { city_ulan_bator, 2021, MONTH_Apr, 0.2133368779237394f, 0, 0 }, +[370] = { city_ulan_bator, 2021, MONTH_Jun, 0.4350453296437505f, 0, 0 }, +[371] = { city_ulan_bator, 2021, MONTH_Oct, 0.887232414698376f, 0, 0 }, +[372] = { city_rabat, 2019, MONTH_Apr, 0.4848684557100414f, 0, 0 }, +[373] = { city_rabat, 2019, MONTH_Jul, 0.830378389707985f, 0, 0 }, +[374] = { city_rabat, 2019, MONTH_Sep, 0.267946912678618f, 0, 0 }, +[375] = { city_rabat, 2020, MONTH_Jan, 0.21686208646062f, 0, 0 }, +[376] = { city_rabat, 2020, MONTH_Feb, 0.639484185249096f, 0, 0 }, +[377] = { city_rabat, 2020, MONTH_Apr, 0.795734886425641f, 0, 0 }, +[378] = { city_rabat, 2020, MONTH_Jun, 0.3544991360983855f, 0, 0 }, +[379] = { city_rabat, 2020, MONTH_Oct, 0.88478654358351f, 0, 0 }, +[380] = { city_rabat, 2021, MONTH_Feb, 0.754599832364994f, 0, 0 }, +[381] = { city_rabat, 2021, MONTH_Apr, 0.4417992899161763f, 0, 0 }, +[382] = { city_rabat, 2021, MONTH_Jun, 0.607116720946833f, 0, 0 }, +[383] = { city_rabat, 2021, MONTH_Oct, 0.358623776327881f, 0, 0 }, +[384] = { city_amsterdam, 2019, MONTH_Feb, 0.731625264443053f, 0, 0 }, +[385] = { city_amsterdam, 2019, MONTH_Apr, 0.566868738166083f, 0, 0 }, +[386] = { city_amsterdam, 2019, MONTH_Jun, 0.557667088829960f, 0, 0 }, +[387] = { city_amsterdam, 2019, MONTH_Oct, 0.4165140225359793f, 0, 0 }, +[388] = { city_amsterdam, 2020, MONTH_Mar, 0.1369118545708988f, 0, 0 }, +[389] = { city_amsterdam, 2020, MONTH_May, 0.996381145058562f, 0, 0 }, +[390] = { city_amsterdam, 2020, MONTH_Oct, 0.567884655995259f, 0, 0 }, +[391] = { city_amsterdam, 2020, MONTH_Dec, 0.3599824946665225f, 0, 0 }, +[392] = { city_amsterdam, 2021, MONTH_May, 0.3617612455991281f, 0, 0 }, +[393] = { city_amsterdam, 2021, MONTH_Aug, 0.145208263117762f, 0, 0 }, +[394] = { city_amsterdam, 2021, MONTH_Nov, 0.405925018466976f, 0, 0 }, +[395] = { city_amsterdam, 2021, MONTH_Dec, 0.466865583671862f, 0, 0 }, +[396] = { city_wellington, 2019, MONTH_Mar, 0.2399790368405242f, 0, 0 }, +[397] = { city_wellington, 2019, MONTH_May, 0.0513312639497346f, 0, 0 }, +[398] = { city_wellington, 2019, MONTH_Oct, 0.154820278468702f, 0, 0 }, +[399] = { city_wellington, 2019, MONTH_Dec, 0.342480035947826f, 0, 0 }, +[400] = { city_wellington, 2020, MONTH_Feb, 0.02270196410158653f, 0, 0 }, +[401] = { city_wellington, 2020, MONTH_Apr, 0.549977096428455f, 0, 0 }, +[402] = { city_wellington, 2020, MONTH_Jun, 0.825352479423318f, 0, 0 }, +[403] = { city_wellington, 2020, MONTH_Oct, 0.00533147733597216f, 0, 0 }, +[404] = { city_wellington, 2021, MONTH_May, 0.92165713944193f, 0, 0 }, +[405] = { city_wellington, 2021, MONTH_Aug, 0.1030939587069419f, 0, 0 }, +[406] = { city_wellington, 2021, MONTH_Nov, 0.626356522706967f, 0, 0 }, +[407] = { city_wellington, 2021, MONTH_Dec, 0.202081862772906f, 0, 0 }, +[408] = { city_managua, 2019, MONTH_Apr, 0.0558278728762413f, 0, 0 }, +[409] = { city_managua, 2019, MONTH_Jul, 0.4838275959297315f, 0, 0 }, +[410] = { city_managua, 2019, MONTH_Sep, 0.982787118880607f, 0, 0 }, +[411] = { city_managua, 2020, MONTH_Jan, 0.0001771442144287149f, 0, 0 }, +[412] = { city_managua, 2020, MONTH_Feb, 0.924958034469370f, 0, 0 }, +[413] = { city_managua, 2020, MONTH_Apr, 0.804497555444690f, 0, 0 }, +[414] = { city_managua, 2020, MONTH_Jun, 0.562726395776656f, 0, 0 }, +[415] = { city_managua, 2020, MONTH_Oct, 0.323725027619491f, 0, 0 }, +[416] = { city_managua, 2021, MONTH_Mar, 0.02044880108483926f, 0, 0 }, +[417] = { city_managua, 2021, MONTH_May, 0.890130453740734f, 0, 0 }, +[418] = { city_managua, 2021, MONTH_Oct, 0.731841044395474f, 0, 0 }, +[419] = { city_managua, 2021, MONTH_Dec, 0.884381400825929f, 0, 0 }, +[420] = { city_abuja, 2019, MONTH_May, 0.66478819034649f, 0, 0 }, +[421] = { city_abuja, 2019, MONTH_Aug, 0.3457386667673525f, 0, 0 }, +[422] = { city_abuja, 2019, MONTH_Nov, 0.092988823835393f, 0, 0 }, +[423] = { city_abuja, 2019, MONTH_Dec, 0.824262528959534f, 0, 0 }, +[424] = { city_abuja, 2020, MONTH_Apr, 0.61049766413043f, 0, 0 }, +[425] = { city_abuja, 2020, MONTH_Jul, 0.1304592836307013f, 0, 0 }, +[426] = { city_abuja, 2020, MONTH_Sep, 0.593187180006649f, 0, 0 }, +[427] = { city_abuja, 2021, MONTH_Jan, 0.876199072732621f, 0, 0 }, +[428] = { city_abuja, 2021, MONTH_Mar, 0.0329722159321588f, 0, 0 }, +[429] = { city_abuja, 2021, MONTH_May, 0.266368310626165f, 0, 0 }, +[430] = { city_abuja, 2021, MONTH_Oct, 0.475247255909794f, 0, 0 }, +[431] = { city_abuja, 2021, MONTH_Dec, 0.2181789145549840f, 0, 0 }, +[432] = { city_islamabad, 2019, MONTH_Feb, 0.689456535686944f, 0, 0 }, +[433] = { city_islamabad, 2019, MONTH_Apr, 0.0447373363978489f, 0, 0 }, +[434] = { city_islamabad, 2019, MONTH_Jun, 0.822514095879552f, 0, 0 }, +[435] = { city_islamabad, 2019, MONTH_Oct, 0.916703876449938f, 0, 0 }, +[436] = { city_islamabad, 2020, MONTH_Mar, 0.1893115617875816f, 0, 0 }, +[437] = { city_islamabad, 2020, MONTH_May, 0.86726306770825f, 0, 0 }, +[438] = { city_islamabad, 2020, MONTH_Oct, 0.905215849243983f, 0, 0 }, +[439] = { city_islamabad, 2020, MONTH_Dec, 0.254940376897477f, 0, 0 }, +[440] = { city_islamabad, 2021, MONTH_Mar, 0.281039684229208f, 0, 0 }, +[441] = { city_islamabad, 2021, MONTH_May, 0.887339106739559f, 0, 0 }, +[442] = { city_islamabad, 2021, MONTH_Oct, 0.933048865779014f, 0, 0 }, +[443] = { city_islamabad, 2021, MONTH_Dec, 0.0340736858267484f, 0, 0 }, +[444] = { city_lima, 2019, MONTH_Feb, 0.328346577769536f, 0, 0 }, +[445] = { city_lima, 2019, MONTH_Apr, 0.2756724157263651f, 0, 0 }, +[446] = { city_lima, 2019, MONTH_Jun, 0.609815087863952f, 0, 0 }, +[447] = { city_lima, 2019, MONTH_Oct, 0.782731155908874f, 0, 0 }, +[448] = { city_lima, 2020, MONTH_May, 0.000478011020313862f, 0, 0 }, +[449] = { city_lima, 2020, MONTH_Aug, 0.3235917681085961f, 0, 0 }, +[450] = { city_lima, 2020, MONTH_Nov, 0.792016455238391f, 0, 0 }, +[451] = { city_lima, 2020, MONTH_Dec, 0.0868050405329673f, 0, 0 }, +[452] = { city_lima, 2021, MONTH_Feb, 0.281555206177401f, 0, 0 }, +[453] = { city_lima, 2021, MONTH_Apr, 0.794656766555093f, 0, 0 }, +[454] = { city_lima, 2021, MONTH_Jun, 0.934873911408016f, 0, 0 }, +[455] = { city_lima, 2021, MONTH_Oct, 0.966444893770645f, 0, 0 }, +[456] = { city_bucharest, 2019, MONTH_Apr, 0.275421524025559f, 0, 0 }, +[457] = { city_bucharest, 2019, MONTH_Jul, 0.934257554721354f, 0, 0 }, +[458] = { city_bucharest, 2019, MONTH_Sep, 0.456175571716915f, 0, 0 }, +[459] = { city_bucharest, 2020, MONTH_Jan, 0.581535351702321f, 0, 0 }, +[460] = { city_bucharest, 2020, MONTH_Feb, 0.0955369623031351f, 0, 0 }, +[461] = { city_bucharest, 2020, MONTH_Apr, 0.797724127406068f, 0, 0 }, +[462] = { city_bucharest, 2020, MONTH_Jun, 0.1158114218862972f, 0, 0 }, +[463] = { city_bucharest, 2020, MONTH_Oct, 0.60936646395483f, 0, 0 }, +[464] = { city_bucharest, 2021, MONTH_May, 0.778649374817847f, 0, 0 }, +[465] = { city_bucharest, 2021, MONTH_Aug, 0.370947549484814f, 0, 0 }, +[466] = { city_bucharest, 2021, MONTH_Nov, 0.0640963197950903f, 0, 0 }, +[467] = { city_bucharest, 2021, MONTH_Dec, 0.643541163489257f, 0, 0 }, +[468] = { city_moscow, 2019, MONTH_Mar, 0.301010635427779f, 0, 0 }, +[469] = { city_moscow, 2019, MONTH_May, 0.456078321317001f, 0, 0 }, +[470] = { city_moscow, 2019, MONTH_Oct, 0.0538331203062519f, 0, 0 }, +[471] = { city_moscow, 2019, MONTH_Dec, 0.75192484013845f, 0, 0 }, +[472] = { city_moscow, 2020, MONTH_May, 0.872306088053229f, 0, 0 }, +[473] = { city_moscow, 2020, MONTH_Aug, 0.1239402065770388f, 0, 0 }, +[474] = { city_moscow, 2020, MONTH_Nov, 0.2020263441001254f, 0, 0 }, +[475] = { city_moscow, 2020, MONTH_Dec, 0.278274013412570f, 0, 0 }, +[476] = { city_moscow, 2021, MONTH_May, 0.2488571531010973f, 0, 0 }, +[477] = { city_moscow, 2021, MONTH_Aug, 0.0489617026735895f, 0, 0 }, +[478] = { city_moscow, 2021, MONTH_Nov, 0.868455790657478f, 0, 0 }, +[479] = { city_moscow, 2021, MONTH_Dec, 0.54311463810805f, 0, 0 }, +[480] = { city_belgrade, 2019, MONTH_May, 0.552246653164450f, 0, 0 }, +[481] = { city_belgrade, 2019, MONTH_Aug, 0.608445734269070f, 0, 0 }, +[482] = { city_belgrade, 2019, MONTH_Nov, 0.904417407475315f, 0, 0 }, +[483] = { city_belgrade, 2019, MONTH_Dec, 0.0706690624583042f, 0, 0 }, +[484] = { city_belgrade, 2020, MONTH_May, 0.000863732217009305f, 0, 0 }, +[485] = { city_belgrade, 2020, MONTH_Aug, 0.328824489783167f, 0, 0 }, +[486] = { city_belgrade, 2020, MONTH_Nov, 0.36976843567074f, 0, 0 }, +[487] = { city_belgrade, 2020, MONTH_Dec, 0.961964263330105f, 0, 0 }, +[488] = { city_belgrade, 2021, MONTH_Mar, 0.3057188881540604f, 0, 0 }, +[489] = { city_belgrade, 2021, MONTH_May, 0.449818470067468f, 0, 0 }, +[490] = { city_belgrade, 2021, MONTH_Oct, 0.71154904735186f, 0, 0 }, +[491] = { city_belgrade, 2021, MONTH_Dec, 0.1308593962428957f, 0, 0 }, +[492] = { city_singapore, 2019, MONTH_Feb, 0.193694292780376f, 0, 0 }, +[493] = { city_singapore, 2019, MONTH_Apr, 0.318702929890905f, 0, 0 }, +[494] = { city_singapore, 2019, MONTH_Jun, 0.645215799082995f, 0, 0 }, +[495] = { city_singapore, 2019, MONTH_Oct, 0.591187969918129f, 0, 0 }, +[496] = { city_singapore, 2020, MONTH_May, 0.699396534256987f, 0, 0 }, +[497] = { city_singapore, 2020, MONTH_Aug, 0.2780977621387803f, 0, 0 }, +[498] = { city_singapore, 2020, MONTH_Nov, 0.455489668769613f, 0, 0 }, +[499] = { city_singapore, 2020, MONTH_Dec, 0.724372367679592f, 0, 0 }, +[500] = { city_singapore, 2021, MONTH_Apr, 0.0229979967292621f, 0, 0 }, +[501] = { city_singapore, 2021, MONTH_Jul, 0.0249669479037042f, 0, 0 }, +[502] = { city_singapore, 2021, MONTH_Sep, 0.879108640287500f, 0, 0 }, +[503] = { city_singapore, 2022, MONTH_Jan, 0.612089991020752f, 0, 0 }, +[504] = { city_seoul, 2019, MONTH_May, 0.277150821785431f, 0, 0 }, +[505] = { city_seoul, 2019, MONTH_Aug, 0.3348478329043680f, 0, 0 }, +[506] = { city_seoul, 2019, MONTH_Nov, 0.4503487807607835f, 0, 0 }, +[507] = { city_seoul, 2019, MONTH_Dec, 0.2103442020665882f, 0, 0 }, +[508] = { city_seoul, 2020, MONTH_May, 0.3640140905380354f, 0, 0 }, +[509] = { city_seoul, 2020, MONTH_Aug, 0.706729161499808f, 0, 0 }, +[510] = { city_seoul, 2020, MONTH_Nov, 0.885612236808133f, 0, 0 }, +[511] = { city_seoul, 2020, MONTH_Dec, 0.519775809368071f, 0, 0 }, +[512] = { city_seoul, 2021, MONTH_Apr, 0.732835881732319f, 0, 0 }, +[513] = { city_seoul, 2021, MONTH_Jul, 0.903712712868978f, 0, 0 }, +[514] = { city_seoul, 2021, MONTH_Sep, 0.579911957881779f, 0, 0 }, +[515] = { city_seoul, 2022, MONTH_Jan, 0.523793425841401f, 0, 0 }, +[516] = { city_tunis, 2019, MONTH_Mar, 0.0982735360423472f, 0, 0 }, +[517] = { city_tunis, 2019, MONTH_May, 0.2783517128913841f, 0, 0 }, +[518] = { city_tunis, 2019, MONTH_Oct, 0.0179865221608522f, 0, 0 }, +[519] = { city_tunis, 2019, MONTH_Dec, 0.594911360748928f, 0, 0 }, +[520] = { city_tunis, 2020, MONTH_Mar, 0.4492429946395797f, 0, 0 }, +[521] = { city_tunis, 2020, MONTH_May, 0.285860802759041f, 0, 0 }, +[522] = { city_tunis, 2020, MONTH_Oct, 0.532021890496857f, 0, 0 }, +[523] = { city_tunis, 2020, MONTH_Dec, 0.664899909160940f, 0, 0 }, +[524] = { city_tunis, 2021, MONTH_Apr, 0.373665071634036f, 0, 0 }, +[525] = { city_tunis, 2021, MONTH_Jul, 0.965776337366f, 0, 0 }, +[526] = { city_tunis, 2021, MONTH_Sep, 0.659560620156704f, 0, 0 }, +[527] = { city_tunis, 2022, MONTH_Jan, 0.624321203896919f, 0, 0 }, +[528] = { city_bangkok, 2019, MONTH_Feb, 0.257845660876937f, 0, 0 }, +[529] = { city_bangkok, 2019, MONTH_Apr, 0.224888541670249f, 0, 0 }, +[530] = { city_bangkok, 2019, MONTH_Jun, 0.619847391242953f, 0, 0 }, +[531] = { city_bangkok, 2019, MONTH_Oct, 0.850551515098475f, 0, 0 }, +[532] = { city_bangkok, 2020, MONTH_Feb, 0.911861784979914f, 0, 0 }, +[533] = { city_bangkok, 2020, MONTH_Apr, 0.854345367132697f, 0, 0 }, +[534] = { city_bangkok, 2020, MONTH_Jun, 0.976580885030065f, 0, 0 }, +[535] = { city_bangkok, 2020, MONTH_Oct, 0.515880023341469f, 0, 0 }, +[536] = { city_bangkok, 2021, MONTH_Apr, 0.05074702972151967f, 0, 0 }, +[537] = { city_bangkok, 2021, MONTH_Jul, 0.4253267917878572f, 0, 0 }, +[538] = { city_bangkok, 2021, MONTH_Sep, 0.915287731012829f, 0, 0 }, +[539] = { city_bangkok, 2022, MONTH_Jan, 0.258306431399695f, 0, 0 }, +[540] = { city_washington_dc, 2019, MONTH_May, 0.643359616915746f, 0, 0 }, +[541] = { city_washington_dc, 2019, MONTH_Aug, 0.370206005261732f, 0, 0 }, +[542] = { city_washington_dc, 2019, MONTH_Nov, 0.0623440040458129f, 0, 0 }, +[543] = { city_washington_dc, 2019, MONTH_Dec, 0.816457481734427f, 0, 0 }, +[544] = { city_washington_dc, 2020, MONTH_May, 0.538708625763008f, 0, 0 }, +[545] = { city_washington_dc, 2020, MONTH_Aug, 0.650384533924187f, 0, 0 }, +[546] = { city_washington_dc, 2020, MONTH_Nov, 0.116951545075829f, 0, 0 }, +[547] = { city_washington_dc, 2020, MONTH_Dec, 0.148219641272978f, 0, 0 }, +[548] = { city_washington_dc, 2021, MONTH_Apr, 0.02100655560513664f, 0, 0 }, +[549] = { city_washington_dc, 2021, MONTH_Jul, 0.871980590290593f, 0, 0 }, +[550] = { city_washington_dc, 2021, MONTH_Sep, 0.282318232339043f, 0, 0 }, +[551] = { city_washington_dc, 2022, MONTH_Jan, 0.805829276934675f, 0, 0 }, +[552] = { city_hanoi, 2019, MONTH_May, 0.41659113260472f, 0, 0 }, +[553] = { city_hanoi, 2019, MONTH_Aug, 0.1152641995827389f, 0, 0 }, +[554] = { city_hanoi, 2019, MONTH_Nov, 0.360035965294691f, 0, 0 }, +[555] = { city_hanoi, 2019, MONTH_Dec, 0.784196077332438f, 0, 0 }, +[556] = { city_hanoi, 2020, MONTH_May, 0.761414062564656f, 0, 0 }, +[557] = { city_hanoi, 2020, MONTH_Aug, 0.972249586627066f, 0, 0 }, +[558] = { city_hanoi, 2020, MONTH_Nov, 0.477242926987743f, 0, 0 }, +[559] = { city_hanoi, 2020, MONTH_Dec, 0.548426649668160f, 0, 0 }, +[560] = { city_hanoi, 2021, MONTH_May, 0.548248192976479f, 0, 0 }, +[561] = { city_hanoi, 2021, MONTH_Aug, 0.591016543120125f, 0, 0 }, +[562] = { city_hanoi, 2021, MONTH_Nov, 0.788317457936361f, 0, 0 }, +[563] = { city_hanoi, 2021, MONTH_Dec, 0.800132571339982f, 0, 0 }, +[564] = { city_harare, 2019, MONTH_Mar, 0.729786759502753f, 0, 0 }, +[565] = { city_harare, 2019, MONTH_May, 0.907286585478762f, 0, 0 }, +[566] = { city_harare, 2019, MONTH_Oct, 0.750261430981712f, 0, 0 }, +[567] = { city_harare, 2019, MONTH_Dec, 0.493438071814215f, 0, 0 }, +[568] = { city_harare, 2020, MONTH_Feb, 0.65132695252707f, 0, 0 }, +[569] = { city_harare, 2020, MONTH_Apr, 0.674409513858446f, 0, 0 }, +[570] = { city_harare, 2020, MONTH_Jun, 0.613534154048466f, 0, 0 }, +[571] = { city_harare, 2020, MONTH_Oct, 0.332698486042969f, 0, 0 }, +[572] = { city_harare, 2021, MONTH_Apr, 0.326843377521804f, 0, 0 }, +[573] = { city_harare, 2021, MONTH_Jul, 0.95259836088787f, 0, 0 }, +[574] = { city_harare, 2021, MONTH_Sep, 0.634598307047354f, 0, 0 }, +[575] = { city_harare, 2022, MONTH_Jan, 0.970130180099394f, 0, 0 }, +[576] = { city_ankara, 2019, MONTH_Feb, 0.1067739057302146f, 0, 0 }, +[577] = { city_ankara, 2019, MONTH_Apr, 0.636578294822275f, 0, 0 }, +[578] = { city_ankara, 2019, MONTH_Jun, 0.1065001987771908f, 0, 0 }, +[579] = { city_ankara, 2019, MONTH_Oct, 0.395046230673565f, 0, 0 }, +[580] = { city_ankara, 2020, MONTH_May, 0.516626872063971f, 0, 0 }, +[581] = { city_ankara, 2020, MONTH_Aug, 0.707711604441861f, 0, 0 }, +[582] = { city_ankara, 2020, MONTH_Nov, 0.492978525577345f, 0, 0 }, +[583] = { city_ankara, 2020, MONTH_Dec, 0.417615483179953f, 0, 0 }, +[584] = { city_ankara, 2021, MONTH_Mar, 0.3916401752130632f, 0, 0 }, +[585] = { city_ankara, 2021, MONTH_May, 0.642573767822410f, 0, 0 }, +[586] = { city_ankara, 2021, MONTH_Oct, 0.2332685344442790f, 0, 0 }, +[587] = { city_ankara, 2021, MONTH_Dec, 0.348302140835808f, 0, 0 }, +}; +global u32 test_data_len = sizeof(test_data) / sizeof(test_data[0]); \ No newline at end of file diff --git a/run_tree/data/incenter_test_data_clean.csv b/run_tree/data/incenter_test_data_clean.csv new file mode 100644 index 0000000..5a6f382 --- /dev/null +++ b/run_tree/data/incenter_test_data_clean.csv @@ -0,0 +1,588 @@ +0,city_kiev,2019,MONTH_Mar,0.8208904644894152 +1,city_kiev,2019,MONTH_May,0.560734073251748 +2,city_kiev,2019,MONTH_Oct,0.6374267513460055 +3,city_kiev,2019,MONTH_Dec,0.808628906405562 +4,city_kiev,2020,MONTH_Apr,0.5930763917923403 +5,city_kiev,2020,MONTH_Jul,0.8580149759139355 +6,city_kiev,2020,MONTH_Sep,0.1797655715379879 +7,city_kiev,2021,MONTH_Jan,0.2632534693864327 +8,city_kiev,2021,MONTH_Mar,0.8414969999187483 +9,city_kiev,2021,MONTH_May,0.5374924169034345 +10,city_kiev,2021,MONTH_Oct,0.4069815620754663 +11,city_kiev,2021,MONTH_Dec,0.767921059845557 +12,city_buenos_aires,2019,MONTH_Mar,0.8774591161262479 +13,city_buenos_aires,2019,MONTH_May,0.20624465389973745 +14,city_buenos_aires,2019,MONTH_Oct,0.9847976477350923 +15,city_buenos_aires,2019,MONTH_Dec,0.06729540587017169 +16,city_buenos_aires,2020,MONTH_Apr,0.8985765810829179 +17,city_buenos_aires,2020,MONTH_Jul,0.8147416450345571 +18,city_buenos_aires,2020,MONTH_Sep,0.39419316092894296 +19,city_buenos_aires,2021,MONTH_Jan,0.2844815741140395 +20,city_buenos_aires,2021,MONTH_Mar,0.9929587462564623 +21,city_buenos_aires,2021,MONTH_May,0.1550649172505355 +22,city_buenos_aires,2021,MONTH_Oct,0.6522096246196023 +23,city_buenos_aires,2021,MONTH_Dec,0.7408605917514841 +24,city_canberra,2019,MONTH_May,0.13386899374995143 +25,city_canberra,2019,MONTH_Aug,0.01251845204640567 +26,city_canberra,2019,MONTH_Nov,0.31069477884938224 +27,city_canberra,2019,MONTH_Dec,0.6144432795767782 +28,city_canberra,2020,MONTH_Apr,0.38215052324569254 +29,city_canberra,2020,MONTH_Jul,0.49258667615249774 +30,city_canberra,2020,MONTH_Sep,0.014024575946441353 +31,city_canberra,2021,MONTH_Jan,0.6302469024538054 +32,city_canberra,2021,MONTH_Mar,0.6657411558237325 +33,city_canberra,2021,MONTH_May,0.6375153743649629 +34,city_canberra,2021,MONTH_Oct,0.4355080346524989 +35,city_canberra,2021,MONTH_Dec,0.7842671017087504 +36,city_yerevan,2019,MONTH_Feb,0.2224804342202128 +37,city_yerevan,2019,MONTH_Apr,0.40295435638966803 +38,city_yerevan,2019,MONTH_Jun,0.00841304129117737 +39,city_yerevan,2019,MONTH_Oct,0.49353338935245084 +40,city_yerevan,2020,MONTH_Mar,0.7956088092430287 +41,city_yerevan,2020,MONTH_May,0.8718522813330138 +42,city_yerevan,2020,MONTH_Oct,0.7578502696544491 +43,city_yerevan,2020,MONTH_Dec,0.3059739437150092 +44,city_yerevan,2021,MONTH_Mar,0.5751057083330098 +45,city_yerevan,2021,MONTH_May,0.32415650181804556 +46,city_yerevan,2021,MONTH_Oct,0.13919376564116737 +47,city_yerevan,2021,MONTH_Dec,0.4082901290089086 +48,city_bishkek,2019,MONTH_Feb,0.8545389644898143 +49,city_bishkek,2019,MONTH_Apr,0.8679714734156914 +50,city_bishkek,2019,MONTH_Jun,0.9793901564982332 +51,city_bishkek,2019,MONTH_Oct,0.8289790309876645 +52,city_bishkek,2020,MONTH_Apr,0.1458951287005129 +53,city_bishkek,2020,MONTH_Jul,0.8034467113679751 +54,city_bishkek,2020,MONTH_Sep,0.34789595434452725 +55,city_bishkek,2021,MONTH_Jan,0.07184230396111713 +56,city_bishkek,2021,MONTH_Mar,0.7836073496687682 +57,city_bishkek,2021,MONTH_May,0.7217500839378747 +58,city_bishkek,2021,MONTH_Oct,0.28313109637712275 +59,city_bishkek,2021,MONTH_Dec,0.1071367737747645 +60,city_dhaka,2019,MONTH_Mar,0.6964870450822525 +61,city_dhaka,2019,MONTH_May,0.9268741946156642 +62,city_dhaka,2019,MONTH_Oct,0.0657847048182576 +63,city_dhaka,2019,MONTH_Dec,0.2679787325156153 +64,city_dhaka,2020,MONTH_Feb,0.7415948996627278 +65,city_dhaka,2020,MONTH_Apr,0.8887928797784511 +66,city_dhaka,2020,MONTH_Jun,0.9526160257787081 +67,city_dhaka,2020,MONTH_Oct,0.5394245399621023 +68,city_dhaka,2021,MONTH_Feb,0.7832918710573495 +69,city_dhaka,2021,MONTH_Apr,0.16703003479420253 +70,city_dhaka,2021,MONTH_Jun,0.9160800358967391 +71,city_dhaka,2021,MONTH_Oct,0.045576519669261906 +72,city_sucre,2019,MONTH_Feb,0.9057953843385798 +73,city_sucre,2019,MONTH_Apr,0.048949252273037924 +74,city_sucre,2019,MONTH_Jun,0.39748267526958336 +75,city_sucre,2019,MONTH_Oct,0.32402533613913065 +76,city_sucre,2020,MONTH_Feb,0.2555061186834925 +77,city_sucre,2020,MONTH_Apr,0.6834698453947482 +78,city_sucre,2020,MONTH_Jun,0.08607874887258926 +79,city_sucre,2020,MONTH_Oct,0.4802000825511048 +80,city_sucre,2021,MONTH_Apr,0.9333881101247026 +81,city_sucre,2021,MONTH_Jul,0.8260557264582842 +82,city_sucre,2021,MONTH_Sep,0.6558618586863463 +83,city_sucre,2022,MONTH_Jan,0.9951355772306388 +84,city_brasilia,2019,MONTH_Apr,0.9343497529635403 +85,city_brasilia,2019,MONTH_Jul,0.5570852230328219 +86,city_brasilia,2019,MONTH_Sep,0.2242530147430456 +87,city_brasilia,2020,MONTH_Jan,0.37927683595779194 +88,city_brasilia,2020,MONTH_Feb,0.1345707686817872 +89,city_brasilia,2020,MONTH_Apr,0.29826624893861653 +90,city_brasilia,2020,MONTH_Jun,0.8471161140155271 +91,city_brasilia,2020,MONTH_Oct,0.7106683451334669 +92,city_brasilia,2021,MONTH_Apr,0.8821305385207572 +93,city_brasilia,2021,MONTH_Jul,0.6341264853965499 +94,city_brasilia,2021,MONTH_Sep,0.8793042884983516 +95,city_brasilia,2022,MONTH_Jan,0.3678368890456808 +96,city_ottawa,2019,MONTH_Feb,0.46446610262374566 +97,city_ottawa,2019,MONTH_Apr,0.270441763178759 +98,city_ottawa,2019,MONTH_Jun,0.785020644703367 +99,city_ottawa,2019,MONTH_Oct,0.4397878896865377 +100,city_ottawa,2020,MONTH_Mar,0.6250700533476734 +101,city_ottawa,2020,MONTH_May,0.8543918093977015 +102,city_ottawa,2020,MONTH_Oct,0.10924765266094849 +103,city_ottawa,2020,MONTH_Dec,0.06989308957770357 +104,city_ottawa,2021,MONTH_May,0.02192228695177112 +105,city_ottawa,2021,MONTH_Aug,0.31180470130290383 +106,city_ottawa,2021,MONTH_Nov,0.8009641310226249 +107,city_ottawa,2021,MONTH_Dec,0.8939282034537013 +108,city_santiago,2019,MONTH_Feb,0.2604066622789484 +109,city_santiago,2019,MONTH_Apr,0.04408219650514589 +110,city_santiago,2019,MONTH_Jun,0.033700853867721814 +111,city_santiago,2019,MONTH_Oct,0.07020014506385863 +112,city_santiago,2020,MONTH_Mar,0.669167062800284 +113,city_santiago,2020,MONTH_May,0.3946672417327506 +114,city_santiago,2020,MONTH_Oct,0.96961707780403 +115,city_santiago,2020,MONTH_Dec,0.6926699539539745 +116,city_santiago,2021,MONTH_Feb,0.8855788170714998 +117,city_santiago,2021,MONTH_Apr,0.022485852743379775 +118,city_santiago,2021,MONTH_Jun,0.016611682837006425 +119,city_santiago,2021,MONTH_Oct,0.7388064669432675 +120,city_beijing,2019,MONTH_Mar,0.3984649808928382 +121,city_beijing,2019,MONTH_May,0.5516481646386852 +122,city_beijing,2019,MONTH_Oct,0.0212362107359646 +123,city_beijing,2019,MONTH_Dec,0.23392793545990853 +124,city_beijing,2020,MONTH_Mar,0.8976580542276967 +125,city_beijing,2020,MONTH_May,0.5125178728872494 +126,city_beijing,2020,MONTH_Oct,0.09885903925252493 +127,city_beijing,2020,MONTH_Dec,0.996158072334728 +128,city_beijing,2021,MONTH_May,0.3910244510687829 +129,city_beijing,2021,MONTH_Aug,0.5919057621735655 +130,city_beijing,2021,MONTH_Nov,0.22830963063642795 +131,city_beijing,2021,MONTH_Dec,0.8218119255978358 +132,city_bogota,2019,MONTH_Feb,0.040559618555634946 +133,city_bogota,2019,MONTH_Apr,0.6697544946555136 +134,city_bogota,2019,MONTH_Jun,0.7012648347686247 +135,city_bogota,2019,MONTH_Oct,0.9266430067995907 +136,city_bogota,2020,MONTH_May,0.9265350964858453 +137,city_bogota,2020,MONTH_Aug,0.5622719648324987 +138,city_bogota,2020,MONTH_Nov,0.18505076213184524 +139,city_bogota,2020,MONTH_Dec,0.13200979435040983 +140,city_bogota,2021,MONTH_Apr,0.25492724368701236 +141,city_bogota,2021,MONTH_Jul,0.6551881370411056 +142,city_bogota,2021,MONTH_Sep,0.3301507156757937 +143,city_bogota,2022,MONTH_Jan,0.9319825381469947 +144,city_nicosia,2019,MONTH_Feb,0.8112536780481092 +145,city_nicosia,2019,MONTH_Apr,0.7122242228197432 +146,city_nicosia,2019,MONTH_Jun,0.3992731724465637 +147,city_nicosia,2019,MONTH_Oct,0.0560925034296097 +148,city_nicosia,2020,MONTH_Mar,0.605635873827316 +149,city_nicosia,2020,MONTH_May,0.8155285147048078 +150,city_nicosia,2020,MONTH_Oct,0.7283140343929381 +151,city_nicosia,2020,MONTH_Dec,0.1593773388870281 +152,city_nicosia,2021,MONTH_May,0.5330985723420278 +153,city_nicosia,2021,MONTH_Aug,0.46643412774693715 +154,city_nicosia,2021,MONTH_Nov,0.7302379618035622 +155,city_nicosia,2021,MONTH_Dec,0.5971774259867612 +156,city_quito,2019,MONTH_May,0.39005009418535863 +157,city_quito,2019,MONTH_Aug,0.9025102526506403 +158,city_quito,2019,MONTH_Nov,0.507479232033487 +159,city_quito,2019,MONTH_Dec,0.5046753623312223 +160,city_quito,2020,MONTH_Mar,0.8932394343266225 +161,city_quito,2020,MONTH_May,0.19722367870643642 +162,city_quito,2020,MONTH_Oct,0.4616243916670646 +163,city_quito,2020,MONTH_Dec,0.22929952610965976 +164,city_quito,2021,MONTH_Apr,0.675839552639689 +165,city_quito,2021,MONTH_Jul,0.7522737622328722 +166,city_quito,2021,MONTH_Sep,0.7547694762384426 +167,city_quito,2022,MONTH_Jan,0.5224768718138563 +168,city_cairo,2019,MONTH_Apr,0.12251978169018596 +169,city_cairo,2019,MONTH_Jul,0.640214441842041 +170,city_cairo,2019,MONTH_Sep,0.11292283290324012 +171,city_cairo,2020,MONTH_Jan,0.443793309914693 +172,city_cairo,2020,MONTH_May,0.3695331911519818 +173,city_cairo,2020,MONTH_Aug,0.0875719219910186 +174,city_cairo,2020,MONTH_Nov,0.1300237622828465 +175,city_cairo,2020,MONTH_Dec,0.6190802409945482 +176,city_cairo,2021,MONTH_May,0.2654316735327361 +177,city_cairo,2021,MONTH_Aug,0.08380868314075796 +178,city_cairo,2021,MONTH_Nov,0.0021753600424576636 +179,city_cairo,2021,MONTH_Dec,0.3427143851789648 +180,city_addis_ababa,2019,MONTH_Feb,0.5274830002683538 +181,city_addis_ababa,2019,MONTH_Apr,0.028601788414122087 +182,city_addis_ababa,2019,MONTH_Jun,0.22406045632190197 +183,city_addis_ababa,2019,MONTH_Oct,0.1570840093379693 +184,city_addis_ababa,2020,MONTH_Apr,0.4696975980332939 +185,city_addis_ababa,2020,MONTH_Jul,0.7018912168460542 +186,city_addis_ababa,2020,MONTH_Sep,0.6707188950806201 +187,city_addis_ababa,2021,MONTH_Jan,0.22223531255669327 +188,city_addis_ababa,2021,MONTH_Mar,0.7397846957044468 +189,city_addis_ababa,2021,MONTH_May,0.2963331880851181 +190,city_addis_ababa,2021,MONTH_Oct,0.22720267945089334 +191,city_addis_ababa,2021,MONTH_Dec,0.974100472469575 +192,city_berlin,2019,MONTH_May,0.9663306486026292 +193,city_berlin,2019,MONTH_Aug,0.01762058526956345 +194,city_berlin,2019,MONTH_Nov,0.5845476680327896 +195,city_berlin,2019,MONTH_Dec,0.05267359388143655 +196,city_berlin,2020,MONTH_Feb,0.002912080115626603 +197,city_berlin,2020,MONTH_Apr,0.461618898119614 +198,city_berlin,2020,MONTH_Jun,0.9187177319896965 +199,city_berlin,2020,MONTH_Oct,0.5269226682934646 +200,city_berlin,2021,MONTH_Feb,0.4075331475357029 +201,city_berlin,2021,MONTH_Apr,0.2606312545694286 +202,city_berlin,2021,MONTH_Jun,0.8506910998631624 +203,city_berlin,2021,MONTH_Oct,0.4477453626196978 +204,city_athens,2019,MONTH_Apr,0.4758101962785981 +205,city_athens,2019,MONTH_Jul,0.7273511637085998 +206,city_athens,2019,MONTH_Sep,0.11734674091437469 +207,city_athens,2020,MONTH_Jan,0.7011339146700339 +208,city_athens,2020,MONTH_May,0.5021874710835791 +209,city_athens,2020,MONTH_Aug,0.7224696530590028 +210,city_athens,2020,MONTH_Nov,0.07057044368715926 +211,city_athens,2020,MONTH_Dec,0.4122021872654802 +212,city_athens,2021,MONTH_Apr,0.7895293746783079 +213,city_athens,2021,MONTH_Jul,0.42630517679620317 +214,city_athens,2021,MONTH_Sep,0.4220148157231979 +215,city_athens,2022,MONTH_Jan,0.07930894159509938 +216,city_guatemala_city,2019,MONTH_Feb,0.5606053808546305 +217,city_guatemala_city,2019,MONTH_Apr,0.33825266811210186 +218,city_guatemala_city,2019,MONTH_Jun,0.3958121309669401 +219,city_guatemala_city,2019,MONTH_Oct,0.8123276948852205 +220,city_guatemala_city,2020,MONTH_May,0.6546106461958394 +221,city_guatemala_city,2020,MONTH_Aug,0.3656038852091794 +222,city_guatemala_city,2020,MONTH_Nov,0.2991555036870628 +223,city_guatemala_city,2020,MONTH_Dec,0.1841388365131713 +224,city_guatemala_city,2021,MONTH_Mar,0.7049763199759551 +225,city_guatemala_city,2021,MONTH_May,0.03619294914439686 +226,city_guatemala_city,2021,MONTH_Oct,0.641970219489322 +227,city_guatemala_city,2021,MONTH_Dec,0.7290144352251158 +228,city_jakarta,2019,MONTH_May,0.48730648880158967 +229,city_jakarta,2019,MONTH_Aug,0.13324811999375974 +230,city_jakarta,2019,MONTH_Nov,0.7457459498265384 +231,city_jakarta,2019,MONTH_Dec,0.6770615920087426 +232,city_jakarta,2020,MONTH_Feb,0.0972221706377665 +233,city_jakarta,2020,MONTH_Apr,0.4548133647241398 +234,city_jakarta,2020,MONTH_Jun,0.5990306990429254 +235,city_jakarta,2020,MONTH_Oct,0.46254435882852785 +236,city_jakarta,2021,MONTH_Feb,0.4877541089570895 +237,city_jakarta,2021,MONTH_Apr,0.3176272110731281 +238,city_jakarta,2021,MONTH_Jun,0.46016498959627317 +239,city_jakarta,2021,MONTH_Oct,0.8195183115041934 +240,city_tehran,2019,MONTH_Apr,0.3018613336723692 +241,city_tehran,2019,MONTH_Jul,0.6904442096458521 +242,city_tehran,2019,MONTH_Sep,0.44041453753801474 +243,city_tehran,2020,MONTH_Jan,0.5122166734476404 +244,city_tehran,2020,MONTH_Mar,0.4048771020719195 +245,city_tehran,2020,MONTH_May,0.04251315267732536 +246,city_tehran,2020,MONTH_Oct,0.25935369695061494 +247,city_tehran,2020,MONTH_Dec,0.7838900287619984 +248,city_tehran,2021,MONTH_Mar,0.949263546042006 +249,city_tehran,2021,MONTH_May,0.05690727846201249 +250,city_tehran,2021,MONTH_Oct,0.5775680944871373 +251,city_tehran,2021,MONTH_Dec,0.6189061878508625 +252,city_baghdad,2019,MONTH_Mar,0.20410987826326765 +253,city_baghdad,2019,MONTH_May,0.4184107416408793 +254,city_baghdad,2019,MONTH_Oct,0.40451138082476246 +255,city_baghdad,2019,MONTH_Dec,0.09350363172641074 +256,city_baghdad,2020,MONTH_May,0.8813880636872825 +257,city_baghdad,2020,MONTH_Aug,0.5428448381939682 +258,city_baghdad,2020,MONTH_Nov,0.9196449942226893 +259,city_baghdad,2020,MONTH_Dec,0.40125352418748994 +260,city_baghdad,2021,MONTH_Feb,0.33369599729325594 +261,city_baghdad,2021,MONTH_Apr,0.17961977212424662 +262,city_baghdad,2021,MONTH_Jun,0.8287427670166482 +263,city_baghdad,2021,MONTH_Oct,0.18435480122550651 +264,city_tokyo,2019,MONTH_May,0.1558911089926377 +265,city_tokyo,2019,MONTH_Aug,0.7103297441558276 +266,city_tokyo,2019,MONTH_Nov,0.7670372958998607 +267,city_tokyo,2019,MONTH_Dec,0.34552140914704765 +268,city_tokyo,2020,MONTH_Feb,0.34744339811029146 +269,city_tokyo,2020,MONTH_Apr,0.9456312160307011 +270,city_tokyo,2020,MONTH_Jun,0.6966696315201248 +271,city_tokyo,2020,MONTH_Oct,0.7221513702811281 +272,city_tokyo,2021,MONTH_Apr,0.1247446921008375 +273,city_tokyo,2021,MONTH_Jul,0.7802487336558712 +274,city_tokyo,2021,MONTH_Sep,0.8026525028301382 +275,city_tokyo,2022,MONTH_Jan,0.19500309318308984 +276,city_amman,2019,MONTH_Apr,0.9135647763017481 +277,city_amman,2019,MONTH_Jul,0.519959651824404 +278,city_amman,2019,MONTH_Sep,0.07349623710797859 +279,city_amman,2020,MONTH_Jan,0.8209280523427239 +280,city_amman,2020,MONTH_Feb,0.8580494733125601 +281,city_amman,2020,MONTH_Apr,0.4722288209752745 +282,city_amman,2020,MONTH_Jun,0.8594503298528673 +283,city_amman,2020,MONTH_Oct,0.7343971570872213 +284,city_amman,2021,MONTH_Feb,0.4715316911875882 +285,city_amman,2021,MONTH_Apr,0.746664117982623 +286,city_amman,2021,MONTH_Jun,0.04497553004647725 +287,city_amman,2021,MONTH_Oct,0.9897280982388877 +288,city_nairobi,2019,MONTH_May,0.3532584699087581 +289,city_nairobi,2019,MONTH_Aug,0.6372658032245778 +290,city_nairobi,2019,MONTH_Nov,0.6529632981666209 +291,city_nairobi,2019,MONTH_Dec,0.9801366674005787 +292,city_nairobi,2020,MONTH_May,0.11232544995237859 +293,city_nairobi,2020,MONTH_Aug,0.6363406749343267 +294,city_nairobi,2020,MONTH_Nov,0.4572050517602766 +295,city_nairobi,2020,MONTH_Dec,0.5016838053742663 +296,city_nairobi,2021,MONTH_May,0.2871335451015594 +297,city_nairobi,2021,MONTH_Aug,0.6134863745452062 +298,city_nairobi,2021,MONTH_Nov,0.6646687928232157 +299,city_nairobi,2021,MONTH_Dec,0.4604603108510942 +300,city_beirut,2019,MONTH_May,0.20657079280157575 +301,city_beirut,2019,MONTH_Aug,0.08060512516532647 +302,city_beirut,2019,MONTH_Nov,0.3121758077040654 +303,city_beirut,2019,MONTH_Dec,0.5704450329632651 +304,city_beirut,2020,MONTH_May,0.49711298135083226 +305,city_beirut,2020,MONTH_Aug,0.2651799515773383 +306,city_beirut,2020,MONTH_Nov,0.37582969737955385 +307,city_beirut,2020,MONTH_Dec,0.23214191453836386 +308,city_beirut,2021,MONTH_Feb,0.9769205528039658 +309,city_beirut,2021,MONTH_Apr,0.5714471639055412 +310,city_beirut,2021,MONTH_Jun,0.7866510539409003 +311,city_beirut,2021,MONTH_Oct,0.10968686507430592 +312,city_tripoli,2019,MONTH_Apr,0.3459256866028718 +313,city_tripoli,2019,MONTH_Jul,0.8762903773435768 +314,city_tripoli,2019,MONTH_Sep,0.7902752440774569 +315,city_tripoli,2020,MONTH_Jan,0.39655891397903786 +316,city_tripoli,2020,MONTH_Mar,0.2853487707159261 +317,city_tripoli,2020,MONTH_May,0.4963336260125154 +318,city_tripoli,2020,MONTH_Oct,0.017927444716766217 +319,city_tripoli,2020,MONTH_Dec,0.49479276214492607 +320,city_tripoli,2021,MONTH_May,0.13084483339218256 +321,city_tripoli,2021,MONTH_Aug,0.3972967126563762 +322,city_tripoli,2021,MONTH_Nov,0.44945112228561657 +323,city_tripoli,2021,MONTH_Dec,0.9189092853708906 +324,city_kuala_lumpur,2019,MONTH_Feb,0.16756258334398821 +325,city_kuala_lumpur,2019,MONTH_Apr,0.7292001698733792 +326,city_kuala_lumpur,2019,MONTH_Jun,0.5157281213252976 +327,city_kuala_lumpur,2019,MONTH_Oct,0.8014958747496247 +328,city_kuala_lumpur,2020,MONTH_May,0.8602854104400254 +329,city_kuala_lumpur,2020,MONTH_Aug,0.43333673199642 +330,city_kuala_lumpur,2020,MONTH_Nov,0.3736418013982573 +331,city_kuala_lumpur,2020,MONTH_Dec,0.9933212143240009 +332,city_kuala_lumpur,2021,MONTH_May,0.9558969606204645 +333,city_kuala_lumpur,2021,MONTH_Aug,0.8474663747876059 +334,city_kuala_lumpur,2021,MONTH_Nov,0.7259309917369569 +335,city_kuala_lumpur,2021,MONTH_Dec,0.07716765857962526 +336,city_male,2019,MONTH_May,0.11859194162248121 +337,city_male,2019,MONTH_Aug,0.10933036332271562 +338,city_male,2019,MONTH_Nov,0.3512985312079444 +339,city_male,2019,MONTH_Dec,0.9390140198052906 +340,city_male,2020,MONTH_May,0.9058257181974001 +341,city_male,2020,MONTH_Aug,0.47744511584315097 +342,city_male,2020,MONTH_Nov,0.8658614942065163 +343,city_male,2020,MONTH_Dec,0.38798872766896986 +344,city_male,2021,MONTH_Feb,0.7620947026588929 +345,city_male,2021,MONTH_Apr,0.9307031365367027 +346,city_male,2021,MONTH_Jun,0.4132674715381708 +347,city_male,2021,MONTH_Oct,0.07150772598482613 +348,city_mexico_city,2019,MONTH_Mar,0.2826892717581577 +349,city_mexico_city,2019,MONTH_May,0.6928013923863494 +350,city_mexico_city,2019,MONTH_Oct,0.8563008311643129 +351,city_mexico_city,2019,MONTH_Dec,0.627526483522628 +352,city_mexico_city,2020,MONTH_Apr,0.9928776824550084 +353,city_mexico_city,2020,MONTH_Jul,0.32889448012572653 +354,city_mexico_city,2020,MONTH_Sep,0.5673016627623955 +355,city_mexico_city,2021,MONTH_Jan,0.6536524032020574 +356,city_mexico_city,2021,MONTH_Feb,0.36173684152563834 +357,city_mexico_city,2021,MONTH_Apr,0.19990517830323706 +358,city_mexico_city,2021,MONTH_Jun,0.22345205229744747 +359,city_mexico_city,2021,MONTH_Oct,0.22492657039602948 +360,city_ulan_bator,2019,MONTH_Feb,0.09731115691626857 +361,city_ulan_bator,2019,MONTH_Apr,0.7176250351822594 +362,city_ulan_bator,2019,MONTH_Jun,0.688881154365618 +363,city_ulan_bator,2019,MONTH_Oct,0.3175980682827121 +364,city_ulan_bator,2020,MONTH_Mar,0.5320422814207855 +365,city_ulan_bator,2020,MONTH_May,0.9377318205081451 +366,city_ulan_bator,2020,MONTH_Oct,0.15075146061048983 +367,city_ulan_bator,2020,MONTH_Dec,0.02105164967117734 +368,city_ulan_bator,2021,MONTH_Feb,0.6952583644077902 +369,city_ulan_bator,2021,MONTH_Apr,0.21333687792373945 +370,city_ulan_bator,2021,MONTH_Jun,0.43504532964375053 +371,city_ulan_bator,2021,MONTH_Oct,0.8872324146983761 +372,city_rabat,2019,MONTH_Apr,0.48486845571004145 +373,city_rabat,2019,MONTH_Jul,0.8303783897079856 +374,city_rabat,2019,MONTH_Sep,0.2679469126786186 +375,city_rabat,2020,MONTH_Jan,0.216862086460625 +376,city_rabat,2020,MONTH_Feb,0.6394841852490968 +377,city_rabat,2020,MONTH_Apr,0.7957348864256418 +378,city_rabat,2020,MONTH_Jun,0.35449913609838557 +379,city_rabat,2020,MONTH_Oct,0.884786543583512 +380,city_rabat,2021,MONTH_Feb,0.7545998323649945 +381,city_rabat,2021,MONTH_Apr,0.44179928991617634 +382,city_rabat,2021,MONTH_Jun,0.6071167209468333 +383,city_rabat,2021,MONTH_Oct,0.3586237763278812 +384,city_amsterdam,2019,MONTH_Feb,0.7316252644430535 +385,city_amsterdam,2019,MONTH_Apr,0.5668687381660837 +386,city_amsterdam,2019,MONTH_Jun,0.5576670888299602 +387,city_amsterdam,2019,MONTH_Oct,0.41651402253597936 +388,city_amsterdam,2020,MONTH_Mar,0.13691185457089883 +389,city_amsterdam,2020,MONTH_May,0.9963811450585627 +390,city_amsterdam,2020,MONTH_Oct,0.5678846559952594 +391,city_amsterdam,2020,MONTH_Dec,0.35998249466652255 +392,city_amsterdam,2021,MONTH_May,0.36176124559912815 +393,city_amsterdam,2021,MONTH_Aug,0.1452082631177628 +394,city_amsterdam,2021,MONTH_Nov,0.4059250184669765 +395,city_amsterdam,2021,MONTH_Dec,0.4668655836718629 +396,city_wellington,2019,MONTH_Mar,0.23997903684052424 +397,city_wellington,2019,MONTH_May,0.05133126394973464 +398,city_wellington,2019,MONTH_Oct,0.1548202784687026 +399,city_wellington,2019,MONTH_Dec,0.3424800359478265 +400,city_wellington,2020,MONTH_Feb,0.022701964101586536 +401,city_wellington,2020,MONTH_Apr,0.5499770964284553 +402,city_wellington,2020,MONTH_Jun,0.8253524794233187 +403,city_wellington,2020,MONTH_Oct,0.005331477335972168 +404,city_wellington,2021,MONTH_May,0.921657139441937 +405,city_wellington,2021,MONTH_Aug,0.10309395870694193 +406,city_wellington,2021,MONTH_Nov,0.6263565227069673 +407,city_wellington,2021,MONTH_Dec,0.2020818627729063 +408,city_managua,2019,MONTH_Apr,0.05582787287624136 +409,city_managua,2019,MONTH_Jul,0.48382759592973157 +410,city_managua,2019,MONTH_Sep,0.9827871188806075 +411,city_managua,2020,MONTH_Jan,0.00017714421442871497 +412,city_managua,2020,MONTH_Feb,0.9249580344693701 +413,city_managua,2020,MONTH_Apr,0.8044975554446903 +414,city_managua,2020,MONTH_Jun,0.5627263957766564 +415,city_managua,2020,MONTH_Oct,0.3237250276194914 +416,city_managua,2021,MONTH_Mar,0.020448801084839263 +417,city_managua,2021,MONTH_May,0.8901304537407349 +418,city_managua,2021,MONTH_Oct,0.7318410443954749 +419,city_managua,2021,MONTH_Dec,0.8843814008259293 +420,city_abuja,2019,MONTH_May,0.664788190346494 +421,city_abuja,2019,MONTH_Aug,0.34573866676735254 +422,city_abuja,2019,MONTH_Nov,0.0929888238353932 +423,city_abuja,2019,MONTH_Dec,0.8242625289595346 +424,city_abuja,2020,MONTH_Apr,0.610497664130435 +425,city_abuja,2020,MONTH_Jul,0.13045928363070136 +426,city_abuja,2020,MONTH_Sep,0.5931871800066496 +427,city_abuja,2021,MONTH_Jan,0.8761990727326217 +428,city_abuja,2021,MONTH_Mar,0.03297221593215882 +429,city_abuja,2021,MONTH_May,0.2663683106261656 +430,city_abuja,2021,MONTH_Oct,0.4752472559097941 +431,city_abuja,2021,MONTH_Dec,0.21817891455498406 +432,city_islamabad,2019,MONTH_Feb,0.6894565356869449 +433,city_islamabad,2019,MONTH_Apr,0.04473733639784894 +434,city_islamabad,2019,MONTH_Jun,0.8225140958795525 +435,city_islamabad,2019,MONTH_Oct,0.9167038764499388 +436,city_islamabad,2020,MONTH_Mar,0.18931156178758168 +437,city_islamabad,2020,MONTH_May,0.867263067708257 +438,city_islamabad,2020,MONTH_Oct,0.9052158492439835 +439,city_islamabad,2020,MONTH_Dec,0.2549403768974773 +440,city_islamabad,2021,MONTH_Mar,0.2810396842292088 +441,city_islamabad,2021,MONTH_May,0.8873391067395595 +442,city_islamabad,2021,MONTH_Oct,0.9330488657790148 +443,city_islamabad,2021,MONTH_Dec,0.03407368582674841 +444,city_lima,2019,MONTH_Feb,0.3283465777695367 +445,city_lima,2019,MONTH_Apr,0.27567241572636514 +446,city_lima,2019,MONTH_Jun,0.6098150878639521 +447,city_lima,2019,MONTH_Oct,0.7827311559088742 +448,city_lima,2020,MONTH_May,0.0004780110203138621 +449,city_lima,2020,MONTH_Aug,0.32359176810859613 +450,city_lima,2020,MONTH_Nov,0.7920164552383919 +451,city_lima,2020,MONTH_Dec,0.08680504053296734 +452,city_lima,2021,MONTH_Feb,0.2815552061774018 +453,city_lima,2021,MONTH_Apr,0.7946567665550932 +454,city_lima,2021,MONTH_Jun,0.9348739114080165 +455,city_lima,2021,MONTH_Oct,0.9664448937706452 +456,city_bucharest,2019,MONTH_Apr,0.2754215240255594 +457,city_bucharest,2019,MONTH_Jul,0.9342575547213549 +458,city_bucharest,2019,MONTH_Sep,0.4561755717169159 +459,city_bucharest,2020,MONTH_Jan,0.5815353517023211 +460,city_bucharest,2020,MONTH_Feb,0.09553696230313513 +461,city_bucharest,2020,MONTH_Apr,0.7977241274060681 +462,city_bucharest,2020,MONTH_Jun,0.11581142188629723 +463,city_bucharest,2020,MONTH_Oct,0.609366463954831 +464,city_bucharest,2021,MONTH_May,0.7786493748178472 +465,city_bucharest,2021,MONTH_Aug,0.3709475494848148 +466,city_bucharest,2021,MONTH_Nov,0.06409631979509034 +467,city_bucharest,2021,MONTH_Dec,0.6435411634892579 +468,city_moscow,2019,MONTH_Mar,0.3010106354277793 +469,city_moscow,2019,MONTH_May,0.4560783213170011 +470,city_moscow,2019,MONTH_Oct,0.05383312030625198 +471,city_moscow,2019,MONTH_Dec,0.751924840138458 +472,city_moscow,2020,MONTH_May,0.8723060880532295 +473,city_moscow,2020,MONTH_Aug,0.12394020657703886 +474,city_moscow,2020,MONTH_Nov,0.20202634410012543 +475,city_moscow,2020,MONTH_Dec,0.2782740134125702 +476,city_moscow,2021,MONTH_May,0.24885715310109735 +477,city_moscow,2021,MONTH_Aug,0.04896170267358957 +478,city_moscow,2021,MONTH_Nov,0.8684557906574781 +479,city_moscow,2021,MONTH_Dec,0.543114638108053 +480,city_belgrade,2019,MONTH_May,0.5522466531644503 +481,city_belgrade,2019,MONTH_Aug,0.6084457342690707 +482,city_belgrade,2019,MONTH_Nov,0.9044174074753157 +483,city_belgrade,2019,MONTH_Dec,0.07066906245830429 +484,city_belgrade,2020,MONTH_May,0.0008637322170093054 +485,city_belgrade,2020,MONTH_Aug,0.3288244897831679 +486,city_belgrade,2020,MONTH_Nov,0.369768435670744 +487,city_belgrade,2020,MONTH_Dec,0.9619642633301051 +488,city_belgrade,2021,MONTH_Mar,0.30571888815406045 +489,city_belgrade,2021,MONTH_May,0.4498184700674681 +490,city_belgrade,2021,MONTH_Oct,0.711549047351862 +491,city_belgrade,2021,MONTH_Dec,0.13085939624289578 +492,city_singapore,2019,MONTH_Feb,0.1936942927803761 +493,city_singapore,2019,MONTH_Apr,0.3187029298909052 +494,city_singapore,2019,MONTH_Jun,0.6452157990829956 +495,city_singapore,2019,MONTH_Oct,0.5911879699181295 +496,city_singapore,2020,MONTH_May,0.6993965342569872 +497,city_singapore,2020,MONTH_Aug,0.27809776213878035 +498,city_singapore,2020,MONTH_Nov,0.4554896687696134 +499,city_singapore,2020,MONTH_Dec,0.7243723676795923 +500,city_singapore,2021,MONTH_Apr,0.02299799672926217 +501,city_singapore,2021,MONTH_Jul,0.02496694790370424 +502,city_singapore,2021,MONTH_Sep,0.8791086402875006 +503,city_singapore,2022,MONTH_Jan,0.6120899910207525 +504,city_seoul,2019,MONTH_May,0.2771508217854315 +505,city_seoul,2019,MONTH_Aug,0.33484783290436804 +506,city_seoul,2019,MONTH_Nov,0.45034878076078355 +507,city_seoul,2019,MONTH_Dec,0.21034420206658822 +508,city_seoul,2020,MONTH_May,0.36401409053803546 +509,city_seoul,2020,MONTH_Aug,0.7067291614998081 +510,city_seoul,2020,MONTH_Nov,0.8856122368081336 +511,city_seoul,2020,MONTH_Dec,0.5197758093680719 +512,city_seoul,2021,MONTH_Apr,0.7328358817323198 +513,city_seoul,2021,MONTH_Jul,0.9037127128689783 +514,city_seoul,2021,MONTH_Sep,0.5799119578817793 +515,city_seoul,2022,MONTH_Jan,0.5237934258414012 +516,city_tunis,2019,MONTH_Mar,0.09827353604234723 +517,city_tunis,2019,MONTH_May,0.27835171289138416 +518,city_tunis,2019,MONTH_Oct,0.01798652216085228 +519,city_tunis,2019,MONTH_Dec,0.5949113607489287 +520,city_tunis,2020,MONTH_Mar,0.44924299463957973 +521,city_tunis,2020,MONTH_May,0.2858608027590416 +522,city_tunis,2020,MONTH_Oct,0.5320218904968578 +523,city_tunis,2020,MONTH_Dec,0.6648999091609407 +524,city_tunis,2021,MONTH_Apr,0.3736650716340366 +525,city_tunis,2021,MONTH_Jul,0.9657763373669 +526,city_tunis,2021,MONTH_Sep,0.6595606201567045 +527,city_tunis,2022,MONTH_Jan,0.6243212038969197 +528,city_bangkok,2019,MONTH_Feb,0.2578456608769377 +529,city_bangkok,2019,MONTH_Apr,0.2248885416702492 +530,city_bangkok,2019,MONTH_Jun,0.6198473912429538 +531,city_bangkok,2019,MONTH_Oct,0.8505515150984757 +532,city_bangkok,2020,MONTH_Feb,0.9118617849799147 +533,city_bangkok,2020,MONTH_Apr,0.8543453671326979 +534,city_bangkok,2020,MONTH_Jun,0.9765808850300658 +535,city_bangkok,2020,MONTH_Oct,0.5158800233414695 +536,city_bangkok,2021,MONTH_Apr,0.050747029721519676 +537,city_bangkok,2021,MONTH_Jul,0.42532679178785726 +538,city_bangkok,2021,MONTH_Sep,0.9152877310128299 +539,city_bangkok,2022,MONTH_Jan,0.2583064313996952 +540,city_washington_dc,2019,MONTH_May,0.6433596169157464 +541,city_washington_dc,2019,MONTH_Aug,0.3702060052617322 +542,city_washington_dc,2019,MONTH_Nov,0.06234400404581297 +543,city_washington_dc,2019,MONTH_Dec,0.8164574817344272 +544,city_washington_dc,2020,MONTH_May,0.5387086257630082 +545,city_washington_dc,2020,MONTH_Aug,0.6503845339241877 +546,city_washington_dc,2020,MONTH_Nov,0.1169515450758295 +547,city_washington_dc,2020,MONTH_Dec,0.1482196412729787 +548,city_washington_dc,2021,MONTH_Apr,0.021006555605136645 +549,city_washington_dc,2021,MONTH_Jul,0.8719805902905939 +550,city_washington_dc,2021,MONTH_Sep,0.2823182323390435 +551,city_washington_dc,2022,MONTH_Jan,0.8058292769346758 +552,city_hanoi,2019,MONTH_May,0.416591132604722 +553,city_hanoi,2019,MONTH_Aug,0.11526419958273892 +554,city_hanoi,2019,MONTH_Nov,0.3600359652946916 +555,city_hanoi,2019,MONTH_Dec,0.7841960773324388 +556,city_hanoi,2020,MONTH_May,0.7614140625646568 +557,city_hanoi,2020,MONTH_Aug,0.9722495866270668 +558,city_hanoi,2020,MONTH_Nov,0.4772429269877435 +559,city_hanoi,2020,MONTH_Dec,0.5484266496681606 +560,city_hanoi,2021,MONTH_May,0.5482481929764795 +561,city_hanoi,2021,MONTH_Aug,0.5910165431201254 +562,city_hanoi,2021,MONTH_Nov,0.7883174579363615 +563,city_hanoi,2021,MONTH_Dec,0.8001325713399826 +564,city_harare,2019,MONTH_Mar,0.7297867595027538 +565,city_harare,2019,MONTH_May,0.9072865854787621 +566,city_harare,2019,MONTH_Oct,0.7502614309817123 +567,city_harare,2019,MONTH_Dec,0.4934380718142153 +568,city_harare,2020,MONTH_Feb,0.651326952527076 +569,city_harare,2020,MONTH_Apr,0.6744095138584462 +570,city_harare,2020,MONTH_Jun,0.6135341540484665 +571,city_harare,2020,MONTH_Oct,0.3326984860429695 +572,city_harare,2021,MONTH_Apr,0.3268433775218048 +573,city_harare,2021,MONTH_Jul,0.952598360887876 +574,city_harare,2021,MONTH_Sep,0.6345983070473546 +575,city_harare,2022,MONTH_Jan,0.9701301800993941 +576,city_ankara,2019,MONTH_Feb,0.10677390573021461 +577,city_ankara,2019,MONTH_Apr,0.6365782948222759 +578,city_ankara,2019,MONTH_Jun,0.10650019877719086 +579,city_ankara,2019,MONTH_Oct,0.3950462306735656 +580,city_ankara,2020,MONTH_May,0.5166268720639717 +581,city_ankara,2020,MONTH_Aug,0.7077116044418617 +582,city_ankara,2020,MONTH_Nov,0.4929785255773451 +583,city_ankara,2020,MONTH_Dec,0.4176154831799538 +584,city_ankara,2021,MONTH_Mar,0.39164017521306327 +585,city_ankara,2021,MONTH_May,0.6425737678224106 +586,city_ankara,2021,MONTH_Oct,0.23326853444427909 +587,city_ankara,2021,MONTH_Dec,0.3483021408358088 \ No newline at end of file diff --git a/run_tree/data/incenter_test_data_clean_old.csv b/run_tree/data/incenter_test_data_clean_old.csv new file mode 100644 index 0000000..914635b --- /dev/null +++ b/run_tree/data/incenter_test_data_clean_old.csv @@ -0,0 +1,490 @@ +0,city_kiev,2019-Jan,0.4135864139,0.01956557108,0.3199632899 +1,city_kiev,2019-May,0.5108363835,0.8589876789,0.2033754817 +2,city_kiev,2019-Sep,0.3098831619,0.2965779176,0.8780642384 +3,city_kiev,2020-Jan,0.6513288588,0.969807378,0.4734936057 +4,city_kiev,2020-May,0.4017988233,0.08149953656,0.1917572298 +5,city_kiev,2020-Sep,0.2700455917,0.6525809233,0.3808256497 +6,city_kiev,2021-Jan,0.9957073392,0.8955640153,0.08200560685 +7,city_kiev,2021-May,0.08359383932,0.878866307,0.2737393541 +8,city_kiev,2021-Sep,0.3864062227,0.8355196902,0.1672691656 +9,city_kiev,2022-Jan,0.03859181836,0.8382749998,0.8116680932 +10,city_buenos_aires,2019-Jan,0.9308313567,0.6466857107,0.8641769833 +11,city_buenos_aires,2019-May,0.3700134984,0.7837693637,0.4343937489 +12,city_buenos_aires,2019-Sep,0.5994078053,0.2148970716,0.2135238874 +13,city_buenos_aires,2020-Jan,0.4941897857,0.9995185631,0.4317838305 +14,city_buenos_aires,2020-May,0.3257251742,0.1786902536,0.9581480625 +15,city_buenos_aires,2020-Sep,0.4133663483,0.4895787017,0.3266269703 +16,city_buenos_aires,2021-Jan,0.4185051363,0.6196468097,0.8595087401 +17,city_buenos_aires,2021-May,0.967209952,0.9684863108,0.1240276343 +18,city_buenos_aires,2021-Sep,0.9547593981,0.4235904569,0.7747874597 +19,city_buenos_aires,2022-Jan,0.7438244778,0.63418064,0.08865491745 +20,city_canberra,2019-Jan,0.642174332,0.2388107887,0.4174561786 +21,city_canberra,2019-May,0.275049574,0.5548509861,0.6932049183 +22,city_canberra,2019-Sep,0.7137277005,0.2288560273,0.3374528905 +23,city_canberra,2020-Jan,0.7776833239,0.2323082658,0.412349501 +24,city_canberra,2020-May,0.240911076,0.7393032141,0.03500517153 +25,city_canberra,2020-Sep,0.3222924521,0.6443196701,0.8722973134 +26,city_canberra,2021-Jan,0.03333787808,0.942723093,0.9307922515 +27,city_canberra,2021-May,0.6754651903,0.8715185605,0.7317628479 +28,city_canberra,2021-Sep,0.6679682277,0.3739222301,0.1775886144 +29,city_canberra,2022-Jan,0.5068355685,0.1635081943,0.1361671877 +30,city_yerevan,2019-Jan,0.2147489967,0.1612449722,0.8831791504 +31,city_yerevan,2019-May,0.9215334967,0.5782146645,0.4315847514 +32,city_yerevan,2019-Sep,0.08998384769,0.243931627,0.9968073448 +33,city_yerevan,2020-Jan,0.6352732643,0.1800861503,0.09468051361 +34,city_yerevan,2020-May,0.9732926191,0.3591501359,0.2549700998 +35,city_yerevan,2020-Sep,0.8958159719,0.9162956265,0.1139302618 +36,city_yerevan,2021-Jan,0.03360279599,0.999251994,0.6504557519 +37,city_yerevan,2021-May,0.2320210872,0.7948166485,0.3111218033 +38,city_yerevan,2021-Sep,0.7518920271,0.2746721747,0.1822453912 +39,city_yerevan,2022-Jan,0.9828234148,0.07410452188,0.8394608475 +40,city_bishkek,2019-Jan,0.1452622254,0.7491750047,0.9541456661 +41,city_bishkek,2019-May,0.5750325423,0.03818584404,0.4018200559 +42,city_bishkek,2019-Sep,0.2234510709,0.8535100292,0.2897079852 +43,city_bishkek,2020-Jan,0.5124122989,0.5110659435,0.3112428697 +44,city_bishkek,2020-May,0.6543130255,0.04240204986,0.622299684 +45,city_bishkek,2020-Sep,0.291880605,0.4159968733,0.2820567858 +46,city_bishkek,2021-Jan,0.04837900082,0.6784619452,0.1266086804 +47,city_bishkek,2021-May,0.7297099912,0.5149978596,0.5162051605 +48,city_bishkek,2021-Sep,0.5357617635,0.1818118381,0.8049034964 +49,city_bishkek,2022-Jan,0.8776874504,0.526233849,0.5263148206 +50,city_dhaka,2019-Jan,0.6751063458,0.1258686413,0.1016408419 +51,city_dhaka,2019-May,0.1479538758,0.137851628,0.5491982115 +52,city_dhaka,2019-Sep,0.0975619112,0.07457551448,0.03538831459 +53,city_dhaka,2020-Jan,0.4430038543,0.1828778611,0.2944631539 +54,city_dhaka,2020-May,0.4983727344,0.2630854991,0.3943451107 +55,city_dhaka,2020-Sep,0.4484292451,0.2339481189,0.2726949863 +56,city_dhaka,2021-Jan,0.5386010889,0.6933623389,0.4272398241 +57,city_dhaka,2021-May,0.8000427347,0.1994170511,0.390616751 +58,city_dhaka,2021-Sep,0.6004021175,0.3635764249,0.7907815985 +59,city_dhaka,2022-Jan,0.7859317154,0.9442375658,0.4927301142 +60,city_sucre,2019-Jan,0.5256472928,0.6907740522,0.615610268 +61,city_sucre,2019-May,0.09963983779,0.7664825572,0.06144303964 +62,city_sucre,2019-Sep,0.2666295548,0.8243600228,0.9654478129 +63,city_sucre,2020-Jan,0.8832832537,0.8316651207,0.506107938 +64,city_sucre,2020-May,0.5119837485,0.8836395641,0.5570675648 +65,city_sucre,2020-Sep,0.2845784627,0.9690913465,0.8959150557 +66,city_sucre,2021-Jan,0.6332564923,0.6389759815,0.1370995872 +67,city_sucre,2021-May,0.3936684553,0.5841123856,0.7516655319 +68,city_sucre,2021-Sep,0.2701367573,0.3501915684,0.6336972499 +69,city_sucre,2022-Jan,0.5919516162,0.4011786881,0.401258499 +70,city_brasilia,2019-Jan,0.9362317028,0.7884664385,0.422647608 +71,city_brasilia,2019-May,0.8524471342,0.430337496,0.6524337378 +72,city_brasilia,2019-Sep,0.3174124746,0.2555113355,0.7316351622 +73,city_brasilia,2020-Jan,0.7486195535,0.9015460575,0.7223646562 +74,city_brasilia,2020-May,0.3439380221,0.4736994161,0.2520318998 +75,city_brasilia,2020-Sep,0.3628079446,0.8676514395,0.03414644115 +76,city_brasilia,2021-Jan,0.7881248045,0.07831938111,0.1207919623 +77,city_brasilia,2021-May,0.9250479078,0.8901303748,0.07106044929 +78,city_brasilia,2021-Sep,0.4424696223,0.1006045971,0.5623995233 +79,city_brasilia,2022-Jan,0.774905499,0.2060788813,0.8296158878 +80,city_ottawa,2019-Jan,0.415154305,0.1059680177,0.3308787448 +81,city_ottawa,2019-May,0.6493463515,0.8937871978,0.3920436129 +82,city_ottawa,2019-Sep,0.7302853507,0.959377626,0.6185701564 +83,city_ottawa,2020-Jan,0.7511642768,0.9351348965,0.3946346882 +84,city_ottawa,2020-May,0.7724624372,0.9600619198,0.7859329103 +85,city_ottawa,2020-Sep,0.3041129836,0.7255126855,0.5221992715 +86,city_ottawa,2021-Jan,0.2503068936,0.3966644239,0.9602804747 +87,city_ottawa,2021-May,0.9312852988,0.3889126695,0.7929940878 +88,city_ottawa,2021-Sep,0.4981112549,0.1059935693,0.8574743066 +89,city_ottawa,2022-Jan,0.2752719283,0.719554905,0.6726537328 +90,city_santiago,2019-Jan,0.7354927387,0.4213001179,0.8802422329 +91,city_santiago,2019-May,0.7656384917,0.04327784254,0.4415898581 +92,city_santiago,2019-Sep,0.9611505259,0.6413038085,0.3379016843 +93,city_santiago,2020-Jan,0.2073040591,0.9427695446,0.6375111631 +94,city_santiago,2020-May,0.3194905106,0.7217433052,0.5085047009 +95,city_santiago,2020-Sep,0.3848264613,0.4960023984,0.9355666638 +96,city_santiago,2021-Jan,0.8416596967,0.8012664085,0.9257390628 +97,city_santiago,2021-May,0.04492334998,0.5346889758,0.7850799406 +98,city_santiago,2021-Sep,0.2037147168,0.5946083862,0.2569824786 +99,city_santiago,2022-Jan,0.1393061974,0.3129179343,0.952991536 +100,city_beijing,2019-Jan,0.3178648282,0.6780576423,0.310220077 +101,city_beijing,2019-May,0.08431258495,0.4251703457,0.325551065 +102,city_beijing,2019-Sep,0.9445905243,0.6002283849,0.2930351001 +103,city_beijing,2020-Jan,0.2790601521,0.6238888439,0.1195087407 +104,city_beijing,2020-May,0.7794297238,0.1274087865,0.8642829933 +105,city_beijing,2020-Sep,0.1180488469,0.6663626158,0.2607091672 +106,city_beijing,2021-Jan,0.0704770744,0.1823784313,0.266078728 +107,city_beijing,2021-May,0.6136936433,0.9076039223,0.7423526451 +108,city_beijing,2021-Sep,0.1818364902,0.8480116889,0.1921589399 +109,city_beijing,2022-Jan,0.9251074867,0.9359530202,0.1770008157 +110,city_bogota,2019-Jan,0.624155697,0.03153673702,0.194147822 +111,city_bogota,2019-May,0.6693112776,0.9194170452,0.7562801226 +112,city_bogota,2019-Sep,0.2270854552,0.5727321164,0.1383067024 +113,city_bogota,2020-Jan,0.1680212218,0.9342808077,0.8749805221 +114,city_bogota,2020-May,0.7202858441,0.9917960947,0.6322514442 +115,city_bogota,2020-Sep,0.2521898539,0.6263208583,0.4677228154 +116,city_bogota,2021-Jan,0.1522785431,0.3525519967,0.7373106672 +117,city_bogota,2021-May,0.5294850571,0.5696053899,0.8817775003 +118,city_bogota,2021-Sep,0.4124724998,0.8456196102,0.6640041077 +119,city_bogota,2022-Jan,0.3733020161,0.02006290035,0.7176733233 +120,city_nicosia,2019-Jan,0.05459926779,0.5053119181,0.7161425568 +121,city_nicosia,2019-May,0.1106513246,0.05436806241,0.3515319482 +122,city_nicosia,2019-Sep,0.2890129589,0.5327814479,0.0564076411 +123,city_nicosia,2020-Jan,0.5163181441,0.6338465939,0.6444040696 +124,city_nicosia,2020-May,0.368582402,0.2737939017,0.5093951622 +125,city_nicosia,2020-Sep,0.471424489,0.7035862994,0.2042673249 +126,city_nicosia,2021-Jan,0.6501679348,0.3863401401,0.06039493853 +127,city_nicosia,2021-May,0.8365728469,0.9942683732,0.2896511837 +128,city_nicosia,2021-Sep,0.995211768,0.4426742775,0.2572311547 +129,city_nicosia,2022-Jan,0.4359362671,0.3118280621,0.6705883368 +130,city_quito,2019-Jan,0.008417639206,0.3014245876,0.3052574326 +131,city_quito,2019-May,0.9857935547,0.1817759722,0.6952597878 +132,city_quito,2019-Sep,0.5276216133,0.130251563,0.3240003865 +133,city_quito,2020-Jan,0.9035196298,0.05698437866,0.7702244321 +134,city_quito,2020-May,0.3066932204,0.4436222048,0.260779084 +135,city_quito,2020-Sep,0.7272718268,0.5725148062,0.9164124193 +136,city_quito,2021-Jan,0.1059151872,0.08895582061,0.2928971124 +137,city_quito,2021-May,0.5118712419,0.3026817401,0.4279458258 +138,city_quito,2021-Sep,0.3330274894,0.4468848481,0.1236207096 +139,city_quito,2022-Jan,0.1244205704,0.1358899607,0.09450148278 +140,city_cairo,2019-Jan,0.4615407783,0.9520223142,0.5749502467 +141,city_cairo,2019-May,0.475409533,0.8210527062,0.4346789398 +142,city_cairo,2019-Sep,0.8066731319,0.6534694757,0.02837567269 +143,city_cairo,2020-Jan,0.8670750153,0.3625430406,0.3825884646 +144,city_cairo,2020-May,0.4951683874,0.3254080811,0.3654370688 +145,city_cairo,2020-Sep,0.7770142608,0.3716663152,0.7309639163 +146,city_cairo,2021-Jan,0.7855635031,0.066121297,0.4673674219 +147,city_cairo,2021-May,0.1730690216,0.6707204192,0.04674807743 +148,city_cairo,2021-Sep,0.489859121,0.7975075822,0.4092845343 +149,city_cairo,2022-Jan,0.4026321904,0.3023607084,0.4688463182 +150,city_addis_ababa,2019-Jan,0.4158713422,0.723030428,0.7597643722 +151,city_addis_ababa,2019-May,0.6785635739,0.1609066638,0.3381258458 +152,city_addis_ababa,2019-Sep,0.4569397919,0.526164665,0.1769840336 +153,city_addis_ababa,2020-Jan,0.6383916423,0.9232172286,0.1182792853 +154,city_addis_ababa,2020-May,0.7178022526,0.2387936324,0.02385348652 +155,city_addis_ababa,2020-Sep,0.9849294332,0.7956996228,0.4222712868 +156,city_addis_ababa,2021-Jan,0.07887778219,0.69387249,0.1295531304 +157,city_addis_ababa,2021-May,0.1808748003,0.06275186687,0.07472647253 +158,city_addis_ababa,2021-Sep,0.4839227903,0.4053925375,0.5147437288 +159,city_addis_ababa,2022-Jan,0.7803588092,0.727980068,0.6142244773 +160,city_berlin,2019-Jan,0.8326116144,0.1655051488,0.9828841108 +161,city_berlin,2019-May,0.250598596,0.8092499198,0.2239228888 +162,city_berlin,2019-Sep,0.8741896975,0.2665338382,0.1668458375 +163,city_berlin,2020-Jan,0.8399662922,0.7424132106,0.7362431642 +164,city_berlin,2020-May,0.6234997751,0.1409901662,0.1120024816 +165,city_berlin,2020-Sep,0.5161994486,0.5217599377,0.2535940892 +166,city_berlin,2021-Jan,0.1199007456,0.4344814743,0.1242415921 +167,city_berlin,2021-May,0.7303554923,0.3020973192,0.07171730289 +168,city_berlin,2021-Sep,0.7721955593,0.1087218774,0.6464209647 +169,city_berlin,2022-Jan,0.7614676523,0.08317084863,0.2325090714 +170,city_athens,2019-Jan,0.5327877289,0.9744463465,0.08180874782 +171,city_athens,2019-May,0.3652119168,0.01078413186,0.3276447375 +172,city_athens,2019-Sep,0.02943374111,0.9488744953,0.839420683 +173,city_athens,2020-Jan,0.8262571714,0.3638952168,0.00987960679 +174,city_athens,2020-May,0.5744768806,0.345623497,0.02740369312 +175,city_athens,2020-Sep,0.1795134643,0.3635695132,0.5559708634 +176,city_athens,2021-Jan,0.7699177565,0.392814441,0.61825789 +177,city_athens,2021-May,0.2212081657,0.9191236281,0.2313453472 +178,city_athens,2021-Sep,0.6074897578,0.7022955185,0.9424673176 +179,city_athens,2022-Jan,0.8794169545,0.3645845791,0.03908482265 +180,city_guatemala_city,2019-Jan,0.2898139176,0.763974548,0.1414512253 +181,city_guatemala_city,2019-May,0.6106569652,0.8240962332,0.6939830925 +182,city_guatemala_city,2019-Sep,0.5861384162,0.04609006852,0.8409472079 +183,city_guatemala_city,2020-Jan,0.7872155024,0.1606561264,0.2650589027 +184,city_guatemala_city,2020-May,0.1910735766,0.557900717,0.600110758 +185,city_guatemala_city,2020-Sep,0.6290094549,0.2562474722,0.7560094788 +186,city_guatemala_city,2021-Jan,0.4257358075,0.1027767675,0.4144983414 +187,city_guatemala_city,2021-May,0.7099732679,0.08313104975,0.284854386 +188,city_guatemala_city,2021-Sep,0.892413365,0.5532906407,0.2968339741 +189,city_guatemala_city,2022-Jan,0.8273477199,0.7395492724,0.9457886281 +190,city_jakarta,2019-Jan,0.9193766389,0.562096263,0.08597256563 +191,city_jakarta,2019-May,0.9613467154,0.6769316276,0.6942166445 +192,city_jakarta,2019-Sep,0.8911849078,0.7562774935,0.931896191 +193,city_jakarta,2020-Jan,0.4624306474,0.2038734797,0.9108010452 +194,city_jakarta,2020-May,0.7789672101,0.4319469274,0.5955267956 +195,city_jakarta,2020-Sep,0.937567279,0.5425494534,0.1971329509 +196,city_jakarta,2021-Jan,0.05969973106,0.8612950096,0.1110350332 +197,city_jakarta,2021-May,0.2180583953,0.129191418,0.8485609101 +198,city_jakarta,2021-Sep,0.5603349001,0.4438715596,0.3221066821 +199,city_jakarta,2022-Jan,0.5924979531,0.7839538361,0.9407650221 +200,city_tehran,2019-Jan,0.5292539582,0.9150355842,0.5624261915 +201,city_tehran,2019-May,0.7509693779,0.2702537133,0.05959118151 +202,city_tehran,2019-Sep,0.0004306332507,0.5449529067,0.7126608061 +203,city_tehran,2020-Jan,0.1082794742,0.4536112847,0.9691479921 +204,city_tehran,2020-May,0.3819988509,0.6632068954,0.5233308183 +205,city_tehran,2020-Sep,0.9333775196,0.6158183662,0.6980507813 +206,city_tehran,2021-Jan,0.4710513182,0.05454750359,0.5645271704 +207,city_tehran,2021-May,0.2485026502,0.7312942592,0.2627718368 +208,city_tehran,2021-Sep,0.01302679826,0.336700741,0.6003091579 +209,city_tehran,2022-Jan,0.819297579,0.9598619279,0.6779261352 +210,city_baghdad,2019-Jan,0.6571740151,0.7467470149,0.6081817043 +211,city_baghdad,2019-May,0.8853581326,0.7189311143,0.7448624368 +212,city_baghdad,2019-Sep,0.6146196468,0.6768913331,0.7571456788 +213,city_baghdad,2020-Jan,0.08117439619,0.8747030021,0.7191705185 +214,city_baghdad,2020-May,0.3522675259,0.8238104615,0.1537342642 +215,city_baghdad,2020-Sep,0.2356301438,0.3576600925,0.6118789786 +216,city_baghdad,2021-Jan,0.4391707399,0.4474647074,0.6430828897 +217,city_baghdad,2021-May,0.268736745,0.394059054,0.119349115 +218,city_baghdad,2021-Sep,0.2073373839,0.407147767,0.8267744414 +219,city_baghdad,2022-Jan,0.01562994523,0.7208303197,0.3132938272 +220,city_tokyo,2019-Jan,0.8352048365,0.4889643586,0.5708637608 +221,city_tokyo,2019-May,0.07092244122,0.7175987454,0.548696431 +222,city_tokyo,2019-Sep,0.435831484,0.7019761931,0.8220189625 +223,city_tokyo,2020-Jan,0.5223738584,0.9554340802,0.7499007696 +224,city_tokyo,2020-May,0.303390769,0.9935451138,0.9673256357 +225,city_tokyo,2020-Sep,0.4384910546,0.06373422983,0.9278227045 +226,city_tokyo,2021-Jan,0.4244047664,0.8205993601,0.3039457448 +227,city_tokyo,2021-May,0.01059055428,0.1387852586,0.202489681 +228,city_tokyo,2021-Sep,0.8243603537,0.01143751208,0.6110956967 +229,city_tokyo,2022-Jan,0.9934216564,0.5012722622,0.8378971436 +230,city_amman,2019-Jan,0.1540357106,0.6803451745,0.7406204618 +231,city_amman,2019-May,0.3376841081,0.8528543434,0.8947938379 +232,city_amman,2019-Sep,0.8652355208,0.7611803277,0.4579395501 +233,city_amman,2020-Jan,0.9236248973,0.597652822,0.3755196877 +234,city_amman,2020-May,0.4995982826,0.924389631,0.306112936 +235,city_amman,2020-Sep,0.5400326648,0.09029500814,0.474054147 +236,city_amman,2021-Jan,0.08564701964,0.3066904227,0.7320517679 +237,city_amman,2021-May,0.4889587211,0.2702591115,0.7290170229 +238,city_amman,2021-Sep,0.0335487674,0.2504805992,0.7181076944 +239,city_amman,2022-Jan,0.3418902923,0.8970783354,0.1739518732 +240,city_nairobi,2019-Jan,0.8272692723,0.2193240076,0.02060070785 +241,city_nairobi,2019-May,0.25413013,0.273279121,0.9193914915 +242,city_nairobi,2019-Sep,0.2576763868,0.8634612874,0.4355158525 +243,city_nairobi,2020-Jan,0.9763060138,0.1430317922,0.6483186049 +244,city_nairobi,2020-May,0.6939313329,0.5892953211,0.9663935709 +245,city_nairobi,2020-Sep,0.2764149061,0.1774120717,0.7812622959 +246,city_nairobi,2021-Jan,0.7707636847,0.8689268495,0.1363146058 +247,city_nairobi,2021-May,0.9163507683,0.2515377182,0.07565517255 +248,city_nairobi,2021-Sep,0.7513935872,0.1532284207,0.7363183336 +249,city_nairobi,2022-Jan,0.1767128894,0.1454489297,0.3971665474 +250,city_beirut,2019-Jan,0.788339519,0.5127333364,0.8333304991 +251,city_beirut,2019-May,0.7230935424,0.2298084849,0.5472381483 +252,city_beirut,2019-Sep,0.5909867246,0.02179296134,0.7592174254 +253,city_beirut,2020-Jan,0.9340891126,0.8696574846,0.5400465709 +254,city_beirut,2020-May,0.0276754093,0.8986496952,0.5265469731 +255,city_beirut,2020-Sep,0.4649235896,0.3356422036,0.5517011162 +256,city_beirut,2021-Jan,0.7389463326,0.947502386,0.6815278477 +257,city_beirut,2021-May,0.7670585948,0.6473540111,0.5277366776 +258,city_beirut,2021-Sep,0.5942151705,0.4821676255,0.1016388854 +259,city_beirut,2022-Jan,0.5882001691,0.361997451,0.293222771 +260,city_tripoli,2019-Jan,0.2677810804,0.2357072677,0.3565856652 +261,city_tripoli,2019-May,0.07104588209,0.5513605839,0.0451456715 +262,city_tripoli,2019-Sep,0.4257855731,0.616771154,0.5592935074 +263,city_tripoli,2020-Jan,0.3449656127,0.687252387,0.2071332881 +264,city_tripoli,2020-May,0.05954930585,0.08429442185,0.5561507364 +265,city_tripoli,2020-Sep,0.5287426821,0.7518475156,0.605454666 +266,city_tripoli,2021-Jan,0.926167857,0.4054919777,0.01780159166 +267,city_tripoli,2021-May,0.1158836845,0.1263661794,0.5107072656 +268,city_tripoli,2021-Sep,0.3098832321,0.8877507511,0.9402516681 +269,city_tripoli,2022-Jan,0.2471150536,0.9391734631,0.05978336229 +270,city_kuala_lumpur,2019-Jan,0.6863528274,0.8697980657,0.2282523362 +271,city_kuala_lumpur,2019-May,0.8358905297,0.9856091378,0.9827359299 +272,city_kuala_lumpur,2019-Sep,0.8423115828,0.8475761347,0.6705055844 +273,city_kuala_lumpur,2020-Jan,0.352567735,0.1954722531,0.2030722961 +274,city_kuala_lumpur,2020-May,0.04741808923,0.210640203,0.01469151867 +275,city_kuala_lumpur,2020-Sep,0.957184061,0.4772033411,0.06693120676 +276,city_kuala_lumpur,2021-Jan,0.8694608057,0.4899108808,0.6298810317 +277,city_kuala_lumpur,2021-May,0.03785739177,0.215056941,0.4898345725 +278,city_kuala_lumpur,2021-Sep,0.8474861196,0.8203214118,0.9639926419 +279,city_kuala_lumpur,2022-Jan,0.09388447049,0.8918711252,0.8982826914 +280,city_male,2019-Jan,0.9535318247,0.150372675,0.945000347 +281,city_male,2019-May,0.7412962727,0.003038298983,0.4180035581 +282,city_male,2019-Sep,0.2345256191,0.9034615199,0.4484671987 +283,city_male,2020-Jan,0.04034677353,0.1748185368,0.4505723828 +284,city_male,2020-May,0.5639263503,0.2796195837,0.2018342222 +285,city_male,2020-Sep,0.2502278203,0.5534360568,0.4339739447 +286,city_male,2021-Jan,0.3031630191,0.07439445923,0.4700919847 +287,city_male,2021-May,0.8624679204,0.2578625741,0.09027702491 +288,city_male,2021-Sep,0.2454379645,0.9075344381,0.05214485101 +289,city_male,2022-Jan,0.3611491011,0.9851549825,0.4531224627 +290,city_mexico_city,2019-Jan,0.5367583915,0.258080948,0.6816746827 +291,city_mexico_city,2019-May,0.9853964418,0.6359366543,0.4883879642 +292,city_mexico_city,2019-Sep,0.9563011498,0.0299396029,0.9594745399 +293,city_mexico_city,2020-Jan,0.4688441336,0.8191478053,0.8617118239 +294,city_mexico_city,2020-May,0.1927625183,0.5748900138,0.8513407749 +295,city_mexico_city,2020-Sep,0.4454512258,0.5824312156,0.9636387659 +296,city_mexico_city,2021-Jan,0.9859257045,0.1759599736,0.4286920936 +297,city_mexico_city,2021-May,0.363776648,0.1809230842,0.2368178691 +298,city_mexico_city,2021-Sep,0.6824795264,0.2990136144,0.0405011663 +299,city_mexico_city,2022-Jan,0.8905587395,0.1905990529,0.4882507814 +300,city_ulan_bator,2019-Jan,0.6741485464,0.717576578,0.4293573811 +301,city_ulan_bator,2019-May,0.3262047159,0.8716206568,0.5458236269 +302,city_ulan_bator,2019-Sep,0.6265632177,0.2317454106,0.7036908001 +303,city_ulan_bator,2020-Jan,0.5113218116,0.221105242,0.888826252 +304,city_ulan_bator,2020-May,0.3906062072,0.66427438,0.2935980572 +305,city_ulan_bator,2020-Sep,0.3971036952,0.01783759712,0.8998790336 +306,city_ulan_bator,2021-Jan,0.2637427101,0.2385390121,0.6249611526 +307,city_ulan_bator,2021-May,0.912242776,0.08731497158,0.6532080205 +308,city_ulan_bator,2021-Sep,0.397708583,0.8048328144,0.7926631264 +309,city_ulan_bator,2022-Jan,0.9942061508,0.2470806419,0.4383188216 +310,city_rabat,2019-Jan,0.2230411495,0.3676032952,0.4107616888 +311,city_rabat,2019-May,0.1492052294,0.3892316663,0.1094391123 +312,city_rabat,2019-Sep,0.5472040034,0.9976653002,0.1954636489 +313,city_rabat,2020-Jan,0.9966868022,0.2096797583,0.3057921875 +314,city_rabat,2020-May,0.2045133008,0.2371876672,0.4427255118 +315,city_rabat,2020-Sep,0.925035033,0.584423711,0.6622095958 +316,city_rabat,2021-Jan,0.09596785333,0.1155214101,0.9929036089 +317,city_rabat,2021-May,0.5279036078,0.2882972716,0.2605861754 +318,city_rabat,2021-Sep,0.9105437212,0.3634054264,0.5256147774 +319,city_rabat,2022-Jan,0.7458623714,0.1574213382,0.6264820458 +320,city_amsterdam,2019-Jan,0.799256021,0.3395427351,0.4031577596 +321,city_amsterdam,2019-May,0.1804581241,0.845954797,0.3228938347 +322,city_amsterdam,2019-Sep,0.1970508803,0.04130658614,0.5235063506 +323,city_amsterdam,2020-Jan,0.9242590394,0.1852741273,0.3749524614 +324,city_amsterdam,2020-May,0.8783562576,0.08261349126,0.3541495132 +325,city_amsterdam,2020-Sep,0.8995390999,0.8467088641,0.8145635751 +326,city_amsterdam,2021-Jan,0.6193291884,0.3946284311,0.6509909684 +327,city_amsterdam,2021-May,0.7058310687,0.2254146029,0.3006021917 +328,city_amsterdam,2021-Sep,0.6448915078,0.2207063867,0.7670154359 +329,city_amsterdam,2022-Jan,0.6566724581,0.4963253272,0.5882010246 +330,city_wellington,2019-Jan,0.975771214,0.7828569709,0.8579568289 +331,city_wellington,2019-May,0.4808303848,0.2147995042,0.5427822914 +332,city_wellington,2019-Sep,0.982612098,0.2017583263,0.6818840957 +333,city_wellington,2020-Jan,0.8282939128,0.0173039828,0.8484000112 +334,city_wellington,2020-May,0.7067879274,0.1232934138,0.1583243715 +335,city_wellington,2020-Sep,0.05426185515,0.9523095362,0.8600642333 +336,city_wellington,2021-Jan,0.849837313,0.6723412286,0.3539009568 +337,city_wellington,2021-May,0.851419205,0.08734822939,0.3631028432 +338,city_wellington,2021-Sep,0.5211397365,0.601091111,0.8736619915 +339,city_wellington,2022-Jan,0.0004370141048,0.7856350051,0.7967341982 +340,city_managua,2019-Jan,0.4449076437,0.07095081666,0.2226768192 +341,city_managua,2019-May,0.9058054532,0.9825352592,0.8801532619 +342,city_managua,2019-Sep,0.4664849351,0.1507856153,0.6859989836 +343,city_managua,2020-Jan,0.7063256142,0.8480495571,0.6506210446 +344,city_managua,2020-May,0.5672273277,0.1732735134,0.0473325036 +345,city_managua,2020-Sep,0.6152126641,0.262875193,0.06784724677 +346,city_managua,2021-Jan,0.5630548661,0.139303683,0.2497055152 +347,city_managua,2021-May,0.7090141669,0.6050612033,0.717160999 +348,city_managua,2021-Sep,0.6726886326,0.3955881513,0.05659926761 +349,city_managua,2022-Jan,0.5118331134,0.9697227523,0.6694463186 +350,city_abuja,2019-Jan,0.7215577985,0.8069645818,0.2144030138 +351,city_abuja,2019-May,0.2389187672,0.1132551265,0.6855980263 +352,city_abuja,2019-Sep,0.3713433464,0.8430974465,0.7186428163 +353,city_abuja,2020-Jan,0.3213201344,0.9099336087,0.8449178856 +354,city_abuja,2020-May,0.8469259071,0.5524627768,0.9260609535 +355,city_abuja,2020-Sep,0.4366534985,0.4725483191,0.6004087497 +356,city_abuja,2021-Jan,0.6629119774,0.2245666268,0.2164730197 +357,city_abuja,2021-May,0.7151602496,0.852215806,0.9994776477 +358,city_abuja,2021-Sep,0.2657906656,0.8775827085,0.02569985435 +359,city_abuja,2022-Jan,0.6656366265,0.5595354603,0.3052805174 +360,city_islamabad,2019-Jan,0.5657435109,0.06594882308,0.05639372024 +361,city_islamabad,2019-May,0.3617440488,0.8182270972,0.5020515613 +362,city_islamabad,2019-Sep,0.8972054882,0.5389161919,0.08204922443 +363,city_islamabad,2020-Jan,0.6361910136,0.7719467598,0.3555156382 +364,city_islamabad,2020-May,0.5658655482,0.9978291866,0.9204755129 +365,city_islamabad,2020-Sep,0.5229417395,0.4433901007,0.3977836013 +366,city_islamabad,2021-Jan,0.9304358199,0.5494074576,0.689688983 +367,city_islamabad,2021-May,0.04229158644,0.4005375448,0.4328307124 +368,city_islamabad,2021-Sep,0.3071366189,0.4742819877,0.8376670766 +369,city_islamabad,2022-Jan,0.9667463886,0.8263189953,0.9260605166 +370,city_lima,2019-Jan,0.004449000129,0.5359554688,0.5170556156 +371,city_lima,2019-May,0.0040391066,0.727889608,0.3979039803 +372,city_lima,2019-Sep,0.4752783789,0.286290551,0.9038587969 +373,city_lima,2020-Jan,0.5243305401,0.9542521021,0.8437255443 +374,city_lima,2020-May,0.5189281056,0.9532682341,0.04858519966 +375,city_lima,2020-Sep,0.9698181754,0.2626736181,0.07547748485 +376,city_lima,2021-Jan,0.42487374,0.7219955088,0.03794786379 +377,city_lima,2021-May,0.1580065461,0.7412839844,0.78239396 +378,city_lima,2021-Sep,0.5313078226,0.6906399598,0.1497155574 +379,city_lima,2022-Jan,0.7137341222,0.9608880466,0.7117129761 +380,city_bucharest,2019-Jan,0.9989856747,0.3173551828,0.3589126521 +381,city_bucharest,2019-May,0.7987576639,0.431771908,0.1180147721 +382,city_bucharest,2019-Sep,0.4474069189,0.716171076,0.3027452883 +383,city_bucharest,2020-Jan,0.9724268855,0.3257941961,0.8441895702 +384,city_bucharest,2020-May,0.9980411751,0.1256631536,0.07115468458 +385,city_bucharest,2020-Sep,0.1213183636,0.3941146639,0.06092239127 +386,city_bucharest,2021-Jan,0.4205241143,0.1941809277,0.4877147348 +387,city_bucharest,2021-May,0.3360387926,0.3922642193,0.2054573166 +388,city_bucharest,2021-Sep,0.06667197523,0.1235198397,0.5762869522 +389,city_bucharest,2022-Jan,0.306929458,0.7091646997,0.8807736754 +390,city_moscow,2019-Jan,0.4884820054,0.3664299465,0.5947931914 +391,city_moscow,2019-May,0.8045965787,0.645890862,0.6135267009 +392,city_moscow,2019-Sep,0.5168853064,0.005617348514,0.03449093575 +393,city_moscow,2020-Jan,0.5083457969,0.1835582116,0.9683744996 +394,city_moscow,2020-May,0.1155265419,0.02495497214,0.9077392365 +395,city_moscow,2020-Sep,0.3679246739,0.4012096928,0.1788263876 +396,city_moscow,2021-Jan,0.04563746129,0.5524970339,0.2758883611 +397,city_moscow,2021-May,0.874515788,0.5738406989,0.4389562884 +398,city_moscow,2021-Sep,0.5644210913,0.1248259343,0.3045741317 +399,city_moscow,2022-Jan,0.02472030916,0.5212881284,0.6865817501 +400,city_belgrade,2019-Jan,0.2054378336,0.3388140331,0.1560520775 +401,city_belgrade,2019-May,0.8233419498,0.06099252492,0.3285799916 +402,city_belgrade,2019-Sep,0.737910215,0.0218623579,0.8147299491 +403,city_belgrade,2020-Jan,0.9112117631,0.9656860025,0.3786632918 +404,city_belgrade,2020-May,0.7803837773,0.09974279125,0.003345917394 +405,city_belgrade,2020-Sep,0.2159103445,0.4208667863,0.306492557 +406,city_belgrade,2021-Jan,0.8099756545,0.1659555892,0.5686013193 +407,city_belgrade,2021-May,0.9153223024,0.7262449027,0.5551206235 +408,city_belgrade,2021-Sep,0.5130398179,0.01271602991,0.9210065704 +409,city_belgrade,2022-Jan,0.815222032,0.2659741857,0.2871871833 +410,city_singapore,2019-Jan,0.2134172681,0.8580276605,0.9601842113 +411,city_singapore,2019-May,0.6023894791,0.4216392972,0.7161700994 +412,city_singapore,2019-Sep,0.6858661731,0.7862881275,0.2316293129 +413,city_singapore,2020-Jan,0.6841130768,0.2949128642,0.5366420271 +414,city_singapore,2020-May,0.498180307,0.47856757,0.5634083248 +415,city_singapore,2020-Sep,0.005418301445,0.6835751602,0.5749891016 +416,city_singapore,2021-Jan,0.2189054618,0.9144602713,0.7515237128 +417,city_singapore,2021-May,0.4224346227,0.2277588726,0.5884623504 +418,city_singapore,2021-Sep,0.00726630776,0.4287783353,0.9893778021 +419,city_singapore,2022-Jan,0.415505623,0.5043323742,0.04127731435 +420,city_seoul,2019-Jan,0.4158292137,0.3235311166,0.3313557261 +421,city_seoul,2019-May,0.3720615125,0.5183966398,0.5281903814 +422,city_seoul,2019-Sep,0.2898671082,0.1498256654,0.6543104049 +423,city_seoul,2020-Jan,0.2590961078,0.03198788857,0.7939989818 +424,city_seoul,2020-May,0.158505935,0.646670114,0.8497340793 +425,city_seoul,2020-Sep,0.7733778533,0.8329950401,0.6951126836 +426,city_seoul,2021-Jan,0.2333382418,0.3836525618,0.7553079657 +427,city_seoul,2021-May,0.7819967758,0.974315225,0.07959266939 +428,city_seoul,2021-Sep,0.5964142264,0.248241969,0.6541351389 +429,city_seoul,2022-Jan,0.90841441,0.1943781343,0.09601869236 +430,city_tunis,2019-Jan,0.6652183138,0.4894266427,0.4240159206 +431,city_tunis,2019-May,0.9884960516,0.9755110617,0.06384271908 +432,city_tunis,2019-Sep,0.680123991,0.3601116984,0.5918194417 +433,city_tunis,2020-Jan,0.1473826674,0.9219684102,0.513104658 +434,city_tunis,2020-May,0.7317874879,0.7317059155,0.5088701786 +435,city_tunis,2020-Sep,0.978750762,0.8405181067,0.9071571207 +436,city_tunis,2021-Jan,0.4223105477,0.182839254,0.9445235115 +437,city_tunis,2021-May,0.1376962812,0.3380520816,0.9820850094 +438,city_tunis,2021-Sep,0.9888050345,0.7938678388,0.4087101449 +439,city_tunis,2022-Jan,0.08062628741,0.811235545,0.6412991336 +440,city_bangkok,2019-Jan,0.7740886353,0.00393096204,0.9355208309 +441,city_bangkok,2019-May,0.9261865051,0.5543156401,0.2301005313 +442,city_bangkok,2019-Sep,0.0036399897,0.5151920906,0.7759955482 +443,city_bangkok,2020-Jan,0.4058027436,0.03111692238,0.5575806328 +444,city_bangkok,2020-May,0.657934059,0.5883429191,0.4110502161 +445,city_bangkok,2020-Sep,0.2211613657,0.8307157083,0.5495225194 +446,city_bangkok,2021-Jan,0.9381384113,0.3390859316,0.3941873429 +447,city_bangkok,2021-May,0.1913245397,0.8985675591,0.1613629563 +448,city_bangkok,2021-Sep,0.4849294818,0.07434437657,0.212956493 +449,city_bangkok,2022-Jan,0.5632024472,0.05342124515,0.608214207 +450,city_washington_d.c.,2019-Jan,0.706354796,0.5566582481,0.3888501308 +451,city_washington_d.c.,2019-May,0.3967146921,0.6871371398,0.3749746333 +452,city_washington_d.c.,2019-Sep,0.1461645524,0.07178227096,0.008434495791 +453,city_washington_d.c.,2020-Jan,0.7767257209,0.6806659613,0.2452377716 +454,city_washington_d.c.,2020-May,0.03369730849,0.4195955155,0.8280863275 +455,city_washington_d.c.,2020-Sep,0.7276129361,0.1779246857,0.1500722549 +456,city_washington_d.c.,2021-Jan,0.9155963204,0.9973251079,0.701925965 +457,city_washington_d.c.,2021-May,0.1160842378,0.1693766214,0.6736147037 +458,city_washington_d.c.,2021-Sep,0.4549449302,0.9554399549,0.7586370391 +459,city_washington_d.c.,2022-Jan,0.4006997702,0.955893003,0.1364601882 +460,city_hanoi,2019-Jan,0.4131646918,0.6762825725,0.5131651918 +461,city_hanoi,2019-May,0.219613407,0.4764566921,0.5947576005 +462,city_hanoi,2019-Sep,0.7775954747,0.5535598775,0.9161480338 +463,city_hanoi,2020-Jan,0.1749110224,0.03153303649,0.2325527303 +464,city_hanoi,2020-May,0.6513750193,0.9378385276,0.6723599033 +465,city_hanoi,2020-Sep,0.8846442259,0.5905572431,0.8375318419 +466,city_hanoi,2021-Jan,0.04438681781,0.7197215338,0.5135403183 +467,city_hanoi,2021-May,0.8841873451,0.01386415254,0.9290412269 +468,city_hanoi,2021-Sep,0.9471121112,0.8845281879,0.4825962156 +469,city_hanoi,2022-Jan,0.6399693588,0.3162389532,0.351121779 +470,city_harare,2019-Jan,0.05113965261,0.6079969608,0.7127907344 +471,city_harare,2019-May,0.5499694149,0.7112740295,0.8657201091 +472,city_harare,2019-Sep,0.6705953617,0.8481746283,0.7781915229 +473,city_harare,2020-Jan,0.5448455637,0.761481783,0.3161047732 +474,city_harare,2020-May,0.02555600558,0.8157707267,0.05503697195 +475,city_harare,2020-Sep,0.627355327,0.5530698033,0.5992110078 +476,city_harare,2021-Jan,0.6049262896,0.527575273,0.5758586976 +477,city_harare,2021-May,0.4274464672,0.22878636,0.1059028406 +478,city_harare,2021-Sep,0.3598503868,0.4448781561,0.1940659583 +479,city_harare,2022-Jan,0.2554936994,0.04221218981,0.8283157554 +480,city_ankara,2019-Jan,0.5773037837,0.2326703291,0.5464883464 +481,city_ankara,2019-May,0.7535813143,0.4992113773,0.9809685139 +482,city_ankara,2019-Sep,0.5976797307,0.794414639,0.8742555726 +483,city_ankara,2020-Jan,0.08520386108,0.8773860695,0.3858137862 +484,city_ankara,2020-May,0.004111445517,0.8040046923,0.1569392782 +485,city_ankara,2020-Sep,0.2601369272,0.2083602167,0.8048114997 +486,city_ankara,2021-Jan,0.06646180846,0.1508074934,0.7621242697 +487,city_ankara,2021-May,0.2056833359,0.4014711821,0.5422262985 +488,city_ankara,2021-Sep,0.2211609615,0.7420965859,0.9192380563 +489,city_ankara,2022-Jan,0.5664276514,0.1191242719,0.5142831272 \ No newline at end of file diff --git a/run_tree/osx/arm64/debug/convert_csv b/run_tree/osx/arm64/debug/convert_csv new file mode 100755 index 0000000..e1790c9 Binary files /dev/null and b/run_tree/osx/arm64/debug/convert_csv differ diff --git a/run_tree/osx/arm64/debug/lumenarium b/run_tree/osx/arm64/debug/lumenarium new file mode 100755 index 0000000..2d5ff7e Binary files /dev/null and b/run_tree/osx/arm64/debug/lumenarium differ diff --git a/run_tree/osx/arm64/prod/lumenarium b/run_tree/osx/arm64/prod/lumenarium new file mode 100755 index 0000000..7eb2057 Binary files /dev/null and b/run_tree/osx/arm64/prod/lumenarium differ diff --git a/run_tree/osx/arm64/prod/lumenarium_arm64 b/run_tree/osx/arm64/prod/lumenarium_arm64 new file mode 100755 index 0000000..e3c8be8 Binary files /dev/null and b/run_tree/osx/arm64/prod/lumenarium_arm64 differ diff --git a/run_tree/osx/intel/debug/lumenarium b/run_tree/osx/intel/debug/lumenarium new file mode 100755 index 0000000..9cce34e Binary files /dev/null and b/run_tree/osx/intel/debug/lumenarium differ diff --git a/run_tree/osx/intel/prod/lumenarium b/run_tree/osx/intel/prod/lumenarium new file mode 100755 index 0000000..9ed88e2 Binary files /dev/null and b/run_tree/osx/intel/prod/lumenarium differ diff --git a/run_tree/raspi/arm64/debug/convert_csv b/run_tree/raspi/arm64/debug/convert_csv new file mode 100755 index 0000000..1dce8d3 Binary files /dev/null and b/run_tree/raspi/arm64/debug/convert_csv differ diff --git a/run_tree/raspi/arm64/debug/lumenarium b/run_tree/raspi/arm64/debug/lumenarium new file mode 100755 index 0000000..eed03e6 Binary files /dev/null and b/run_tree/raspi/arm64/debug/lumenarium differ diff --git a/run_tree/raspi/arm64/prod/convert_csv b/run_tree/raspi/arm64/prod/convert_csv new file mode 100755 index 0000000..5578c4d Binary files /dev/null and b/run_tree/raspi/arm64/prod/convert_csv differ diff --git a/run_tree/raspi/intel/debug/lumenarium b/run_tree/raspi/intel/debug/lumenarium new file mode 100755 index 0000000..09a9d39 Binary files /dev/null and b/run_tree/raspi/intel/debug/lumenarium differ diff --git a/run_tree/wasm/debug/loader.html b/run_tree/wasm/debug/loader.html new file mode 100644 index 0000000..840c19b --- /dev/null +++ b/run_tree/wasm/debug/loader.html @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/run_tree/wasm/debug/loader.js b/run_tree/wasm/debug/loader.js new file mode 100644 index 0000000..3573534 --- /dev/null +++ b/run_tree/wasm/debug/loader.js @@ -0,0 +1,39 @@ + +let module = null; +let instance = null; + + +async function load_webassembly_module () +{ + lumenarium_wasm_imports = webgl_add_imports("#gl_canvas", lumenarium_wasm_imports); + + const path = "lumenarium.wasm"; + const promise = fetch(path); + const module = await WebAssembly.compileStreaming(promise); + + let memory = new WebAssembly.Memory({ initial: 2 }); + const env = { + memory, + ...lumenarium_wasm_imports, + }; + + let table = new WebAssembly.Table({ element: "anyfunc", initial: 32, }); + + instance = await WebAssembly.instantiate(module, { env }) + .then((res, err) => { + return res; + }) + .catch((a, b) => { + console.log(a,b); + }); + lumenarium_wasm_instance = instance; + + // If function '__wasm_call_ctors' (global C++ constructors) exists, call it + if (instance.exports.__wasm_call_ctors) instance.exports.__wasm_call_ctors(); + + // If function 'main' exists, call it with dummy arguments + let result = 0; + if (instance.exports.main) result = instance.exports.main(); +} + +window.addEventListener("load", load_webassembly_module) diff --git a/run_tree/wasm/debug/lumenarium_wasm_imports.js b/run_tree/wasm/debug/lumenarium_wasm_imports.js new file mode 100644 index 0000000..ff42920 --- /dev/null +++ b/run_tree/wasm/debug/lumenarium_wasm_imports.js @@ -0,0 +1,507 @@ +var lumenarium_wasm_module = null; +var lumenarium_wasm_instance = null; + +var WASM_PAGE_SIZE = 65536; + +function wasm_mem_get_u8_arr(inst, ptr, size) +{ + let view = new Uint8Array(inst.exports.memory.buffer, ptr, size); + return view; +} + +function wasm_read_string(inst, ptr, len) +{ + let view = wasm_mem_get_u8_arr(inst, ptr, len); + let string = ''; + for (let i = 0; i < len; i++) + { + string += String.fromCharCode(view[i]); + } + return string; +} + +function wasm_write_bytes(inst, src, ptr, len) +{ + let view = wasm_mem_get_u8_arr(inst, ptr, len); + for (let i = 0; i < len; i++) view[i] = src[i]; +} + +function wasm_get_proc(inst, proc_ptr) +{ + let result = inst.exports.__indirect_function_table.get(proc_ptr); + return result; +} + +function fract (v) { return v % 1; } + +function u32_to_byte_array_32 (v) +{ + let result = [0, 0, 0, 0]; + result[0] = (v & 0xff); + result[1] = (((v - result[0]) >> 8 ) & 0xff); + result[2] = (((v - result[1]) >> 16) & 0xff); + result[3] = (((v - result[2]) >> 24) & 0xff); + return result; +} + +function byte_array_32_to_u32 (arr) +{ + // NOTE(PS): the '>>>' operators in this function deal with the fact + // that bit shift operators convert numbers to s32's. The >>> just + // converts them back to u32s + let r0 = ((arr[0] & 0xff) << 0 ); + let r1 = ((arr[1] & 0xff) << 8 ); + let r2 = ((arr[2] & 0xff) << 16); + let r3 = (((arr[3] & 0xff) << 24) >>> 0); + let result = (r0 | r1 | r2 | r3) >>> 0; + return result; +} + +function put_u32 (ptr, value) +{ + let src = u32_to_byte_array_32(value); + wasm_write_bytes(lumenarium_wasm_instance, src, ptr, 4); +} + +var lumenarium_wasm_imports = { + + memset: (dst, size, value) => { + let view_dst = wasm_mem_get_u8_arr(lumenarium_wasm_instance, dst, size); + for (let i = 0; i < size; i++) + { + view_dst[i] = value; + } + }, + + memcpy: (dst, src, size) => { + let view_dst = wasm_mem_get_u8_arr(lumenarium_wasm_instance, dst, size); + let view_src = wasm_mem_get_u8_arr(lumenarium_wasm_instance, src, size); + for (let i = 0; i < size; i++) + { + view_dst[i] = view_src[i]; + } + }, + + wasm_assert_always: (file, file_len, line) => { + let file_str = wasm_read_string(lumenarium_wasm_instance, file, file_len); + console.assert(false, "At: " + file_str + "::" + line); + }, + + wasm_get_memory_size: () => { + return instance.exports.memory.buffer.byteLength; + }, + + wasm_mem_grow: (new_size) => { + let new_size_ = new_size >>> 0; + let pages = new_size_ / WASM_PAGE_SIZE; + let pages_rem = fract(pages); + if (pages_rem > 0) pages = Math.floor(pages) + 1; + let size_before = lumenarium_wasm_instance.exports.memory.buffer.byteLength; + let old_page_count = lumenarium_wasm_instance.exports.memory.grow(pages); + + console.log("mem_grow\n", + "req size: ", new_size_, "\n", + "old size: ", (old_page_count * WASM_PAGE_SIZE), "\n", + "old size: ", size_before, "\n", + "grew by: ", (pages * WASM_PAGE_SIZE), "\n", + "new size: ", lumenarium_wasm_instance.exports.memory.buffer.byteLength, ""); + }, + + malloc: (size) => { + + }, + + free: (base) => { + + }, + + sin: Math.sin, + sinf: Math.sin, + cos: Math.cos, + cosf: Math.cos, + tan: Math.tan, + tanf: Math.tan, + asin: Math.asin, + asinf: Math.asin, + acos: Math.acos, + acosf: Math.acos, + atan: Math.atan, + atanf: Math.atan, + pow: Math.pow, + powf: Math.pow, + fmodf: (f,d) => { return f % d; }, + strlen: (ptr) => { + let len = 0; + let len_checked = 0; + let len_to_check = 256; + let found_end = false; + while (true) + { + let string = wasm_mem_get_u8_arr(lumenarium_wasm_instance, ptr, len_checked); + for (let i = len_checked; i < len_to_check; i++) + { + if (string[i] == 0) + { + len = i; + break; + } + } + len_checked *= 2; + } + return len_checked; + }, + + wasm_platform_file_async_work_on_job: (path, path_len, data, data_size, read, write) => { + + }, + + wasm_performance_now: () => { + return performance.now(); + }, + + wasm_sleep: (milliseconds) => { + let start = Date.now(); + for (let at = Date.now(); (at - start) < milliseconds; at = Date.now()) {} + }, + + wasm_fetch: async (file_path, file_path_len, dest, dest_size) => { + let path = wasm_read_string(lumenarium_wasm_instance, file_path, file_path_len); + fetch(path) + .then(async (res) => { + // TODO(PS): success checking + let reader = res.body.getReader(); + let read_res = { done: false }; + + let view = wasm_mem_get_u8_arr(lumenarium_wasm_instance, dest, dest_size); + let last_write = 0; + while (!read_res.done) + { + read_res = await reader.read(); + if (read_res.done) break; + + let len = read_res.value.length; + let write_end = last_write + len; + for (let i = last_write; i < write_end; i++) + { + view[i] = read_res.value[i - last_write]; + } + last_write = write_end + 1; + } + }); + return 0; + }, + + wasm_request_animation_frame: (cb) => { + let cb_proc = wasm_get_proc(lumenarium_wasm_instance, cb); + window.requestAnimationFrame(cb_proc); + }, + + print: (str_base, len) => { + let string = wasm_read_string(lumenarium_wasm_instance, str_base, len); + console.log(string); + }, + + wasm_get_canvas_dim: (w_ptr, h_ptr) => { + const canvas = document.querySelector("#gl_canvas"); + + let w_view = wasm_mem_get_u8_arr(lumenarium_wasm_instance, w_ptr, 4); + let w = canvas.width; + let wb = u32_to_byte_array_32(w); + for (let i = 0; i < 4; i++) w_view[i] = wb[i]; + + let h_view = wasm_mem_get_u8_arr(lumenarium_wasm_instance, h_ptr, 4); + let h = canvas.height; + let hb = u32_to_byte_array_32(h); + for (let i = 0; i < 4; i++) h_view[i] = hb[i]; + }, +}; + +/////////////////////////////////////// +// Web GL Imports + +let gl = null; +let gl_error = false; + +function glErrorReport(outer_args) { + const err = gl.getError(); + if (err == gl.NO_ERROR) return; + + gl_error = true; + let msg = ""; + switch (err) { + case gl.NO_ERROR: { msg = "NO_ERROR"; } break; + case gl.INVALID_ENUM: { msg = "INVALID_ENUM"; } break; + case gl.INVALID_VALUE: { msg = "INVALID_VALUE"; } break; + case gl.INVALID_OPERATION: { msg = "INVALID_OPERATION"; } break; + case gl.INVALID_FRAMEBUFFER_OPERATION: { msg = "INVALID_FRAMEBUFFER_OPERATION"; } break; + case gl.OUT_OF_MEMORY: { msg = "OUT_OF_MEMORY"; } break; + case gl.CONTEXT_LOST_WEBGL: { msg = "CONTEXT_LOST_WEBGL"; } break; + default: { msg = "Uknown error"; } break; + } + console.error(`WebGL Error: ${msg} ${err}`, outer_args); +} + +// NOTE(PS): it seems like its not enough to set +// the values of imports to gl.function +// ie. imports.glClearColor = gl.clearColor +// instead we need to wrap them for some reason. +// Not sure why +function glClearColor (r, g, b, a) { return gl.clearColor(r,g,b,a); } +function glEnable(v) { + const r = gl.enable(v); + glErrorReport(arguments); + return r; +} +function glDisable(v) { + const r = gl.disable(v); + glErrorReport(arguments); + return r; +} +function glBlendFunc(a,b) { + const r = gl.blendFunc(a,b); + glErrorReport(arguments); + return r; +} +function glViewport(xmin, ymin, xmax, ymax) { return gl.viewport(xmin,ymin,xmax,ymax); } +function glDepthFunc(v) { + const r = gl.depthFunc(v); + glErrorReport(arguments); + return r; +} +function glClear(mask) { + const r = gl.clear(mask); + glErrorReport(arguments); + return r; +} + +let glBuffers = []; +let glShaders = []; +let glPrograms = []; +let glTextures = []; +function gl_get_managed_resource(arr, id) { + if (id == 0) return null; + return arr[id - 1]; +} +function gl_get_buffer(id) { return gl_get_managed_resource(glBuffers, id); } +function gl_get_shader(id) { return gl_get_managed_resource(glShaders, id); } +function gl_get_program(id) { return gl_get_managed_resource(glPrograms, id); } +function gl_get_texture(id) { return gl_get_managed_resource(glTextures, id); } + +function glCreateBuffer() { + let buffer = gl.createBuffer(); + glErrorReport(arguments); + let new_len = glBuffers.push(buffer); + return new_len; +} + +function glBindBuffer(buffer_kind, buffer_id) +{ + const r = gl.bindBuffer(buffer_kind, gl_get_buffer(buffer_id)); + glErrorReport(arguments); + return r; +} + +function glBufferData(target, size, ptr, usage) +{ + let data = wasm_mem_get_u8_arr(lumenarium_wasm_instance, ptr, size); + const r = gl.bufferData(target, data, usage); + glErrorReport(arguments); + return r; +} + +function glBufferSubData(target, offset, size, ptr) +{ + let data = wasm_mem_get_u8_arr(lumenarium_wasm_instance, ptr, size); + const r = gl.bufferSubData(target, offset, data, 0, size); + glErrorReport(arguments); + return r; +} + +function glCreateShader(kind) +{ + let shader = gl.createShader(kind); + glErrorReport(arguments); + let new_len = glShaders.push(shader); + return new_len; +} + +function glShaderSource(shader_id, shader_code, shader_code_len) +{ + let str = wasm_read_string(lumenarium_wasm_instance, shader_code, shader_code_len); + const r = gl.shaderSource(gl_get_shader(shader_id), str); + glErrorReport(arguments); + return r; +} + +function glCompileShader(shader_id) +{ + let s = gl_get_shader(shader_id); + let r = gl.compileShader(s); + glErrorReport(arguments); + let m = gl.getShaderInfoLog(s); + glErrorReport(arguments); + if (m.length > 0) + { + console.error("glCompileShader: \n\n" + m); + } +} + +function glCreateProgram() +{ + let prog = gl.createProgram(); + glErrorReport(arguments); + let new_len = glPrograms.push(prog); + return new_len; +} + +function glAttachShader(program, shader) +{ + let s = gl_get_shader(shader); + let p = gl_get_program(program); + const r = gl.attachShader(p, s); + glErrorReport(arguments); + return r; +} + +function glLinkProgram(program) +{ + let p = gl_get_program(program); + gl.linkProgram(p); + if (!gl.getProgramParameter(p, gl.LINK_STATUS)) { + var info = gl.getProgramInfoLog(p); + console.error("Failed to compile WebGL program. \n\n"+info); + } +} + +function glUseProgram(program) +{ + let p = gl_get_program(program); + const r = gl.useProgram(p); + glErrorReport(arguments); + return r; +} + +function glGetAttribLocation(program, name, name_len) +{ + let str = wasm_read_string(lumenarium_wasm_instance, name, name_len); + const r = gl.getAttribLocation(gl_get_program(program), str); + glErrorReport(arguments); + return r; +} + +function glVertexAttribPointer(attr, size, type, normalized, stride, pointer) +{ + const r = gl.vertexAttribPointer(attr, size, type, normalized, stride, pointer); + glErrorReport(arguments); + return r; +} + +function glEnableVertexAttribArray(index) +{ + const r = gl.enableVertexAttribArray(index); + glErrorReport(arguments); + return r; +} + +function glDrawElements(type, index_count, ele_type, indices) +{ + const r = gl.drawElements(type, index_count, ele_type, indices); + glErrorReport(arguments); + return r; +} + +function glGenTextures(count, ids_ptr, ids_size) +{ + for (let i = 0; i < count; i++) + { + const tex = gl.createTexture(); + glErrorReport(arguments); + let new_len = glTextures.push(tex); + put_u32(ids_ptr + (i * 4), new_len); + } +} + +function glBindTexture(slot, id) +{ + let tex = gl_get_texture(id); + const r = gl.bindTexture(slot, tex); + glErrorReport(arguments); + return r; +} + +function glTexParameteri(slot, param, value) +{ + const r = gl.texParameteri(slot, param, value); + glErrorReport(arguments); + return r; +} + +function glTexImage2D(target, level, internalformat, width, height, border, format, type, data_ptr, data_size) +{ + const data = wasm_mem_get_u8_arr(lumenarium_wasm_instance, data_ptr, data_size); + const r = gl.texImage2D(target, level, internalformat, width, height, border, format, type, data); + glErrorReport(arguments); + return r; +} + +function glTexSubImage2D(target, level, offsetx, offsety, width, height, format, type, data_ptr, data_size) +{ + const data = wasm_mem_get_u8_arr(lumenarium_wasm_instance, data_ptr, data_size); + const r = gl.texSubImage2D(target, level, offsetx, offsety, width, height, format, type, data); + glErrorReport(arguments); + return r; +} + +function glGetUniformLocation(program, name, name_len) +{ + // TODO(PS): complete + return 0; +} + +function glUniformMatrix4fv() +{ + // TODO(PS): +} + +function webgl_add_imports (canvas_selector, imports) { + const canvas = document.querySelector(canvas_selector); + if (!canvas) return console.error("no canvas"); + + gl = canvas.getContext("webgl2"); + if (gl === null) return console.error("no webgl ctx"); + + imports.glHadError = () => { return gl_error; }; + imports.glClearColor = glClearColor; + imports.glEnable = glEnable; + imports.glDisable = glDisable; + imports.glBlendFunc = glBlendFunc; + imports.glViewport = glViewport; + imports.glDepthFunc = glDepthFunc; + imports.glClear = glClear; + + imports.glCreateBuffer = glCreateBuffer; + imports.glBindBuffer = glBindBuffer; + imports.glBufferData = glBufferData; + imports.glBufferSubData = glBufferSubData; + imports.glCreateShader = glCreateShader; + imports.glShaderSource = glShaderSource; + imports.glCompileShader = glCompileShader; + imports.glCreateProgram = glCreateProgram; + imports.glAttachShader = glAttachShader; + imports.glLinkProgram = glLinkProgram; + imports.glUseProgram = glUseProgram; + imports.glGetAttribLocation = glGetAttribLocation; + imports.glVertexAttribPointer = glVertexAttribPointer; + imports.glEnableVertexAttribArray = glEnableVertexAttribArray; + imports.glDrawElements = glDrawElements; + imports.glGenTextures = glGenTextures; + imports.glBindTexture = glBindTexture; + imports.glTexParameteri = glTexParameteri; + imports.glTexImage2D = glTexImage2D; + imports.glTexSubImage2D = glTexSubImage2D; + imports.glBindTexture = glBindTexture; + imports.glGetUniformLocation = glGetUniformLocation; + imports.glUniformMatrix4fv = glUniformMatrix4fv; + + return imports; +} \ No newline at end of file diff --git a/run_tree/wasm/debug/text.txt b/run_tree/wasm/debug/text.txt new file mode 100644 index 0000000..ccfbc29 Binary files /dev/null and b/run_tree/wasm/debug/text.txt differ diff --git a/run_tree/webgl/debug/lumenarium_wasm_imports.js b/run_tree/webgl/debug/lumenarium_wasm_imports.js new file mode 100644 index 0000000..b7808c3 --- /dev/null +++ b/run_tree/webgl/debug/lumenarium_wasm_imports.js @@ -0,0 +1,167 @@ +var lumenarium_wasm_module = null; +var lumenarium_wasm_instance = null; + +var WASM_PAGE_SIZE = 65536; + +function wasm_mem_get_u8_arr(inst, ptr, size) +{ + let view = new Uint8Array(inst.exports.memory.buffer, ptr, size); + return view; +} + +function wasm_read_string(inst, ptr, len) +{ + let view = wasm_mem_get_u8_arr(inst, ptr, len); + let string = ''; + for (let i = 0; i < len; i++) + { + string += String.fromCharCode(view[i]); + } + return string; +} + +function wasm_write_bytes(inst, src, ptr, len) +{ + let view = wasm_mem_get_u8_arr(inst, ptr, len); + for (let i = 0; i < len; i++) view[i] = src[i]; +} + +function wasm_get_proc(inst, proc_ptr) +{ + let result = inst.exports.__indirect_function_table.get(proc_ptr); + return result; +} + +function fract (v) { return v % 1; } + +var lumenarium_wasm_imports = { + + memset: (dst, size, value) => { + let view_dst = wasm_mem_get_u8_arr(lumenarium_wasm_instance, dst, size); + for (let i = 0; i < size; i++) + { + view_dst[i] = value; + } + }, + + memcpy: (dst, src, size) => { + let view_dst = wasm_mem_get_u8_arr(lumenarium_wasm_instance, dst, size); + let view_src = wasm_mem_get_u8_arr(lumenarium_wasm_instance, src, size); + for (let i = 0; i < size; i++) + { + view_dst[i] = view_src[i]; + } + }, + + wasm_assert_always: () => { + console.assert(false); + }, + + wasm_get_memory_size: () => { + return instance.exports.memory.buffer.byteLength; + }, + + wasm_mem_grow: (new_size) => { + let pages = new_size / WASM_PAGE_SIZE; + let pages_rem = fract(pages); + if (pages_rem > 0) pages = Math.floor(pages) + 1; + let size_before = lumenarium_wasm_instance.exports.memory.buffer.byteLength; + let old_page_count = lumenarium_wasm_instance.exports.memory.grow(pages); + + console.log("mem_grow\n", + "req size: ", new_size, "\n", + "old size: ", (old_page_count * WASM_PAGE_SIZE), "\n", + "old size: ", size_before, "\n", + "grew by: ", (pages * WASM_PAGE_SIZE), "\n", + "new size: ", lumenarium_wasm_instance.exports.memory.buffer.byteLength, ""); + }, + + wasm_performance_now: () => { + return performance.now(); + }, + + wasm_sleep: (milliseconds) => { + let start = Date.now(); + for (let at = Date.now(); (at - start) < milliseconds; at = Date.now()) {} + }, + + wasm_fetch: async (file_path, file_path_len, dest, dest_size) => { + let path = wasm_read_string(lumenarium_wasm_instance, file_path, file_path_len); + fetch(path) + .then(async (res) => { + // TODO(PS): success checking + let reader = res.body.getReader(); + let read_res = { done: false }; + + let view = wasm_mem_get_u8_arr(lumenarium_wasm_instance, dest, dest_size); + let last_write = 0; + while (!read_res.done) + { + read_res = await reader.read(); + if (read_res.done) break; + + let len = read_res.value.length; + let write_end = last_write + len; + for (let i = last_write; i < write_end; i++) + { + view[i] = read_res.value[i - last_write]; + } + last_write = write_end + 1; + } + }); + return 0; + }, + + wasm_request_animation_frame: (cb) => { + let cb_proc = wasm_get_proc(lumenarium_wasm_instance, cb); + window.requestAnimationFrame(cb_proc); + }, + + print: (str_base, len) => { + let string = wasm_read_string(lumenarium_wasm_instance, str_base, len); + console.log(string); + }, +}; + +let gl = null; + +function glClearColor (r, g, b, a) { gl.clearColor(r,g,b,a); } +function glEnable(v) { gl.enable(v); } +function glDisable(v) { gl.disable(v); } +function glBlendFunc(a,b) { gl.blendFunc(a,b); } +function glViewport(xmin, ymin, xmax, ymax) { gl.viewport(xmin,ymin,xmax,ymax); } +function glDepthFunc(v) { gl.depthFunc(v); } +function glClear(mask) { gl.clear(mask); } + +function webgl_add_imports (canvas_selector, imports) { + const canvas = document.querySelector(canvas_selector); + if (!canvas) return console.error("no canvas"); + + gl = canvas.getContext("webgl"); + if (gl === null) return console.error("no webgl ctx"); + + /////////////////////////////////////// + // Constants + + imports.GL_TEXTURE_2D = gl.TEXTURE_2D; + imports.GL_BLEND = gl.BLEND; + imports.GL_SRC_ALPHA = gl.SRC_ALPHA; + imports.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA; + imports.GL_DEPTH_TEST = gl.DEPTH_TEST; + imports.GL_LESS = gl.LESS; + imports.GL_COLOR_BUFFER_BIT = gl.COLOR_BUFFER_BIT; + imports.GL_DEPTH_BUFFER_BIT = gl.DEPTH_BUFFER_BIT; + + /////////////////////////////////////// + // Functions + + imports.glClearColor = glClearColor; + imports.glEnable = glEnable; + imports.glDisable = glDisable; + imports.glBlendFunc = glBlendFunc; + imports.glViewport = glViewport; + imports.glDepthFunc = glDepthFunc; + imports.glClear = glClear; + + return imports; +} \ No newline at end of file diff --git a/run_tree/win32/intel/debug/debug.rdbg b/run_tree/win32/intel/debug/debug.rdbg new file mode 100644 index 0000000..715158d Binary files /dev/null and b/run_tree/win32/intel/debug/debug.rdbg differ diff --git a/run_tree/win32/intel/debug/err.txt b/run_tree/win32/intel/debug/err.txt new file mode 100644 index 0000000..9002a22 --- /dev/null +++ b/run_tree/win32/intel/debug/err.txt @@ -0,0 +1 @@ +OpenGL Version: 3.3.0 - Build 27.20.100.9778 diff --git a/run_tree/win32/intel/debug/lumenarium_first_win32.obj b/run_tree/win32/intel/debug/lumenarium_first_win32.obj new file mode 100644 index 0000000..0420798 Binary files /dev/null and b/run_tree/win32/intel/debug/lumenarium_first_win32.obj differ diff --git a/run_tree/win32/intel/debug/test.obj b/run_tree/win32/intel/debug/test.obj new file mode 100644 index 0000000..6497809 Binary files /dev/null and b/run_tree/win32/intel/debug/test.obj differ diff --git a/src/app/blumen_lumen.cpp b/src/app/blumen_lumen.cpp deleted file mode 100644 index 323b8ae..0000000 --- a/src/app/blumen_lumen.cpp +++ /dev/null @@ -1,280 +0,0 @@ -// -// File: blumen_lumen.cpp -// Author: Peter Slattery -// Creation Date: 2021-01-23 -// -#ifndef BLUMEN_LUMEN_CPP - -internal void -BlumenLumen_MicListenJob(gs_thread_context* Ctx, u8* UserData) -{ - mic_listen_job_data* Data = (mic_listen_job_data*)UserData; - - gs_data Msg = {}; - - u8 WeathermanIPAddr[4] = {}; - WeathermanIPAddr[0] = 127; - WeathermanIPAddr[1] = 0; - WeathermanIPAddr[2] = 0; - WeathermanIPAddr[3] = 1; - - u32 WeathermanIPV4 = (u32)UpackB4(WeathermanIPAddr); - u32 WeathermanPort = 20185; - - while (*Data->Running) - { -#if 1 - if (SocketQueryStatus(Data->SocketManager, Data->ListenSocket)) - { - // TODO(pjs): Removing this block for now - nothing is wrong with it except that SocketPeek is still blocking for some reason - if (SocketPeek(Data->SocketManager, Data->ListenSocket)) - { - // TODO(pjs): Make this a peek operation - Msg = SocketRecieve(Data->SocketManager, Data->ListenSocket, Ctx->Transient); - if (Msg.Size > 0) - { - Data->MicPacketBuffer->Values[Data->MicPacketBuffer->WriteHead++] = Msg; - if (Data->MicPacketBuffer->WriteHead >= PACKETS_MAX) - { - Data->MicPacketBuffer->WriteHead = 0; - } - } - } -#endif - - while (Data->OutgoingMsgQueue->ReadHead != Data->OutgoingMsgQueue->WriteHead) - { - u32 ReadIndex = Data->OutgoingMsgQueue->ReadHead++; - if (Data->OutgoingMsgQueue->ReadHead >= BLUMEN_MESSAGE_QUEUE_COUNT) - { - Data->OutgoingMsgQueue->ReadHead = 0; - } - - Msg = Data->OutgoingMsgQueue->Buffers[ReadIndex]; - u32 Address = WeathermanIPV4; - u32 Port = WeathermanPort; - s32 Flags = 0; - SocketSend(Data->SocketManager, Data->ListenSocket, Address, Port, Msg, Flags); - } - } - } - - CloseSocket(Data->SocketManager, Data->ListenSocket); -} - -internal void -BlumenLumen_LoadPatterns(app_state* State) -{ - animation_pattern_array* Patterns = &State->Patterns; - if (Patterns->CountMax == 0) - { - *Patterns = Patterns_Create(&State->Permanent, 32); - } - - Patterns->Count = 0; - Patterns_PushPattern(Patterns, TestPatternOne); - Patterns_PushPattern(Patterns, TestPatternTwo); - Patterns_PushPattern(Patterns, TestPatternThree); - Patterns_PushPattern(Patterns, Pattern_AllGreen); - Patterns_PushPattern(Patterns, Pattern_HueShift); - Patterns_PushPattern(Patterns, Pattern_HueFade); - Patterns_PushPattern(Patterns, Pattern_Spots); - Patterns_PushPattern(Patterns, Pattern_LighthouseRainbow); - Patterns_PushPattern(Patterns, Pattern_SmoothGrowRainbow); - Patterns_PushPattern(Patterns, Pattern_GrowAndFade); - Patterns_PushPattern(Patterns, Pattern_ColorToWhite); - Patterns_PushPattern(Patterns, Pattern_Blue); - Patterns_PushPattern(Patterns, Pattern_Green); - Patterns_PushPattern(Patterns, Pattern_FlowerColors); - Patterns_PushPattern(Patterns, Pattern_FlowerColorToWhite); - Patterns_PushPattern(Patterns, Pattern_BasicFlowers); -} - -internal pixel -TEMP_Saturate(pixel P) -{ - v4 CRGB = v4{ (r32)P.R / 255.f, (r32)P.G / 255.f, (r32)P.B / 255.f, 1.f }; - v4 CHSV = RGBToHSV(CRGB); - if (CHSV.g > .3f) - { - CHSV.g = 1; - CRGB = HSVToRGB(CHSV); - } - return V4ToRGBPixel(CRGB); -} - -internal gs_data -BlumenLumen_CustomInit(app_state* State, context Context) -{ - // This is memory for any custom data that we want to use - // as a part of a particular sculpture. - // By returning it from here, it will be sent as an argument to - // the sculpture's CustomUpdate function; - gs_data Result = {}; - - Result = PushSizeToData(&State->Permanent, sizeof(blumen_lumen_state)); - - blumen_lumen_state* BLState = (blumen_lumen_state*)Result.Memory; - BLState->Running = true; - - BLState->MicListenJobData.Running = &BLState->Running; - BLState->MicListenJobData.SocketManager = Context.SocketManager; - BLState->MicListenJobData.MicPacketBuffer = &BLState->MicPacketBuffer; - BLState->MicListenJobData.OutgoingMsgQueue = &BLState->OutgoingMsgQueue; - BLState->MicListenJobData.ListenSocket = CreateSocket(Context.SocketManager, "127.0.0.1", "20185"); - - //BLState->MicListenThread = CreateThread(Context.ThreadManager, BlumenLumen_MicListenJob, (u8*)&BLState->MicListenJobData); - - gs_const_string SculpturePath = ConstString("data/test_blumen.fold"); - LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, SculpturePath, State->GlobalLog); - - { // Animation PLAYGROUND - animation Anim0 = {0}; - Anim0.Name = PushStringF(&State->Permanent, 256, "test_anim_zero"); - Anim0.Layers = AnimLayerArray_Create(State->AnimationSystem.Storage, 8); - Anim0.Blocks_ = AnimBlockArray_Create(State->AnimationSystem.Storage, 8); - Anim0.PlayableRange.Min = 0; - Anim0.PlayableRange.Max = SecondsToFrames(15, State->AnimationSystem); - Animation_AddLayer(&Anim0, MakeString("Base Layer"), BlendMode_Overwrite, &State->AnimationSystem); - - Animation_AddBlock(&Anim0, 0, Anim0.PlayableRange.Max, Patterns_IndexToHandle(15), 0); - - AnimationArray_Push(&State->AnimationSystem.Animations, Anim0); - - animation Anim1 = {0}; - Anim1.Name = PushStringF(&State->Permanent, 256, "test_anim_one"); - Anim1.Layers = AnimLayerArray_Create(State->AnimationSystem.Storage, 8); - Anim1.Blocks_ = AnimBlockArray_Create(State->AnimationSystem.Storage, 8); - Anim1.PlayableRange.Min = 0; - Anim1.PlayableRange.Max = SecondsToFrames(15, State->AnimationSystem); - Animation_AddLayer(&Anim1, MakeString("Base Layer"), BlendMode_Overwrite, &State->AnimationSystem); - - Animation_AddBlock(&Anim1, 0, Anim0.PlayableRange.Max, Patterns_IndexToHandle(12), 0); - - AnimationArray_Push(&State->AnimationSystem.Animations, Anim1); - - animation Anim2 = {0}; - Anim2.Name = PushStringF(&State->Permanent, 256, "i_love_you"); - Anim2.Layers = AnimLayerArray_Create(State->AnimationSystem.Storage, 8); - Anim2.Blocks_ = AnimBlockArray_Create(State->AnimationSystem.Storage, 8); - Anim2.PlayableRange.Min = 0; - Anim2.PlayableRange.Max = SecondsToFrames(15, State->AnimationSystem); - Animation_AddLayer(&Anim2, MakeString("Base Layer"), BlendMode_Overwrite, &State->AnimationSystem); - - Animation_AddBlock(&Anim2, 0, Anim0.PlayableRange.Max, Patterns_IndexToHandle(10), 0); - - AnimationArray_Push(&State->AnimationSystem.Animations, Anim2); - - State->AnimationSystem.TimelineShouldAdvance = true; - } // End Animation Playground - - for (u32 i = 0; i < FLOWER_COLORS_COUNT; i++) - { - FlowerAColors[i] = TEMP_Saturate(FlowerAColors[i]); - FlowerBColors[i] = TEMP_Saturate(FlowerBColors[i]); - FlowerCColors[i] = TEMP_Saturate(FlowerCColors[i]); - } - - return Result; -} - -internal void -BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context) -{ - blumen_lumen_state* BLState = (blumen_lumen_state*)UserData.Memory; - - MotorTimeElapsed += Context->DeltaTime; - - gs_string BlueString = MakeString("blue"); - gs_string GreenString = MakeString("green"); - gs_string ILoveYouString = MakeString("i_love_you"); - - while (BLState->MicPacketBuffer.ReadHead != BLState->MicPacketBuffer.WriteHead) - { - gs_data PacketData = BLState->MicPacketBuffer.Values[BLState->MicPacketBuffer.ReadHead++]; - microphone_packet Packet = *(microphone_packet*)PacketData.Memory; - - u32 NameLen = CStringLength(Packet.AnimationFileName); - if (StringEqualsCharArray(BlueString.ConstString, Packet.AnimationFileName, NameLen)) - { - State->AnimationSystem.ActiveAnimationIndex = 0; - } - else if (StringEqualsCharArray(GreenString.ConstString, Packet.AnimationFileName, NameLen)) - { - State->AnimationSystem.ActiveAnimationIndex = 1; - } - else if (StringEqualsCharArray(ILoveYouString.ConstString, Packet.AnimationFileName, NameLen)) - { - State->AnimationSystem.ActiveAnimationIndex = 2; - } - - if (BLState->MicPacketBuffer.ReadHead >= PACKETS_MAX) - { - BLState->MicPacketBuffer.ReadHead = 0; - } - } - - if (MotorTimeElapsed > 60) - { - // NOTE(pjs): - MotorTimeElapsed = 0; - u8 Position = LastPosition; - if (LastPosition == 2) - { - LastPosition = 1; - } - else - { - LastPosition = 2; - } - - if ((BLState->OutgoingMsgQueue.WriteHead >= BLState->OutgoingMsgQueue.ReadHead) || - (BLState->OutgoingMsgQueue.WriteHead < BLState->OutgoingMsgQueue.ReadHead)) - { - u32 WriteIndex = BLState->OutgoingMsgQueue.WriteHead; - - gs_data* Msg = BLState->OutgoingMsgQueue.Buffers + WriteIndex; - if (Msg->Size == 0) - { - *Msg = PushSizeToData(&State->Permanent, sizeof(motor_packet)); - } - motor_packet* Packet = (motor_packet*)Msg->Memory; - Packet->FlowerPositions[0] = Position; - Packet->FlowerPositions[1] = Position; - Packet->FlowerPositions[2] = Position; - - // NOTE(pjs): We increment the write head AFTER we've written so that - // the network thread doesn't think the buffer is ready to send before - // the data is set. We want to avoid the case of: - // 1. Main Thread increments write head to 1 - // 2. Network Thread thinks theres a new message to send at 0 - // 3. Network Thread sends the message at 0 - // 4. Main Thread sets the message at 0 - BLState->OutgoingMsgQueue.WriteHead += 1; - if (BLState->OutgoingMsgQueue.WriteHead >= BLUMEN_MESSAGE_QUEUE_COUNT) - { - BLState->OutgoingMsgQueue.WriteHead = 0; - } - } - } -} - -US_CUSTOM_CLEANUP(BlumenLumen_CustomCleanup) -{ - blumen_lumen_state* BLState = (blumen_lumen_state*)UserData.Memory; - BLState->Running = false; -} - -internal user_space_desc -BlumenLumen_UserSpaceCreate() -{ - user_space_desc Result = {}; - Result.LoadPatterns = BlumenLumen_LoadPatterns; - Result.CustomInit = BlumenLumen_CustomInit; - Result.CustomUpdate = BlumenLumen_CustomUpdate; - Result.CustomCleanup = BlumenLumen_CustomCleanup; - return Result; -} - -#define BLUMEN_LUMEN_CPP -#endif // BLUMEN_LUMEN_CPP \ No newline at end of file diff --git a/src/app/blumen_lumen.h b/src/app/blumen_lumen.h deleted file mode 100644 index 0ea9db5..0000000 --- a/src/app/blumen_lumen.h +++ /dev/null @@ -1,119 +0,0 @@ -// -// File: blumen_lumen.h -// Author: Peter Slattery -// Creation Date: 2021-01-15 -// -#ifndef BLUMEN_LUMEN_H - -typedef struct motor_packet -{ - u8 FlowerPositions[3]; -} motor_packet; - -#pragma pack(push, 1) -struct microphone_packet -{ - b8 ChangeAnimation; - char AnimationFileName[32]; - b8 SetLayer; - char LayerName[32]; - r32 LayerOpacity; - b8 SetLayerParamColor; - char LayerParamColor[7]; - r32 OverrideDuration; -}; -#pragma pack(pop) - -#define BLUMEN_MESSAGE_QUEUE_COUNT 32 -typedef struct blumen_network_msg_queue -{ - gs_data Buffers[BLUMEN_MESSAGE_QUEUE_COUNT]; - u32 WriteHead; - u32 ReadHead; -} blumen_network_msg_queue; - -// TODO(pjs): Refactor this -> blumen_network_job_state -struct mic_listen_job_data -{ - bool* Running; - - platform_socket_manager* SocketManager; - packet_ringbuffer* MicPacketBuffer; - platform_socket_handle_ ListenSocket; - - blumen_network_msg_queue* OutgoingMsgQueue; -}; - -struct blumen_lumen_state -{ - bool Running; - - packet_ringbuffer MicPacketBuffer; - blumen_network_msg_queue OutgoingMsgQueue; - - temp_job_req JobReq; - - - platform_thread_handle MicListenThread; - mic_listen_job_data MicListenJobData; -}; - - - - - - - - - - - - - - - - - - -// If you change anything, exit lumenarium if its running -// then in this application hit f1 to compile then -// go to remedybg (the debugger) and hit f5 - - -// don't touch this -u8 LastPosition = 1; - -u8 ClosedValue = 1; -u8 OpenValue = 2; - - -r64 MotorTimeElapsed = 0; -r64 OpenClosePeriod = 15.0f; - - - - - - - - - - - - - - - - - - - - - - - - - - -#define BLUMEN_LUMEN_H -#endif // BLUMEN_LUMEN_H \ No newline at end of file diff --git a/src/app/editor/foldhaus_editor.cpp b/src/app/editor/foldhaus_editor.cpp index 6d71ca3..8db76a9 100644 --- a/src/app/editor/foldhaus_editor.cpp +++ b/src/app/editor/foldhaus_editor.cpp @@ -8,149 +8,147 @@ internal void Editor_HandleInput (app_state* State, rect2 WindowBounds, input_queue InputQueue, mouse_state Mouse, context Context) { - DEBUG_TRACK_FUNCTION; + DEBUG_TRACK_FUNCTION; + + b32 MouseInputHandled = HandleMousePanelInteraction(&State->PanelSystem, State->WindowBounds, Mouse, State); + + gs_string TextInputString = PushString(State->Transient, 32); + + panel* ActivePanel = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Mouse.Pos); + if (ActivePanel) + { + panel_definition ActiveDef = State->PanelSystem.PanelDefs[ActivePanel->TypeIndex]; - b32 MouseInputHandled = HandleMousePanelInteraction(&State->PanelSystem, State->WindowBounds, Mouse, State); - - gs_string TextInputString = PushString(State->Transient, 32); - - panel* ActivePanel = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Mouse.Pos); - if (ActivePanel) + input_command_registry ActiveCommands = {}; + if (State->Modes.ActiveModesCount > 0) { - panel_definition ActiveDef = State->PanelSystem.PanelDefs[ActivePanel->TypeIndex]; - - input_command_registry ActiveCommands = {}; - if (State->Modes.ActiveModesCount > 0) - { - ActiveCommands = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Commands; - } - else if (ActiveDef.InputCommands) - { - ActiveCommands.Commands = ActiveDef.InputCommands; - ActiveCommands.Size = sizeof(*ActiveDef.InputCommands) / sizeof(ActiveDef.InputCommands[0]); - ActiveCommands.Used = ActiveCommands.Size; - } - - // Fill up the command queue - for (s32 EventIdx = 0; EventIdx < InputQueue.QueueUsed; EventIdx++) - { - input_entry Event = InputQueue.Entries[EventIdx]; - - bool IsMouseEvent = (Event.Key == KeyCode_MouseLeftButton || - Event.Key == KeyCode_MouseMiddleButton || - Event.Key == KeyCode_MouseRightButton); - if (IsMouseEvent && MouseInputHandled) - { - continue; - } - - // NOTE(Peter): These are in the order Down, Up, Held because we want to privalege - // Down and Up over Held. In other words, we don't want to call a Held command on the - // frame when the button was released, even if the command is registered to both events - if (KeyTransitionedDown(Event)) - { - if (!FindAndPushExistingCommand(ActiveCommands, Event, Command_Began, &State->CommandQueue)) - { - char KeyASCII = KeyCodeToChar(Event.Key); - if (KeyASCII) - { - OutChar(&TextInputString, KeyASCII); - } - } - } - else if (KeyTransitionedUp(Event)) - { - FindAndPushExistingCommand(ActiveCommands, Event, Command_Ended, &State->CommandQueue); - } - else if (KeyHeldDown(Event)) - { - if (!FindAndPushExistingCommand(ActiveCommands, Event, Command_Held, &State->CommandQueue)) - { - char KeyASCII = KeyCodeToChar(Event.Key); - if (KeyASCII) - { - OutChar(&TextInputString, KeyASCII); - } - } - } - } + ActiveCommands = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Commands; + } + else if (ActiveDef.InputCommands) + { + ActiveCommands.Commands = ActiveDef.InputCommands; + ActiveCommands.Size = sizeof(*ActiveDef.InputCommands) / sizeof(ActiveDef.InputCommands[0]); + ActiveCommands.Used = ActiveCommands.Size; } - // Execute all commands in CommandQueue - for (s32 CommandIdx = State->CommandQueue.Used - 1; CommandIdx >= 0; CommandIdx--) + // Fill up the command queue + for (s32 EventIdx = 0; EventIdx < InputQueue.QueueUsed; EventIdx++) { - command_queue_entry* Entry = &State->CommandQueue.Commands[CommandIdx]; - if (Entry->Command.Proc) + input_entry Event = InputQueue.Entries[EventIdx]; + + bool IsMouseEvent = (Event.Key == KeyCode_MouseLeftButton || + Event.Key == KeyCode_MouseMiddleButton || + Event.Key == KeyCode_MouseRightButton); + if (IsMouseEvent && MouseInputHandled) + { + continue; + } + + // NOTE(Peter): These are in the order Down, Up, Held because we want to privalege + // Down and Up over Held. In other words, we don't want to call a Held command on the + // frame when the button was released, even if the command is registered to both events + if (KeyTransitionedDown(Event)) + { + if (!FindAndPushExistingCommand(ActiveCommands, Event, Command_Began, &State->CommandQueue)) { - Entry->Command.Proc(State, Entry->Event, Mouse, Context, ActivePanel); + char KeyASCII = KeyCodeToChar(Event.Key); + if (KeyASCII) + { + OutChar(&TextInputString, KeyASCII); + } } - else + } + else if (KeyTransitionedUp(Event)) + { + FindAndPushExistingCommand(ActiveCommands, Event, Command_Ended, &State->CommandQueue); + } + else if (KeyHeldDown(Event)) + { + if (!FindAndPushExistingCommand(ActiveCommands, Event, Command_Held, &State->CommandQueue)) { - EndCurrentOperationMode(State); + char KeyASCII = KeyCodeToChar(Event.Key); + if (KeyASCII) + { + OutChar(&TextInputString, KeyASCII); + } } + } } - - State->Interface.TempInputString = TextInputString.ConstString; - - ClearCommandQueue(&State->CommandQueue); + } + + // Execute all commands in CommandQueue + for (s32 CommandIdx = State->CommandQueue.Used - 1; CommandIdx >= 0; CommandIdx--) + { + command_queue_entry* Entry = &State->CommandQueue.Commands[CommandIdx]; + if (Entry->Command.Proc) + { + Entry->Command.Proc(State, Entry->Event, Mouse, Context, ActivePanel); + } + else + { + EndCurrentOperationMode(State); + } + } + + State->Interface.TempInputString = TextInputString.ConstString; + + ClearCommandQueue(&State->CommandQueue); } internal void Editor_Update(app_state* State, context* Context, input_queue InputQueue) { - Context->Mouse.CursorType = CursorType_Arrow; - State->WindowBounds = Context->WindowBounds; - State->Interface.Mouse = Context->Mouse; - - State->Interface.HotWidgetFramesSinceUpdate += 1; - if (State->Interface.HotWidgetFramesSinceUpdate > 1) - { - State->Interface.HotWidget = {}; - } - - Assert(State->Interface.PerFrameMemory && - (u64)State->Interface.PerFrameMemory != 0x5); - - PanelSystem_UpdateLayout(&State->PanelSystem, State->WindowBounds); - Editor_HandleInput(State, State->WindowBounds, InputQueue, Context->Mouse, *Context); + Context->Mouse.CursorType = CursorType_Arrow; + State->WindowBounds = Context->WindowBounds; + State->Interface.Mouse = Context->Mouse; + + State->Interface.HotWidgetFramesSinceUpdate += 1; + if (State->Interface.HotWidgetFramesSinceUpdate > 1) + { + State->Interface.HotWidget = {}; + } + + Assert(State->Interface.PerFrameMemory && + (u64)State->Interface.PerFrameMemory != 0x5); + + PanelSystem_UpdateLayout(&State->PanelSystem, State->WindowBounds); + Editor_HandleInput(State, State->WindowBounds, InputQueue, Context->Mouse, *Context); } internal void Editor_Render(app_state* State, context* Context, render_command_buffer* RenderBuffer) { - State->Interface.WindowBounds = Context->WindowBounds; - PushRenderOrthographic(RenderBuffer, State->WindowBounds); - PushRenderClearScreen(RenderBuffer); + State->Interface.WindowBounds = Context->WindowBounds; + PushRenderOrthographic(RenderBuffer, State->WindowBounds); + PushRenderClearScreen(RenderBuffer); + + + ui_InterfaceReset(&State->Interface); + State->Interface.RenderBuffer = RenderBuffer; + ui_PushLayout(&State->Interface, Context->WindowBounds, LayoutDirection_TopDown, MakeString("Editor Layout")); + { + DrawAllPanels(State->PanelSystem, RenderBuffer, &Context->Mouse, State, *Context); - - ui_InterfaceReset(&State->Interface); - State->Interface.RenderBuffer = RenderBuffer; - ui_PushLayout(&State->Interface, Context->WindowBounds, LayoutDirection_TopDown, MakeString("Editor Layout")); + for (s32 m = 0; m < State->Modes.ActiveModesCount; m++) { - DrawAllPanels(State->PanelSystem, RenderBuffer, &Context->Mouse, State, *Context); - - for (s32 m = 0; m < State->Modes.ActiveModesCount; m++) - { - operation_mode OperationMode = State->Modes.ActiveModes[m]; - if (OperationMode.Render != 0) - { - OperationMode.Render(State, RenderBuffer, OperationMode, Context->Mouse, *Context); - } - } + operation_mode OperationMode = State->Modes.ActiveModes[m]; + if (OperationMode.Render != 0) + { + OperationMode.Render(State, RenderBuffer, OperationMode, Context->Mouse, *Context); + } } - ui_PopLayout(&State->Interface, MakeString("Editor Layout")); - - - // Draw the Interface - if (State->Interface.DrawOrderRoot != 0) - { - ui_widget Widget = *State->Interface.DrawOrderRoot; - Editor_DrawWidget(State, Context, RenderBuffer, Widget, Context->WindowBounds); - } - - Context->GeneralWorkQueue->CompleteQueueWork(Context->GeneralWorkQueue, Context->ThreadContext); - ResetWorkQueue(Context->GeneralWorkQueue); - + } + ui_PopLayout(&State->Interface, MakeString("Editor Layout")); + + + // Draw the Interface + if (State->Interface.DrawOrderRoot != 0) + { + ui_widget* Widget = State->Interface.DrawOrderRoot; + Editor_DrawWidgetList(State, Context, RenderBuffer, Widget, Context->WindowBounds); + } + + Context->GeneralWorkQueue->CompleteQueueWork(Context->GeneralWorkQueue, Context->ThreadContext); } diff --git a/src/app/editor/foldhaus_editor_draw.h b/src/app/editor/foldhaus_editor_draw.h index 00c7949..bad44a2 100644 --- a/src/app/editor/foldhaus_editor_draw.h +++ b/src/app/editor/foldhaus_editor_draw.h @@ -6,12 +6,12 @@ #ifndef FOLDHAUS_EDITOR_DRAW_H internal void -Editor_DrawWidgetString(app_state* State, context* Context, render_command_buffer* RenderBuffer, ui_widget Widget, rect2 ClippingBox, v4 Color) +Editor_DrawWidgetString(app_state* State, context* Context, render_command_buffer* RenderBuffer, ui_widget Widget, rect2 ClippingBox, v4 Color, s32 CursorPosition) { gs_string Temp = PushString(State->Transient, 256); PrintF(&Temp, "%d", Widget.Id.Id); render_quad_batch_constructor BatchConstructor = PushRenderTexture2DBatch(RenderBuffer, - Widget.String.Length, + Widget.String.Length + 1, State->Interface.Style.Font->BitmapMemory, State->Interface.Style.Font->BitmapTextureHandle, State->Interface.Style.Font->BitmapWidth, @@ -25,7 +25,8 @@ Editor_DrawWidgetString(app_state* State, context* Context, render_command_buffe { case Align_Left: { - RegisterPosition = DrawStringLeftAligned(&BatchConstructor, StringExpand(Widget.String), RegisterPosition, State->Interface.Style.Font, ClippingBox, Color); + RegisterPosition = DrawStringLeftAligned(RenderBuffer, + &BatchConstructor, StringExpand(Widget.String), RegisterPosition, State->Interface.Style.Font, ClippingBox, Color, CursorPosition, GreenV4); }break; case Align_Right: @@ -76,12 +77,13 @@ Editor_GetWidgetFillBounds(ui_widget Widget) return Result; } +internal void Editor_DrawWidgetList(app_state* State, context* Context, render_command_buffer* RenderBuffer, ui_widget Widget, rect2 ParentClipBounds); + internal void -Editor_DrawWidget(app_state* State, context* Context, render_command_buffer* RenderBuffer, ui_widget Widget, rect2 ParentClipBounds) +Editor_DrawWidget(app_state* State, context* Context, render_command_buffer* RenderBuffer, ui_widget Widget, rect2 WidgetParentUnion) { - rect2 WidgetParentUnion = Widget.Bounds; - WidgetParentUnion = Rect2Union(Widget.Bounds, ParentClipBounds); - + bool IsActiveWidget = ui_WidgetIdsEqual(Widget.Id, State->Interface.ActiveWidget); + ; if (!Widget.Parent || (Rect2Area(WidgetParentUnion) > 0)) { if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawBackground)) @@ -101,7 +103,13 @@ Editor_DrawWidget(app_state* State, context* Context, render_command_buffer* Ren if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawString) && Widget.String.Length > 0) { v4 Color = State->Interface.Style.TextColor; - Editor_DrawWidgetString(State, Context, RenderBuffer, Widget, WidgetParentUnion, Color); + s32 CursorPosition = -1; + if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_Typable) && IsActiveWidget) + { + CursorPosition = State->Interface.CursorPosition; + } + + Editor_DrawWidgetString(State, Context, RenderBuffer, Widget, WidgetParentUnion, Color, CursorPosition); } if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawHorizontalFill) || @@ -120,13 +128,15 @@ Editor_DrawWidget(app_state* State, context* Context, render_command_buffer* Ren if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawString) && Widget.String.Length > 0) { - // TODO(pjs): add this color to the style v4 TextColor = BlackV4; - Editor_DrawWidgetString(State, Context, RenderBuffer, Widget, ClippedFillBounds, TextColor); + Editor_DrawWidgetString(State, Context, RenderBuffer, Widget, ClippedFillBounds, TextColor, -1); } } - if (ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawOutline)) + bool DrawOutline = ui_WidgetIsFlagSet(Widget, UIWidgetFlag_DrawOutline); + DrawOutline |= ui_WidgetIsFlagSet(Widget, UIWidgetFlag_Typable) && IsActiveWidget; + + if (DrawOutline) { // TODO(pjs): replace these with values from the style r32 Thickness = 1.0f; @@ -134,18 +144,27 @@ Editor_DrawWidget(app_state* State, context* Context, render_command_buffer* Ren PushRenderBoundingBox2D(RenderBuffer, WidgetParentUnion.Min, WidgetParentUnion.Max, Thickness, Color); } } - - if (Widget.ChildrenRoot) - { - Editor_DrawWidget(State, Context, RenderBuffer, *Widget.ChildrenRoot, WidgetParentUnion); - } - - if (Widget.Next) - { - Editor_DrawWidget(State, Context, RenderBuffer, *Widget.Next, ParentClipBounds); - } } +internal void Editor_DrawWidgetList(app_state* State, context* Context, render_command_buffer* RenderBuffer, ui_widget* Widget, rect2 ParentClipBounds) +{ + ui_widget* WidgetAt = Widget; + while (WidgetAt) + { + rect2 WidgetParentUnion = WidgetAt->Bounds; + WidgetParentUnion = Rect2Union(WidgetAt->Bounds, ParentClipBounds); + + Editor_DrawWidget(State, Context, RenderBuffer, *WidgetAt, WidgetParentUnion); + + if (WidgetAt->ChildrenRoot) + { + Editor_DrawWidgetList(State, Context, RenderBuffer, WidgetAt->ChildrenRoot, WidgetParentUnion); + } + + WidgetAt = WidgetAt->Next; + } +} + #define FOLDHAUS_EDITOR_DRAW_H #endif // FOLDHAUS_EDITOR_DRAW_H \ No newline at end of file diff --git a/src/app/editor/foldhaus_operation_mode.h b/src/app/editor/foldhaus_operation_mode.h index 81e12fe..375d342 100644 --- a/src/app/editor/foldhaus_operation_mode.h +++ b/src/app/editor/foldhaus_operation_mode.h @@ -14,78 +14,77 @@ typedef OPERATION_RENDER_PROC(operation_render_proc); struct operation_mode { - input_command_registry Commands; - operation_render_proc* Render; - gs_memory_cursor Memory; - u8* OpStateMemory; + input_command_registry Commands; + operation_render_proc* Render; + gs_memory_cursor Memory; + u8* OpStateMemory; }; #define OPERATION_MODES_MAX 32 struct operation_mode_system { - s32 ActiveModesCount; - operation_mode ActiveModes[OPERATION_MODES_MAX]; - //arena_snapshot ModeMemorySnapshots[OPERATION_MODES_MAX]; - gs_data_array ModeMemoryPagesFreeList; - - // NOTE(Peter): This acts as mode scoped memory. When a mode gets activated, it can allocate - // temporary memory which then gets freed when the mode is deactivated - gs_memory_arena Arena; + s32 ActiveModesCount; + operation_mode ActiveModes[OPERATION_MODES_MAX]; + //arena_snapshot ModeMemorySnapshots[OPERATION_MODES_MAX]; + gs_data_array ModeMemoryPagesFreeList; + + // NOTE(Peter): This acts as mode scoped memory. When a mode gets activated, it can allocate + // temporary memory which then gets freed when the mode is deactivated + gs_memory_arena Arena; }; internal operation_mode_system OperationModeSystemInit(gs_memory_arena* Storage, gs_thread_context ThreadContext) { - operation_mode_system Result = {0}; - // TODO(Peter): Do we really need an arena? Can this just operate in constant memory footprint? - Result.Arena.Allocator = ThreadContext.Allocator; - - Result.ModeMemoryPagesFreeList.CountMax = 32; // TODO(Peter): Static number of modes that can be active simultaneously - Result.ModeMemoryPagesFreeList.Data = PushArray(Storage, gs_data, Result.ModeMemoryPagesFreeList.CountMax); - for (u32 Page = 0; Page < Result.ModeMemoryPagesFreeList.CountMax; Page++) - { - // TODO(Peter): 4k pages = page size on windows - Result.ModeMemoryPagesFreeList.Data[Page] = PushSizeToData(Storage, KB(4)); - } - Result.ModeMemoryPagesFreeList.Count = Result.ModeMemoryPagesFreeList.CountMax; - - return Result; + operation_mode_system Result = {0}; + // TODO(Peter): Do we really need an arena? Can this just operate in constant memory footprint? + Result.Arena.Allocator = ThreadContext.Allocator; + + Result.ModeMemoryPagesFreeList.CountMax = 8; + Result.ModeMemoryPagesFreeList.Data = PushArray(Storage, gs_data, Result.ModeMemoryPagesFreeList.CountMax); + for (u32 Page = 0; Page < Result.ModeMemoryPagesFreeList.CountMax; Page++) + { + Result.ModeMemoryPagesFreeList.Data[Page] = PushSize(Storage, KB(4)); + } + Result.ModeMemoryPagesFreeList.Count = Result.ModeMemoryPagesFreeList.CountMax; + + return Result; } internal gs_data OperationModeTakeMemoryPage(operation_mode_system* System) { - Assert(System->ModeMemoryPagesFreeList.Count > 0); - gs_data Result = {0}; - System->ModeMemoryPagesFreeList.Count -= 1; - u64 LastIndex = System->ModeMemoryPagesFreeList.Count; - Result = System->ModeMemoryPagesFreeList.Data[LastIndex]; - return Result; + Assert(System->ModeMemoryPagesFreeList.Count > 0); + gs_data Result = {0}; + System->ModeMemoryPagesFreeList.Count -= 1; + u64 LastIndex = System->ModeMemoryPagesFreeList.Count; + Result = System->ModeMemoryPagesFreeList.Data[LastIndex]; + return Result; } internal void OperationModeFreeMemoryPage(operation_mode_system* System, gs_data Data) { - Assert(System->ModeMemoryPagesFreeList.Count < System->ModeMemoryPagesFreeList.CountMax); - u64 LastIndex = System->ModeMemoryPagesFreeList.Count; - System->ModeMemoryPagesFreeList.Count += 1; - System->ModeMemoryPagesFreeList.Data[LastIndex] = Data; + Assert(System->ModeMemoryPagesFreeList.Count < System->ModeMemoryPagesFreeList.CountMax); + u64 LastIndex = System->ModeMemoryPagesFreeList.Count; + System->ModeMemoryPagesFreeList.Count += 1; + System->ModeMemoryPagesFreeList.Data[LastIndex] = Data; } internal operation_mode* ActivateOperationMode (operation_mode_system* System, operation_render_proc* RenderProc) { - Assert(System->ActiveModesCount < OPERATION_MODES_MAX); - operation_mode* Result = 0; - s32 ModeIndex = System->ActiveModesCount++; - - //System->ModeMemorySnapshots[ModeIndex] = TakeSnapshotOfArena(&System->Arena); - - Result = &System->ActiveModes[ModeIndex]; - Result->Memory = CreateMemoryCursor(OperationModeTakeMemoryPage(System)); - Result->Render = RenderProc; - - return Result; + Assert(System->ActiveModesCount < OPERATION_MODES_MAX); + operation_mode* Result = 0; + s32 ModeIndex = System->ActiveModesCount++; + + //System->ModeMemorySnapshots[ModeIndex] = TakeSnapshotOfArena(&System->Arena); + + Result = &System->ActiveModes[ModeIndex]; + Result->Memory = MemoryCursorCreateFromData(OperationModeTakeMemoryPage(System)); + Result->Render = RenderProc; + + return Result; } #define ActivateOperationModeWithCommands(sys, cmds, render) \ @@ -94,30 +93,30 @@ ActivateOperationModeWithCommands_(sys, cmds, (s32)(sizeof(cmds) / sizeof(cmds[0 internal operation_mode* ActivateOperationModeWithCommands_(operation_mode_system* System, input_command* Commands, s32 CommandsCount, operation_render_proc* RenderProc) { - operation_mode* NewMode = ActivateOperationMode(System, RenderProc); - + operation_mode* NewMode = ActivateOperationMode(System, RenderProc); + #if 0 - InitializeInputCommandRegistry(&NewMode->Commands, CommandsCount, &System->Arena); - for (s32 i = 0; i < CommandsCount; i++) - { - input_command Command = Commands[i]; - RegisterKeyPressCommand(&NewMode->Commands, Command.Key, Command.Flags, Command.Mdfr, Command.Proc); - } + InitializeInputCommandRegistry(&NewMode->Commands, CommandsCount, &System->Arena); + for (s32 i = 0; i < CommandsCount; i++) + { + input_command Command = Commands[i]; + RegisterKeyPressCommand(&NewMode->Commands, Command.Key, Command.Flags, Command.Mdfr, Command.Proc); + } #else - NewMode->Commands.Commands = Commands; - NewMode->Commands.Size = CommandsCount; - NewMode->Commands.Used = CommandsCount; + NewMode->Commands.Commands = Commands; + NewMode->Commands.Size = CommandsCount; + NewMode->Commands.Used = CommandsCount; #endif - return NewMode; + return NewMode; } internal void DeactivateCurrentOperationMode (operation_mode_system* System) { - Assert(System->ActiveModesCount > 0); - s32 ModeIndex = --System->ActiveModesCount; - OperationModeFreeMemoryPage(System, System->ActiveModes[ModeIndex].Memory.Data); - //ClearArenaToSnapshot(&System->Arena, System->ModeMemorySnapshots[ModeIndex]); + Assert(System->ActiveModesCount > 0); + s32 ModeIndex = --System->ActiveModesCount; + OperationModeFreeMemoryPage(System, System->ActiveModes[ModeIndex].Memory.Data); + //ClearArenaToSnapshot(&System->Arena, System->ModeMemorySnapshots[ModeIndex]); } #define CreateOperationState(mode, modeSystem, stateType) \ @@ -130,12 +129,12 @@ DeactivateCurrentOperationMode (operation_mode_system* System) internal u8* CreateOperationState_ (operation_mode* Mode, operation_mode_system* System, s32 StateSize) { - // NOTE(Peter): This isn't a problem if this fires, it just means our page size is too small, - // and its time to make the pages dynamically sized - Assert(Mode->Memory.Data.Size >= StateSize); - u8* Result = PushSizeOnCursor(&Mode->Memory, StateSize).Memory; - Mode->OpStateMemory = Result; - return Result; + // NOTE(Peter): This isn't a problem if this fires, it just means our page size is too small, + // and its time to make the pages dynamically sized + Assert(Mode->Memory.Data.Size >= StateSize); + u8* Result = MemoryCursorPushSize(&Mode->Memory, StateSize).Memory; + Mode->OpStateMemory = Result; + return Result; } diff --git a/src/app/editor/foldhaus_panel.h b/src/app/editor/foldhaus_panel.h index aec8cb9..b8a59a8 100644 --- a/src/app/editor/foldhaus_panel.h +++ b/src/app/editor/foldhaus_panel.h @@ -11,11 +11,11 @@ enum panel_split_direction { - PanelSplit_NoSplit, - PanelSplit_Horizontal, - PanelSplit_Vertical, - - PanelSplit_Count, + PanelSplit_NoSplit, + PanelSplit_Horizontal, + PanelSplit_Vertical, + + PanelSplit_Count, }; typedef struct panel panel; @@ -25,32 +25,32 @@ typedef PANEL_MODAL_OVERRIDE_CALLBACK(panel_modal_override_callback); struct panel { - s32 TypeIndex; - gs_data StateMemory; - - panel* ModalOverride; - panel* IsModalOverrideFor; - panel_modal_override_callback* ModalOverrideCB; - - rect2 Bounds; - panel_split_direction SplitDirection; - r32 SplitPercent; - - panel* Parent; - - union{ - panel* Left; - panel* Top; - }; - union{ - panel* Right; - panel* Bottom; - }; + s32 TypeIndex; + gs_data StateMemory; + + panel* ModalOverride; + panel* IsModalOverrideFor; + panel_modal_override_callback* ModalOverrideCB; + + rect2 Bounds; + panel_split_direction SplitDirection; + r32 SplitPercent; + + panel* Parent; + + union{ + panel* Left; + panel* Top; + }; + union{ + panel* Right; + panel* Bottom; + }; }; struct free_panel { - free_panel* Next; + free_panel* Next; }; #define PANEL_INIT_PROC(name) void name(panel* Panel, app_state* State, context Context) @@ -65,25 +65,25 @@ typedef PANEL_RENDER_PROC(panel_render_proc); // NOTE(Peter): This is used by the meta system to generate panel type info struct panel_definition { - char* PanelName; - s32 PanelNameLength; - panel_init_proc* Init; - panel_cleanup_proc* Cleanup; - panel_render_proc* Render; - input_command* InputCommands; - s32 InputCommandsCount; + char* PanelName; + s32 PanelNameLength; + panel_init_proc* Init; + panel_cleanup_proc* Cleanup; + panel_render_proc* Render; + input_command* InputCommands; + s32 InputCommandsCount; }; #define PANELS_MAX 16 struct panel_system { - panel_definition* PanelDefs; - u32 PanelDefsCount; - - panel* Panels; - u32 PanelsUsed; - - free_panel* FreeList; + panel_definition* PanelDefs; + u32 PanelDefsCount; + + panel* Panels; + u32 PanelsUsed; + + free_panel* FreeList; }; ///////////////////////////////// @@ -95,164 +95,164 @@ struct panel_system internal void PanelSystem_Init(panel_system* PanelSystem, panel_definition* PanelDefs, u32 PanelDefsCount, gs_memory_arena* Storage) { - PanelSystem->FreeList = 0; - PanelSystem->PanelDefs = PanelDefs; - PanelSystem->PanelDefsCount = PanelDefsCount; - - PanelSystem->Panels = PushArray(Storage, panel, PANELS_MAX); + PanelSystem->FreeList = 0; + PanelSystem->PanelDefs = PanelDefs; + PanelSystem->PanelDefsCount = PanelDefsCount; + + PanelSystem->Panels = PushArray(Storage, panel, PANELS_MAX); } internal panel* PanelSystem_TakePanel(panel_system* PanelSystem) { - panel* FreeEntry = 0; - if (PanelSystem->FreeList != 0) - { - free_panel* FreePanel = PanelSystem->FreeList; - PanelSystem->FreeList = FreePanel->Next; - FreeEntry = (panel*)FreePanel; - } - else - { - Assert(PanelSystem->PanelsUsed < PANELS_MAX); - FreeEntry = PanelSystem->Panels + PanelSystem->PanelsUsed++; - } - return FreeEntry; + panel* FreeEntry = 0; + if (PanelSystem->FreeList != 0) + { + free_panel* FreePanel = PanelSystem->FreeList; + PanelSystem->FreeList = FreePanel->Next; + FreeEntry = (panel*)FreePanel; + } + else + { + Assert(PanelSystem->PanelsUsed < PANELS_MAX); + FreeEntry = PanelSystem->Panels + PanelSystem->PanelsUsed++; + } + return FreeEntry; } internal void PanelSystem_FreePanel(panel* Panel, panel_system* PanelSystem) { - Assert(Panel >= PanelSystem->Panels && Panel <= PanelSystem->Panels + PANELS_MAX); - - free_panel* FreeEntry = (free_panel*)Panel; - FreeEntry->Next = PanelSystem->FreeList; - PanelSystem->FreeList = FreeEntry; + Assert(Panel >= PanelSystem->Panels && Panel <= PanelSystem->Panels + PANELS_MAX); + + free_panel* FreeEntry = (free_panel*)Panel; + FreeEntry->Next = PanelSystem->FreeList; + PanelSystem->FreeList = FreeEntry; } internal void PanelSystem_FreePanelRecursive(panel* Panel, panel_system* PanelSystem) { - if (Panel->SplitDirection != PanelSplit_NoSplit) - { - PanelSystem_FreePanelRecursive(Panel->Left, PanelSystem); - PanelSystem_FreePanelRecursive(Panel->Right, PanelSystem); - } - PanelSystem_FreePanel(Panel, PanelSystem); + if (Panel->SplitDirection != PanelSplit_NoSplit) + { + PanelSystem_FreePanelRecursive(Panel->Left, PanelSystem); + PanelSystem_FreePanelRecursive(Panel->Right, PanelSystem); + } + PanelSystem_FreePanel(Panel, PanelSystem); } internal panel* Panel_GetModalOverride(panel* Panel) { - panel* Result = Panel; - if (Panel->ModalOverride != 0) - { - Result = Panel_GetModalOverride(Panel->ModalOverride); - } - return Result; + panel* Result = Panel; + if (Panel->ModalOverride != 0) + { + Result = Panel_GetModalOverride(Panel->ModalOverride); + } + return Result; } internal void Panel_PushModalOverride(panel* Root, panel* Override, panel_modal_override_callback* Callback) { - Root->ModalOverride = Override; - Root->ModalOverrideCB = Callback; - Override->IsModalOverrideFor = Root; - Override->Bounds = Root->Bounds; + Root->ModalOverride = Override; + Root->ModalOverrideCB = Callback; + Override->IsModalOverrideFor = Root; + Override->Bounds = Root->Bounds; } internal void Panel_PopModalOverride(panel* Parent, panel_system* System) { - // TODO(pjs): Free the overrided panel - PanelSystem_FreePanel(Parent->ModalOverride, System); - Parent->ModalOverride = 0; + // TODO(pjs): Free the overrided panel + PanelSystem_FreePanel(Parent->ModalOverride, System); + Parent->ModalOverride = 0; } internal void Panel_SetCurrentType(panel* Panel, panel_system* System, s32 NewPanelType, gs_data TypeStateMemory, app_state* State, context Context) { - s32 OldTypeIndex = Panel->TypeIndex; - - Panel->TypeIndex = NewPanelType; - Panel->StateMemory = TypeStateMemory; - - if(OldTypeIndex >= 0) - { - System->PanelDefs[OldTypeIndex].Cleanup(Panel, State); - } + s32 OldTypeIndex = Panel->TypeIndex; + + Panel->TypeIndex = NewPanelType; + Panel->StateMemory = TypeStateMemory; + + if(OldTypeIndex >= 0) + { + System->PanelDefs[OldTypeIndex].Cleanup(Panel, State); + } } internal void Panel_SetType(panel* Panel, panel_system* System, s32 NewPanelTypeIndex, app_state* State, context Context) { - gs_data EmptyStateData = {0}; - Panel_SetCurrentType(Panel, System, NewPanelTypeIndex, EmptyStateData, State, Context); - System->PanelDefs[NewPanelTypeIndex].Init(Panel, State, Context); + gs_data EmptyStateData = {0}; + Panel_SetCurrentType(Panel, System, NewPanelTypeIndex, EmptyStateData, State, Context); + System->PanelDefs[NewPanelTypeIndex].Init(Panel, State, Context); } #define Panel_GetStateStruct(p, type) (type*)Panel_GetStateMemory((p), sizeof(type)).Memory internal gs_data Panel_GetStateMemory(panel* Panel, u64 Size) { - Assert(Panel->StateMemory.Size == Size); - gs_data Result = Panel->StateMemory; - return Result; + Assert(Panel->StateMemory.Size == Size); + gs_data Result = Panel->StateMemory; + return Result; } internal panel* PanelSystem_PushPanel(panel_system* PanelSystem, s32 PanelTypeIndex, app_state* State, context Context) { - panel* Panel = PanelSystem_TakePanel(PanelSystem); - Panel_SetType(Panel, PanelSystem, PanelTypeIndex, State, Context); - return Panel; + panel* Panel = PanelSystem_TakePanel(PanelSystem); + Panel_SetType(Panel, PanelSystem, PanelTypeIndex, State, Context); + return Panel; } internal void SplitPanel(panel* Parent, r32 Percent, panel_split_direction SplitDirection, panel_system* PanelSystem, app_state* State, context Context) { - if (Percent >= 0.0f && Percent <= 1.0f) - { - Parent->SplitDirection = SplitDirection; - Parent->SplitPercent = Percent; - - s32 ParentTypeIndex = Parent->TypeIndex; - gs_data ParentStateMemory = Parent->StateMemory; - - Parent->Left = PanelSystem_TakePanel(PanelSystem); - Panel_SetCurrentType(Parent->Left, PanelSystem, ParentTypeIndex, ParentStateMemory, State, Context); - Parent->Left->Parent = Parent; - - Parent->Right = PanelSystem_TakePanel(PanelSystem); - Panel_SetCurrentType(Parent->Right, PanelSystem, ParentTypeIndex, ParentStateMemory, State, Context); - Parent->Right->Parent = Parent; - } + if (Percent >= 0.0f && Percent <= 1.0f) + { + Parent->SplitDirection = SplitDirection; + Parent->SplitPercent = Percent; + + s32 ParentTypeIndex = Parent->TypeIndex; + gs_data ParentStateMemory = Parent->StateMemory; + + Parent->Left = PanelSystem_TakePanel(PanelSystem); + Panel_SetCurrentType(Parent->Left, PanelSystem, ParentTypeIndex, ParentStateMemory, State, Context); + Parent->Left->Parent = Parent; + + Parent->Right = PanelSystem_TakePanel(PanelSystem); + Panel_SetCurrentType(Parent->Right, PanelSystem, ParentTypeIndex, ParentStateMemory, State, Context); + Parent->Right->Parent = Parent; + } } internal void SplitPanelVertically(panel* Parent, r32 Percent, panel_system* PanelSystem, app_state* State, context Context) { - SplitPanel(Parent, Percent, PanelSplit_Vertical, PanelSystem, State, Context); + SplitPanel(Parent, Percent, PanelSplit_Vertical, PanelSystem, State, Context); } internal void SplitPanelHorizontally(panel* Parent, r32 Percent, panel_system* PanelSystem, app_state* State, context Context) { - SplitPanel(Parent, Percent, PanelSplit_Horizontal, PanelSystem, State, Context); + SplitPanel(Parent, Percent, PanelSplit_Horizontal, PanelSystem, State, Context); } internal void ConsolidatePanelsKeepOne(panel* Parent, panel* PanelToKeep, panel_system* PanelSystem) { - panel* LeftChild = Parent->Left; - panel* RightChild = Parent->Right; - - panel* PanelToDestroy = PanelToKeep == LeftChild ? RightChild : LeftChild; - - *Parent = *PanelToKeep; - - PanelSystem_FreePanel(PanelToKeep, PanelSystem); - PanelSystem_FreePanelRecursive(PanelToDestroy, PanelSystem); + panel* LeftChild = Parent->Left; + panel* RightChild = Parent->Right; + + panel* PanelToDestroy = PanelToKeep == LeftChild ? RightChild : LeftChild; + + *Parent = *PanelToKeep; + + PanelSystem_FreePanel(PanelToKeep, PanelSystem); + PanelSystem_FreePanelRecursive(PanelToDestroy, PanelSystem); } ///////////////////////////////// @@ -264,178 +264,178 @@ ConsolidatePanelsKeepOne(panel* Parent, panel* PanelToKeep, panel_system* PanelS internal rect2 GetTopPanelBounds(panel* Panel) { - rect2 Result = {}; - Result.Min = v2{ - Panel->Bounds.Min.x, - LerpR32(Panel->SplitPercent, Panel->Bounds.Min.y, Panel->Bounds.Max.y) - }; - Result.Max = Panel->Bounds.Max; - return Result; + rect2 Result = {}; + Result.Min = v2{ + Panel->Bounds.Min.x, + LerpR32(Panel->SplitPercent, Panel->Bounds.Min.y, Panel->Bounds.Max.y) + }; + Result.Max = Panel->Bounds.Max; + return Result; } internal rect2 GetBottomPanelBounds(panel* Panel) { - rect2 Result = {}; - Result.Min = Panel->Bounds.Min; - Result.Max = v2{ - Panel->Bounds.Max.x, - LerpR32(Panel->SplitPercent, Panel->Bounds.Min.y, Panel->Bounds.Max.y) - }; - return Result; + rect2 Result = {}; + Result.Min = Panel->Bounds.Min; + Result.Max = v2{ + Panel->Bounds.Max.x, + LerpR32(Panel->SplitPercent, Panel->Bounds.Min.y, Panel->Bounds.Max.y) + }; + return Result; } internal rect2 GetRightPanelBounds(panel* Panel) { - rect2 Result = {}; - Result.Min = v2{ - LerpR32(Panel->SplitPercent, Panel->Bounds.Min.x, Panel->Bounds.Max.x), - Panel->Bounds.Min.y - }; - Result.Max = Panel->Bounds.Max; - return Result; + rect2 Result = {}; + Result.Min = v2{ + LerpR32(Panel->SplitPercent, Panel->Bounds.Min.x, Panel->Bounds.Max.x), + Panel->Bounds.Min.y + }; + Result.Max = Panel->Bounds.Max; + return Result; } internal rect2 GetLeftPanelBounds(panel* Panel) { - rect2 Result = {}; - Result.Min = Panel->Bounds.Min; - Result.Max = v2{ - LerpR32(Panel->SplitPercent, Panel->Bounds.Min.x, Panel->Bounds.Max.x), - Panel->Bounds.Max.y - }; - return Result; + rect2 Result = {}; + Result.Min = Panel->Bounds.Min; + Result.Max = v2{ + LerpR32(Panel->SplitPercent, Panel->Bounds.Min.x, Panel->Bounds.Max.x), + Panel->Bounds.Max.y + }; + return Result; } internal rect2 GetTopPanelBounds(panel* Panel, rect2 PanelBounds) { - rect2 Result = {}; - Result.Min = v2{ - PanelBounds.Min.x, - LerpR32(Panel->SplitPercent, PanelBounds.Min.y, PanelBounds.Max.y) - }; - Result.Max = PanelBounds.Max; - return Result; + rect2 Result = {}; + Result.Min = v2{ + PanelBounds.Min.x, + LerpR32(Panel->SplitPercent, PanelBounds.Min.y, PanelBounds.Max.y) + }; + Result.Max = PanelBounds.Max; + return Result; } internal rect2 GetBottomPanelBounds(panel* Panel, rect2 PanelBounds) { - rect2 Result = {}; - Result.Min = PanelBounds.Min; - Result.Max = v2{ - PanelBounds.Max.x, - LerpR32(Panel->SplitPercent, PanelBounds.Min.y, PanelBounds.Max.y) - }; - return Result; + rect2 Result = {}; + Result.Min = PanelBounds.Min; + Result.Max = v2{ + PanelBounds.Max.x, + LerpR32(Panel->SplitPercent, PanelBounds.Min.y, PanelBounds.Max.y) + }; + return Result; } internal rect2 GetRightPanelBounds(panel* Panel, rect2 PanelBounds) { - rect2 Result = {}; - Result.Min = v2{ - LerpR32(Panel->SplitPercent, PanelBounds.Min.x, PanelBounds.Max.x), - PanelBounds.Min.y - }; - Result.Max = PanelBounds.Max; - return Result; + rect2 Result = {}; + Result.Min = v2{ + LerpR32(Panel->SplitPercent, PanelBounds.Min.x, PanelBounds.Max.x), + PanelBounds.Min.y + }; + Result.Max = PanelBounds.Max; + return Result; } internal rect2 GetLeftPanelBounds(panel* Panel, rect2 PanelBounds) { - rect2 Result = {}; - Result.Min = PanelBounds.Min; - Result.Max = v2{ - LerpR32(Panel->SplitPercent, PanelBounds.Min.x, PanelBounds.Max.x), - PanelBounds.Max.y - }; - return Result; + rect2 Result = {}; + Result.Min = PanelBounds.Min; + Result.Max = v2{ + LerpR32(Panel->SplitPercent, PanelBounds.Min.x, PanelBounds.Max.x), + PanelBounds.Max.y + }; + return Result; } internal void Panel_UpdateLayout(panel* Panel, rect2 Bounds) { - Panel->Bounds = Bounds; - - if (Panel->SplitDirection != PanelSplit_NoSplit) + Panel->Bounds = Bounds; + + if (Panel->SplitDirection != PanelSplit_NoSplit) + { + rect2 LeftOrTopBounds = {}; + rect2 RightOrBottomBounds = {}; + switch (Panel->SplitDirection) { - rect2 LeftOrTopBounds = {}; - rect2 RightOrBottomBounds = {}; - switch (Panel->SplitDirection) - { - case PanelSplit_Horizontal: - { - LeftOrTopBounds = GetTopPanelBounds(Panel); - RightOrBottomBounds = GetBottomPanelBounds(Panel); - } break; - - case PanelSplit_Vertical: - { - LeftOrTopBounds = GetLeftPanelBounds(Panel); - RightOrBottomBounds = GetRightPanelBounds(Panel); - } break; - - InvalidDefaultCase; - } - - Panel_UpdateLayout(Panel->Left, LeftOrTopBounds); - Panel_UpdateLayout(Panel->Right, RightOrBottomBounds); + case PanelSplit_Horizontal: + { + LeftOrTopBounds = GetTopPanelBounds(Panel); + RightOrBottomBounds = GetBottomPanelBounds(Panel); + } break; + + case PanelSplit_Vertical: + { + LeftOrTopBounds = GetLeftPanelBounds(Panel); + RightOrBottomBounds = GetRightPanelBounds(Panel); + } break; + + InvalidDefaultCase; } + + Panel_UpdateLayout(Panel->Left, LeftOrTopBounds); + Panel_UpdateLayout(Panel->Right, RightOrBottomBounds); + } } internal void PanelSystem_UpdateLayout(panel_system* System, rect2 WindowBounds) { - panel* Root = System->Panels; - Panel_UpdateLayout(Root, WindowBounds); + panel* Root = System->Panels; + Panel_UpdateLayout(Root, WindowBounds); } internal panel* GetPanelContainingPoint(panel* Panel, v2 Point) { - panel* Result = 0; - - if (PointIsInRect(Panel->Bounds, Point)) + panel* Result = 0; + + if (PointIsInRect(Panel->Bounds, Point)) + { + switch (Panel->SplitDirection) { - switch (Panel->SplitDirection) + case PanelSplit_NoSplit: + { + Result = Panel; + }break; + + case PanelSplit_Vertical: + case PanelSplit_Horizontal: + {asdfasdfasdfasdfasdf + if (PointIsInRect(Panel->Left->Bounds, Point)) { - case PanelSplit_NoSplit: - { - Result = Panel; - }break; - - case PanelSplit_Vertical: - case PanelSplit_Horizontal: - { - if (PointIsInRect(Panel->Left->Bounds, Point)) - { - Result = GetPanelContainingPoint(Panel->Left, Point); - } - else if (PointIsInRect(Panel->Right->Bounds, Point)) - { - Result = GetPanelContainingPoint(Panel->Right, Point); - } - }break; - - InvalidDefaultCase; + Result = GetPanelContainingPoint(Panel->Left, Point); } + else if (PointIsInRect(Panel->Right->Bounds, Point)) + { + Result = GetPanelContainingPoint(Panel->Right, Point); + } + }break; + + InvalidDefaultCase; } - - return Result; + } + + return Result; } internal panel* PanelSystem_GetPanelContainingPoint(panel_system* System, v2 Point) { - panel* Result = 0; - panel* Root = System->Panels; - Result = GetPanelContainingPoint(Root, Point); - return Result; + panel* Result = 0; + panel* Root = System->Panels; + Result = GetPanelContainingPoint(Root, Point); + return Result; } #define FOLDHAUS_PANEL_H diff --git a/src/app/editor/interface.h b/src/app/editor/interface.h new file mode 100644 index 0000000..d618089 --- /dev/null +++ b/src/app/editor/interface.h @@ -0,0 +1,1677 @@ +// +// File: interface.h +// Author: Peter Slattery +// Creation Date: 2020-01-01 +// +#ifndef INTERFACE_H + +#define InterfaceAssert(IMemPtr) Assert(IMemPtr && (u64)IMemPtr != 0x5 && (u64)IMemPtr != 0xC) + +enum gs_string_alignment +{ + Align_Left, + Align_Center, + Align_Right, +}; + +internal void +ClipUVRect(rect2* Bounds, rect2* UVs, rect2 ClippingBox) +{ + rect2 NewBounds = Rect2Union(*Bounds, ClippingBox); + + r32 OldWidth = Rect2Width(*Bounds); + r32 OldHeight = Rect2Height(*Bounds); + + v2 MinInsetPercent = v2{ + (NewBounds.Min.x - Bounds->Min.x) / OldWidth, + (NewBounds.Min.y - Bounds->Min.y) / OldHeight, + }; + + v2 MaxInsetPercent = v2{ + (NewBounds.Max.x - Bounds->Min.x) / OldWidth, + (NewBounds.Max.y - Bounds->Min.y) / OldHeight, + }; + + UVs->Min.x = LerpR32(MinInsetPercent.x, UVs->Min.x, UVs->Max.x); + UVs->Min.y = LerpR32(MinInsetPercent.y, UVs->Min.y, UVs->Max.y); + UVs->Max.x = LerpR32(MaxInsetPercent.x, UVs->Min.x, UVs->Max.x); + UVs->Max.y = LerpR32(MaxInsetPercent.y, UVs->Min.y, UVs->Max.y); + + *Bounds = NewBounds; +} + +internal void +DrawCharacter_ (render_quad_batch_constructor* BatchConstructor, r32 MinX, r32 MinY, codepoint_bitmap CodepointInfo, rect2 ClippingBox, v4 Color) +{ + rect2 Bounds = {}; + Bounds.Min.x = FloorR32(MinX); + Bounds.Min.y = FloorR32(MinY); + Bounds.Max.x = Bounds.Min.x + (CodepointInfo.Width); + Bounds.Max.y = Bounds.Min.y + (CodepointInfo.Height); + + rect2 UVBounds = {}; + UVBounds.Min = CodepointInfo.UVMin; + UVBounds.Max = CodepointInfo.UVMax; + + ClipUVRect(&Bounds, &UVBounds, ClippingBox); + + s32 AlignedMinX = (s32)(MinX); + s32 AlignedMinY = (s32)(MinY); + s32 AlignedMaxX = AlignedMinX + (CodepointInfo.Width); + s32 AlignedMaxY = AlignedMinY + (CodepointInfo.Height); + + PushQuad2DOnBatch(BatchConstructor, + Rect2BottomLeft(Bounds), Rect2BottomRight(Bounds), + Rect2TopRight(Bounds), Rect2TopLeft(Bounds), + UVBounds.Min, UVBounds.Max, + Color); +} + +internal v2 +DrawCharacterLeftAligned (render_quad_batch_constructor* BatchConstructor, char C, bitmap_font Font, v2 Position, rect2 ClippingBox, v4 Color) +{ + s32 GlyphDataIndex = GetIndexForCodepoint(Font, C); + codepoint_bitmap CodepointInfo = Font.CodepointValues[GlyphDataIndex]; + + // NOTE(Peter): + r32 MinX = Position.x + CodepointInfo.XOffset; + r32 MinY = Position.y + CodepointInfo.YOffset; + DrawCharacter_(BatchConstructor, MinX, MinY, CodepointInfo, ClippingBox, Color); + + // NOTE(Peter): + v2 PointAfterCharacter = v2{Position.x + CodepointInfo.Width, Position.y}; + return PointAfterCharacter; +} + +internal v2 +DrawCharacterRightAligned (render_quad_batch_constructor* BatchConstructor, char C, bitmap_font Font, v2 Position, rect2 ClippingBox, v4 Color) +{ + s32 GlyphDataIndex = GetIndexForCodepoint(Font, C); + codepoint_bitmap CodepointInfo = Font.CodepointValues[GlyphDataIndex]; + + // NOTE(Peter): + r32 MinX = Position.x - (CodepointInfo.XOffset + CodepointInfo.Width); + r32 MinY = Position.y + CodepointInfo.YOffset + CodepointInfo.YOffset; + DrawCharacter_(BatchConstructor, MinX, MinY, CodepointInfo, ClippingBox, Color); + + // NOTE(Peter): + v2 PointAfterCharacter = v2{Position.x-(CodepointInfo.Width + CodepointInfo.XOffset), Position.y}; + return PointAfterCharacter; +} + +internal void +DrawCursor (render_command_buffer* RenderBuffer, v2 RegisterPosition, bitmap_font* Font, v4 Color) +{ + rect2 CursorRect = {}; + CursorRect.Min = RegisterPosition; + CursorRect.Max = CursorRect.Min + v2{5, (r32)Font->Ascent}; + PushRenderQuad2D(RenderBuffer, CursorRect, Color); +} + +internal v2 +DrawStringLeftAligned (render_command_buffer* RenderBuffer, render_quad_batch_constructor* BatchConstructor, s32 Length, char* gs_string, v2 InitialRegisterPosition, bitmap_font* Font, rect2 ClippingBox, v4 Color, s32 CursorBeforeIndex, v4 CursorColor) +{ + v2 RegisterPosition = InitialRegisterPosition; + char* C = gs_string; + for (s32 i = 0; i < Length; i++) + { + if (i == CursorBeforeIndex) + { + DrawCursor(RenderBuffer, RegisterPosition, Font, CursorColor); + } + + v2 PositionAfterCharacter = DrawCharacterLeftAligned(BatchConstructor, *C, *Font, RegisterPosition, ClippingBox, Color); + RegisterPosition.x = PositionAfterCharacter.x; + C++; + } + if (CursorBeforeIndex == Length) + { + DrawCursor(RenderBuffer, RegisterPosition, Font, CursorColor); + } + return RegisterPosition; +} + +internal v2 +DrawStringRightAligned (render_quad_batch_constructor* BatchConstructor, s32 Length, char* gs_string, v2 InitialRegisterPosition, bitmap_font* Font, rect2 ClippingBox, v4 Color) +{ + v2 RegisterPosition = InitialRegisterPosition; + char* C = gs_string + Length - 1; + for (s32 i = Length - 1; i >= 0; i--) + { + v2 PositionAfterCharacter = DrawCharacterRightAligned(BatchConstructor, *C, *Font, RegisterPosition, ClippingBox, Color); + RegisterPosition.x = PositionAfterCharacter.x; + C--; + } + return RegisterPosition; +} + +internal v2 +DrawString(render_command_buffer* RenderBuffer, gs_string String, bitmap_font* Font, v2 Position, v4 Color, s32 CursorPosition, v4 CursorColor, gs_string_alignment Alignment = Align_Left) +{ + DEBUG_TRACK_FUNCTION; + v2 LowerRight = Position; + + render_quad_batch_constructor BatchConstructor = PushRenderTexture2DBatch(RenderBuffer, String.Length + 1, + Font->BitmapMemory, + Font->BitmapTextureHandle, + Font->BitmapWidth, + Font->BitmapHeight, + Font->BitmapBytesPerPixel, + Font->BitmapStride); + + // TODO(pjs): I don't like this solution but it'll do for now and I want to focus on other problems + // especially since I think this one will go away once I finish the ui overhaul + rect2 InfiniteClipBox = {}; + InfiniteClipBox.Min.x = -100000; + InfiniteClipBox.Min.y = -100000; + InfiniteClipBox.Max.x = 100000; + InfiniteClipBox.Max.y = 100000; + + v2 RegisterPosition = Position; + if (Alignment == Align_Left) + { + RegisterPosition = DrawStringLeftAligned(RenderBuffer, &BatchConstructor, StringExpand(String), RegisterPosition, Font, InfiniteClipBox, Color, CursorPosition, CursorColor); + } + else if (Alignment == Align_Right) + { + RegisterPosition = DrawStringRightAligned(&BatchConstructor, StringExpand(String), RegisterPosition, Font, InfiniteClipBox, Color); + } + else + { + InvalidCodePath; + } + + LowerRight.x = RegisterPosition.x; + + return LowerRight; +} + +internal void +DrawCursor (render_quad_batch_constructor* BatchConstructor, v2 Position, v4 Color, bitmap_font Font) +{ + v2 Min = Position; + v2 Max = Position + v2{(r32)Font.MaxCharWidth, (r32)(Font.Ascent + Font.Descent)}; + PushQuad2DOnBatch(BatchConstructor, Min, Max, Color); +} + +#if 0 +internal v2 +DrawStringWithCursor (render_command_buffer* RenderBuffer, gs_string String, s32 CursorPosition, bitmap_font* Font, v2 Position, v4 Color, v4 CursorColor, gs_string_alignment Alignment = Align_Left) +{ + DEBUG_TRACK_FUNCTION; + v2 LowerRight = Position; + + // NOTE(Peter): We push this on first so that the cursor will be drawn underneath any character it may overlap with + render_quad_batch_constructor CursorBatch = PushRenderQuad2DBatch(RenderBuffer, 1); + render_quad_batch_constructor BatchConstructor = PushRenderTexture2DBatch(RenderBuffer, String.Length, + Font->BitmapMemory, + Font->BitmapTextureHandle, + Font->BitmapWidth, + Font->BitmapHeight, + Font->BitmapBytesPerPixel, + Font->BitmapStride); + + v2 RegisterPosition = Position; + if (Alignment == Align_Left) + { + RegisterPosition = DrawStringLeftAligned(&BatchConstructor, StringExpand(String), RegisterPosition, Font, Color); + DrawCursor(&CursorBatch, RegisterPosition, GreenV4, *Font); + if (String.Length - CursorPosition > 0) + { + RegisterPosition = DrawStringLeftAligned(&BatchConstructor, + String.Length - CursorPosition, + String.Str + CursorPosition, + RegisterPosition, Font, Color); + } + } + else if (Alignment == Align_Right) + { + RegisterPosition = DrawStringRightAligned(&BatchConstructor, + CursorPosition, String.Str, + RegisterPosition, Font, Color); + DrawCursor(&CursorBatch, RegisterPosition, GreenV4, *Font); + if (String.Length - CursorPosition > 0) + { + RegisterPosition = DrawStringRightAligned(&BatchConstructor, + String.Length - CursorPosition, + String.Str + CursorPosition, + RegisterPosition, Font, Color); + } + } + else + { + InvalidCodePath; + } + + LowerRight.x = RegisterPosition.x; + return LowerRight; +} +#endif + +enum ui_widget_flag +{ + UIWidgetFlag_ExpandsToFitChildren, + + UIWidgetFlag_DrawBackground, + UIWidgetFlag_DrawString, + UIWidgetFlag_DrawOutline, + UIWidgetFlag_DrawHorizontalFill, + UIWidgetFlag_DrawVerticalFill, + UIWidgetFlag_DrawFillReversed, + UIWidgetFlag_DrawFillAsHandle, + + UIWidgetFlag_Clickable, + UIWidgetFlag_Selectable, + UIWidgetFlag_Typable, +}; + +struct ui_widget_id +{ + u64 Id; + u64 ZIndex; +}; + +enum ui_layout_direction +{ + LayoutDirection_TopDown, + LayoutDirection_BottomUp, + LayoutDirection_Inherit, +}; + +struct ui_column +{ + r32 XMin; + r32 XMax; +}; + +struct ui_widget +{ + ui_widget_id Id; + + gs_string String; + gs_string_alignment Alignment; + + rect2 Bounds; + u64 Flags; + + ui_widget* Next; + + // Slider + r32 FillPercent; + + // Layout + ui_widget* Parent; + + v2 Margin; + r32 RowHeight; + r32 RowYAt; + + ui_layout_direction FillDirection; + + ui_column* Columns; + u32 ColumnsCount; + u32 ColumnsFilled; + + // NOTE(pjs): I'm not sure this will stay but + // its here so that when we end things like a dropdown, + // we can check the retained state of that dropdown + ui_widget_id WidgetReference; + + u64 ChildZIndexOffset; + + ui_widget* ChildrenRoot; + ui_widget* ChildrenHead; + u32 ChildCount; +}; + +struct ui_eval_result +{ + bool Clicked; + bool Held; + v2 DragDelta; +}; + +struct interface_config +{ + v4 PanelBG; + + // TODO(pjs): Turn these into _Default, _Hot, _Active + v4 ButtonColor_Inactive, ButtonColor_Active, ButtonColor_Selected; + + v4 TextColor; + +#define LIST_BG_COLORS_COUNT 2 + v4 ListBGColors[LIST_BG_COLORS_COUNT]; + v4 ListBGHover; + v4 ListBGSelected; + + bitmap_font* Font; + r32 FontSize; + v2 Margin; + r32 RowHeight; +}; + +struct ui_widget_retained_state +{ + ui_widget_id Id; + bool Value; + r32 InitialValueR32; + u32 FramesSinceAccess; + + // For use in layouts that allow you to scroll / pan + v2 ChildrenDrawOffset; + + gs_string EditString; + + // For dropdowns and rows to be able to error check not closing + // a layout you open + u32 MaxChildren; +}; + +struct ui_interface +{ + interface_config Style; + + mouse_state Mouse; + rect2 WindowBounds; + + // A per-frame string of the characters which have been typed + gs_const_string TempInputString; + u64 CursorPosition; + + render_command_buffer* RenderBuffer; + + ui_widget* Widgets; + u64 WidgetsCount; + u64 WidgetsCountMax; + + ui_widget* DrawOrderHead; + ui_widget* DrawOrderRoot; + + ui_widget_id HotWidget; + // This should really never get higher than 1 or 2 + u8 HotWidgetFramesSinceUpdate; + + ui_widget_id ActiveWidget; + ui_widget_id LastActiveWidget; + + ui_widget* ActiveLayout; + +#define RETAINED_STATE_MAX 128 + ui_widget_retained_state RetainedState[RETAINED_STATE_MAX]; + u64 RetainedStateCount; + + gs_memory_arena* PerFrameMemory; + + // TODO(pjs): DONT USE THIS + // Right now you only need this to create EditStrings for ui_widget_retained_state's + // and even for those, you eventually want a better solution than "create a string and it lives forever" + // TODO(pjs): Get rid of the need for this vvv + gs_memory_arena* Permanent; +}; + +internal void +ui_InterfaceReset(ui_interface* Interface) +{ + Interface->WidgetsCount = 0; + Interface->DrawOrderHead = 0; + Interface->DrawOrderRoot = 0; + MemoryArenaClear(Interface->PerFrameMemory); + InterfaceAssert(Interface->PerFrameMemory); + + for (u32 i = 0; i < Interface->RetainedStateCount; i++) + { + Interface->RetainedState[i].FramesSinceAccess += 1; + if (Interface->RetainedState[i].FramesSinceAccess > 1) + { + Interface->RetainedState[i].Id = {0}; + } + } + + Interface->LastActiveWidget = Interface->ActiveWidget; +} + +internal bool +ui_WidgetIdsEqual(ui_widget_id A, ui_widget_id B) +{ + bool Result = (A.Id == B.Id);// && (A.ParentId == B.ParentId); + return Result; +} + +internal void +ui_WidgetSetFlag(ui_widget* Widget, u64 Flag) +{ + u64 Value = ((u64)1 << Flag); + Widget->Flags = Widget->Flags | Value; +} + +internal void +ui_WidgetClearFlag(ui_widget* Widget, u64 Flag) +{ + u64 Value = ((u64)1 << Flag); + Widget->Flags = Widget->Flags & ~Value; +} + +internal bool +ui_WidgetIsFlagSet(ui_widget Widget, u64 Flag) +{ + u64 Value = ((u64)1 << Flag); + bool Result = (Widget.Flags & Value); + return Result; +} + +internal void +ui_WidgetSetChildrenPopover(ui_widget* Widget) +{ + Widget->ChildZIndexOffset = 1000; +} + +internal ui_widget* +ui_WidgetGetWidgetWithId(ui_widget* Parent, ui_widget_id Id) +{ + ui_widget* Result = 0; + + if (ui_WidgetIdsEqual(Parent->Id, Id)) + { + Result = Parent; + } + else if (Parent->ChildrenRoot != 0) + { + for (ui_widget* At = Parent->ChildrenRoot; At != 0; At = At->Next) + { + Result = ui_WidgetGetWidgetWithId(At, Id); + if (Result != 0) + { + break; + } + } + } + + return Result; +} + +internal ui_widget* +ui_InterfaceGetWidgetWithId(ui_interface* Interface, ui_widget_id Id) +{ + ui_widget* Result = 0; + + for (ui_widget* At = Interface->DrawOrderRoot; At != 0; At = At->Next) + { + Result = ui_WidgetGetWidgetWithId(At, Id); + if (Result != 0) + { + break; + } + } + + return Result; +} + +internal ui_widget_retained_state* +ui_GetRetainedState(ui_interface* Interface, ui_widget_id Id) +{ + ui_widget_retained_state* Result = 0; + for (u64 i = 0; i < Interface->RetainedStateCount; i++) + { + if (ui_WidgetIdsEqual(Interface->RetainedState[i].Id, Id)) + { + // NOTE(PS): If we are accessing a retained state, it shouldn't + // have been accessed longer ago than the last frame + //Assert(Interface->RetainedState[i].FramesSinceAccess <= 2); + Interface->RetainedState[i].FramesSinceAccess = 0; + Result = Interface->RetainedState + i; + break; + } + } + return Result; +} + +internal ui_widget_retained_state* +ui_CreateRetainedState(ui_interface* Interface, ui_widget* Widget) +{ + u64 Index = RETAINED_STATE_MAX; + if (Interface->RetainedStateCount >= RETAINED_STATE_MAX) + { + for (u32 i = 0; i < Interface->RetainedStateCount; i++) + { + if (Interface->RetainedState[i].FramesSinceAccess > 0) + { + Index = i; + break; + } + } + } else { + Index = Interface->RetainedStateCount++; + } + + Assert(Index < RETAINED_STATE_MAX); + ui_widget_retained_state* Result = Interface->RetainedState + Index; + Result->Id = Widget->Id; + if (Result->EditString.Size != 256) + { + Result->EditString = PushString(Interface->Permanent, 256); + } + return Result; +} + +internal ui_widget_retained_state* +ui_GetOrCreateRetainedState(ui_interface* Interface, ui_widget* Widget) +{ + ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); + if (!State) + { + State = ui_CreateRetainedState(Interface, Widget); + } + return State; +} + +internal ui_widget* +ui_CreateWidget(ui_interface* Interface, gs_string String) +{ + InterfaceAssert(Interface->PerFrameMemory); + Assert(Interface->WidgetsCount < Interface->WidgetsCountMax); + u64 Index = Interface->WidgetsCount++; + ui_widget* Result = Interface->Widgets + Index; + ZeroStruct(Result); + + Result->Parent = Interface->ActiveLayout; + + u64 Id = HashDJB2ToU64(StringExpand(String)); + if (Result->Parent) + { + Id = HashAppendDJB2ToU32(Id, Result->Parent->Id.Id); + Id = HashAppendDJB2ToU32(Id, Result->Parent->ChildCount); + //Result->Id.ParentId = Result->Parent->Id.Id; + } + Result->Id.Id = Id; + + u64 ZIndex = Index + 1; + if (Result->Parent) + { + Result->ChildZIndexOffset += Result->Parent->ChildZIndexOffset; + ZIndex += Result->Parent->ChildZIndexOffset; + } + Result->Id.ZIndex = ZIndex; + + Result->String = PushStringCopy(Interface->PerFrameMemory, String.ConstString); + InterfaceAssert(Interface->PerFrameMemory); + Result->Alignment = Align_Left; + Result->Next = 0; + Result->ChildrenRoot = 0; + Result->ChildrenHead = 0; + Result->Flags = 0; + ui_WidgetSetFlag(Result, UIWidgetFlag_ExpandsToFitChildren); + + return Result; +} + +// +// Interaction +// + +internal b32 +ui_MouseClickedRect(ui_interface Interface, rect2 Rect) +{ + b32 Result = MouseButtonTransitionedDown(Interface.Mouse.LeftButtonState); + Result &= PointIsInRect(Rect, Interface.Mouse.Pos); + return Result; +} + +// Layout + +static rect2 +ui_ReserveBounds(ui_interface* Interface, ui_widget* Widget, bool Inset) +{ + Assert(Widget->ColumnsCount > 0); + rect2 Bounds = {0}; + u32 ColumnIndex = Widget->ChildCount % Widget->ColumnsCount; + + ui_column Column = Widget->Columns[ColumnIndex]; + Bounds.Min.x = Column.XMin; + Bounds.Min.y = Widget->RowYAt; + Bounds.Max.x = Column.XMax; + Bounds.Max.y = Bounds.Min.y + Widget->RowHeight; + + if (Inset) + { + Bounds.Min.x += Widget->Margin.x; + Bounds.Min.y += Widget->Margin.y; + Bounds.Max.x -= Widget->Margin.x; + Bounds.Max.y -= Widget->Margin.y; + } + + if (Widget->ChildCount == 0) + { + ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); + if (State) + { + Bounds = Rect2Translate(Bounds, State->ChildrenDrawOffset); + } + } + + return Bounds; +} + +internal void +ui_CommitBounds(ui_widget* Parent, rect2 Bounds) +{ + u32 ColumnIndex = Parent->ChildCount % Parent->ColumnsCount; + if (ColumnIndex == 0) + { + switch (Parent->FillDirection) + { + case LayoutDirection_BottomUp: + { + Parent->RowYAt = Bounds.Max.y; + if (ui_WidgetIsFlagSet(*Parent, UIWidgetFlag_ExpandsToFitChildren)) + { + Parent->Bounds.Max.y = Parent->RowYAt; + } + }break; + + case LayoutDirection_TopDown: + { + Parent->RowYAt = Bounds.Min.y - Parent->RowHeight; + if (ui_WidgetIsFlagSet(*Parent, UIWidgetFlag_ExpandsToFitChildren)) + { + Parent->Bounds.Min.y = Bounds.Min.y; + } + }break; + } + } +} + +internal void +ui_ExpandParentToFit(ui_widget* Widget) +{ + ui_widget* Parent = Widget->Parent; + switch (Widget->FillDirection) + { + case LayoutDirection_TopDown: + { + Parent->Bounds.Min.y = Min(Parent->Bounds.Min.y, Widget->Bounds.Min.y - Parent->Margin.y); + }break; + + case LayoutDirection_BottomUp: + { + Parent->Bounds.Max.y = Max(Parent->Bounds.Max.y, Widget->Bounds.Max.y + Parent->Margin.y); + }break; + + InvalidDefaultCase; + } +} + +internal void +ui_WidgetCreateColumns(ui_widget* Widget, u32 ColumnsCount, ui_interface* Interface) +{ + Widget->Columns = PushArray(Interface->PerFrameMemory, ui_column, ColumnsCount); + InterfaceAssert(Interface->PerFrameMemory); + Widget->ColumnsCount = ColumnsCount; + Widget->ColumnsFilled = 0; +} + +internal void +ui_WidgetInitUniformColumns(ui_widget* Widget) +{ + r32 CurrentRowWidth = Rect2Width(Widget->Bounds); + r32 ColumnWidth = CurrentRowWidth / Widget->ColumnsCount; + for (u32 i = 0; i < Widget->ColumnsCount; i++) + { + ui_column* Column = Widget->Columns + i; + Column->XMin = Widget->Bounds.Min.x + (ColumnWidth * i); + Column->XMax = Column->XMin + ColumnWidth; + } +} + +internal ui_widget* +ui_CreateLayoutWidget(ui_interface* Interface, rect2 Bounds, gs_string Name, ui_layout_direction FillDir = LayoutDirection_Inherit) +{ + ui_widget* Result = ui_CreateWidget(Interface, Name); + //ui_WidgetSetFlag(Result, UIWidgetFlag_DrawOutline); + + Result->Bounds = Bounds; + Result->Margin = Interface->Style.Margin; + Result->RowHeight = Interface->Style.RowHeight; + + // Single Column Layout + ui_WidgetCreateColumns(Result, 1, Interface); + ui_WidgetInitUniformColumns(Result); + + if (FillDir == LayoutDirection_Inherit && Result->Parent != 0) + { + Result->FillDirection = Result->Parent->FillDirection; + } + else + { + Result->FillDirection = FillDir; + } + + switch(Result->FillDirection) + { + case LayoutDirection_BottomUp: + { + Result->RowYAt = Bounds.Min.y; + }break; + + case LayoutDirection_TopDown: + { + Result->RowYAt = Bounds.Max.y - Result->RowHeight; + }break; + + InvalidDefaultCase; + } + + return Result; +} + +static ui_widget* +ui_PushOverlayLayout(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir, gs_string Name) +{ + ui_widget* Result = ui_CreateLayoutWidget(Interface, Bounds, Name, FillDir); + SLLPushOrInit(Interface->DrawOrderRoot, Interface->DrawOrderHead, Result); + Interface->ActiveLayout = Result; + return Result; +} + +static gs_string +ui_PushLayoutCategoryName(ui_interface* Interface, gs_string Category, u32 Value) +{ + gs_string Result = PushStringF(Interface->PerFrameMemory, + Category.Length + 25, + "%S%d", + Category.ConstString, + Value); + return Result; +} + +static ui_widget* +ui_PushLayout(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir, gs_string Name) +{ + ui_widget* Result = ui_CreateLayoutWidget(Interface, Bounds, Name, FillDir); + + if (Interface->DrawOrderRoot) + { + SLLPushOrInit(Interface->ActiveLayout->ChildrenRoot, Interface->ActiveLayout->ChildrenHead, Result); + Interface->ActiveLayout->ChildCount++; + } + else + { + SLLPushOrInit(Interface->DrawOrderRoot, Interface->DrawOrderHead, Result); + } + + Interface->ActiveLayout = Result; + return Result; +} +static ui_widget* +ui_PushLayout(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir, gs_string Category, u32 Value) +{ + gs_string Name = ui_PushLayoutCategoryName(Interface, Category, Value); + return ui_PushLayout(Interface, Bounds, FillDir, Name); +} + +static ui_widget* +ui_PushLayout(ui_interface* Interface, gs_string Name, bool Inset = true) +{ + rect2 Bounds = {}; + ui_layout_direction Direction = LayoutDirection_TopDown; + if (Interface->ActiveLayout) + { + Bounds = ui_ReserveBounds(Interface, Interface->ActiveLayout, Inset); + Direction = Interface->ActiveLayout->FillDirection; + } + else + { + Bounds.Min.x = Interface->WindowBounds.Min.x; + Bounds.Min.y = Interface->WindowBounds.Max.y; + Bounds.Max.x = Interface->WindowBounds.Max.x; + Bounds.Max.y = Interface->WindowBounds.Max.y; + + if (Inset) + { + Bounds.Min.x += Interface->Style.Margin.x; + Bounds.Max.x -= Interface->Style.Margin.x; + } + + Direction = LayoutDirection_TopDown; + } + return ui_PushLayout(Interface, Bounds, Direction, Name); +} + +internal void +ui_ExpandToFitChildren(ui_widget* Parent) +{ + if (!ui_WidgetIsFlagSet(*Parent, UIWidgetFlag_ExpandsToFitChildren)) { return; } + + v2 Extents = { Parent->Bounds.Max.y, Parent->Bounds.Min.y }; + for (ui_widget* Child = Parent->ChildrenRoot; Child != 0; Child = Child->Next) + { + Extents.x = Min(Extents.x, Child->Bounds.Min.y); + Extents.y = Max(Extents.y, Child->Bounds.Max.y); + } + + switch(Parent->FillDirection) + { + case LayoutDirection_BottomUp: + { + Parent->Bounds.Max.y = Max(Extents.y + Parent->Margin.y, Parent->Bounds.Max.y); + }break; + + case LayoutDirection_TopDown: + { + Parent->Bounds.Min.y = Min(Extents.x - Parent->Margin.y, Parent->Bounds.Min.y); + }break; + + InvalidDefaultCase; + } +} + +static void +ui_PopLayout(ui_interface* Interface, gs_string LayoutName) +{ + Assert(Interface->ActiveLayout != 0); + + ui_widget* Layout = Interface->ActiveLayout; + + // NOTE(pjs): If this isn't true then a layout was opened without being closed + // Go check for ui_PushLayout, ui_BeginDropdown, ui_BeginRow, etc that don't have + // a corresponding ui_Pop/ui_End* + // + // We use StringsEqualUpToLength here becuase its possible that + // the current layout used the Category + Identifier method + // for generating Layout->String. And if Identifier was a string + // that was edited within the scope of this layout, then + // Layout->String and LayoutName will no longer match. + // + // This is a compromise that will at least let us know if + // we aren't popping all our layouts correctly. + Assert(StringsEqualUpToLength(Layout->String, LayoutName, LayoutName.Length)); + + ui_ExpandToFitChildren(Layout); + + Interface->ActiveLayout = Interface->ActiveLayout->Parent; + + // NOTE(pjs): This indicates that the parent layout should + // expand to fit the layout that we just popped + if (Interface->ActiveLayout != 0 && + Interface->ActiveLayout->ChildrenHead == Layout) + { + ui_CommitBounds(Interface->ActiveLayout, Layout->Bounds); + } +} +static void +ui_PopLayout(ui_interface* Interface, gs_string Category, u32 Value) +{ + gs_string Name = ui_PushLayoutCategoryName(Interface, Category, Value); + ui_PopLayout(Interface, Name); +} + +static ui_widget* +ui_BeginRow(ui_interface* Interface, u32 ColumnsMax) +{ + ui_widget* Layout = ui_PushLayout(Interface, MakeString("Row"), false); + ui_WidgetCreateColumns(Layout, ColumnsMax, Interface); + ui_WidgetInitUniformColumns(Layout); + return Layout; +} + +enum ui_column_size_rule +{ + UIColumnSize_Fixed, + UIColumnSize_Percent, + UIColumnSize_Fill, + UIColumnSize_MaxWidth, +}; + +struct ui_column_spec +{ + ui_column_size_rule Rule; + union + { + r32 Width; + r32 Percent; + }; +}; + +static ui_widget* +ui_BeginRow(ui_interface* Interface, u32 ColumnsMax, ui_column_spec* ColumnRules) +{ + ui_widget* Layout = ui_PushLayout(Interface, MakeString("Row"), false); + ui_WidgetCreateColumns(Layout, ColumnsMax, Interface); + + // First Pass, determine widths of each column, and how much space is left to be divided by the fill columns + // If a size is specified, it is stored in Column->XMax + r32 RowWidth = Rect2Width(Layout->Bounds); + r32 RemainingSpace = RowWidth; + u32 FillColumnsCount = 0; + for (u32 i = 0; i < Layout->ColumnsCount; i++) + { + ui_column_spec Spec = ColumnRules[i]; + ui_column* Column = Layout->Columns + i; + + switch (Spec.Rule) + { + case UIColumnSize_Fixed: + { + Column->XMax = Spec.Width; + RemainingSpace -= Column->XMax; + }break; + + case UIColumnSize_Percent: + { + Column->XMax = Spec.Percent * RowWidth; + RemainingSpace -= Column->XMax; + }break; + + case UIColumnSize_Fill: + { + FillColumnsCount += 1; + }break; + + case UIColumnSize_MaxWidth: + { + if (RemainingSpace >= Spec.Width) + { + Column->XMax = Spec.Width; + } + else + { + Column->XMax = RemainingSpace; + } + RemainingSpace -= Column->XMax; + }break; + + InvalidDefaultCase; + } + } + + r32 FillColumnWidth = RemainingSpace / FillColumnsCount; + + // Second Pass, specify the actual XMin and XMax of each column + r32 ColumnStartX = Layout->Bounds.Min.x; + for (u32 i = 0; i < Layout->ColumnsCount; i++) + { + ui_column_spec Spec = ColumnRules[i]; + ui_column* Column = Layout->Columns + i; + + r32 ColumnWidth = 0; + switch (Spec.Rule) + { + case UIColumnSize_Fixed: + case UIColumnSize_Percent: + case UIColumnSize_MaxWidth: + { + ColumnWidth = Column->XMax; + }break; + + case UIColumnSize_Fill: + { + ColumnWidth = FillColumnWidth; + }break; + } + + Column->XMin = ColumnStartX ; + Column->XMax = Column->XMin + Max(0, ColumnWidth); + ColumnStartX = Column->XMax; + } + + return Layout; +} + +static void +ui_EndRow(ui_interface* Interface) +{ + ui_PopLayout(Interface, MakeString("Row")); +} + +static rect2 +ui_LayoutRemaining(ui_widget Layout) +{ + rect2 Result = Layout.Bounds; + Result.Max.y = Layout.RowYAt; + return Result; +} + +// Widgets + +internal ui_eval_result +ui_EvaluateWidget(ui_interface* Interface, ui_widget* Widget, rect2 Bounds) +{ + ui_eval_result Result = {}; + + Widget->Bounds = Bounds; + SLLPushOrInit(Interface->ActiveLayout->ChildrenRoot, Interface->ActiveLayout->ChildrenHead, Widget); + Interface->ActiveLayout->ChildCount += 1; + ui_CommitBounds(Widget->Parent, Widget->Bounds); + + if (PointIsInRect(Widget->Parent->Bounds, Interface->Mouse.Pos) && + PointIsInRect(Widget->Bounds, Interface->Mouse.Pos)) + { + if (MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState)) + { + if (ui_WidgetIdsEqual(Interface->HotWidget, Widget->Id)) + { + Result.Clicked = true; + Interface->ActiveWidget = Widget->Id; + + if (ui_WidgetIsFlagSet(*Widget, UIWidgetFlag_Typable)) + { + Interface->CursorPosition = Widget->String.Length; + } + } + } + + if (Interface->HotWidget.ZIndex == 0 || + Interface->HotWidget.ZIndex <= Widget->Id.ZIndex) + { + Interface->HotWidget = Widget->Id; + Interface->HotWidgetFramesSinceUpdate = 0; + } + } + else + { + if (ui_WidgetIdsEqual(Interface->ActiveWidget, Widget->Id) && + MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState)) + { + Interface->ActiveWidget = {}; + } + } + + if (ui_WidgetIdsEqual(Interface->ActiveWidget, Widget->Id)) + { + // click & drag + if (MouseButtonHeldDown(Interface->Mouse.LeftButtonState)) + { + Result.Held = true; + Result.DragDelta = Interface->Mouse.Pos - Interface->Mouse.DownPos; + } + + if (ui_WidgetIsFlagSet(*Widget, UIWidgetFlag_Typable) && + Interface->TempInputString.Length > 0) + { + ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); + + Interface->CursorPosition = Clamp(0, Interface->CursorPosition, State->EditString.Length); + for (u32 i = 0; i < Interface->TempInputString.Length; i++) + { + if (Interface->TempInputString.Str[i] == '\b') + { + if (Interface->CursorPosition > 0) + { + State->EditString.Length -= 1; + } + } + else + { + OutChar(&State->EditString, Interface->TempInputString.Str[i]); + Interface->CursorPosition += 1; + } + } + } + } + + Assert(Widget->Parent != 0); + return Result; +} + +internal ui_eval_result +ui_EvaluateWidget(ui_interface* Interface, ui_widget* Widget) +{ + ui_widget* Layout = Interface->ActiveLayout; + rect2 Bounds = ui_ReserveBounds(Interface, Layout, true); + return ui_EvaluateWidget(Interface, Widget, Bounds); +} + +// +// Drawing Functions +// + +static r32 +ui_GetTextLineHeight(ui_interface Interface) +{ + r32 Result = Interface.Style.Font->PixelHeight + (2 * Interface.Style.Margin.y); + return Result; +} + +static void +ui_FillRect(ui_interface* Interface, rect2 Bounds, v4 Color) +{ + PushRenderQuad2D(Interface->RenderBuffer, Bounds.Min, Bounds.Max, Color); +} + +static void +ui_OutlineRect(ui_interface* Interface, rect2 Bounds, r32 Thickness, v4 Color) +{ + PushRenderBoundingBox2D(Interface->RenderBuffer, Bounds.Min, Bounds.Max, Thickness, Color); +} + +internal void +ui_Label(ui_interface* Interface, gs_string String, rect2 Bounds, gs_string_alignment Alignment = Align_Left) +{ + DEBUG_TRACK_FUNCTION; + ui_widget* Widget = ui_CreateWidget(Interface, String); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); + ui_EvaluateWidget(Interface, Widget, Bounds); +} + +internal void +ui_Label(ui_interface* Interface, gs_string String, gs_string_alignment Alignment = Align_Left) +{ + DEBUG_TRACK_FUNCTION; + ui_widget* Widget = ui_CreateWidget(Interface, String); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); + ui_EvaluateWidget(Interface, Widget); +} + +internal void +ui_TextEntrySetFlags(ui_widget* Widget, gs_string EditString) +{ + Widget->String = EditString; + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); + ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); + ui_WidgetSetFlag(Widget, UIWidgetFlag_Selectable); + ui_WidgetSetFlag(Widget, UIWidgetFlag_Typable); +} + +internal bool +ui_TextEntry(ui_interface* Interface, gs_string Identifier, gs_string* Value) +{ + ui_widget* Widget = ui_CreateWidget(Interface, Identifier); + ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); + if (!State) + { + State = ui_CreateRetainedState(Interface, Widget); + } + PrintF(&State->EditString, "%S", *Value); + + ui_TextEntrySetFlags(Widget, State->EditString); + + ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); + bool StringEdited = !StringsEqual(*Value, State->EditString); + PrintF(Value, "%S", State->EditString); + + return StringEdited; +} + +internal u64 +ui_TextEntryU64(ui_interface* Interface, gs_string String, u64 CurrentValue) +{ + ui_widget* Widget = ui_CreateWidget(Interface, String); + ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); + if (!State) + { + State = ui_CreateRetainedState(Interface, Widget); + PrintF(&State->EditString, "%u", CurrentValue); + } + ui_TextEntrySetFlags(Widget, State->EditString); + + ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); + parse_uint_result ParseResult = ValidateAndParseUInt(State->EditString.ConstString); + u64 ValueResult = CurrentValue; + if (ParseResult.Success) + { + ValueResult = ParseResult.Value; + } + return ValueResult; +} + +internal r64 +ui_TextEntryR64(ui_interface* Interface, gs_string String, r64 CurrentValue) +{ + ui_widget* Widget = ui_CreateWidget(Interface, String); + ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); + if (!State) + { + State = ui_CreateRetainedState(Interface, Widget); + PrintF(&State->EditString, "%f", CurrentValue); + } + ui_TextEntrySetFlags(Widget, State->EditString); + ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); + parse_float_result ParseResult = ValidateAndParseFloat(State->EditString.ConstString); + r64 ValueResult = CurrentValue; + if (ParseResult.Success) + { + ValueResult = ParseResult.Value; + } + return ValueResult; +} + +internal ui_widget* +ui_CreateButtonWidget(ui_interface* Interface, gs_string Text) +{ + ui_widget* Widget = ui_CreateWidget(Interface, Text); + ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); + return Widget; +} + +internal b32 +ui_Button(ui_interface* Interface, gs_string Text) +{ + ui_widget* Widget = ui_CreateButtonWidget(Interface, Text); + ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); + return Result.Clicked; +} + +internal b32 +ui_Button(ui_interface* Interface, gs_string Text, rect2 Bounds) +{ + ui_widget* Widget = ui_CreateButtonWidget(Interface, Text); + ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds); + return Result.Clicked; +} + +struct list_item_colors +{ + v4 Hover; + v4 Selected; + v4 BGColor; +}; + +inline v4 +ui_GetListItemBGColor(interface_config Style, u32 ElementIndex) +{ + v4 Result = Style.ListBGColors[ElementIndex % LIST_BG_COLORS_COUNT]; + return Result; +} + +static list_item_colors +ui_GetListItemColors(ui_interface* Interface, u32 ListItemIndex) +{ + list_item_colors Result = {}; + Result.Hover = Interface->Style.ListBGHover; + Result.Selected = Interface->Style.ListBGSelected; + Result.BGColor = ui_GetListItemBGColor(Interface->Style, ListItemIndex); + return Result; +} + +static b32 +ui_ListButton(ui_interface* Interface, gs_string Text, rect2 Bounds, u32 ListItemIndex) +{ + ui_widget* Widget = ui_CreateWidget(Interface, Text); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); + ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); + // TODO(pjs): Reimplement alternating color backgrounds + Widget->Bounds = Bounds; + ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); + return Result.Clicked; +} + +static b32 +ui_LayoutListButton(ui_interface* Interface, gs_string Text, u32 ListItemIndex) +{ + // TODO(pjs): Reimplement alternating colors + return ui_Button(Interface, Text); +} + +internal bool +ui_EvaluateDropdown(ui_interface* Interface, ui_widget* Widget, ui_eval_result EvalResult) +{ + ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); + if (!State) + { + State = ui_CreateRetainedState(Interface, Widget); + } + + if (EvalResult.Clicked) + { + State->Value = !State->Value; + } + + if (State->Value) + { + ui_widget ParentLayout = *Interface->ActiveLayout; + + r32 SpaceAbove = Interface->WindowBounds.Max.y - Widget->Bounds.Max.y; + r32 SpaceBelow = Widget->Bounds.Min.y - Interface->WindowBounds.Min.y; + ui_layout_direction Direction = LayoutDirection_TopDown; + rect2 MenuBounds = {}; + + if (SpaceAbove > SpaceBelow) + { + r32 ParentLayoutMaxY = ParentLayout.Bounds.Max.y; + Direction = LayoutDirection_BottomUp; + MenuBounds = rect2{ + v2{ Widget->Bounds.Min.x - ParentLayout.Margin.x, Widget->Bounds.Max.y }, + v2{ Widget->Bounds.Max.x + ParentLayout.Margin.x, ParentLayoutMaxY } + }; + } + else + { + r32 ParentLayoutMinY = ParentLayout.Bounds.Min.y; + Direction = LayoutDirection_TopDown; + MenuBounds = rect2{ + v2{ Widget->Bounds.Min.x - ParentLayout.Margin.x, ParentLayoutMinY }, + v2{ Widget->Bounds.Max.x + ParentLayout.Margin.x, Widget->Bounds.Min.y } + }; + } + + ui_widget* Layout = ui_PushOverlayLayout(Interface, MenuBounds, Direction, MakeString("DropdownLayout")); + Layout->Margin.y = 0; + Layout->WidgetReference = Widget->Id; + ui_WidgetClearFlag(Layout, UIWidgetFlag_DrawOutline); + ui_WidgetSetChildrenPopover(Layout); + } + + return State->Value; +} + +internal bool +ui_BeginDropdown(ui_interface* Interface, gs_string Text, rect2 Bounds) +{ + ui_widget* Widget = ui_CreateWidget(Interface, Text); + ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); + + ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds); + return ui_EvaluateDropdown(Interface, Widget, Result); +} + +internal bool +ui_BeginDropdown(ui_interface* Interface, gs_string Text) +{ + ui_widget* Widget = ui_CreateWidget(Interface, Text); + ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); + ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); + return ui_EvaluateDropdown(Interface, Widget, Result); +} + +internal void +ui_EndDropdown(ui_interface* Interface) +{ + gs_string LayoutName = MakeString("DropdownLayout"); + ui_widget* Layout = Interface->ActiveLayout; + ui_widget_retained_state* State = ui_GetRetainedState(Interface, Layout->WidgetReference); + if (State) + { + bool IsOpen = State->Value; + ui_widget* Widget = Interface->ActiveLayout; + bool IsStillHot = StringsEqualUpToLength(Widget->String, LayoutName, LayoutName.Length); + if (IsOpen && IsStillHot) + { + ui_PopLayout(Interface, LayoutName); + } else if (IsOpen && !IsStillHot) + { + State->Value = false; + } + } +} + +internal r32 +ui_EvaluateRangeSlider(ui_interface* Interface, ui_widget* Widget, ui_eval_result EvalResult, r32 Value, r32 MinValue, r32 MaxValue) +{ + r32 NewValue = Value; + ui_widget_retained_state* State = ui_GetOrCreateRetainedState(Interface, Widget); + + if (EvalResult.Clicked) + { + State->InitialValueR32 = Value; + } + + if (EvalResult.Held) + { + r32 Percent = (Interface->Mouse.Pos.x - Widget->Bounds.Min.x) / Rect2Width(Widget->Bounds); + NewValue = LerpR32(Percent, MinValue, MaxValue); + } + + NewValue = Clamp(MinValue, NewValue, MaxValue); + Widget->FillPercent = RemapR32(NewValue, MinValue, MaxValue, 0, 1); + return NewValue; +} + +internal ui_widget* +ui_CreateRangeSliderWidget(ui_interface* Interface, gs_string Text, r32 Value) +{ + ui_widget* Widget = ui_CreateWidget(Interface, Text); + ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawHorizontalFill); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); + Widget->String = PushStringF(Interface->PerFrameMemory, 128, "%f", Value); + InterfaceAssert(Interface->PerFrameMemory); + return Widget; +} + +internal r32 +ui_RangeSlider(ui_interface* Interface, gs_string Text, r32 Value, r32 ValueMin, r32 ValueMax) +{ + ui_widget* Widget = ui_CreateRangeSliderWidget(Interface, Text, Value); + ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); + return ui_EvaluateRangeSlider(Interface, Widget, Result, Value, ValueMin, ValueMax); + +} + +internal r32 +ui_RangeSlider(ui_interface* Interface, gs_string Text, rect2 Bounds, r32 Value, r32 ValueMin, r32 ValueMax) +{ + ui_widget* Widget = ui_CreateRangeSliderWidget(Interface, Text, Value); + ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds); + return ui_EvaluateRangeSlider(Interface, Widget, Result, Value, ValueMin, ValueMax); +} + +internal bool +ui_Toggle(ui_interface* Interface, gs_string Text, bool Value) +{ + ui_widget* Widget = ui_CreateWidget(Interface, Text); + ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawHorizontalFill); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); + ui_eval_result Eval = ui_EvaluateWidget(Interface, Widget); + + bool Result = Eval.Clicked ? !Value : Value; + Widget->FillPercent = Result ? 1.0f : 0.0f; + return Result; +} + +internal bool +ui_ToggleText(ui_interface* Interface, gs_string Text, bool Value) +{ + ui_widget* Widget = ui_CreateWidget(Interface, Text); + ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawHorizontalFill); + ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); + ui_eval_result Eval = ui_EvaluateWidget(Interface, Widget); + + bool Result = Eval.Clicked ? !Value : Value; + Widget->FillPercent = Result ? 1.0f : 0.0f; + return Result; +} + +internal void +ui_BeginList(ui_interface* Interface, gs_string Text, u32 ViewportRows, u32 ElementCount) +{ + if (ElementCount < ViewportRows) + { + ViewportRows = ElementCount; + } + + ui_column_spec ColumnRules[] = { + { UIColumnSize_Fixed, 32 }, + { UIColumnSize_Fill, 0 }, + }; + ui_widget* Layout = ui_BeginRow(Interface, 2, ColumnRules); + ui_WidgetClearFlag(Layout, UIWidgetFlag_ExpandsToFitChildren); + + ui_widget_retained_state* State = ui_GetRetainedState(Interface, Layout->Id); + if (!State) + { + State = ui_CreateRetainedState(Interface, Layout); + State->InitialValueR32 = 1.0f; + } + + r32 LayoutHeight = Layout->RowHeight * ViewportRows; + switch (Layout->Parent->FillDirection) + { + case LayoutDirection_TopDown: + { + Layout->Bounds.Min.y = Layout->Bounds.Max.y - LayoutHeight; + }break; + + case LayoutDirection_BottomUp: + { + Layout->Bounds.Max.y = Layout->Bounds.Min.y + LayoutHeight; + }break; + + InvalidDefaultCase; + } + + // Create the scroll bar + // + // TODO(pjs): Maybe make this a vertical slider widget? + + ui_widget* SliderRegion = ui_CreateWidget(Interface, MakeString("Slider")); + ui_WidgetSetFlag(SliderRegion, UIWidgetFlag_DrawOutline); + ui_WidgetSetFlag(SliderRegion, UIWidgetFlag_DrawVerticalFill); + ui_WidgetSetFlag(SliderRegion, UIWidgetFlag_DrawFillAsHandle); + + ui_WidgetSetFlag(SliderRegion, UIWidgetFlag_Clickable); + + rect2 SliderBounds = ui_ReserveBounds(Interface, Layout, true); + SliderBounds.Min.y = Layout->Bounds.Min.y + Layout->Margin.y; + SliderBounds.Max.y = Layout->Bounds.Max.y - Layout->Margin.y; + + ui_eval_result SliderEval = ui_EvaluateWidget(Interface, SliderRegion, SliderBounds); + if (SliderEval.Clicked || SliderEval.Held) + { + r32 Percent = (Interface->Mouse.Pos.y - SliderRegion->Bounds.Min.y) / Rect2Height(SliderRegion->Bounds); + State->InitialValueR32 = Clamp01(Percent); + } + SliderRegion->FillPercent = State->InitialValueR32; + + // Create the viewport that offsets list contents (and at render time determines what is visible) + // + ui_widget* ViewportLayout = ui_PushLayout(Interface, MakeString("Contents")); + ui_WidgetSetFlag(ViewportLayout, UIWidgetFlag_DrawOutline); + ui_WidgetClearFlag(ViewportLayout, UIWidgetFlag_ExpandsToFitChildren); + ViewportLayout->FillDirection = LayoutDirection_TopDown; + + ViewportLayout->Bounds.Min.y = SliderBounds.Min.y; + ViewportLayout->Bounds.Max.y = SliderBounds.Max.y; + + s32 ScrollableElements = Max(0, ElementCount - ViewportRows); + ui_widget_retained_state* ViewportState = ui_GetOrCreateRetainedState(Interface, ViewportLayout); + ViewportState->ChildrenDrawOffset.x = 0; + r32 BaseOffset = 0; + r32 ScrollPct = 1.0 - State->InitialValueR32; + r32 RowsOffset = ScrollPct * ScrollableElements; + r32 ScrollOffset = (ViewportLayout->RowHeight - (Interface->Style.Margin.y)) * RowsOffset; + ViewportState->ChildrenDrawOffset.y = BaseOffset + ScrollOffset; +} + +internal void +ui_EndList(ui_interface* Interface) +{ + // Pop the Viewport Layout + ui_PopLayout(Interface, MakeString("Contents")); + // Pop the actual list layout + ui_EndRow(Interface); +} + +internal void +ui_BeginMousePopup(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir, gs_string Text) +{ + rect2 FollowMouseBounds = Rect2Translate(Bounds, Interface->Mouse.Pos); + ui_widget* Layout = ui_PushOverlayLayout(Interface, FollowMouseBounds, FillDir, MakeString("MousePopup")); + ui_WidgetSetFlag(Layout, UIWidgetFlag_DrawBackground); +} + +internal void +ui_EndMousePopup(ui_interface* Interface) +{ + ui_PopLayout(Interface, MakeString("MousePopup")); +} + +// +internal void +ui_BeginLabelRow(ui_interface* Interface, gs_string Label, u32 Count = 2) +{ + ui_BeginRow(Interface, Count); + ui_Label(Interface, Label); +} + +internal bool +ui_LabeledToggle(ui_interface* Interface, gs_string Label, bool Value) +{ + ui_BeginLabelRow(Interface, Label); + bool Result = ui_Toggle(Interface, Label, Value); + ui_EndRow(Interface); + return Result; +} + +internal r32 +ui_LabeledRangeSlider(ui_interface* Interface, gs_string Label, r32 Value, r32 ValueMin, r32 ValueMax) +{ + ui_BeginLabelRow(Interface, Label); + r32 Result = ui_RangeSlider(Interface, Label, Value, ValueMin, ValueMax); + ui_EndRow(Interface); + return Result; +} + +internal void +ui_LabeledTextEntry(ui_interface* Interface, gs_string Label, gs_string* Value) +{ + ui_BeginLabelRow(Interface, Label); + ui_TextEntry(Interface, Label, Value); + ui_EndRow(Interface); +} + + +internal u64 +ui_LabeledTextEntryU64(ui_interface* Interface, gs_string Label, u32 Value) +{ + ui_BeginLabelRow(Interface, Label); + u64 Result = ui_TextEntryU64(Interface, Label, Value); + ui_EndRow(Interface); + return Result; +} + +internal bool +ui_BeginLabeledDropdown(ui_interface* Interface, gs_string Label, gs_string DropdownValue) +{ + ui_BeginLabelRow(Interface, Label); + return ui_BeginDropdown(Interface, DropdownValue); +} + +internal void +ui_EndLabeledDropdown(ui_interface* Interface) +{ + ui_EndDropdown(Interface); + ui_EndRow(Interface); +} + +internal ui_interface +ui_InterfaceCreate(context Context, interface_config Style, gs_memory_arena* Permanent) +{ + ui_interface Result = {0}; + Result.Style = Style; + + gs_file FontFile = ReadEntireFile(Context.ThreadContext.FileHandler, ConstString("data/Anonymous Pro.ttf")); + Result.Style.Font = PushStruct(Permanent, bitmap_font); + *Result.Style.Font = TextFont_Create(FontFile, 512, Style.FontSize, Context, Permanent); + + Result.Style.RowHeight = ui_GetTextLineHeight(Result) + (2 * Result.Style.Margin.y); + + Result.WidgetsCountMax = 4096; + Result.Widgets = PushArray(Permanent, ui_widget, Result.WidgetsCountMax); + Result.PerFrameMemory = PushStruct(Permanent, gs_memory_arena); + *Result.PerFrameMemory = MemoryArenaCreate(KB(32), Bytes(8), Context.ThreadContext.Allocator, 0, 0, "Interface Per Frame Memory Arena"); + InterfaceAssert(Result.PerFrameMemory); + + Result.Permanent = Permanent; + + return Result; +} + +#define INTERFACE_H +#endif // INTERFACE_H \ No newline at end of file diff --git a/src/app/editor/panels/foldhaus_panel_animation_timeline.h b/src/app/editor/panels/foldhaus_panel_animation_timeline.h index 92ee12c..822cf58 100644 --- a/src/app/editor/panels/foldhaus_panel_animation_timeline.h +++ b/src/app/editor/panels/foldhaus_panel_animation_timeline.h @@ -13,9 +13,18 @@ struct animation_timeline_state { frame_range VisibleRange; handle SelectedBlockHandle; - u32 SelectedAnimationLayer; + animation_handle EditingAnimationHandle; + s32 SelectedAnimationLayer; + + animation_handle NextActiveAnim; }; +internal void +AnimationTimeline_SelectLayer(animation_timeline_state* TLState, s32 Layer) +{ + TLState->SelectedAnimationLayer = Layer; +} + inline u32 GetFrameFromPointInAnimationPanel(v2 Point, rect2 PanelBounds, frame_range VisibleRange) { @@ -33,22 +42,13 @@ GetXPositionFromFrameInAnimationPanel (u32 Frame, rect2 PanelBounds, frame_range return XPositionAtFrame; } -internal handle -AddAnimationBlockAtCurrentTime (animation_pattern_handle AnimationProcHandle, u32 LayerHandle, animation_system* System) -{ - u32 NewBlockStart = System->CurrentFrame; - u32 NewBlockEnd = NewBlockStart + SecondsToFrames(3, *System); - animation* ActiveAnim = AnimationSystem_GetActiveAnimation(System); - handle AnimHandle = Animation_AddBlock(ActiveAnim, NewBlockStart, NewBlockEnd, AnimationProcHandle, LayerHandle); - return AnimHandle; -} - FOLDHAUS_INPUT_COMMAND_PROC(DeleteAnimationBlockCommand) { animation_timeline_state* PanelState = Panel_GetStateStruct(Panel, animation_timeline_state); handle SelectedBlockHandle = PanelState->SelectedBlockHandle; - animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem); + animation* ActiveAnim = AnimationArray_GetSafe(State->AnimationSystem.Animations, PanelState->EditingAnimationHandle); + if(SelectedBlockHandle.Index < ActiveAnim->Blocks_.Count && ActiveAnim->Blocks_.Generations[SelectedBlockHandle.Index] == SelectedBlockHandle.Generation) { @@ -112,6 +112,7 @@ StartDragTimeMarker(rect2 TimelineBounds, frame_range VisibleFrames, app_state* OPERATION_STATE_DEF(drag_animation_block_state) { rect2 TimelineBounds; + animation_handle EditingAnimationHandle; handle BlockHandle; frame_range VisibleRange; frame_range ClipRange; @@ -133,7 +134,9 @@ OPERATION_RENDER_PROC(UpdateDragAnimationBlock) { drag_animation_block_state* OpState = (drag_animation_block_state*)Operation.OpStateMemory; - animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem); + animation_array Animations = State->AnimationSystem.Animations; + animation_handle Handle = OpState->EditingAnimationHandle; + animation* ActiveAnim = AnimationArray_GetSafe(Animations, Handle); r32 ClipInitialStartFrameXPercent = FrameToPercentRange(OpState->ClipRange.Min, OpState->VisibleRange); u32 ClipInitialStartFrameXPosition = LerpR32(ClipInitialStartFrameXPercent, @@ -237,7 +240,10 @@ SelectAndBeginDragAnimationBlock(animation_timeline_state* TimelineState, handle { TimelineState->SelectedBlockHandle = BlockHandle; - animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem); + animation_handle Handle = TimelineState->EditingAnimationHandle; + animation_array Animations = State->AnimationSystem.Animations; + animation* ActiveAnim = AnimationArray_GetSafe(Animations, Handle); + operation_mode* DragAnimationBlockMode = ActivateOperationModeWithCommands(&State->Modes, DragAnimationBlockCommands, UpdateDragAnimationBlock); animation_block* SelectedBlock = Animation_GetBlockFromHandle(ActiveAnim, BlockHandle); @@ -245,29 +251,45 @@ SelectAndBeginDragAnimationBlock(animation_timeline_state* TimelineState, handle &State->Modes, drag_animation_block_state); OpState->TimelineBounds = TimelineBounds; + OpState->EditingAnimationHandle = Handle; OpState->BlockHandle = BlockHandle; OpState->VisibleRange = VisibleRange; OpState->ClipRange = SelectedBlock->Range; } // ------------------- -FOLDHAUS_INPUT_COMMAND_PROC(AddAnimationBlockCommand) +internal void +AnimationTimeline_AddAnimationBlockCommand(animation_timeline_state* TimelineState, app_state* State, context Context) { - animation_timeline_state* TimelineState = Panel_GetStateStruct(Panel, animation_timeline_state); + animation_handle Handle = TimelineState->EditingAnimationHandle; + animation_array Animations = State->AnimationSystem.Animations; + animation* ActiveAnim = AnimationArray_GetSafe(Animations, Handle); - animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem); - - frame_range Range = ActiveAnim->PlayableRange; - u32 MouseDownFrame = GetFrameFromPointInAnimationPanel(Mouse.Pos, Panel->Bounds, Range); - - animation_pattern_handle PatternHandle = Patterns_IndexToHandle(4); - handle NewBlockHandle = Animation_AddBlock(ActiveAnim, MouseDownFrame, MouseDownFrame + SecondsToFrames(3, State->AnimationSystem), PatternHandle, TimelineState->SelectedAnimationLayer); - TimelineState->SelectedBlockHandle = NewBlockHandle; + s32 StartFrame = State->AnimationSystem.CurrentFrame; + s32 EndFrame = StartFrame + SecondsToFrames(3, State->AnimationSystem); + EndFrame = Clamp(0, EndFrame, ActiveAnim->PlayableRange.Max); + if ((EndFrame - StartFrame) > 0) + { + animation_pattern_handle PatternHandle = Patterns_IndexToHandle(0); + s32 Layer = TimelineState->SelectedAnimationLayer; + if (Layer < 0) + { + Layer = Animation_AddLayer(ActiveAnim, MakeString("[New Layer]"), BlendMode_Add, &State->AnimationSystem); + AnimationTimeline_SelectLayer(TimelineState, Layer); + } + Assert(Layer >= 0); + + handle NewBlockHandle = Animation_AddBlock(ActiveAnim, StartFrame, EndFrame, PatternHandle, Layer); + + TimelineState->SelectedBlockHandle = NewBlockHandle; + } else { + // TODO(pjs): we don't want to create a block of zero frames + // since you won't be able to delete it. What do we do here?? + } } input_command AnimationTimeline_Commands[] = { { KeyCode_X, KeyCode_Invalid, Command_Began, DeleteAnimationBlockCommand }, - { KeyCode_A, KeyCode_Invalid, Command_Began, AddAnimationBlockCommand }, }; s32 AnimationTimeline_CommandsCount = 2; @@ -276,10 +298,17 @@ GSMetaTag(panel_type_animation_timeline); internal void AnimationTimeline_Init(panel* Panel, app_state* State, context Context) { + animation_handle Handle = State->AnimationSystem.ActiveFadeGroup.From; + // TODO: :FreePanelMemory - animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem); animation_timeline_state* TimelineState = PushStruct(&State->Permanent, animation_timeline_state); - TimelineState->VisibleRange = ActiveAnim->PlayableRange; + TimelineState->EditingAnimationHandle = Handle; + + if (IsValid(Handle)) { + animation_array Animations = State->AnimationSystem.Animations; + animation* ActiveAnim = AnimationArray_GetSafe(Animations, Handle); + TimelineState->VisibleRange = ActiveAnim->PlayableRange; + } Panel->StateMemory = StructToData(TimelineState, animation_timeline_state); } @@ -320,7 +349,7 @@ DrawFrameBar (animation_system* AnimationSystem, ui_interface Interface, frame_r r32 FramePercent = FrameToPercentRange(Frame, VisibleFrames); r32 FrameX = LerpR32(FramePercent, BarBounds.Min.x, BarBounds.Max.x); v2 FrameTextPos = v2{FrameX, BarBounds.Min.y + 2}; - DrawString(Interface.RenderBuffer, TempString, Interface.Style.Font, FrameTextPos, WhiteV4); + DrawString(Interface.RenderBuffer, TempString, Interface.Style.Font, FrameTextPos, WhiteV4, -1, GreenV4); } // Time Slider @@ -337,7 +366,7 @@ DrawFrameBar (animation_system* AnimationSystem, ui_interface Interface, frame_r v2 HeadMin = v2{SliderX - SliderHalfWidth, BarBounds.Min.y}; v2 HeadMax = v2{SliderX + SliderHalfWidth, BarBounds.Max.y}; PushRenderQuad2D(Interface.RenderBuffer, HeadMin, HeadMax, TimeSliderColor); - DrawString(Interface.RenderBuffer, TempString, Interface.Style.Font, HeadMin + v2{6, 4}, WhiteV4); + DrawString(Interface.RenderBuffer, TempString, Interface.Style.Font, HeadMin + v2{6, 4}, WhiteV4, -1, GreenV4); } } @@ -450,123 +479,10 @@ DrawLayerMenu(animation_system* AnimationSystem, animation ActiveAnim, ui_interf { PushRenderBoundingBox2D(Interface.RenderBuffer, LayerBounds.Min, LayerBounds.Max, 1, WhiteV4); } - DrawString(Interface.RenderBuffer, Layer->Name, Interface.Style.Font, LayerTextPos, WhiteV4); + DrawString(Interface.RenderBuffer, Layer->Name, Interface.Style.Font, LayerTextPos, WhiteV4, -1, GreenV4); } } -internal rect2 -DrawAnimationBlock (animation_block AnimationBlock, v4 BlockColor, frame_range VisibleFrames, rect2 TimelineBounds, render_command_buffer* RenderBuffer) -{ - rect2 BlockBounds = {}; - - r32 TimelineWidth = Rect2Width(TimelineBounds); - - u32 ClampedBlockStartFrame = ClampFrameToRange(AnimationBlock.Range.Min, VisibleFrames); - r32 StartFramePercent = FrameToPercentRange(ClampedBlockStartFrame, VisibleFrames); - r32 StartPosition = TimelineWidth * StartFramePercent; - - u32 ClampedBlockEndFrame = ClampFrameToRange(AnimationBlock.Range.Max, VisibleFrames); - r32 EndFramePercent = FrameToPercentRange(ClampedBlockEndFrame, VisibleFrames); - r32 EndPosition = TimelineWidth * EndFramePercent; - - r32 LayerYOffset = LAYER_HEIGHT * AnimationBlock.Layer; - BlockBounds.Min = TimelineBounds.Min + v2{StartPosition, LayerYOffset}; - BlockBounds.Max = TimelineBounds.Min + v2{EndPosition, LayerYOffset + LAYER_HEIGHT}; - - PushRenderQuad2D(RenderBuffer, BlockBounds.Min, BlockBounds.Max, BlockColor); - PushRenderBoundingBox2D(RenderBuffer, BlockBounds.Min, BlockBounds.Max, 1, WhiteV4); - - // TODO(pjs): If mouse is on one of the border hot spots, render an off colored square to signal the region is hot - - return BlockBounds; -} - -internal handle -DrawAnimationTimeline (animation_system* AnimationSystem, animation_timeline_state* TimelineState, rect2 PanelBounds, handle SelectedBlockHandle, ui_interface* Interface, app_state* State) -{ - gs_string Tempgs_string = PushString(State->Transient, 256); - handle Result = SelectedBlockHandle; - - animation CurrAnimation = *AnimationSystem_GetActiveAnimation(AnimationSystem); - - rect2 LayerMenuBounds, TimelineBounds; - RectVSplitAtDistanceFromLeft(PanelBounds, 256, &LayerMenuBounds, &TimelineBounds); - - // In Top To Bottom Order - rect2 TimelineFrameBarBounds; - rect2 TimelineBlockDisplayBounds; - rect2 TimelineRangeBarBounds; - RectHSplitAtDistanceFromTop(TimelineBounds, 32, &TimelineFrameBarBounds, &TimelineBounds); - RectHSplitAtDistanceFromBottom(TimelineBounds, 24, &TimelineBlockDisplayBounds, &TimelineRangeBarBounds); - - DrawLayerMenu(AnimationSystem, CurrAnimation, *Interface, LayerMenuBounds, &TimelineState->SelectedAnimationLayer); - - frame_range AdjustedViewRange = DrawTimelineRangeBar(AnimationSystem, CurrAnimation, TimelineState, *Interface, TimelineRangeBarBounds); - - DrawFrameBar(AnimationSystem, *Interface, AdjustedViewRange, TimelineFrameBarBounds, State); - - ui_FillRect(Interface, TimelineBlockDisplayBounds, v4{.25f, .25f, .25f, 1.0f}); - - // Animation Blocks - b32 MouseDownAndNotHandled = MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState); - handle DragBlockHandle = {0}; - for (u32 i = 0; i < CurrAnimation.Blocks_.Count; i++) - { - animation_block* AnimationBlockAt = CurrAnimation.Blocks_.Values + i; - - // If either end is in the range, we should draw it - b32 RangeIsVisible = (FrameIsInRange(AdjustedViewRange, AnimationBlockAt->Range.Min) || - FrameIsInRange(AdjustedViewRange, AnimationBlockAt->Range.Max)); - // If neither end is in the range, but the ends surround the visible range, - // we should still draw it. - RangeIsVisible |= (AnimationBlockAt->Range.Min <= AdjustedViewRange.Min && - AnimationBlockAt->Range.Max>= AdjustedViewRange.Max); - if (RangeIsVisible) - { - v4 BlockColor = BlackV4; - if (SelectedBlockHandle.Index == i && SelectedBlockHandle.Generation == CurrAnimation.Blocks_.Generations[i]) - { - BlockColor = PinkV4; - } - rect2 BlockBounds = DrawAnimationBlock(*AnimationBlockAt, BlockColor, AdjustedViewRange, TimelineBounds, Interface->RenderBuffer); - if (PointIsInRect(BlockBounds, Interface->Mouse.Pos)) - { - DragBlockHandle.Index = i; - DragBlockHandle.Generation = CurrAnimation.Blocks_.Generations[i]; - } - } - } - - if (MouseDownAndNotHandled && Handle_IsValid(DragBlockHandle)) - { - MouseDownAndNotHandled = false; - SelectAndBeginDragAnimationBlock(TimelineState, DragBlockHandle, AdjustedViewRange, TimelineBounds, State); - } - - // Time Slider - if (FrameIsInRange(AdjustedViewRange, AnimationSystem->CurrentFrame)) - { - r32 FrameAtPercentVisibleRange = FrameToPercentRange(AnimationSystem->CurrentFrame, AdjustedViewRange); - r32 SliderX = LerpR32(FrameAtPercentVisibleRange, TimelineBounds.Min.x, TimelineBounds.Max.x); - rect2 SliderBounds = { - v2{ SliderX, TimelineBounds.Min.y }, - v2{ SliderX + 1, TimelineBounds.Max.y } - }; - ui_FillRect(Interface, SliderBounds, TimeSliderColor); - } - - ui_OutlineRect(Interface, TimelineRangeBarBounds, 1.f, RedV4); - ui_OutlineRect(Interface, TimelineFrameBarBounds, 1.f, RedV4); - ui_OutlineRect(Interface, TimelineBlockDisplayBounds, 1.f, RedV4); - - if (MouseDownAndNotHandled && PointIsInRect(TimelineBounds, Interface->Mouse.Pos)) - { - TimelineState->SelectedBlockHandle = {0}; - } - - return Result; -} - PANEL_MODAL_OVERRIDE_CALLBACK(LoadAnimationFileCallback) { Assert(ReturningFrom->TypeIndex == PanelType_FileView); @@ -575,37 +491,19 @@ PANEL_MODAL_OVERRIDE_CALLBACK(LoadAnimationFileCallback) if (FileInfo.Path.Length > 0) { - gs_file AnimFile = ReadEntireFile(Context.ThreadContext.FileHandler, FileInfo.Path); - - gs_string AnimFileString = MakeString((char*)AnimFile.Data.Memory, AnimFile.Data.Size); - animation NewAnim = AnimParser_Parse(AnimFileString, State->AnimationSystem.Storage, State->Patterns); - NewAnim.FileInfo = AnimFile.FileInfo; - - u32 NewAnimIndex = AnimationArray_Push(&State->AnimationSystem.Animations, NewAnim); - State->AnimationSystem.ActiveAnimationIndex = NewAnimIndex; + animation_handle NewAnimHandle = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, + State->Patterns, + Context, + FileInfo.Path); + State->AnimationSystem.ActiveFadeGroup.From = NewAnimHandle; } } -internal void -DrawAnimationPatternList(rect2 PanelBounds, ui_interface* Interface, u32 SelectedAnimationLayerHandle, animation_system* AnimationSystem, animation_pattern_array Patterns) -{ - ui_PushLayout(Interface, PanelBounds, LayoutDirection_TopDown, MakeString("AnimClips Layout")); - for (u32 i = 0; i < Patterns.Count; i++) - { - animation_pattern Pattern = Patterns.Values[i]; - gs_string PatternName = MakeString(Pattern.Name, Pattern.NameLength); - if (ui_Button(Interface, PatternName)) - { - animation_pattern_handle PatternHandle = Patterns_IndexToHandle(i); - AddAnimationBlockAtCurrentTime(PatternHandle, SelectedAnimationLayerHandle, AnimationSystem); - } - } - ui_PopLayout(Interface, MakeString("AnimClips Layout")); -} - internal void PlayBar_Render(animation_timeline_state* TimelineState, rect2 Bounds, panel* Panel, render_command_buffer* RenderBuffer, app_state* State, context Context) { + DEBUG_TRACK_FUNCTION; + animation_system* AnimSystem = &State->AnimationSystem; ui_interface* Interface = &State->Interface; ui_PushLayout(Interface, Bounds, LayoutDirection_TopDown, MakeString("PlayBar Layout")); @@ -634,14 +532,20 @@ PlayBar_Render(animation_timeline_state* TimelineState, rect2 Bounds, panel* Pan } internal void -FrameCount_Render(animation_timeline_state* TimelineState, rect2 Bounds, render_command_buffer* RenderBuffer, app_state* State, context Context) +FrameCount_Render(animation_timeline_state* TimelineState, animation* ActiveAnim, rect2 Bounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { + DEBUG_TRACK_FUNCTION; + ui_interface* Interface = &State->Interface; gs_string TempString = PushString(State->Transient, 256); + // :FrameRange // frame_range VisibleFrames = TimelineState->VisibleRange; - animation ActiveAnim = *AnimationSystem_GetActiveAnimation(&State->AnimationSystem); - frame_range VisibleFrames = ActiveAnim.PlayableRange; + + frame_range VisibleFrames = {}; + if (ActiveAnim) { + VisibleFrames = ActiveAnim->PlayableRange; + } s32 VisibleFrameCount = VisibleFrames.Max - VisibleFrames.Min; @@ -657,7 +561,7 @@ FrameCount_Render(animation_timeline_state* TimelineState, rect2 Bounds, render_ r32 FramePercent = FrameToPercentRange(Frame, VisibleFrames); r32 FrameX = LerpR32(FramePercent, Bounds.Min.x, Bounds.Max.x); v2 FrameTextPos = v2{FrameX, Bounds.Min.y + 2}; - DrawString(Interface->RenderBuffer, TempString, Interface->Style.Font, FrameTextPos, WhiteV4); + DrawString(Interface->RenderBuffer, TempString, Interface->Style.Font, FrameTextPos, WhiteV4, -1, GreenV4); } // Time Slider @@ -675,7 +579,7 @@ FrameCount_Render(animation_timeline_state* TimelineState, rect2 Bounds, render_ v2 HeadMin = v2{SliderX - SliderHalfWidth, Bounds.Min.y}; v2 HeadMax = v2{SliderX + SliderHalfWidth, Bounds.Max.y}; PushRenderQuad2D(Interface->RenderBuffer, HeadMin, HeadMax, TimeSliderColor); - DrawString(Interface->RenderBuffer, TempString, Interface->Style.Font, HeadMin + v2{6, 4}, WhiteV4); + DrawString(Interface->RenderBuffer, TempString, Interface->Style.Font, HeadMin + v2{6, 4}, WhiteV4, -1, GreenV4); } // Interaction @@ -686,11 +590,33 @@ FrameCount_Render(animation_timeline_state* TimelineState, rect2 Bounds, render_ } } -internal void -LayerList_Render(animation_timeline_state* TimelineState, rect2 Bounds, panel* Panel, render_command_buffer* RenderBuffer, app_state* State, context Context) +internal bool +LayerList_DrawLayerButton (ui_interface* Interface, gs_string Name, rect2 Bounds, bool Selected) { + bool Result = ui_MouseClickedRect(*Interface, Bounds); + v2 TextPos = { Bounds.Min.x + 6, Bounds.Max.y - 16}; + + v4 BoxColor = WhiteV4; + bool DrawBox = Selected; + if (PointIsInRect(Bounds, Interface->Mouse.Pos)) + { + DrawBox = true; + BoxColor = PinkV4; + } + + if (DrawBox) + { + PushRenderBoundingBox2D(Interface->RenderBuffer, Bounds.Min, Bounds.Max, 1, BoxColor); + } + DrawString(Interface->RenderBuffer, Name, Interface->Style.Font, TextPos, WhiteV4, -1, GreenV4); + return Result; +} + +internal void +LayerList_Render(animation_timeline_state* TimelineState, animation* ActiveAnim, rect2 Bounds, panel* Panel, render_command_buffer* RenderBuffer, app_state* State, context Context) +{ + DEBUG_TRACK_FUNCTION; ui_interface* Interface = &State->Interface; - animation ActiveAnim = *AnimationSystem_GetActiveAnimation(&State->AnimationSystem); ui_FillRect(Interface, Bounds, Interface->Style.PanelBG); @@ -698,38 +624,84 @@ LayerList_Render(animation_timeline_state* TimelineState, rect2 Bounds, panel* P rect2 LayerBounds = {0}; LayerBounds.Min = Bounds.Min; LayerBounds.Max = LayerBounds.Min + LayerDim; - for (u32 i = 0; i < ActiveAnim.Layers.Count; i++) + + if (ActiveAnim) { - anim_layer* Layer = ActiveAnim.Layers.Values + i; - - if (ui_MouseClickedRect(*Interface, LayerBounds)) + v2 LayerTextPos = {}; + for (s32 i = 0; i < (s32)ActiveAnim->Layers.Count; i++) { - TimelineState->SelectedAnimationLayer = i; + anim_layer* Layer = ActiveAnim->Layers.Values + i; + + bool Selected = (TimelineState->SelectedAnimationLayer == i); + if (LayerList_DrawLayerButton(Interface, Layer->Name, LayerBounds, Selected)) + { + TimelineState->SelectedAnimationLayer = i; + } + LayerBounds = Rect2TranslateY(LayerBounds, LayerDim.y); } - v2 LayerTextPos = { LayerBounds.Min.x + 6, LayerBounds.Max.y - 16}; - if (TimelineState->SelectedAnimationLayer == i) + if (LayerList_DrawLayerButton(Interface, MakeString("+ Add Layer"), LayerBounds, false)) { - PushRenderBoundingBox2D(Interface->RenderBuffer, LayerBounds.Min, LayerBounds.Max, 1, WhiteV4); + u32 NewLayer = Animation_AddLayer(ActiveAnim, MakeString("[New Layer]"), BlendMode_Add, &State->AnimationSystem); } - DrawString(Interface->RenderBuffer, Layer->Name, Interface->Style.Font, LayerTextPos, WhiteV4); - - LayerBounds = Rect2TranslateY(LayerBounds, LayerDim.y); } } internal void -TimeRange_Render(animation_timeline_state* TimelineState, rect2 Bounds, render_command_buffer* RenderBuffer, app_state* State, context Context) +TimeRange_RenderBlock (rect2 BlockBounds, u32 BlockIndex, animation* ActiveAnim, handle SelectedBlockHandle, ui_interface* Interface, render_command_buffer* RenderBuffer) { + v4 BlockColor = BlackV4; + if (SelectedBlockHandle.Index == BlockIndex && SelectedBlockHandle.Generation == ActiveAnim->Blocks_.Generations[BlockIndex]) + { + BlockColor = TealV4; + } + + PushRenderQuad2D(RenderBuffer, BlockBounds.Min, BlockBounds.Max, BlockColor); + PushRenderBoundingBox2D(RenderBuffer, BlockBounds.Min, BlockBounds.Max, 1, WhiteV4); +} + +struct block_bounds_lut_entry +{ + rect2 Bounds; + u32 Index; +}; + +internal void +TimeRange_RenderBlockArray(block_bounds_lut_entry* Blocks, u32* LUT, u32 LUTCount, r32 HeightOffset, animation* ActiveAnim, handle SelectedBlockHandle, handle* DragBlockHandle, ui_interface* Interface, render_command_buffer* RenderBuffer) +{ + for (u32 i = 0; i < LUTCount; i++) + { + u32 BlockBoundsIndex = LUT[i]; + block_bounds_lut_entry Block = Blocks[BlockBoundsIndex]; + Block.Bounds.Max.y += HeightOffset; + + TimeRange_RenderBlock(Block.Bounds, Block.Index, ActiveAnim, SelectedBlockHandle, Interface, RenderBuffer); + + if (PointIsInRect(Block.Bounds, Interface->Mouse.Pos)) + { + DragBlockHandle->Index = Block.Index; + DragBlockHandle->Generation = ActiveAnim->Blocks_.Generations[Block.Index]; + } + } +} + +internal void +TimeRange_Render(animation_timeline_state* TimelineState, animation* ActiveAnim, rect2 Bounds, render_command_buffer* RenderBuffer, app_state* State, context Context) +{ + DEBUG_TRACK_FUNCTION; + ui_interface* Interface = &State->Interface; - animation ActiveAnim = *AnimationSystem_GetActiveAnimation(&State->AnimationSystem); // TODO(pjs): setting the timeline to show the entire range // of the current animation until I reimplement the range // slider bars // :FrameRange // frame_range ViewRange = TimelineState->VisibleRange; - frame_range ViewRange = ActiveAnim.PlayableRange; + frame_range ViewRange = {}; + if (ActiveAnim) + { + ViewRange = ActiveAnim->PlayableRange; + } handle SelectedBlockHandle = TimelineState->SelectedBlockHandle; s32 CurrentFrame = State->AnimationSystem.CurrentFrame; @@ -737,31 +709,110 @@ TimeRange_Render(animation_timeline_state* TimelineState, rect2 Bounds, render_c // Animation Blocks b32 MouseDownAndNotHandled = MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState); handle DragBlockHandle = {0}; - for (u32 i = 0; i < ActiveAnim.Blocks_.Count; i++) + if (ActiveAnim) { - animation_block* AnimationBlockAt = ActiveAnim.Blocks_.Values + i; + u32 BlocksCountMax = ActiveAnim->Blocks_.Count; + u32 BlocksCount = 0; + block_bounds_lut_entry* Blocks = PushArray(State->Transient, block_bounds_lut_entry, BlocksCountMax); - // If either end is in the range, we should draw it - b32 RangeIsVisible = (FrameIsInRange(ViewRange, AnimationBlockAt->Range.Min) || - FrameIsInRange(ViewRange, AnimationBlockAt->Range.Max)); - // If neither end is in the range, but the ends surround the visible range, - // we should still draw it. - RangeIsVisible |= (AnimationBlockAt->Range.Min <= ViewRange.Min && - AnimationBlockAt->Range.Max>= ViewRange.Max); - if (RangeIsVisible) + u32 FrontBlocksCount = 0; + u32* FrontBlocks = PushArray(State->Transient, u32, BlocksCountMax); + u32 BackBlocksCount = 0; + u32* BackBlocks = PushArray(State->Transient, u32, BlocksCountMax); + + for (u32 l = 0; l < ActiveAnim->Layers.Count; l++) { - v4 BlockColor = BlackV4; - if (SelectedBlockHandle.Index == i && SelectedBlockHandle.Generation == ActiveAnim.Blocks_.Generations[i]) - { - BlockColor = PinkV4; - } - rect2 BlockBounds = DrawAnimationBlock(*AnimationBlockAt, BlockColor, ViewRange, Bounds, Interface->RenderBuffer); + BlocksCount = 0; + FrontBlocksCount = 0; + BackBlocksCount = 0; - if (PointIsInRect(BlockBounds, Interface->Mouse.Pos)) + for (u32 i = 0; i < ActiveAnim->Blocks_.Count; i++) { - DragBlockHandle.Index = i; - DragBlockHandle.Generation = ActiveAnim.Blocks_.Generations[i]; + animation_block* AnimationBlockAt = ActiveAnim->Blocks_.Values + i; + if (AnimationBlockAt->Layer != l) continue; + + // If either end is in the range, we should draw it + b32 RangeIsVisible = (FrameIsInRange(ViewRange, AnimationBlockAt->Range.Min) || + FrameIsInRange(ViewRange, AnimationBlockAt->Range.Max)); + // If neither end is in the range, but the ends surround the visible range, + // we should still draw it. + RangeIsVisible |= (AnimationBlockAt->Range.Min <= ViewRange.Min && + AnimationBlockAt->Range.Max>= ViewRange.Max); + if (!RangeIsVisible) continue; + + r32 TimelineWidth = Rect2Width(Bounds); + + frame_range BlockAtRange = AnimationBlockAt->Range; + u32 ClampedBlockStartFrame = ClampFrameToRange(BlockAtRange.Min, ViewRange); + r32 StartFramePercent = FrameToPercentRange(ClampedBlockStartFrame, ViewRange); + r32 StartPosition = TimelineWidth * StartFramePercent; + + u32 ClampedBlockEndFrame = ClampFrameToRange(BlockAtRange.Max, ViewRange); + r32 EndFramePercent = FrameToPercentRange(ClampedBlockEndFrame, ViewRange); + r32 EndPosition = TimelineWidth * EndFramePercent; + + r32 LayerYOffset = LAYER_HEIGHT * AnimationBlockAt->Layer; + + rect2 NewBlockBounds = {}; + NewBlockBounds.Min = Bounds.Min + v2{StartPosition, LayerYOffset}; + NewBlockBounds.Max = Bounds.Min + v2{EndPosition, LayerYOffset + LAYER_HEIGHT}; + + block_bounds_lut_entry NewBlock = {}; + NewBlock.Bounds = NewBlockBounds; + NewBlock.Index = i; + + // fast (implementation-wise) insert sort. + // TODO(PS): probably not great + for (u32 j = 0; j < BlocksCount; j++) + { + if (Blocks[j].Bounds.Min.x > NewBlock.Bounds.Min.x) + { + block_bounds_lut_entry Old = Blocks[j]; + Blocks[j] = NewBlock; + NewBlock = Old; + } + } + Blocks[BlocksCount++] = NewBlock; } + + // BlockBounds are sorted by their render bounds from left to right + // This iterates over them to see if any on the same layer overlap, and if + // so, shrinks one of them, putting it in a new list + for (u32 i = 0; i < BlocksCount; i++) + { + if (i % 2 == 0) + { + BackBlocks[BackBlocksCount++] = i; + continue; + } + + bool ShortCandidate = false; + block_bounds_lut_entry Block = Blocks[i]; + if (i > 0) + { + block_bounds_lut_entry PrevBlock = Blocks[i - 1]; + rect2 Union = Rect2Union(PrevBlock.Bounds, Block.Bounds); + ShortCandidate |= Rect2Width(Union) > 0; + } + if (i < BlocksCount - 1) + { + block_bounds_lut_entry NextBlock = Blocks[i + 1]; + rect2 Union = Rect2Union(NextBlock.Bounds, Block.Bounds); + ShortCandidate |= Rect2Width(Union) > 0; + } + + if (ShortCandidate) + { + FrontBlocks[FrontBlocksCount++] = i; + } + else + { + BackBlocks[BackBlocksCount++] = i; + } + } + + TimeRange_RenderBlockArray(Blocks, BackBlocks, BackBlocksCount, 0, ActiveAnim, SelectedBlockHandle, &DragBlockHandle, Interface, RenderBuffer); + TimeRange_RenderBlockArray(Blocks, FrontBlocks, FrontBlocksCount, -15, ActiveAnim, SelectedBlockHandle, &DragBlockHandle, Interface, RenderBuffer); } } @@ -793,24 +844,64 @@ TimeRange_Render(animation_timeline_state* TimelineState, rect2 Bounds, render_c } internal void -AnimInfoView_Render(animation_timeline_state* TimelineState, rect2 Bounds, panel* Panel, render_command_buffer* RenderBuffer, app_state* State, context Context) +AnimInfoView_SaveAnimFile (gs_const_string Path, app_state* State, context Context) { - animation_system* AnimSystem = &State->AnimationSystem; - animation* ActiveAnim = AnimationSystem_GetActiveAnimation(AnimSystem); + animation_handle ActiveAnimHandle = State->AnimationSystem.ActiveFadeGroup.From; + animation ActiveAnim = *AnimationArray_GetSafe(State->AnimationSystem.Animations, ActiveAnimHandle); + gs_string FileText = AnimSerializer_Serialize(ActiveAnim, State->Patterns, State->Transient); + + if (!WriteEntireFile(Context.ThreadContext.FileHandler, Path, StringToData(FileText))) + { + InvalidCodePath; + } +} + +PANEL_MODAL_OVERRIDE_CALLBACK(AnimInfoView_SaveAnimFileCallback) +{ + Assert(ReturningFrom->TypeIndex == PanelType_FileView); + file_view_state* FileViewState = Panel_GetStateStruct(ReturningFrom, file_view_state); + gs_file_info FileInfo = FileViewState->SelectedFile; + + AnimInfoView_SaveAnimFile(FileInfo.Path, State, Context); +} + +internal void +AnimationTimeline_SetActiveAnimation (animation_handle Handle, animation_timeline_state* TimelineState) +{ + TimelineState->NextActiveAnim = Handle; +} + +internal void +AnimInfoView_Render(animation_timeline_state* TimelineState, animation* ActiveAnim, rect2 Bounds, panel* Panel, render_command_buffer* RenderBuffer, app_state* State, context Context) +{ + DEBUG_TRACK_FUNCTION; + animation_system* AnimSystem = &State->AnimationSystem; + + animation_handle ActiveAnimHandle = State->AnimationSystem.ActiveFadeGroup.From; ui_interface* Interface = &State->Interface; - ui_PushLayout(Interface, Bounds, LayoutDirection_TopDown, MakeString("AnimInfo Layout")); + ui_PushLayout(Interface, Bounds, LayoutDirection_TopDown, MakeString("AnimInfo Layout"), ActiveAnimHandle.Index); ui_FillRect(&State->Interface, Bounds, Interface->Style.PanelBG); - if (ui_BeginLabeledDropdown(Interface, MakeString("Active Animation"), ActiveAnim->Name)) + gs_string AnimName = {}; + if (ActiveAnim) + { + AnimName = ActiveAnim->Name; + } else { + AnimName = MakeString("[None]"); + } + + if (ui_BeginLabeledDropdown(Interface, MakeString("Active Animation"), AnimName)) { for (u32 i = 0; i < AnimSystem->Animations.Count; i++) { animation Animation = AnimSystem->Animations.Values[i]; if (ui_Button(Interface, Animation.Name)) { - AnimSystem->ActiveAnimationIndex = i; + animation_handle NewHandle = {}; + NewHandle.Index = i; + AnimationTimeline_SetActiveAnimation(NewHandle, TimelineState); } } } @@ -820,23 +911,31 @@ AnimInfoView_Render(animation_timeline_state* TimelineState, rect2 Bounds, panel { if (ui_Button(Interface, MakeString("New"))) { - animation NewAnim = {}; - NewAnim.Name = PushString(State->AnimationSystem.Storage, 256); + animation_desc Desc = {}; + Desc.NameSize = 256; + Desc.LayersCount = 8; + Desc.BlocksCount = 8; + Desc.MinFrames = 0; + Desc.MaxFrames = SecondsToFrames(15, State->AnimationSystem); - u32 NewAnimIndex = AnimationArray_Push(&State->AnimationSystem.Animations, NewAnim); - State->AnimationSystem.ActiveAnimationIndex = NewAnimIndex; + animation NewAnim = Animation_Create(Desc, &State->AnimationSystem); + animation_handle NewAnimHandle = AnimationArray_Push(&State->AnimationSystem.Animations, NewAnim); + AnimationTimeline_SetActiveAnimation(NewAnimHandle, TimelineState); } - if (ui_Button(Interface, MakeString("Save"))) + if (ActiveAnim && ui_Button(Interface, MakeString("Save"))) { // Save Animation File // TODO(pjs): If you created the animation via the "new" button, there won't be a file attached. // need to use the file browser to create a file - u32 ActiveAnimIndex = State->AnimationSystem.ActiveAnimationIndex; - animation ActiveAnimation = State->AnimationSystem.Animations.Values[ActiveAnimIndex]; - gs_string FileText = AnimSerializer_Serialize(ActiveAnimation, State->Patterns, State->Transient); - if (WriteEntireFile(Context.ThreadContext.FileHandler, ActiveAnimation.FileInfo.Path, StringToData(FileText))) + animation ActiveAnimation = *AnimationArray_GetSafe(State->AnimationSystem.Animations, ActiveAnimHandle); + + if (!ActiveAnimation.FileInfo.Path.Str) { - InvalidCodePath; + panel* FileBrowser = PanelSystem_PushPanel(&State->PanelSystem, PanelType_FileView, State, Context); + FileView_SetMode(FileBrowser, FileViewMode_Save); + Panel_PushModalOverride(Panel, FileBrowser, AnimInfoView_SaveAnimFileCallback); + } else { + AnimInfoView_SaveAnimFile(ActiveAnimation.FileInfo.Path, State, Context); } } if (ui_Button(Interface, MakeString("Load"))) @@ -848,39 +947,75 @@ AnimInfoView_Render(animation_timeline_state* TimelineState, rect2 Bounds, panel } ui_EndRow(Interface); - ui_TextEntry(Interface, MakeString("Anim Name"), &ActiveAnim->Name); - - ui_Label(Interface, MakeString("Frame Range")); - ui_BeginRow(Interface, 3); + if (ActiveAnim) { - ActiveAnim->PlayableRange.Min = ui_TextEntryU64(Interface, MakeString("StartFrame"), ActiveAnim->PlayableRange.Min); - ActiveAnim->PlayableRange.Max = ui_TextEntryU64(Interface, MakeString("EndFrame"), ActiveAnim->PlayableRange.Max); - - } - ui_EndRow(Interface); - - animation_block* SelectedBlock = Animation_GetBlockFromHandle(ActiveAnim, TimelineState->SelectedBlockHandle); - if (SelectedBlock) - { - animation_pattern BlockPattern = Patterns_GetPattern(State->Patterns, SelectedBlock->AnimationProcHandle); + ui_TextEntry(Interface, MakeString("Anim Name"), &ActiveAnim->Name); + ui_Label(Interface, MakeString("Frame Range")); ui_BeginRow(Interface, 3); - ui_Label(Interface, MakeString("Selected Pattern")); - //if (ui_BeginLabeledDropdown(Interface, MakeString("Selected Pattern"), MakeString(BlockPattern.Name, BlockPattern.NameLength))) - if (ui_BeginDropdown(Interface, MakeString(BlockPattern.Name, BlockPattern.NameLength))) { - for (u32 i = 0; i < State->Patterns.Count; i++) + ActiveAnim->PlayableRange.Min = ui_TextEntryU64(Interface, MakeString("StartFrame"), ActiveAnim->PlayableRange.Min); + ActiveAnim->PlayableRange.Max = ui_TextEntryU64(Interface, MakeString("EndFrame"), ActiveAnim->PlayableRange.Max); + + } + ui_EndRow(Interface); + + ui_Label(Interface, MakeString("Layer")); + + s32 LayerIndex = TimelineState->SelectedAnimationLayer; + anim_layer* SelectedLayer = 0; + if (LayerIndex >= 0) + { + SelectedLayer = ActiveAnim->Layers.Values + LayerIndex; + + ui_TextEntry(Interface, MakeString("Layer Name"), &SelectedLayer->Name); + gs_string BlendStr = BlendModeStrings[SelectedLayer->BlendMode]; + if (ui_BeginLabeledDropdown(Interface, MakeString("Blend Mode"), BlendStr)) { - animation_pattern Pattern = State->Patterns.Values[i]; - if (ui_Button(Interface, MakeString(Pattern.Name, Pattern.NameLength))) + for (u32 i = 0; i < BlendMode_Count; i++) { - SelectedBlock->AnimationProcHandle = Patterns_IndexToHandle(i); + if (ui_Button(Interface, BlendModeStrings[i])) + { + SelectedLayer->BlendMode = (blend_mode)i; + } } } + ui_EndLabeledDropdown(Interface); + } + + ui_Label(Interface, MakeString("Pattern")); + + animation_block* SelectedBlock = Animation_GetBlockFromHandle(ActiveAnim, TimelineState->SelectedBlockHandle); + if (SelectedBlock) + { + animation_pattern BlockPattern = Patterns_GetPattern(State->Patterns, SelectedBlock->AnimationProcHandle); + + ui_BeginRow(Interface, 2); + ui_Label(Interface, MakeString("Selected Pattern")); + if (ui_BeginDropdown(Interface, MakeString(BlockPattern.Name, BlockPattern.NameLength))) + { + Interface->ActiveLayout->Bounds.Max.x += 128.0f; + Interface->ActiveLayout->Columns[0].XMax += 128.0f; + + ui_BeginList(Interface, MakeString("Patterns List"), 5, State->Patterns.Count); + for (u32 i = 0; i < State->Patterns.Count; i++) + { + animation_pattern Pattern = State->Patterns.Values[i]; + if (ui_Button(Interface, MakeString(Pattern.Name, Pattern.NameLength))) + { + SelectedBlock->AnimationProcHandle = Patterns_IndexToHandle(i); + } + } + ui_EndList(Interface); + } + ui_EndLabeledDropdown(Interface); + } + + if (ui_Button(Interface, MakeString("+ Add Block"))) + { + AnimationTimeline_AddAnimationBlockCommand(TimelineState, State, Context); } - ui_EndLabeledDropdown(Interface); } - ui_PopLayout(Interface, MakeString("AnimInfo Layout")); } @@ -895,8 +1030,20 @@ GSMetaTag(panel_type_animation_timeline); internal void AnimationTimeline_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { + DEBUG_TRACK_FUNCTION; + animation_timeline_state* TimelineState = Panel_GetStateStruct(Panel, animation_timeline_state); + animation* ActiveAnim = 0; + animation_handle Handle = State->AnimationSystem.ActiveFadeGroup.From; + TimelineState->NextActiveAnim = Handle; + if (IsValid(Handle)) + { + animation_array Animations = State->AnimationSystem.Animations; + ActiveAnim = AnimationArray_GetSafe(Animations, Handle); + TimelineState->EditingAnimationHandle = Handle; + } + ui_FillRect(&State->Interface, PanelBounds, v4{.1f,.1f,.1f,1.f}); rect2 TimelineBounds, InfoBounds; @@ -913,10 +1060,18 @@ AnimationTimeline_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RectHSplitAtDistanceFromTop(TimeRangePanelBounds, TitleBarHeight, &FrameCountBounds, &TimeRangeBounds); PlayBar_Render(TimelineState, PlayBarBounds, Panel, RenderBuffer, State, Context); - FrameCount_Render(TimelineState, FrameCountBounds, RenderBuffer, State, Context); - LayerList_Render(TimelineState, LayersBounds, Panel, RenderBuffer, State, Context); - TimeRange_Render(TimelineState, TimeRangeBounds, RenderBuffer, State, Context); - AnimInfoView_Render(TimelineState, InfoBounds, Panel, RenderBuffer, State, Context); + FrameCount_Render(TimelineState, ActiveAnim, FrameCountBounds, RenderBuffer, State, Context); + LayerList_Render(TimelineState, ActiveAnim, LayersBounds, Panel, RenderBuffer, State, Context); + TimeRange_Render(TimelineState, ActiveAnim, TimeRangeBounds, RenderBuffer, State, Context); + AnimInfoView_Render(TimelineState, ActiveAnim, InfoBounds, Panel, RenderBuffer, State, Context); + + if (!AnimHandlesAreEqual(TimelineState->NextActiveAnim, + Handle)) + { + State->AnimationSystem.ActiveFadeGroup.From = TimelineState->NextActiveAnim; + TimelineState->EditingAnimationHandle = TimelineState->NextActiveAnim; + TimelineState->SelectedAnimationLayer = -1; + } } #define FOLDHAUS_PANEL_ANIMATION_TIMELINE_H diff --git a/src/app/editor/panels/foldhaus_panel_assembly_debug.h b/src/app/editor/panels/foldhaus_panel_assembly_debug.h index 2f4f1a2..4ef3599 100644 --- a/src/app/editor/panels/foldhaus_panel_assembly_debug.h +++ b/src/app/editor/panels/foldhaus_panel_assembly_debug.h @@ -43,72 +43,102 @@ AssemblyDebug_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* Ren ui_interface* Interface = &State->Interface; ui_PushLayout(Interface, PanelBounds, LayoutDirection_TopDown, MakeString("Assembly Debug Layout")); - InterfaceAssert(Interface->PerFrameMemory); - - gs_string OverrideStr = MakeString(OverrideTypeStrings[State->AssemblyDebugState.Override]); - if (ui_BeginLabeledDropdown(Interface, MakeString("Override"), OverrideStr)) + ui_BeginRow(Interface, 2); { - for (u32 i = 0; i < ADS_Override_Count; i++) + if (ui_Button(Interface, MakeString("Assembly"))) { - if (ui_Button(Interface, MakeString(OverrideTypeStrings[i]))) - { - State->AssemblyDebugState.Override = (override_type)i; - } + State->ShowingUserSpaceDebug = false; + } + + if (ui_Button(Interface, MakeString("User Space"))) + { + State->ShowingUserSpaceDebug = true; } } - ui_EndLabeledDropdown(Interface); - InterfaceAssert(Interface->PerFrameMemory); + ui_EndRow(Interface); - switch (State->AssemblyDebugState.Override) + if (State->ShowingUserSpaceDebug && State->UserSpaceDesc.CustomDebugUI) { - case ADS_Override_TagWhite: - case ADS_Override_TagStripWhite: + US_CustomDebugUI(&State->UserSpaceDesc, Panel, PanelBounds, RenderBuffer, + State, Context); + } + else + { + InterfaceAssert(Interface->PerFrameMemory); + + State->AssemblyDebugState.AllAssemblies = ui_ToggleText(Interface, MakeString("All Assemblies"), State->AssemblyDebugState.AllAssemblies); + + gs_string OverrideStr = MakeString(OverrideTypeStrings[State->AssemblyDebugState.Override]); + if (ui_BeginLabeledDropdown(Interface, MakeString("Override"), OverrideStr)) { - ui_LabeledTextEntry(Interface, MakeString("Tag Name"), &State->AssemblyDebugState.TagName); - ui_LabeledTextEntry(Interface, MakeString("Tag Value"), &State->AssemblyDebugState.TagValue); - - if (State->AssemblyDebugState.Override == ADS_Override_TagStripWhite) + for (u32 i = 0; i < ADS_Override_Count; i++) { + if (ui_Button(Interface, MakeString(OverrideTypeStrings[i]))) + { + State->AssemblyDebugState.Override = (override_type)i; + } + } + } + ui_EndLabeledDropdown(Interface); + InterfaceAssert(Interface->PerFrameMemory); + + switch (State->AssemblyDebugState.Override) + { + case ADS_Override_TagWhite: + case ADS_Override_TagStripWhite: + { + ui_LabeledTextEntry(Interface, MakeString("Tag Name"), &State->AssemblyDebugState.TagName); + ui_LabeledTextEntry(Interface, MakeString("Tag Value"), &State->AssemblyDebugState.TagValue); + + if (State->AssemblyDebugState.Override == ADS_Override_TagStripWhite) + { + State->AssemblyDebugState.TargetAssembly = ui_LabeledTextEntryU64(Interface, MakeString("Assembly"), State->AssemblyDebugState.TargetAssembly); + + State->AssemblyDebugState.TargetStrip = ui_LabeledTextEntryU64(Interface, MakeString("Strip"), State->AssemblyDebugState.TargetStrip); + } + }break; + + case ADS_Override_ChannelWhite: + { + u64 Board = 0; + u64 Strip = 0; + Board = ui_LabeledTextEntryU64(Interface, MakeString("Board"), Board); + Strip = ui_LabeledTextEntryU64(Interface, MakeString("Strip"), Strip); + + State->AssemblyDebugState.TargetChannel = FSC(Board, Strip); + }break; + + case ADS_Override_AllOff: + case ADS_Override_AllRed: + case ADS_Override_AllGreen: + case ADS_Override_AllBlue: + case ADS_Override_AllWhite: + { + State->AssemblyDebugState.Brightness = (u8)ui_LabeledRangeSlider(Interface, MakeString("Brightness"), (r32)State->AssemblyDebugState.Brightness, 0, 255); + State->AssemblyDebugState.TargetAssembly = ui_LabeledTextEntryU64(Interface, MakeString("Assembly"), State->AssemblyDebugState.TargetAssembly); + }break; + + case ADS_Override_AllHue: + { + State->AssemblyDebugState.TargetHue = (u32)ui_LabeledRangeSlider(Interface, MakeString("Hue"), (r32)State->AssemblyDebugState.TargetHue, 0, 360); + }break; + + default: + { + InterfaceAssert(Interface->PerFrameMemory); + State->AssemblyDebugState.TargetAssembly = ui_LabeledTextEntryU64(Interface, MakeString("Assembly"), State->AssemblyDebugState.TargetAssembly); + InterfaceAssert(Interface->PerFrameMemory); + State->AssemblyDebugState.TargetStrip = ui_LabeledTextEntryU64(Interface, MakeString("Strip"), State->AssemblyDebugState.TargetStrip); - } - }break; - - case ADS_Override_ChannelWhite: - { - u64 Board = 0; - u64 Strip = 0; - Board = ui_LabeledTextEntryU64(Interface, MakeString("Board"), Board); - Strip = ui_LabeledTextEntryU64(Interface, MakeString("Strip"), Strip); - - State->AssemblyDebugState.TargetChannel = FSC(Board, Strip); - }break; - - case ADS_Override_AllRed: - case ADS_Override_AllGreen: - case ADS_Override_AllBlue: - case ADS_Override_AllWhite: - { - State->AssemblyDebugState.Brightness = (u8)ui_LabeledRangeSlider(Interface, MakeString("Brightness"), (r32)State->AssemblyDebugState.Brightness, 0, 255); - }break; - - default: - { - InterfaceAssert(Interface->PerFrameMemory); - - State->AssemblyDebugState.TargetAssembly = ui_LabeledTextEntryU64(Interface, MakeString("Assembly"), State->AssemblyDebugState.TargetAssembly); - - InterfaceAssert(Interface->PerFrameMemory); - - State->AssemblyDebugState.TargetStrip = ui_LabeledTextEntryU64(Interface, MakeString("Strip"), State->AssemblyDebugState.TargetStrip); - - InterfaceAssert(Interface->PerFrameMemory); - }break; + + InterfaceAssert(Interface->PerFrameMemory); + }break; + } } - ui_RangeSlider(Interface, MakeString("Test"), .5f, 0, 1); - + State->SendEmptyPackets = ui_LabeledToggle(Interface, MakeString("Send Empty Packets"), State->SendEmptyPackets); ui_PopLayout(Interface, MakeString("Assembly Debug Layout")); } diff --git a/src/app/editor/panels/foldhaus_panel_file_view.h b/src/app/editor/panels/foldhaus_panel_file_view.h index eaf5013..64b03d5 100644 --- a/src/app/editor/panels/foldhaus_panel_file_view.h +++ b/src/app/editor/panels/foldhaus_panel_file_view.h @@ -7,40 +7,42 @@ enum file_view_mode { - FileViewMode_Load, - FileViewMode_Save, + FileViewMode_Load, + FileViewMode_Save, }; struct file_view_state { - file_view_mode Mode; - - gs_string WorkingDirectory; - gs_memory_arena FileNamesArena; - gs_file_info_array FileNames; - - gs_file_info SelectedFile; + file_view_mode Mode; + + gs_string WorkingDirectory; + gs_string DisplayDirectory; + + gs_memory_arena FileNamesArena; + gs_file_info_array FileNames; + + gs_file_info SelectedFile; }; internal void FileView_SetMode(panel* Panel, file_view_mode Mode) { - file_view_state* FileViewState = Panel_GetStateStruct(Panel, file_view_state); - FileViewState->Mode = Mode; + file_view_state* FileViewState = Panel_GetStateStruct(Panel, file_view_state); + FileViewState->Mode = Mode; } internal void FileView_Exit_(panel* FileViewPanel, app_state* State, context Context) { - // TODO(pjs): Free State->FileNamesArena - - Assert(FileViewPanel->IsModalOverrideFor != 0); - panel* ReturnTo = FileViewPanel->IsModalOverrideFor; - if (ReturnTo->ModalOverrideCB) - { - ReturnTo->ModalOverrideCB(FileViewPanel, State, Context); - } - Panel_PopModalOverride(ReturnTo, &State->PanelSystem); + // TODO(pjs): Free State->FileNamesArena + + Assert(FileViewPanel->IsModalOverrideFor != 0); + panel* ReturnTo = FileViewPanel->IsModalOverrideFor; + if (ReturnTo->ModalOverrideCB) + { + ReturnTo->ModalOverrideCB(FileViewPanel, State, Context); + } + Panel_PopModalOverride(ReturnTo, &State->PanelSystem); } global input_command* FileView_Commands = 0; @@ -49,31 +51,35 @@ s32 FileView_CommandsCount = 0; internal void FileView_UpdateWorkingDirectory(gs_const_string WorkingDirectory, file_view_state* State, context Context) { - ClearArena(&State->FileNamesArena); + // NOTE(pjs): make sure we're only passing valid directory paths to the + // function + char LastChar = WorkingDirectory.Str[WorkingDirectory.Length - 1]; + Assert(LastChar == '\\' || LastChar == '/'); + MemoryArenaClear(&State->FileNamesArena); + + + gs_string SanitizedDir = PushString(Context.ThreadContext.Transient, WorkingDirectory.Length + 2); + SanitizePath(WorkingDirectory, &SanitizedDir, Context.ThreadContext.Transient); + if (SanitizedDir.Str[SanitizedDir.Length - 1] != '\\') + { + AppendPrintF(&SanitizedDir, "\\"); + } + + gs_const_string SanitizedDisplayDir = SanitizedDir.ConstString; + + gs_file_info NewWorkingDir = GetFileInfo(Context.ThreadContext.FileHandler, SanitizedDir.ConstString); + if (NewWorkingDir.IsDirectory) + { + AppendPrintF(&SanitizedDir, "*"); + NullTerminate(&SanitizedDir); - gs_const_string SanitizedDirectory = WorkingDirectory; + State->FileNames = EnumerateDirectory(Context.ThreadContext.FileHandler, &State->FileNamesArena, SanitizedDir.ConstString, EnumerateDirectory_IncludeDirectories); - u32 LastSlashIndex = FindLast(SanitizedDirectory, '\\'); - gs_const_string LastDir = Substring(SanitizedDirectory, LastSlashIndex + 1, SanitizedDirectory.Length); - if (StringsEqual(LastDir, ConstString(".."))) - { - u32 SecondLastSlashIndex = FindLast(SanitizedDirectory, LastSlashIndex - 1, '\\'); - SanitizedDirectory = Substring(SanitizedDirectory, 0, SecondLastSlashIndex); - } - else if (StringsEqual(LastDir, ConstString(".")) && LastDir.Length > 1) - { - SanitizedDirectory = Substring(SanitizedDirectory, 0, LastSlashIndex); - } - - gs_file_info NewWorkingDirectory = GetFileInfo(Context.ThreadContext.FileHandler, SanitizedDirectory); - if (NewWorkingDirectory.IsDirectory) - { - // NOTE(pjs): we might be printing from State->WorkingDirectory to State->WorkingDirectory - // in some cases. Shouldn't be a problem but it is unnecessary - PrintF(&State->WorkingDirectory, "%S", WorkingDirectory); - - State->FileNames = EnumerateDirectory(Context.ThreadContext.FileHandler, &State->FileNamesArena, State->WorkingDirectory.ConstString, EnumerateDirectory_IncludeDirectories); - } + // NOTE(pjs): we might be printing from State->WorkingDirectory to State->WorkingDirectory + // in some cases. Shouldn't be a problem but it is unnecessary + PrintF(&State->WorkingDirectory, "%S", SanitizedDir.ConstString); + PrintF(&State->DisplayDirectory, "%S", SanitizedDisplayDir); + } } GSMetaTag(panel_init); @@ -81,14 +87,16 @@ GSMetaTag(panel_type_file_view); internal void FileView_Init(panel* Panel, app_state* State, context Context) { - // TODO: :FreePanelMemory - file_view_state* FileViewState = PushStruct(&State->Permanent, file_view_state); - Panel->StateMemory = StructToData(FileViewState, file_view_state); - FileViewState->FileNamesArena = CreateMemoryArena(Context.ThreadContext.Allocator); - - // TODO(pjs): this shouldn't be stored in permanent - FileViewState->WorkingDirectory = PushString(&State->Permanent, 256); - FileView_UpdateWorkingDirectory(ConstString("."), FileViewState, Context); + // TODO: :FreePanelMemory + file_view_state* FileViewState = PushStruct(&State->Permanent, file_view_state); + Panel->StateMemory = StructToData(FileViewState, file_view_state); + FileViewState->FileNamesArena = MemoryArenaCreate(MB(4), Bytes(8), Context.ThreadContext.Allocator, 0, 0, "File View - File Names Arena"); + + // TODO(pjs): this shouldn't be stored in permanent + FileViewState->DisplayDirectory = PushString(&State->Permanent, 1024); + FileViewState->WorkingDirectory = PushString(&State->Permanent, 1024); + + FileView_UpdateWorkingDirectory(ConstString(".\\"), FileViewState, Context); } GSMetaTag(panel_cleanup); @@ -96,7 +104,7 @@ GSMetaTag(panel_type_file_view); internal void FileView_Cleanup(panel* Panel, app_state* State) { - + } GSMetaTag(panel_render); @@ -104,60 +112,87 @@ GSMetaTag(panel_type_file_view); internal void FileView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { - file_view_state* FileViewState = Panel_GetStateStruct(Panel, file_view_state); - Assert(FileViewState->Mode == FileViewMode_Save); - - ui_PushLayout(&State->Interface, PanelBounds, LayoutDirection_TopDown, MakeString("FileView Layout")); + file_view_state* FileViewState = Panel_GetStateStruct(Panel, file_view_state); + + ui_PushLayout(&State->Interface, PanelBounds, LayoutDirection_TopDown, MakeString("FileView Layout")); + { + ui_BeginRow(&State->Interface, 3); { - if (ui_Button(&State->Interface, MakeString("Exit"))) + if (FileViewState->Mode == FileViewMode_Save) + { + if (ui_Button(&State->Interface, MakeString("Save"))) { - FileView_Exit_(Panel, State, Context); + if (!FileViewState->SelectedFile.Path.Str) + { + FileViewState->SelectedFile.Path = FileViewState->DisplayDirectory.ConstString; + } + + FileView_Exit_(Panel, State, Context); } - - // Header - if (ui_TextEntry(&State->Interface, MakeString("pwd"), &FileViewState->WorkingDirectory)) - { - // if last character is a slash, update pwd, and clear the filter string - // otherwise update the filter string - gs_string Pwd = FileViewState->WorkingDirectory; - char LastChar = Pwd.Str[Pwd.Length - 1]; - if (LastChar == '\\' || LastChar == '/') - { - FileView_UpdateWorkingDirectory(Pwd.ConstString, FileViewState, Context); - } - else - { - - } - } - - // File Display - ui_BeginList(&State->Interface, MakeString("Files"), 10, FileViewState->FileNames.Count); - for (u32 i = 0; i < FileViewState->FileNames.Count; i++) - { - gs_file_info File = FileViewState->FileNames.Values[i]; - - u32 LastSlashIndex = FindLast(File.Path, '\\'); - gs_const_string FileName = Substring(File.Path, LastSlashIndex + 1, File.Path.Length); - gs_string PathString = PushString(State->Transient, FileName.Length); - PrintF(&PathString, "%S", FileName); - - if (ui_LayoutListButton(&State->Interface, PathString, i)) - { - if (File.IsDirectory) - { - FileView_UpdateWorkingDirectory(File.Path, FileViewState, Context); - } - else - { - FileViewState->SelectedFile = File; - FileView_Exit_(Panel, State, Context); - } - } - } - ui_EndList(&State->Interface); + } + + if (ui_Button(&State->Interface, MakeString("Exit"))) + { + FileView_Exit_(Panel, State, Context); + } } - ui_PopLayout(&State->Interface, MakeString("FileView Layout")); + ui_EndRow(&State->Interface); + + // Header + if (ui_TextEntry(&State->Interface, MakeString("pwd"), &FileViewState->DisplayDirectory)) + { + // if last character is a slash, update pwd, and clear the filter string + // otherwise update the filter string + gs_string Pwd = FileViewState->DisplayDirectory; + char LastChar = Pwd.Str[Pwd.Length - 1]; + if (LastChar == '\\' || LastChar == '/') + { + FileView_UpdateWorkingDirectory(Pwd.ConstString, FileViewState, Context); + } + else + { + + } + } + + // File Display + ui_BeginList(&State->Interface, MakeString("Files"), 10, FileViewState->FileNames.Count); + for (u32 i = 0; i < FileViewState->FileNames.Count; i++) + { + gs_file_info File = FileViewState->FileNames.Values[i]; + + u32 LastSlashIndex = FindLast(File.Path, File.Path.Length - 2, '\\'); + gs_const_string FileName = Substring(File.Path, LastSlashIndex + 1, File.Path.Length); + gs_string PathString = PushString(State->Transient, FileName.Length); + PrintF(&PathString, "%S", FileName); + + if (ui_LayoutListButton(&State->Interface, PathString, i)) + { + if (File.IsDirectory) + { + FileView_UpdateWorkingDirectory(File.Path, FileViewState, Context); + } + else + { + FileViewState->SelectedFile = File; + switch (FileViewState->Mode) + { + case FileViewMode_Load: + { + FileView_Exit_(Panel, State, Context); + } break; + + case FileViewMode_Save: + { + + } break; + } + } + } + } + ui_EndList(&State->Interface); + } + ui_PopLayout(&State->Interface, MakeString("FileView Layout")); } diff --git a/src/app/editor/panels/foldhaus_panel_hierarchy.h b/src/app/editor/panels/foldhaus_panel_hierarchy.h index 13d45fe..8731660 100644 --- a/src/app/editor/panels/foldhaus_panel_hierarchy.h +++ b/src/app/editor/panels/foldhaus_panel_hierarchy.h @@ -30,7 +30,7 @@ PANEL_MODAL_OVERRIDE_CALLBACK(LoadAssemblyCallback) file_view_state* FileViewState = Panel_GetStateStruct(ReturningFrom, file_view_state); gs_file_info FileInfo = FileViewState->SelectedFile; - LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, FileInfo.Path, State->GlobalLog); + LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, FileInfo.Path, GlobalLogBuffer); } GSMetaTag(panel_render); @@ -69,7 +69,7 @@ HierarchyView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* Ren if (ui_Button(&State->Interface, MakeString("+ Add Assembly"))) { panel* FileBrowser = PanelSystem_PushPanel(&State->PanelSystem, PanelType_FileView, State, Context); - FileView_SetMode(FileBrowser, FileViewMode_Save); + FileView_SetMode(FileBrowser, FileViewMode_Load); Panel_PushModalOverride(Panel, FileBrowser, LoadAssemblyCallback); } ui_EndRow(&State->Interface); diff --git a/src/app/editor/panels/foldhaus_panel_message_log.h b/src/app/editor/panels/foldhaus_panel_message_log.h new file mode 100644 index 0000000..76d7d59 --- /dev/null +++ b/src/app/editor/panels/foldhaus_panel_message_log.h @@ -0,0 +1,46 @@ +/* date = April 12th 2021 4:47 pm */ + +#ifndef FOLDHAUS_PANEL_MESSAGE_LOG_H +#define FOLDHAUS_PANEL_MESSAGE_LOG_H + +GSMetaTag(panel_init); +GSMetaTag(panel_type_file_view); +internal void +MessageLog_Init(panel* Panel, app_state* State, context Context) +{ +} + +GSMetaTag(panel_cleanup); +GSMetaTag(panel_type_file_view); +internal void +MessageLog_Cleanup(panel* Panel, app_state* State) +{ + +} + +GSMetaTag(panel_render); +GSMetaTag(panel_type_file_view); +internal void +MessageLog_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) +{ + ui_interface* Interface = &State->Interface; + ui_widget* Layout = ui_PushLayout(Interface, PanelBounds, LayoutDirection_TopDown, MakeString("Message Log Layout")); + + ui_BeginList(Interface, MakeString("Message Log List"), 10, GlobalLogBuffer->EntriesCount); + + log_buffer_iter Iter = Log_GetIter(GlobalLogBuffer); + while (true) + { + log_entry* At = Iter.At; + ui_Label(Interface, At->String); + if (!LogIter_CanAdvance(Iter)) + { + break; + } + LogIter_Advance(&Iter); + } + ui_EndList(Interface); + + ui_PopLayout(Interface, MakeString("Message Log Layout")); +} +#endif //FOLDHAUS_PANEL_MESSAGE_LOG_H diff --git a/src/app/editor/panels/foldhaus_panel_profiler.h b/src/app/editor/panels/foldhaus_panel_profiler.h index 405b50f..c0ecd79 100644 --- a/src/app/editor/panels/foldhaus_panel_profiler.h +++ b/src/app/editor/panels/foldhaus_panel_profiler.h @@ -13,7 +13,7 @@ GSMetaTag(panel_type_profiler); internal void ProfilerView_Init(panel* Panel, app_state* State, context Context) { - + } GSMetaTag(panel_cleanup); @@ -21,146 +21,217 @@ GSMetaTag(panel_type_profiler); internal void ProfilerView_Cleanup(panel* Panel, app_state* State) { - + } internal void RenderProfiler_ScopeVisualization(ui_interface* Interface, ui_widget* Layout, debug_frame* VisibleFrame, gs_memory_arena* Transient) { - rect2 Bounds = ui_LayoutRemaining(*Layout); - r32 Width = Rect2Width(Bounds); - r32 DepthHeight = 32; + rect2 Bounds = ui_LayoutRemaining(*Layout); + r32 Width = Rect2Width(Bounds); + r32 DepthHeight = 32; + + s64 FrameStartCycles = VisibleFrame->FrameStartCycles; + r32 FrameTotalCycles = (r32)(VisibleFrame->FrameEndCycles - VisibleFrame->FrameStartCycles); + + r32 NextThreadTop = Bounds.Max.y; + + for (s32 t = 0; t < VisibleFrame->ThreadCount; t++) + { + debug_scope_record_list ThreadCalls = VisibleFrame->ThreadCalls[t]; - s64 FrameStartCycles = VisibleFrame->FrameStartCycles; - r32 FrameTotalCycles = (r32)(VisibleFrame->FrameEndCycles - VisibleFrame->FrameStartCycles); + gs_string String = PushString(Transient, 256); - r32 NextThreadTop = Bounds.Max.y; + r32 ThreadScopeMin = Bounds.Max.y; - for (s32 t = 0; t < VisibleFrame->ThreadCount; t++) + //PrintF(&String, "Thread %d", ThreadCalls.ThreadId); + //ui_Label(Interface, String, rect2{ThreadScopeMin); + + r32 Hue = (r32)(t) / (r32)(VisibleFrame->ThreadCount); + Hue += (.5f * (t % 2)); + v4 ThreadHSV = v4{ 360.0f * Hue, .5f, 1.0f, 1.0f }; + v4 ThreadRGB = HSVToRGB(ThreadHSV); + + for (s32 i = 0; i < ThreadCalls.Count; i++) { - debug_scope_record_list ThreadCalls = VisibleFrame->ThreadCalls[t]; - - gs_string String = PushString(Transient, 256); - - r32 ThreadScopeMin = Bounds.Max.y; - - //PrintF(&String, "Thread %d", ThreadCalls.ThreadId); - //ui_Label(Interface, String, rect2{ThreadScopeMin); - - r32 Hue = (r32)(t) / (r32)(VisibleFrame->ThreadCount); - Hue += (.5f * (t % 2)); - v4 ThreadHSV = v4{ 360.0f * Hue, .5f, 1.0f, 1.0f }; - v4 ThreadRGB = HSVToRGB(ThreadHSV); - - for (s32 i = 0; i < ThreadCalls.Count; i++) + scope_record* Record = ThreadCalls.Calls + i; + scope_name* Name = GetOrAddNameHashEntry(VisibleFrame, Record->NameHash); + s64 OffsetStart = Record->StartCycles - FrameStartCycles; + s64 OffsetEnd = Record->EndCycles - FrameStartCycles; + r32 PercentStart = (r32)(OffsetStart) / FrameTotalCycles; + r32 PercentEnd = (r32)(OffsetEnd) / FrameTotalCycles; + r32 PercentWidth = PercentEnd - PercentStart; + + rect2 ScopeBounds = { + v2{0, 0}, + v2{PercentWidth * Width, DepthHeight - 4}, + }; + v2 Offset = { + Bounds.Min.x + (PercentStart * Width), + NextThreadTop - ((Record->CallDepth + 1) * DepthHeight) + }; + ScopeBounds = Rect2Translate(ScopeBounds, Offset); + ThreadScopeMin = Min(ScopeBounds.Min.y, ThreadScopeMin); + + if (Rect2Width(ScopeBounds) >= 1) + { + v4 Color = ThreadRGB; + if (PointIsInRect(ScopeBounds, Interface->Mouse.Pos)) { - scope_record* Record = ThreadCalls.Calls + i; - scope_name* Name = GetOrAddNameHashEntry(VisibleFrame, Record->NameHash); - s64 OffsetStart = Record->StartCycles - FrameStartCycles; - s64 OffsetEnd = Record->EndCycles - FrameStartCycles; - r32 PercentStart = (r32)(OffsetStart) / FrameTotalCycles; - r32 PercentEnd = (r32)(OffsetEnd) / FrameTotalCycles; - r32 PercentWidth = PercentEnd - PercentStart; - - rect2 ScopeBounds = { - v2{0, 0}, - v2{PercentWidth * Width, DepthHeight - 4}, - }; - v2 Offset = { - Bounds.Min.x + (PercentStart * Width), - NextThreadTop - ((Record->CallDepth + 1) * DepthHeight) - }; - ScopeBounds = Rect2Translate(ScopeBounds, Offset); - ThreadScopeMin = Min(ScopeBounds.Min.y, ThreadScopeMin); - - if (Rect2Width(ScopeBounds) >= 1) - { - v4 Color = ThreadRGB; - if (PointIsInRect(ScopeBounds, Interface->Mouse.Pos)) - { - Color = GreenV4; - - ui_BeginMousePopup(Interface, rect2{ 25, 25, 300, 57 }, LayoutDirection_TopDown, MakeString("Hover")); - { - s64 Cycles = (Record->EndCycles - Record->StartCycles); - r32 PercentFrame = (r32)(Cycles) / FrameTotalCycles; - PrintF(&String, "%S : %.2f%% frame | %dcy", - Name->Name, - PercentFrame, - Cycles); - ui_Label(Interface, String); - } - ui_EndMousePopup(Interface); - } - - ui_FillRect(Interface, ScopeBounds, Color); - ui_OutlineRect(Interface, ScopeBounds, 1, BlackV4); - } + Color = GreenV4; + + ui_BeginMousePopup(Interface, rect2{ 25, 25, 300, 57 }, LayoutDirection_TopDown, MakeString("Hover")); + { + s64 Cycles = (Record->EndCycles - Record->StartCycles); + r32 PercentFrame = (r32)(Cycles) / FrameTotalCycles; + PrintF(&String, "%S : %.2f%% frame | %dcy", + Name->Name, + PercentFrame, + Cycles); + ui_Label(Interface, String); + } + ui_EndMousePopup(Interface); } - NextThreadTop = ThreadScopeMin; + ui_FillRect(Interface, ScopeBounds, Color); + ui_OutlineRect(Interface, ScopeBounds, 1, BlackV4); + } } + + NextThreadTop = ThreadScopeMin; + } } internal void RenderProfiler_ListVisualization(ui_interface* Interface, ui_widget* Layout, debug_frame* VisibleFrame, gs_memory_arena* Memory) { - char Backbuffer[256]; - gs_string String = MakeString(Backbuffer, 0, 256); - - ui_column_spec ColumnWidths[] = { - { UIColumnSize_Fixed, 256 }, - { UIColumnSize_Fixed, 128 }, - { UIColumnSize_Fixed, 128 }, - { UIColumnSize_Fixed, 128 }, - { UIColumnSize_Fixed, 128 }}; - ui_BeginRow(Interface, 5, &ColumnWidths[0]); + char Backbuffer[256]; + gs_string String = MakeString(Backbuffer, 0, 256); + + ui_column_spec ColumnWidths[] = { + { UIColumnSize_Fixed, 256 }, + { UIColumnSize_Fixed, 128 }, + { UIColumnSize_Fixed, 128 }, + { UIColumnSize_Fixed, 128 }, + { UIColumnSize_Fixed, 128 }}; + ui_BeginRow(Interface, 5, &ColumnWidths[0]); + { + ui_Label(Interface, MakeString("Procedure")); + ui_Label(Interface, MakeString("% Frame")); + ui_Label(Interface, MakeString("Seconds")); + ui_Label(Interface, MakeString("Cycles")); + ui_Label(Interface, MakeString("Calls")); + } + ui_EndRow(Interface); + + s32 CountedScopes = 0; + for (s32 n = 0; n < VisibleFrame->ScopeNamesMax; n++) + { + scope_name NameEntry = VisibleFrame->ScopeNamesHash[n]; + if (NameEntry.Hash != 0) { - ui_Label(Interface, MakeString("Procedure")); - ui_Label(Interface, MakeString("% Frame")); - ui_Label(Interface, MakeString("Seconds")); - ui_Label(Interface, MakeString("Cycles")); - ui_Label(Interface, MakeString("Calls")); + CountedScopes += 1; } - ui_EndRow(Interface); - - s32 CountedScopes = 0; - for (s32 n = 0; n < VisibleFrame->ScopeNamesMax; n++) + } + + ui_BeginList(Interface, MakeString("Scope List"), 10, CountedScopes); + ui_BeginRow(Interface, 5, &ColumnWidths[0]); + for (s32 n = 0; n < VisibleFrame->ScopeNamesMax; n++) + { + scope_name NameEntry = VisibleFrame->ScopeNamesHash[n]; + if (NameEntry.Hash != 0) { - scope_name NameEntry = VisibleFrame->ScopeNamesHash[n]; - if (NameEntry.Hash != 0) - { - CountedScopes += 1; - } + collated_scope_record* CollatedRecord = VisibleFrame->CollatedScopes + n; + + PrintF(&String, "%S", NameEntry.Name); + ui_Label(Interface, String); + + PrintF(&String, "%f%%", CollatedRecord->PercentFrameTime); + ui_Label(Interface, String); + + PrintF(&String, "%fs", CollatedRecord->TotalSeconds); + ui_Label(Interface, String); + + PrintF(&String, "%dcy", CollatedRecord->TotalCycles); + ui_Label(Interface, String); + + PrintF(&String, "%d", CollatedRecord->CallCount); + ui_Label(Interface, String); } + } + ui_EndRow(Interface); + ui_EndList(Interface); +} + +struct mem_amt +{ + u64 OrigSize; + r64 Size; + char* Units; +}; + +internal mem_amt +GetMemAmt (u64 BytesCount) +{ + mem_amt Result = {}; + Result.OrigSize = BytesCount; + Result.Size = (r64)BytesCount; + Result.Units = "bytes"; + + u32 i = 0; + char* UnitList[] = { "kb", "mb", "gb", "tb" }; + while (Result.Size > 1024) { + Result.Size /= 1024.0; + Result.Units = UnitList[i++]; + } + + return Result; +} + +internal void +RenderProfiler_MemoryView(ui_interface* Interface, ui_widget* Layout, app_state* State, context Context, gs_memory_arena* Memory) +{ + gs_debug_allocations_list* DA = Context.ThreadContext.Allocator.DEBUGAllocList; + + gs_string TempString = PushString(State->Transient, 256); + + mem_amt MemFootprint = GetMemAmt(DA->AllocationsSizeTotal); + u64 AllocCount = DA->AllocationsCount; + + PrintF(&TempString, "Total Memory Size: %.2f %s | Allocations: %lld", MemFootprint.Size, MemFootprint.Units, AllocCount); + ui_Label(Interface, TempString); + + ui_column_spec ColumnWidths[] = { + { UIColumnSize_Fill, 0 }, + { UIColumnSize_Fixed,256 }, + }; + ui_BeginRow(Interface, 2, &ColumnWidths[0]); + { + ui_Label(Interface, MakeString("Location")); + ui_Label(Interface, MakeString("Alloc Size")); + } + ui_EndRow(Interface); + + ui_BeginList(Interface, MakeString("Alloc List"), 10, DA->AllocationsCount); + ui_BeginRow(Interface, 2, &ColumnWidths[0]); + + for (gs_debug_memory_allocation* A = DA->Root; + A && A->Next != 0; + A = A->Next) + { + gs_const_string Str = ConstString(A->Loc.File); + u64 LastSlash = FindLastFromSet(Str, "\\/"); + gs_const_string JustFileName = Substring(Str, LastSlash + 1, Str.Length); + PrintF(&TempString, "%s:%s(%d)", JustFileName.Str, A->Loc.Function, A->Loc.Line); + ui_Label(Interface, TempString); - ui_BeginList(Interface, MakeString("Scope List"), 10, CountedScopes); - ui_BeginRow(Interface, 5, &ColumnWidths[0]); - for (s32 n = 0; n < VisibleFrame->ScopeNamesMax; n++) - { - scope_name NameEntry = VisibleFrame->ScopeNamesHash[n]; - if (NameEntry.Hash != 0) - { - collated_scope_record* CollatedRecord = VisibleFrame->CollatedScopes + n; - - PrintF(&String, "%S", NameEntry.Name); - ui_Label(Interface, String); - - PrintF(&String, "%f%%", CollatedRecord->PercentFrameTime); - ui_Label(Interface, String); - - PrintF(&String, "%fs", CollatedRecord->TotalSeconds); - ui_Label(Interface, String); - - PrintF(&String, "%dcy", CollatedRecord->TotalCycles); - ui_Label(Interface, String); - - PrintF(&String, "%d", CollatedRecord->CallCount); - ui_Label(Interface, String); - } - } - ui_EndRow(Interface); - ui_EndList(Interface); + mem_amt Amt = GetMemAmt(A->Size); + + PrintF(&TempString, "%.2f %s", Amt.Size, Amt.Units); + ui_Label(Interface, TempString); + } + ui_EndRow(Interface); + ui_EndList(Interface); } GSMetaTag(panel_render); @@ -168,93 +239,120 @@ GSMetaTag(panel_type_profiler); internal void ProfilerView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { - gs_memory_arena* Memory = State->Transient; - gs_string String = PushString(Memory, 256); - - v4 FrameColors[] = { GreenV4, YellowV4, RedV4, WhiteV4 }; - - r32 FrameListHeight = 64; - rect2 FrameListBounds, ProcListBounds; - RectHSplitAtDistanceFromTop(PanelBounds, FrameListHeight, &FrameListBounds, &ProcListBounds); - rect2 FrameListInner = RectInset(FrameListBounds, 4); - - r32 SingleFrameStep = Rect2Width(FrameListInner) / DEBUG_FRAME_COUNT; + gs_memory_arena* Memory = State->Transient; + gs_string String = PushString(Memory, 256); + + v4 FrameColors[] = { GreenV4, YellowV4, RedV4, WhiteV4 }; + + r32 FrameListHeight = 64; + rect2 FrameListBounds, ProcListBounds; + RectHSplitAtDistanceFromTop(PanelBounds, FrameListHeight, &FrameListBounds, &ProcListBounds); + rect2 FrameListInner = RectInset(FrameListBounds, 4); + + s32 FramesToDisplay = DEBUG_FRAME_COUNT; + if (FramesToDisplay != 0) + { + r32 SingleFrameStep = Rect2Width(FrameListInner) / FramesToDisplay; r32 SingleFrameWidth = (r32)((s32)SingleFrameStep - 2); ui_OutlineRect(&State->Interface, FrameListBounds, 2, WhiteV4); if (MouseButtonHeldDown(Context.Mouse.LeftButtonState)) { - if (PointIsInRect(FrameListBounds, Context.Mouse.Pos)) + if (PointIsInRect(FrameListBounds, Context.Mouse.Pos)) + { + v2 LocalMouse = Rect2GetRectLocalPoint(FrameListBounds, Context.Mouse.Pos); + s32 ClosestFrameIndex = (LocalMouse.x / SingleFrameStep); + if (ClosestFrameIndex >= 0 && ClosestFrameIndex < FramesToDisplay) { - v2 LocalMouse = Rect2GetRectLocalPoint(FrameListBounds, Context.Mouse.Pos); - s32 ClosestFrameIndex = (LocalMouse.x / SingleFrameStep); - if (ClosestFrameIndex >= 0 && ClosestFrameIndex < DEBUG_FRAME_COUNT) - { - GlobalDebugServices->RecordFrames = false; - GlobalDebugServices->CurrentDebugFrame = ClosestFrameIndex; - } + GlobalDebugServices->RecordFrames = false; + GlobalDebugServices->CurrentDebugFrame = ClosestFrameIndex; } + } } rect2 FrameBounds = MakeRect2MinDim(FrameListInner.Min, v2{SingleFrameWidth, Rect2Height(FrameListInner)}); for (s32 F = 0; F < DEBUG_FRAME_COUNT; F++) { - rect2 PositionedFrameBounds = Rect2TranslateX(FrameBounds, F * SingleFrameStep); - s32 FramesAgo = (GlobalDebugServices->CurrentDebugFrame - F); - if (FramesAgo < 0) { FramesAgo += DEBUG_FRAME_COUNT; } - v4 Color = FrameColors[Clamp(0, FramesAgo, 3)]; - ui_FillRect(&State->Interface, PositionedFrameBounds, Color); + rect2 PositionedFrameBounds = Rect2TranslateX(FrameBounds, F * SingleFrameStep); + s32 FramesAgo = (GlobalDebugServices->CurrentDebugFrame - F); + if (FramesAgo < 0) { FramesAgo += DEBUG_FRAME_COUNT; } + v4 Color = FrameColors[Clamp(0, FramesAgo, 3)]; + ui_FillRect(&State->Interface, PositionedFrameBounds, Color); } - - debug_frame* VisibleFrame = GetLastDebugFrame(GlobalDebugServices); - - ui_widget* Layout = ui_PushLayout(&State->Interface, ProcListBounds, LayoutDirection_TopDown, MakeString("Profiler Layout")); - + } + + ui_widget* Layout = ui_PushLayout(&State->Interface, ProcListBounds, LayoutDirection_TopDown, MakeString("Profiler Layout")); + + debug_frame* VisibleFrame = GetLastDebugFrame(GlobalDebugServices); + if (VisibleFrame) + { ui_BeginRow(&State->Interface, 4); { - s64 FrameStartCycles = VisibleFrame->FrameStartCycles; - s64 FrameTotalCycles = VisibleFrame->FrameEndCycles - VisibleFrame->FrameStartCycles; - u32 CurrentDebugFrame = GlobalDebugServices->CurrentDebugFrame - 1; - PrintF(&String, "Frame %d", CurrentDebugFrame); - ui_Label(&State->Interface, String); - - PrintF(&String, "Total Cycles: %lld", FrameTotalCycles); - ui_Label(&State->Interface, String); - - // NOTE(NAME): Skipping a space for aesthetic reasons, not functional, and could - // be removed, or used for something else - ui_ReserveBounds(&State->Interface, Layout, true); - - if (ui_Button(&State->Interface, MakeString("Resume Recording"))) - { - GlobalDebugServices->RecordFrames = true; - } + s64 FrameStartCycles = VisibleFrame->FrameStartCycles; + s64 FrameTotalCycles = VisibleFrame->FrameEndCycles - VisibleFrame->FrameStartCycles; + u32 CurrentDebugFrame = GlobalDebugServices->CurrentDebugFrame - 1; + PrintF(&String, "Frame %d", CurrentDebugFrame); + ui_Label(&State->Interface, String); + + PrintF(&String, "Total Cycles: %lld", FrameTotalCycles); + ui_Label(&State->Interface, String); + + // NOTE(NAME): Skipping a space for aesthetic reasons, not functional, and could + // be removed, or used for something else + ui_ReserveBounds(&State->Interface, Layout, true); + + if (ui_Button(&State->Interface, MakeString("Resume Recording"))) + { + GlobalDebugServices->RecordFrames = true; + } } ui_EndRow(&State->Interface); - - ui_BeginRow(&State->Interface, 8); + } + + ui_BeginRow(&State->Interface, 8); + { + if (ui_Button(&State->Interface, MakeString("Profiler"))) { - if (ui_Button(&State->Interface, MakeString("Scope View"))) - { - GlobalDebugServices->Interface.FrameView = FRAME_VIEW_PROFILER; - } - if (ui_Button(&State->Interface, MakeString("List View"))) - { - GlobalDebugServices->Interface.FrameView = FRAME_VIEW_SCOPE_LIST; - } + GlobalDebugServices->Interface.FrameView = DebugUI_Profiler; } - ui_EndRow(&State->Interface); - - if (GlobalDebugServices->Interface.FrameView == FRAME_VIEW_PROFILER) + if (ui_Button(&State->Interface, MakeString("List View"))) { + GlobalDebugServices->Interface.FrameView = DebugUI_ScopeList; + } + if (ui_Button(&State->Interface, MakeString("Memory"))) + { + GlobalDebugServices->Interface.FrameView = DebugUI_MemoryView; + } + } + ui_EndRow(&State->Interface); + + switch (GlobalDebugServices->Interface.FrameView) + { + case DebugUI_Profiler: + { + if (VisibleFrame) + { RenderProfiler_ScopeVisualization(&State->Interface, Layout, VisibleFrame, Memory); - } - else - { - RenderProfiler_ListVisualization(&State->Interface, Layout, VisibleFrame, Memory); - } + } + }break; - ui_PopLayout(&State->Interface, MakeString("Profiler Layout")); + case DebugUI_ScopeList: + { + if (VisibleFrame) + { + RenderProfiler_ListVisualization(&State->Interface, Layout, VisibleFrame, Memory); + } + }break; + + case DebugUI_MemoryView: + { + RenderProfiler_MemoryView(&State->Interface, Layout, State, Context, Memory); + }break; + + InvalidDefaultCase; + } + + ui_PopLayout(&State->Interface, MakeString("Profiler Layout")); } diff --git a/src/app/editor/panels/foldhaus_panel_sculpture_view.h b/src/app/editor/panels/foldhaus_panel_sculpture_view.h index 6d4c803..474d5ca 100644 --- a/src/app/editor/panels/foldhaus_panel_sculpture_view.h +++ b/src/app/editor/panels/foldhaus_panel_sculpture_view.h @@ -13,49 +13,49 @@ struct sculpture_view_panel_state { - camera Camera; + camera Camera; }; // 3D Mouse View OPERATION_STATE_DEF(mouse_rotate_view_operation_state) { - v4 CameraStartPos; - camera* Camera; + v4 CameraStartPos; + camera* Camera; }; OPERATION_RENDER_PROC(Update3DViewMouseRotate) { - mouse_rotate_view_operation_state* OpState = (mouse_rotate_view_operation_state*)Operation.OpStateMemory; - - v2 TotalDeltaPos = Mouse.Pos - Mouse.DownPos; - - m44 XRotation = M44RotationX(-TotalDeltaPos.y * PIXEL_TO_WORLD_SCALE); - m44 YRotation = M44RotationY(TotalDeltaPos.x * PIXEL_TO_WORLD_SCALE); - m44 Combined = XRotation * YRotation; - - OpState->Camera->Position = (Combined * OpState->CameraStartPos).xyz; + mouse_rotate_view_operation_state* OpState = (mouse_rotate_view_operation_state*)Operation.OpStateMemory; + + v2 TotalDeltaPos = Mouse.Pos - Mouse.DownPos; + + m44 XRotation = M44RotationX(-TotalDeltaPos.y * PIXEL_TO_WORLD_SCALE); + m44 YRotation = M44RotationY(TotalDeltaPos.x * PIXEL_TO_WORLD_SCALE); + m44 Combined = XRotation * YRotation; + + OpState->Camera->Position = (Combined * OpState->CameraStartPos).xyz; } FOLDHAUS_INPUT_COMMAND_PROC(End3DViewMouseRotate) { - DeactivateCurrentOperationMode(&State->Modes); + DeactivateCurrentOperationMode(&State->Modes); } input_command MouseRotateViewCommands [] = { - { KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, End3DViewMouseRotate}, + { KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Ended, End3DViewMouseRotate}, }; FOLDHAUS_INPUT_COMMAND_PROC(Begin3DViewMouseRotate) { - sculpture_view_panel_state* PanelState = Panel_GetStateStruct(Panel, sculpture_view_panel_state); - - operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, MouseRotateViewCommands, Update3DViewMouseRotate); - mouse_rotate_view_operation_state* OpState = CreateOperationState(RotateViewMode, - &State->Modes, - mouse_rotate_view_operation_state); - OpState->CameraStartPos = ToV4Point(PanelState->Camera.Position); - OpState->Camera = &PanelState->Camera; + sculpture_view_panel_state* PanelState = Panel_GetStateStruct(Panel, sculpture_view_panel_state); + + operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, MouseRotateViewCommands, Update3DViewMouseRotate); + mouse_rotate_view_operation_state* OpState = CreateOperationState(RotateViewMode, + &State->Modes, + mouse_rotate_view_operation_state); + OpState->CameraStartPos = ToV4Point(PanelState->Camera.Position); + OpState->Camera = &PanelState->Camera; } // ---------------- @@ -63,7 +63,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(Begin3DViewMouseRotate) GSMetaTag(panel_commands); GSMetaTag(panel_type_sculpture_view); global input_command SculptureView_Commands[] = { - { KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Began, Begin3DViewMouseRotate }, + { KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Began, Begin3DViewMouseRotate }, }; global s32 SculptureView_CommandsCount = 1; @@ -72,16 +72,16 @@ GSMetaTag(panel_type_sculpture_view); internal void SculptureView_Init(panel* Panel, app_state* State, context Context) { - sculpture_view_panel_state* PanelState = PushStruct(&State->Permanent, sculpture_view_panel_state); - - PanelState->Camera.FieldOfView = 45.0f; - PanelState->Camera.AspectRatio = RectAspectRatio(State->WindowBounds); - PanelState->Camera.Near = .1f; - PanelState->Camera.Far = 800.0f; - PanelState->Camera.Position = v3{0, 0, 400}; - PanelState->Camera.LookAt = v3{0, 0, 0}; - - Panel->StateMemory = StructToData(PanelState, sculpture_view_panel_state); + sculpture_view_panel_state* PanelState = PushStruct(&State->Permanent, sculpture_view_panel_state); + + PanelState->Camera.FieldOfView = 45.0f; + PanelState->Camera.AspectRatio = RectAspectRatio(State->WindowBounds); + PanelState->Camera.Near = .1f; + PanelState->Camera.Far = 800.0f; + PanelState->Camera.Position = v3{0, 0, 400}; + PanelState->Camera.LookAt = v3{0, 0, 0}; + + Panel->StateMemory = StructToData(PanelState, sculpture_view_panel_state); } GSMetaTag(panel_cleanup); @@ -89,92 +89,92 @@ GSMetaTag(panel_type_sculpture_view); internal void SculptureView_Cleanup(panel* Panel, app_state* State) { - + } struct draw_leds_job_data { - v4 CameraPosition; - led_buffer LedBuffer; - s32 StartIndex; - s32 OnePastLastIndex; - render_quad_batch_constructor* Batch; - quad_batch_constructor_reserved_range BatchReservedRange; - r32 LEDHalfWidth; + v4 CameraPosition; + led_buffer LedBuffer; + s32 StartIndex; + s32 OnePastLastIndex; + render_quad_batch_constructor* Batch; + quad_batch_constructor_reserved_range BatchReservedRange; + r32 LEDHalfWidth; }; internal void DrawLedsInBuffer(led_buffer LedBuffer, s32 StartIndex, s32 OnePastLastIndex, render_quad_batch_constructor* Batch, quad_batch_constructor_reserved_range ReservedRange, r32 LedHalfWidth) { - s32 TrisUsed = 0; + s32 TrisUsed = 0; + + v4 P0_In = v4{-LedHalfWidth, -LedHalfWidth, 0, 1}; + v4 P1_In = v4{LedHalfWidth, -LedHalfWidth, 0, 1}; + v4 P2_In = v4{LedHalfWidth, LedHalfWidth, 0, 1}; + v4 P3_In = v4{-LedHalfWidth, LedHalfWidth, 0, 1}; + + v2 UV0 = v2{0, 0}; + v2 UV1 = v2{1, 0}; + v2 UV2 = v2{1, 1}; + v2 UV3 = v2{0, 1}; + + Assert(OnePastLastIndex <= (s32)LedBuffer.LedCount); + for (s32 LedIndex = StartIndex; LedIndex < OnePastLastIndex; LedIndex++) + { + pixel PixelColor = LedBuffer.Colors[LedIndex]; + v4 Color = v4{PixelColor.R / 255.f, PixelColor.G / 255.f, PixelColor.B / 255.f, 1.0f}; - v4 P0_In = v4{-LedHalfWidth, -LedHalfWidth, 0, 1}; - v4 P1_In = v4{LedHalfWidth, -LedHalfWidth, 0, 1}; - v4 P2_In = v4{LedHalfWidth, LedHalfWidth, 0, 1}; - v4 P3_In = v4{-LedHalfWidth, LedHalfWidth, 0, 1}; + v4 Position = LedBuffer.Positions[LedIndex]; + v4 PositionOffset = ToV4Vec(Position.xyz); + v4 P0 = P0_In + PositionOffset; + v4 P1 = P1_In + PositionOffset; + v4 P2 = P2_In + PositionOffset; + v4 P3 = P3_In + PositionOffset; - v2 UV0 = v2{0, 0}; - v2 UV1 = v2{1, 0}; - v2 UV2 = v2{1, 1}; - v2 UV3 = v2{0, 1}; - - Assert(OnePastLastIndex <= (s32)LedBuffer.LedCount); - for (s32 LedIndex = StartIndex; LedIndex < OnePastLastIndex; LedIndex++) - { - pixel PixelColor = LedBuffer.Colors[LedIndex]; - v4 Color = v4{PixelColor.R / 255.f, PixelColor.G / 255.f, PixelColor.B / 255.f, 1.0f}; - - v4 Position = LedBuffer.Positions[LedIndex]; - v4 PositionOffset = ToV4Vec(Position.xyz); - v4 P0 = P0_In + PositionOffset; - v4 P1 = P1_In + PositionOffset; - v4 P2 = P2_In + PositionOffset; - v4 P3 = P3_In + PositionOffset; - - SetTri3DInBatch(Batch, ReservedRange.Start + TrisUsed++, P0, P1, P2, UV0, UV1, UV2, Color, Color, Color); - SetTri3DInBatch(Batch, ReservedRange.Start + TrisUsed++, P0, P2, P3, UV0, UV2, UV3, Color, Color, Color); - } + SetTri3DInBatch(Batch, ReservedRange.Start + TrisUsed++, P0, P1, P2, UV0, UV1, UV2, Color, Color, Color); + SetTri3DInBatch(Batch, ReservedRange.Start + TrisUsed++, P0, P2, P3, UV0, UV2, UV3, Color, Color, Color); + } } internal void DrawLEDsInBufferRangeJob (gs_thread_context Context, gs_data JobData) { - DEBUG_TRACK_FUNCTION; - draw_leds_job_data* Data = (draw_leds_job_data*)JobData.Memory; - DrawLedsInBuffer(Data->LedBuffer, Data->StartIndex, Data->OnePastLastIndex, Data->Batch, Data->BatchReservedRange, Data->LEDHalfWidth); + DEBUG_TRACK_FUNCTION; + draw_leds_job_data* Data = (draw_leds_job_data*)JobData.Memory; + DrawLedsInBuffer(Data->LedBuffer, Data->StartIndex, Data->OnePastLastIndex, Data->Batch, Data->BatchReservedRange, Data->LEDHalfWidth); } internal void DrawQuad(render_command_buffer* RenderBuffer, v4 C, r32 Rad, v4 Color) { - v4 P0 = C + v4{-Rad,-Rad,0,0}; - v4 P1 = C + v4{ Rad,-Rad,0,0}; - v4 P2 = C + v4{ Rad,Rad,0,0}; - v4 P3 = C + v4{ -Rad,Rad,0,0}; - PushRenderQuad3D(RenderBuffer, P0, P1, P2, P3, Color); + v4 P0 = C + v4{-Rad,-Rad,0,0}; + v4 P1 = C + v4{ Rad,-Rad,0,0}; + v4 P2 = C + v4{ Rad,Rad,0,0}; + v4 P3 = C + v4{ -Rad,Rad,0,0}; + PushRenderQuad3D(RenderBuffer, P0, P1, P2, P3, Color); } internal v2 SculptureView_WorldToScreenPosition(v4 WorldPosition, camera Camera, rect2 PanelBounds) { - v2 Result = {0}; - - r32 PanelW = Rect2Width(PanelBounds); - r32 PanelH = Rect2Height(PanelBounds); - - m44 Matrix = GetCameraPerspectiveProjectionMatrix(Camera) * GetCameraModelViewMatrix(Camera); - v4 WorldPos = Matrix * WorldPosition; - - // this is the Perspective Divide - v2 ProjectedPos = WorldPos.xy / WorldPos.w; - - // Projection gets us in a range [-1, 1], and we want [0, width] - ProjectedPos.x = ((ProjectedPos.x / 2) * PanelW) + (PanelW / 2); - ProjectedPos.y = ((ProjectedPos.y / 2) * PanelH) + (PanelH / 2); - - Result = ProjectedPos + PanelBounds.Min; - return Result; + v2 Result = {0}; + + r32 PanelW = Rect2Width(PanelBounds); + r32 PanelH = Rect2Height(PanelBounds); + + m44 Matrix = GetCameraPerspectiveProjectionMatrix(Camera) * GetCameraModelViewMatrix(Camera); + v4 WorldPos = Matrix * WorldPosition; + + // this is the Perspective Divide + v2 ProjectedPos = WorldPos.xy / WorldPos.w; + + // Projection gets us in a range [-1, 1], and we want [0, width] + ProjectedPos.x = ((ProjectedPos.x / 2) * PanelW) + (PanelW / 2); + ProjectedPos.y = ((ProjectedPos.y / 2) * PanelH) + (PanelH / 2); + + Result = ProjectedPos + PanelBounds.Min; + return Result; } GSMetaTag(panel_render); @@ -182,62 +182,62 @@ GSMetaTag(panel_type_sculpture_view); internal void SculptureView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { - DEBUG_TRACK_SCOPE(RenderSculpture); - sculpture_view_panel_state* PanelState = Panel_GetStateStruct(Panel, sculpture_view_panel_state); - PanelState->Camera.AspectRatio = RectAspectRatio(PanelBounds); - - PushRenderPerspective(RenderBuffer, PanelBounds, PanelState->Camera); - - u32 MaxLEDsPerJob = 2048; - render_quad_batch_constructor RenderLEDsBatch = PushRenderQuad3DBatch(RenderBuffer, State->LedSystem.LedsCountTotal); - - u32 FocusPixel = 100; - - for (u32 BufferIndex = 0; BufferIndex < State->LedSystem.BuffersCount; BufferIndex++) + DEBUG_TRACK_SCOPE(RenderSculpture); + sculpture_view_panel_state* PanelState = Panel_GetStateStruct(Panel, sculpture_view_panel_state); + PanelState->Camera.AspectRatio = RectAspectRatio(PanelBounds); + + PushRenderPerspective(RenderBuffer, PanelBounds, PanelState->Camera); + + u32 MaxLEDsPerJob = 2048; + render_quad_batch_constructor RenderLEDsBatch = PushRenderQuad3DBatch(RenderBuffer, State->LedSystem.LedsCountTotal); + + u32 FocusPixel = 100; + + for (u32 BufferIndex = 0; BufferIndex < State->LedSystem.BuffersCount; BufferIndex++) + { + led_buffer* LedBuffer = LedSystemGetBuffer(&State->LedSystem, BufferIndex); + u32 JobsNeeded = U32DivideRoundUp(LedBuffer->LedCount, MaxLEDsPerJob); + u32 NextLEDIndex = 0; + for (u32 Job = 0; Job < JobsNeeded; Job++) { - led_buffer* LedBuffer = LedSystemGetBuffer(&State->LedSystem, BufferIndex); - u32 JobsNeeded = U32DivideRoundUp(LedBuffer->LedCount, MaxLEDsPerJob); - u32 NextLEDIndex = 0; - for (u32 Job = 0; Job < JobsNeeded; Job++) - { - gs_data Data = PushSizeToData(State->Transient, sizeof(draw_leds_job_data)); - draw_leds_job_data* JobData = (draw_leds_job_data*)Data.Memory; - JobData->LedBuffer = *LedBuffer; - JobData->StartIndex = NextLEDIndex; - JobData->OnePastLastIndex = Min(JobData->StartIndex + MaxLEDsPerJob, LedBuffer->LedCount); - s32 JobLedCount = JobData->OnePastLastIndex - JobData->StartIndex; - JobData->Batch = &RenderLEDsBatch; - JobData->BatchReservedRange = ReserveRangeInQuadConstructor(JobData->Batch, JobLedCount * 2); - JobData->LEDHalfWidth = .5f; - JobData->CameraPosition = ToV4Point(PanelState->Camera.Position); + gs_data Data = PushSize(State->Transient, sizeof(draw_leds_job_data)); + draw_leds_job_data* JobData = (draw_leds_job_data*)Data.Memory; + JobData->LedBuffer = *LedBuffer; + JobData->StartIndex = NextLEDIndex; + JobData->OnePastLastIndex = Min(JobData->StartIndex + MaxLEDsPerJob, LedBuffer->LedCount); + s32 JobLedCount = JobData->OnePastLastIndex - JobData->StartIndex; + JobData->Batch = &RenderLEDsBatch; + JobData->BatchReservedRange = ReserveRangeInQuadConstructor(JobData->Batch, JobLedCount * 2); + JobData->LEDHalfWidth = .5f; + JobData->CameraPosition = ToV4Point(PanelState->Camera.Position); #if 1 - Context.GeneralWorkQueue->PushWorkOnQueue(Context.GeneralWorkQueue, (thread_proc*)DrawLEDsInBufferRangeJob, Data, ConstString("Sculpture Draw LEDS")); + Context.GeneralWorkQueue->PushWorkOnQueue(Context.GeneralWorkQueue, (thread_proc*)DrawLEDsInBufferRangeJob, Data, ConstString("Sculpture Draw LEDS")); #else - DrawLedsInBuffer(JobData->LedBuffer, JobData->StartIndex, JobData->OnePastLastIndex, JobData->Batch, JobData->BatchReservedRange, JobData->LEDHalfWidth); + DrawLedsInBuffer(JobData->LedBuffer, JobData->StartIndex, JobData->OnePastLastIndex, JobData->Batch, JobData->BatchReservedRange, JobData->LEDHalfWidth); #endif - NextLEDIndex = JobData->OnePastLastIndex; - } + NextLEDIndex = JobData->OnePastLastIndex; } + } + + // TODO(Peter): I don't like the fact that setting an orthographic view inside a panel render function + // needs to relyon the window bounds rather than the panel bounds. Ideally the panel only needs to know where + // itself is, and nothing else. + PushRenderOrthographic(RenderBuffer, State->WindowBounds); + if (State->Assemblies.Count > 0) + { + assembly Assembly = State->Assemblies.Values[0]; + led_buffer* LedBuffer = LedSystemGetBuffer(&State->LedSystem, Assembly.LedBufferIndex); - // TODO(Peter): I don't like the fact that setting an orthographic view inside a panel render function - // needs to relyon the window bounds rather than the panel bounds. Ideally the panel only needs to know where - // itself is, and nothing else. - PushRenderOrthographic(RenderBuffer, State->WindowBounds); - if (State->Assemblies.Count > 0) - { - assembly Assembly = State->Assemblies.Values[0]; - led_buffer* LedBuffer = LedSystemGetBuffer(&State->LedSystem, Assembly.LedBufferIndex); - - v4 LedPosition = LedBuffer->Positions[FocusPixel]; - v2 LedOnScreenPosition = SculptureView_WorldToScreenPosition(LedPosition, PanelState->Camera, PanelBounds); - - gs_string Tempgs_string = PushString(State->Transient, 256); - PrintF(&Tempgs_string, "Hot Id: %u, ZIndex: %u | Active Id: %u", State->Interface.HotWidget.Id, - State->Interface.HotWidget.ZIndex,State->Interface.ActiveWidget.Id); - DrawString(RenderBuffer, Tempgs_string, State->Interface.Style.Font, v2{PanelBounds.Min.x + 100, PanelBounds.Max.y - 200}, WhiteV4); - - } - Context.GeneralWorkQueue->CompleteQueueWork(Context.GeneralWorkQueue, Context.ThreadContext); + v4 LedPosition = LedBuffer->Positions[FocusPixel]; + v2 LedOnScreenPosition = SculptureView_WorldToScreenPosition(LedPosition, PanelState->Camera, PanelBounds); + + gs_string Tempgs_string = PushString(State->Transient, 256); + PrintF(&Tempgs_string, "Hot Id: %u, ZIndex: %u | Active Id: %u", State->Interface.HotWidget.Id, + State->Interface.HotWidget.ZIndex,State->Interface.ActiveWidget.Id); + DrawString(RenderBuffer, Tempgs_string, State->Interface.Style.Font, v2{PanelBounds.Min.x + 100, PanelBounds.Max.y - 200}, WhiteV4, -1, GreenV4); + + } + Context.GeneralWorkQueue->CompleteQueueWork(Context.GeneralWorkQueue, Context.ThreadContext); } #define FOLDHAUS_PANEL_SCULPTURE_VIEW_H diff --git a/src/app/editor/panels/foldhaus_panel_types.cpp b/src/app/editor/panels/foldhaus_panel_types.cpp index ea56618..db28c35 100644 --- a/src/app/editor/panels/foldhaus_panel_types.cpp +++ b/src/app/editor/panels/foldhaus_panel_types.cpp @@ -4,7 +4,7 @@ // Creation Date: 2020-10-17 // #ifndef FOLDHAUS_PANEL_TYPES_CPP -global s32 GlobalPanelDefsCount = 7; +global s32 GlobalPanelDefsCount = 8; global panel_definition GlobalPanelDefs[] = { { "File View", 9, FileView_Init, FileView_Cleanup, FileView_Render, FileView_Commands, FileView_CommandsCount }, { "Sculpture View", 14, SculptureView_Init, SculptureView_Cleanup, SculptureView_Render, SculptureView_Commands, SculptureView_CommandsCount }, @@ -13,6 +13,7 @@ global panel_definition GlobalPanelDefs[] = { { "Hierarchy", 9, HierarchyView_Init, HierarchyView_Cleanup, HierarchyView_Render, HierarchyView_Commands, HierarchyView_CommandsCount }, { "Profiler", 8, ProfilerView_Init, ProfilerView_Cleanup, ProfilerView_Render, ProfilerView_Commands, ProfilerView_CommandsCount }, { "Assembly Debug", 14, AssemblyDebug_Init, AssemblyDebug_Cleanup, AssemblyDebug_Render, 0, 0 }, + { "Message Log", 11, MessageLog_Init, MessageLog_Cleanup, MessageLog_Render, 0, 0 }, }; #define FOLDHAUS_PANEL_TYPES_CPP #endif // FOLDHAUS_PANEL_TYPES_CPP \ No newline at end of file diff --git a/src/app/editor/panels/foldhaus_panel_types.h b/src/app/editor/panels/foldhaus_panel_types.h index 9177cdd..559bc43 100644 --- a/src/app/editor/panels/foldhaus_panel_types.h +++ b/src/app/editor/panels/foldhaus_panel_types.h @@ -12,6 +12,7 @@ enum panel_type { PanelType_HierarchyView, PanelType_ProfilerView, PanelType_AssemblyDebug, + PanelType_MessageLog }; #define FOLDHAUS_PANEL_TYPES_H #endif // FOLDHAUS_PANEL_TYPES_H \ No newline at end of file diff --git a/src/app/engine/animation/foldhaus_animation.h b/src/app/engine/animation/foldhaus_animation.h index d93f3f1..f0011f2 100644 --- a/src/app/engine/animation/foldhaus_animation.h +++ b/src/app/engine/animation/foldhaus_animation.h @@ -5,18 +5,18 @@ // #ifndef FOLDHAUS_ANIMATION -#define ANIMATION_PROC(name) void name(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +#define ANIMATION_PROC(name) void name(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) typedef ANIMATION_PROC(animation_proc); struct frame_range { - s32 Min; - s32 Max; + s32 Min; + s32 Max; }; struct animation_pattern_handle { - s32 IndexPlusOne; + s32 IndexPlusOne; }; // NOTE(pjs): An animation block is a time range paired with an @@ -25,109 +25,157 @@ struct animation_pattern_handle // will run struct animation_block { - frame_range Range; - animation_pattern_handle AnimationProcHandle; - u32 Layer; + frame_range Range; + animation_pattern_handle AnimationProcHandle; + u32 Layer; }; struct animation_block_array { - u32* Generations; - animation_block* Values; - u32 Count; - u32 CountMax; + u32* Generations; + animation_block* Values; + u32 Count; + u32 CountMax; }; enum blend_mode { - BlendMode_Overwrite, - BlendMode_Add, - BlendMode_Multiply, - BlendMode_Count, + BlendMode_Overwrite, + BlendMode_Add, + BlendMode_Multiply, + BlendMode_Count, }; -// TODO(pjs): Add Opacity to this -typedef pixel led_blend_proc(pixel PixelA, pixel PixelB); - -global gs_const_string BlendModeStrings[] = { - ConstString("Overwrite"), - ConstString("Add"), - ConstString("Multiply"), - ConstString("Count"), +// TODO(pjs): This really doesn't belong here +global gs_string BlendModeStrings[] = { + MakeString("Overwrite"), + MakeString("Add"), + MakeString("Multiply"), + MakeString("Count"), }; struct anim_layer { - gs_string Name; - blend_mode BlendMode; + gs_string Name; + blend_mode BlendMode; }; struct anim_layer_array { - anim_layer* Values; - u32 Count; - u32 CountMax; + anim_layer* Values; + u32 Count; + u32 CountMax; }; // NOTE(pjs): An animation is a stack of layers, each of which // is a timeline of animation blocks. struct animation { - gs_string Name; - - anim_layer_array Layers; - // TODO(pjs): Pretty sure Blocks_ should be obsolete and - // Layers should contain their own blocks - animation_block_array Blocks_; - - frame_range PlayableRange; - - // The information / path to the file where this animation is to be saved / where it is loaded from - gs_file_info FileInfo; + gs_string Name; + + anim_layer_array Layers; + animation_block_array Blocks_; + + frame_range PlayableRange; + + // The information / path to the file where this animation is to be saved / where it is loaded from + gs_file_info FileInfo; }; +struct animation_handle +{ + s32 Index; +}; + +struct animation_handle_array +{ + u32 Count; + animation_handle* Handles; +}; + +internal animation_handle InvalidAnimHandle () { return { -1 }; } +internal bool IsValid (animation_handle H) { return H.Index >= 0; } +internal void Clear (animation_handle* H) { H->Index = -1; } +internal bool AnimHandlesAreEqual (animation_handle A, animation_handle B) +{ + return A.Index == B.Index; +} + struct animation_array { - animation* Values; - u32 Count; - u32 CountMax; + animation* Values; + u32 Count; + u32 CountMax; }; struct animation_layer_frame { - animation_block Hot; - bool HasHot; - - animation_block NextHot; - bool HasNextHot; - - r32 HotOpacity; + animation_block Hot; + bool HasHot; + + animation_block NextHot; + bool HasNextHot; + + r32 NextHotOpacity; + + blend_mode BlendMode; }; // NOTE(pjs): This is an evaluated frame - across all layers in an // animation, these are the blocks that need to be run struct animation_frame { - animation_layer_frame* Layers; - u32 LayersCount; + animation_layer_frame* Layers; + u32 LayersCount; +}; + +enum animation_repeat_mode +{ + AnimationRepeat_Single, + AnimationRepeat_Loop, + AnimationRepeat_Invalid, +}; + +global gs_const_string AnimationRepeatModeStrings[] = { + ConstString("Repeat Single"), + ConstString("Loop"), + ConstString("Invalid"), +}; + +struct animation_fade_group +{ + animation_handle From; + animation_handle To; + r32 FadeElapsed; + r32 FadeDuration; }; #define ANIMATION_SYSTEM_LAYERS_MAX 128 #define ANIMATION_SYSTEM_BLOCKS_MAX 128 struct animation_system { - gs_memory_arena* Storage; - animation_array Animations; - - // NOTE(Peter): The frame currently being displayed/processed. you - // can see which frame you're on by looking at the time slider on the timeline - // panel - u32 ActiveAnimationIndex; - s32 CurrentFrame; - s32 LastUpdatedFrame; - r32 SecondsPerFrame; - b32 TimelineShouldAdvance; - + gs_memory_arena* Storage; + animation_array Animations; + + animation_repeat_mode RepeatMode; + animation_handle_array Playlist; + u32 PlaylistAt; + r32 PlaylistFadeTime; + + // NOTE(Peter): The frame currently being displayed/processed. you + // can see which frame you're on by looking at the time slider on the timeline + // panel + animation_fade_group ActiveFadeGroup; + + r32 SecondsOnCurrentFrame; + s32 CurrentFrame; + s32 LastUpdatedFrame; + r32 SecondsPerFrame; + b32 TimelineShouldAdvance; + u32 UpdatesThisFrame; + + // Settings + bool Multithreaded; }; // NOTE(pjs): A Pattern is a named procedure which can be used as @@ -135,69 +183,70 @@ struct animation_system // and blended via layers to create an animation struct animation_pattern { - char* Name; - s32 NameLength; - animation_proc* Proc; + char* Name; + s32 NameLength; + animation_proc* Proc; + bool Multithreaded; }; struct animation_pattern_array { - animation_pattern* Values; - u32 Count; - u32 CountMax; + animation_pattern* Values; + u32 Count; + u32 CountMax; }; // Serialization enum animation_field { - AnimField_FileIdent, - AnimField_AnimName, - AnimField_LayersCount, - AnimField_BlocksCount, - - AnimField_PlayableRange, - AnimField_PlayableRangeMin, - AnimField_PlayableRangeMax, - - AnimField_LayersArray, - AnimField_Layer, - AnimField_LayerName, - AnimField_LayerBlendMode, - - AnimField_BlocksArray, - AnimField_Block, - AnimField_BlockFrameRange, - AnimField_BlockFrameRangeMin, - AnimField_BlockFrameRangeMax, - AnimField_BlockLayerIndex, - AnimField_BlockAnimName, - - AnimField_Count, + AnimField_FileIdent, + AnimField_AnimName, + AnimField_LayersCount, + AnimField_BlocksCount, + + AnimField_PlayableRange, + AnimField_PlayableRangeMin, + AnimField_PlayableRangeMax, + + AnimField_LayersArray, + AnimField_Layer, + AnimField_LayerName, + AnimField_LayerBlendMode, + + AnimField_BlocksArray, + AnimField_Block, + AnimField_BlockFrameRange, + AnimField_BlockFrameRangeMin, + AnimField_BlockFrameRangeMax, + AnimField_BlockLayerIndex, + AnimField_BlockAnimName, + + AnimField_Count, }; global gs_const_string AnimationFieldStrings[] = { - ConstString("lumenarium_animation_file"), // AnimField_FileIdent - ConstString("animation_name"),// AnimField_AnimName - ConstString("layers_count"),// AnimField_LayersCount - ConstString("blocks_count"),// AnimField_BlocksCount - - ConstString("playable_range"),// AnimField_PlayableRange - ConstString("min"),// AnimField_PlayableRangeMin - ConstString("max"),// AnimField_PlayableRangeMax - - ConstString("layers"),// AnimField_LayersArray - ConstString("layer"),// AnimField_Layer - ConstString("name"),// AnimField_LayerName - ConstString("blend"),// AnimField_LayerBlendMode - - ConstString("blocks"),// AnimField_BlocksArray - ConstString("block"),// AnimField_Block - ConstString("frame_range"),// AnimField_BlockFrameRange - ConstString("min"),// AnimField_BlockFrameRangeMin - ConstString("max"),// AnimField_BlockFrameRangeMax - ConstString("layer_index"),// AnimField_BlockLayerIndex - ConstString("animation_name"),// AnimField_BlockAnimName + ConstString("lumenarium_animation_file"), // AnimField_FileIdent + ConstString("animation_name"),// AnimField_AnimName + ConstString("layers_count"),// AnimField_LayersCount + ConstString("blocks_count"),// AnimField_BlocksCount + + ConstString("playable_range"),// AnimField_PlayableRange + ConstString("min"),// AnimField_PlayableRangeMin + ConstString("max"),// AnimField_PlayableRangeMax + + ConstString("layers"),// AnimField_LayersArray + ConstString("layer"),// AnimField_Layer + ConstString("name"),// AnimField_LayerName + ConstString("blend"),// AnimField_LayerBlendMode + + ConstString("blocks"),// AnimField_BlocksArray + ConstString("block"),// AnimField_Block + ConstString("frame_range"),// AnimField_BlockFrameRange + ConstString("min"),// AnimField_BlockFrameRangeMin + ConstString("max"),// AnimField_BlockFrameRangeMax + ConstString("layer_index"),// AnimField_BlockLayerIndex + ConstString("animation_name"),// AnimField_BlockAnimName }; @@ -208,45 +257,58 @@ global gs_const_string AnimationFieldStrings[] = { internal animation_pattern_array Patterns_Create(gs_memory_arena* Arena, s32 CountMax) { - animation_pattern_array Result = {0}; - Result.CountMax = CountMax; - Result.Values = PushArray(Arena, animation_pattern, Result.CountMax); - return Result; + animation_pattern_array Result = {0}; + Result.CountMax = CountMax; + Result.Values = PushArray(Arena, animation_pattern, Result.CountMax); + return Result; } -#define Patterns_PushPattern(array, proc) Patterns_PushPattern_((array), (proc), Stringify(proc), sizeof(Stringify(proc))) +#define PATTERN_MULTITHREADED true +#define PATTERN_SINGLETHREADED false + +#define Patterns_PushPattern(array, proc, multithread) \ +Patterns_PushPattern_((array), (proc), Stringify(proc), sizeof(Stringify(proc)) - 1, (multithread)) + internal void -Patterns_PushPattern_(animation_pattern_array* Array, animation_proc* Proc, char* Name, u32 NameLength) +Patterns_PushPattern_(animation_pattern_array* Array, animation_proc* Proc, char* Name, u32 NameLength, bool Multithreaded) { - Assert(Array->Count < Array->CountMax); - - animation_pattern Pattern = {0}; - Pattern.Name = Name; - Pattern.NameLength = NameLength; - Pattern.Proc = Proc; - - Array->Values[Array->Count++] = Pattern; + Assert(Array->Count < Array->CountMax); + + animation_pattern Pattern = {0}; + Pattern.Name = Name; + Pattern.NameLength = NameLength; + Pattern.Proc = Proc; + Pattern.Multithreaded = Multithreaded; + + Array->Values[Array->Count++] = Pattern; } internal animation_pattern_handle Patterns_IndexToHandle(s32 Index) { - animation_pattern_handle Result = {}; - Result.IndexPlusOne = Index + 1; - return Result; + animation_pattern_handle Result = {}; + Result.IndexPlusOne = Index + 1; + return Result; +} + +internal bool +IsValid(animation_pattern_handle Handle) +{ + bool Result = Handle.IndexPlusOne > 0; + return Result; } internal animation_pattern Patterns_GetPattern(animation_pattern_array Patterns, animation_pattern_handle Handle) { - animation_pattern Result = {0}; - if (Handle.IndexPlusOne > 0) - { - u32 Index = Handle.IndexPlusOne - 1; - Assert(Index < Patterns.Count); - Result = Patterns.Values[Index]; - } - return Result; + animation_pattern Result = {0}; + if (Handle.IndexPlusOne > 0) + { + u32 Index = Handle.IndexPlusOne - 1; + Assert(Index < Patterns.Count); + Result = Patterns.Values[Index]; + } + return Result; } ////////////////////////// @@ -256,44 +318,44 @@ Patterns_GetPattern(animation_pattern_array Patterns, animation_pattern_handle H internal animation_block_array AnimBlockArray_Create(gs_memory_arena* Storage, u32 CountMax) { - animation_block_array Result = {0}; - Result.CountMax = CountMax; - Result.Values = PushArray(Storage, animation_block, Result.CountMax); - Result.Generations = PushArray(Storage, u32, Result.CountMax); - return Result; + animation_block_array Result = {0}; + Result.CountMax = Max(CountMax, 32); + Result.Values = PushArray(Storage, animation_block, Result.CountMax); + Result.Generations = PushArray(Storage, u32, Result.CountMax); + return Result; } internal handle AnimBlockArray_Push(animation_block_array* Array, animation_block Value) { - Assert(Array->Count < Array->CountMax); - handle Result = {0}; - Result.Index = Array->Count++; - // NOTE(pjs): pre-increment so that generation 0 is always invalid - Result.Generation = ++Array->Generations[Result.Index]; - - Array->Values[Result.Index] = Value; - - return Result; + Assert(Array->Count < Array->CountMax); + handle Result = {0}; + Result.Index = Array->Count++; + // NOTE(pjs): pre-increment so that generation 0 is always invalid + Result.Generation = ++Array->Generations[Result.Index]; + + Array->Values[Result.Index] = Value; + + return Result; } internal void AnimBlockArray_Remove(animation_block_array* Array, handle Handle) { - Assert(Handle.Index < Array->Count); - Assert(Handle_IsValid(Handle)); - Array->Generations[Handle.Index]++; + Assert(Handle.Index < Array->Count); + Assert(Handle_IsValid(Handle)); + Array->Generations[Handle.Index]++; } internal void AnimBlockArray_RemoveAt(animation_block_array* Array, u32 Index) { - Assert(Index < Array->Count); - - handle Handle = {}; - Handle.Index = Index; - Handle.Generation = Array->Generations[Index]; - AnimBlockArray_Remove(Array, Handle); + Assert(Index < Array->Count); + + handle Handle = {}; + Handle.Index = Index; + Handle.Generation = Array->Generations[Index]; + AnimBlockArray_Remove(Array, Handle); } ////////////////////////// @@ -303,29 +365,29 @@ AnimBlockArray_RemoveAt(animation_block_array* Array, u32 Index) internal anim_layer_array AnimLayerArray_Create(gs_memory_arena* Storage, u32 CountMax) { - anim_layer_array Result = {0}; - Result.CountMax = CountMax; - Result.Values = PushArray(Storage, anim_layer, Result.CountMax); - return Result; + anim_layer_array Result = {0}; + Result.CountMax = Max(CountMax, 32); + Result.Values = PushArray(Storage, anim_layer, Result.CountMax); + return Result; } internal u32 AnimLayerArray_Push(anim_layer_array* Array, anim_layer Value) { - Assert(Array->Count < Array->CountMax); - u32 Index = Array->Count++; - Array->Values[Index] = Value; - return Index; + Assert(Array->Count < Array->CountMax); + u32 Index = Array->Count++; + Array->Values[Index] = Value; + return Index; } internal void AnimLayerArray_Remove(anim_layer_array* Array, u32 Index) { - Assert(Index < Array->Count); - for (u32 i = Index; i < Array->Count - 1; i++) - { - Array->Values[i] = Array->Values[i + 1]; - } + Assert(Index < Array->Count); + for (u32 i = Index; i < Array->Count - 1; i++) + { + Array->Values[i] = Array->Values[i + 1]; + } } ////////////////////////// @@ -335,92 +397,146 @@ AnimLayerArray_Remove(anim_layer_array* Array, u32 Index) internal animation_array AnimationArray_Create(gs_memory_arena* Storage, u32 CountMax) { - animation_array Result = {0}; - Result.CountMax = CountMax; - Result.Values = PushArray(Storage, animation, Result.CountMax); - return Result; + animation_array Result = {0}; + Result.CountMax = CountMax; + Result.Values = PushArray(Storage, animation, Result.CountMax); + return Result; } -internal u32 +internal animation_handle AnimationArray_Push(animation_array* Array, animation Value) { - Assert(Array->Count < Array->CountMax); - u32 Index = Array->Count++; - Array->Values[Index] = Value; - return Index; + Assert(Array->Count < Array->CountMax); + animation_handle Result = {0}; + Result.Index = Array->Count++; + Array->Values[Result.Index] = Value; + return Result; +} + +internal animation* +AnimationArray_Get(animation_array Array, animation_handle Handle) +{ + DEBUG_TRACK_FUNCTION; + + animation* Result = 0; + if (IsValid(Handle) && Handle.Index < (s32)Array.Count) + { + Result = Array.Values + Handle.Index; + } + return Result; +} + +internal animation* +AnimationArray_GetSafe(animation_array Array, animation_handle Handle) +{ + Assert(IsValid(Handle)); + Assert(Handle.Index < (s32)Array.Count); + return AnimationArray_Get(Array, Handle); } ////////////////////////// // // Animation +typedef struct animation_desc +{ + u32 NameSize; + char* Name; + + u32 LayersCount; + u32 BlocksCount; + + u32 MinFrames; + u32 MaxFrames; +} animation_desc; + +internal animation +Animation_Create(animation_desc Desc, animation_system* System) +{ + animation Result = {}; + u32 NameLen = Desc.NameSize; + if (Desc.Name) + { + NameLen = Max(CStringLength(Desc.Name), NameLen); + Result.Name = PushStringF(System->Storage, NameLen, "%s", Desc.Name); + } else { + Result.Name = PushStringF(System->Storage, NameLen, "[New Animation]"); + } + + Result.Layers = AnimLayerArray_Create(System->Storage, Desc.LayersCount); + Result.Blocks_ = AnimBlockArray_Create(System->Storage, Desc.BlocksCount); + Result.PlayableRange.Min = Desc.MinFrames; + Result.PlayableRange.Max = Desc.MaxFrames; + return Result; +} + internal handle Animation_AddBlock(animation* Animation, u32 StartFrame, s32 EndFrame, animation_pattern_handle AnimationProcHandle, u32 LayerIndex) { - Assert(LayerIndex < Animation->Layers.Count); - - animation_block NewBlock = {0}; - NewBlock.Range.Min = StartFrame; - NewBlock.Range.Max = EndFrame; - NewBlock.AnimationProcHandle = AnimationProcHandle; - NewBlock.Layer = LayerIndex; - - handle Handle = AnimBlockArray_Push(&Animation->Blocks_, NewBlock); - return Handle; + Assert(LayerIndex < Animation->Layers.Count); + + animation_block NewBlock = {0}; + NewBlock.Range.Min = StartFrame; + NewBlock.Range.Max = EndFrame; + NewBlock.AnimationProcHandle = AnimationProcHandle; + NewBlock.Layer = LayerIndex; + + handle Handle = AnimBlockArray_Push(&Animation->Blocks_, NewBlock); + return Handle; } internal void Animation_RemoveBlock(animation* Animation, handle AnimHandle) { - AnimBlockArray_Remove(&Animation->Blocks_, AnimHandle); + AnimBlockArray_Remove(&Animation->Blocks_, AnimHandle); } internal animation_block* Animation_GetBlockFromHandle(animation* Animation, handle AnimHandle) { - animation_block* Result = 0; - - if (AnimHandle.Generation != 0 && - Animation->Blocks_.Generations[AnimHandle.Index] == AnimHandle.Generation) - { - Result = Animation->Blocks_.Values + AnimHandle.Index; - } - - return Result; + animation_block* Result = 0; + + if (AnimHandle.Generation != 0 && + Animation->Blocks_.Generations[AnimHandle.Index] == AnimHandle.Generation) + { + Result = Animation->Blocks_.Values + AnimHandle.Index; + } + + return Result; } internal u32 Animation_AddLayer(animation* Animation, anim_layer Layer) { - return AnimLayerArray_Push(&Animation->Layers, Layer); + return AnimLayerArray_Push(&Animation->Layers, Layer); } internal u32 Animation_AddLayer (animation* Animation, gs_string Name, blend_mode BlendMode, animation_system* System) { - anim_layer NewLayer = {0}; - NewLayer.Name = PushStringF(System->Storage, 256, "%S", Name); - NewLayer.BlendMode = BlendMode; - - return Animation_AddLayer(Animation, NewLayer); + anim_layer NewLayer = {0}; + NewLayer.Name = PushStringF(System->Storage, 256, "%S", Name); + NewLayer.BlendMode = BlendMode; + + return Animation_AddLayer(Animation, NewLayer); } internal void Animation_RemoveLayer (animation* Animation, u32 LayerIndex) { - AnimLayerArray_Remove(&Animation->Layers, LayerIndex); - for (u32 i = Animation->Blocks_.Count - 1; i >= 0; i--) + AnimLayerArray_Remove(&Animation->Layers, LayerIndex); + for (u32 i = Animation->Blocks_.Count - 1; i >= 0; i--) + { + animation_block* Block = Animation->Blocks_.Values + i; + if (Block->Layer > LayerIndex) { - animation_block* Block = Animation->Blocks_.Values + i; - if (Block->Layer > LayerIndex) - { - Block->Layer -= 1; - } - else if (Block->Layer == LayerIndex) - { - AnimBlockArray_RemoveAt(&Animation->Blocks_, i); - } + Block->Layer -= 1; } + else if (Block->Layer == LayerIndex) + { + AnimBlockArray_RemoveAt(&Animation->Blocks_, i); + } + } } ////////////////////////// @@ -430,160 +546,297 @@ Animation_RemoveLayer (animation* Animation, u32 LayerIndex) internal u32 SecondsToFrames(r32 Seconds, animation_system System) { - u32 Result = Seconds * (1.0f / System.SecondsPerFrame); - return Result; + u32 Result = Seconds * (1.0f / System.SecondsPerFrame); + return Result; +} + +inline frame_range +FrameRange_Overlap(frame_range A, frame_range B) +{ + frame_range Result = {}; + } inline bool FrameIsInRange(frame_range Range, s32 Frame) { - bool Result = (Frame >= Range.Min) && (Frame <= Range.Max); - return Result; + bool Result = (Frame >= Range.Min) && (Frame <= Range.Max); + return Result; } internal u32 GetFrameCount(frame_range Range) { - u32 Result = (u32)Max(0, Range.Max - Range.Min); - return Result; + u32 Result = (u32)Max(0, Range.Max - Range.Min); + return Result; } internal r32 FrameToPercentRange(s32 Frame, frame_range Range) { - r32 Result = (r32)(Frame - Range.Min); - Result = Result / GetFrameCount(Range); - return Result; + r32 Result = (r32)(Frame - Range.Min); + Result = Result / GetFrameCount(Range); + return Result; } internal s32 PercentToFrameInRange(r32 Percent, frame_range Range) { - s32 Result = Range.Min + (s32)(Percent * GetFrameCount(Range)); - return Result; + s32 Result = Range.Min + (s32)(Percent * GetFrameCount(Range)); + return Result; } internal s32 ClampFrameToRange(s32 Frame, frame_range Range) { - s32 Result = Frame; - if (Result < Range.Min) - { - Result = Range.Min; - } - else if (Result > Range.Max) - { - Result = Range.Max; - } - return Result; + s32 Result = Frame; + if (Result < Range.Min) + { + Result = Range.Min; + } + else if (Result > Range.Max) + { + Result = Range.Max; + } + return Result; } // Blocks // Layers +// Fade Group + +internal bool +AnimationFadeGroup_ShouldRender (animation_fade_group FadeGroup) +{ + return IsValid(FadeGroup.From); +} + +internal void +AnimationFadeGroup_Advance(animation_fade_group* Group) +{ + Group->From = Group->To; + Clear(&Group->To); + Group->FadeElapsed = 0; + Group->FadeDuration = 0; +} + +internal void +AnimationFadeGroup_Update(animation_fade_group* Group, r32 DeltaTime) +{ + if (IsValid(Group->To)) + { + r32 FadeBefore = Group->FadeElapsed; + Group->FadeElapsed += DeltaTime; + + if (Group->FadeElapsed >= Group->FadeDuration) + { + AnimationFadeGroup_Advance(Group); + } + } +} + +internal void +AnimationFadeGroup_FadeTo(animation_fade_group* Group, animation_handle To, r32 Duration) +{ + if (IsValid(Group->From)) + { + // complete current fade if there is one in progress + if (IsValid(Group->To)) + { + AnimationFadeGroup_Advance(Group); + } + + Group->To = To; + Group->FadeDuration = Duration; + } + else + { + Group->From = To; + } +} + // System struct animation_system_desc { - gs_memory_arena* Storage; - u32 AnimArrayCount; - r32 SecondsPerFrame; + gs_memory_arena* Storage; + u32 AnimArrayCount; + r32 SecondsPerFrame; }; internal animation_system AnimationSystem_Init(animation_system_desc Desc) { - animation_system Result = {}; - Result.Storage = Desc.Storage; - Result.Animations = AnimationArray_Create(Result.Storage, Desc.AnimArrayCount); - Result.SecondsPerFrame = Desc.SecondsPerFrame; - - return Result; + animation_system Result = {}; + Result.Storage = Desc.Storage; + Result.Animations = AnimationArray_Create(Result.Storage, Desc.AnimArrayCount); + Result.SecondsPerFrame = Desc.SecondsPerFrame; + + Clear(&Result.ActiveFadeGroup.From); + Clear(&Result.ActiveFadeGroup.To); + Result.ActiveFadeGroup.FadeElapsed = 0; + + // Settings + Result.Multithreaded = false; + + return Result; } internal animation* AnimationSystem_GetActiveAnimation(animation_system* System) { - // TODO(pjs): need a way to specify the active animation - return System->Animations.Values + System->ActiveAnimationIndex; + return AnimationArray_Get(System->Animations, System->ActiveFadeGroup.From); } internal animation_frame -AnimationSystem_CalculateAnimationFrame(animation_system* System, gs_memory_arena* Arena) +AnimationSystem_CalculateAnimationFrame(animation_system* System, + animation* Animation, + gs_memory_arena* Arena) { - animation* ActiveAnim = AnimationSystem_GetActiveAnimation(System); + DEBUG_TRACK_FUNCTION; + + animation_frame Result = {0}; + Result.LayersCount = Animation->Layers.Count; + Result.Layers = PushArray(Arena, animation_layer_frame, Result.LayersCount); + ZeroArray(Result.Layers, animation_layer_frame, Result.LayersCount); + + for (u32 l = 0; l < Animation->Layers.Count; l++) + { + animation_layer_frame* Layer = Result.Layers + l; + Layer->BlendMode = Animation->Layers.Values[l].BlendMode; + } + + for (u32 i = 0; i < Animation->Blocks_.Count; i++) + { + animation_block Block = Animation->Blocks_.Values[i]; - animation_frame Result = {0}; - Result.LayersCount = ActiveAnim->Layers.Count; - Result.Layers = PushArray(Arena, animation_layer_frame, Result.LayersCount); - ZeroArray(Result.Layers, animation_layer_frame, Result.LayersCount); - - for (u32 i = 0; i < ActiveAnim->Blocks_.Count; i++) + if (FrameIsInRange(Block.Range, System->CurrentFrame)) { - animation_block Block = ActiveAnim->Blocks_.Values[i]; + animation_layer_frame* Layer = Result.Layers + Block.Layer; + if (Layer->HasHot) + { + // NOTE(pjs): With current implementation, we don't allow + // animations to hvae more than 2 concurrent blocks in the + // timeline + Assert(!Layer->HasNextHot); - if (FrameIsInRange(Block.Range, System->CurrentFrame)) + // NOTE(pjs): Make sure that Hot comes before NextHot + if (Layer->Hot.Range.Min < Block.Range.Min) { - animation_layer_frame* Layer = Result.Layers + Block.Layer; - if (Layer->HasHot) - { - // NOTE(pjs): With current implementation, we don't allow - // animations to hvae more than 2 concurrent blocks in the - // timeline - Assert(!Layer->HasNextHot); - - // NOTE(pjs): Make sure that Hot comes before NextHot - if (Layer->Hot.Range.Min < Block.Range.Min) - { - Layer->NextHot = Block; - } - else - { - Layer->NextHot = Layer->Hot; - Layer->Hot = Block; - } - Layer->HasNextHot = true; - - frame_range BlendRange = {}; - BlendRange.Min = Layer->NextHot.Range.Min; - BlendRange.Max = Layer->Hot.Range.Max; - Layer->HotOpacity = 1.0f - FrameToPercentRange(System->CurrentFrame, BlendRange); - } - else - { - Layer->Hot = Block; - Layer->HotOpacity = 1.0f; - Layer->HasHot = true; - } + Layer->NextHot = Block; } + else + { + Layer->NextHot = Layer->Hot; + Layer->Hot = Block; + } + Layer->HasNextHot = true; + + frame_range BlendRange = {}; + BlendRange.Min = Layer->NextHot.Range.Min; + BlendRange.Max = Layer->Hot.Range.Max; + Layer->NextHotOpacity = FrameToPercentRange(System->CurrentFrame, BlendRange); + } + else + { + Layer->Hot = Block; + Layer->NextHotOpacity = 0.0f; + Layer->HasHot = true; + } } - - return Result; + } + + return Result; } internal void -AnimationSystem_Update(animation_system* System) +AnimationSystem_Update(animation_system* System, r32 DeltaTime) { - animation* ActiveAnim = AnimationSystem_GetActiveAnimation(System); - if (System->TimelineShouldAdvance) { - // TODO(Peter): Revisit this. This implies that the framerate of the animation system - // is tied to the framerate of the simulation. That seems correct to me, but I'm not sure - System->CurrentFrame += 1; - - // Loop back to the beginning - if (System->CurrentFrame > ActiveAnim->PlayableRange.Max) - { - System->CurrentFrame = 0; - } + if (!System->TimelineShouldAdvance) { return; } + if (!AnimationFadeGroup_ShouldRender(System->ActiveFadeGroup)) { return; } + + System->UpdatesThisFrame = 0; + + AnimationFadeGroup_Update(&System->ActiveFadeGroup, DeltaTime); + + animation* ActiveAnim = AnimationSystem_GetActiveAnimation(System); + if (ActiveAnim) + { + System->SecondsOnCurrentFrame += DeltaTime; + while (System->SecondsOnCurrentFrame > System->SecondsPerFrame) + { + System->CurrentFrame += 1; + System->SecondsOnCurrentFrame -= System->SecondsPerFrame; + System->UpdatesThisFrame += 1; } + + // Loop back to the beginning + if (System->CurrentFrame > ActiveAnim->PlayableRange.Max) + { + // NOTE(PS): There's no long term reason why this needs to be true + // but I don't want to implement dealing with PlayableRanges that + // don't start at zero right now becuse there's literally no reason + // I can think of where that's useful. + Assert(ActiveAnim->PlayableRange.Min == 0); + + s32 FramesPastEnd = System->CurrentFrame; + while (FramesPastEnd > ActiveAnim->PlayableRange.Max) + { + FramesPastEnd -= ActiveAnim->PlayableRange.Max; + } + + switch (System->RepeatMode) + { + case AnimationRepeat_Single: + { + System->CurrentFrame = 0; + }break; + + case AnimationRepeat_Loop: + { + Assert(System->Playlist.Count > 0); + u32 NextIndex = System->PlaylistAt; + System->PlaylistAt = (System->PlaylistAt + 1) % System->Playlist.Count; + animation_handle Next = System->Playlist.Handles[NextIndex]; + + AnimationFadeGroup_FadeTo(&System->ActiveFadeGroup, + Next, + System->PlaylistFadeTime); + System->CurrentFrame = 0; + }break; + + InvalidDefaultCase; + } + } + } +} + +internal void +AnimationSystem_FadeToPlaylist(animation_system* System, animation_handle_array Playlist) +{ + System->Playlist = Playlist; + System->PlaylistAt = 0; + + if (System->Playlist.Count > 0) + { + AnimationFadeGroup_FadeTo(&System->ActiveFadeGroup, Playlist.Handles[0], System->PlaylistFadeTime); + } } inline bool AnimationSystem_NeedsRender(animation_system System) { - bool Result = (System.CurrentFrame != System.LastUpdatedFrame); - return Result; + bool Result = (System.CurrentFrame != System.LastUpdatedFrame); + return Result; +} + +inline r32 +AnimationSystem_GetCurrentTime(animation_system System) +{ + r32 Result = System.CurrentFrame * System.SecondsPerFrame; + return Result; } #define FOLDHAUS_ANIMATION diff --git a/src/app/engine/animation/foldhaus_animation_renderer.cpp b/src/app/engine/animation/foldhaus_animation_renderer.cpp index 8915d59..6f7d243 100644 --- a/src/app/engine/animation/foldhaus_animation_renderer.cpp +++ b/src/app/engine/animation/foldhaus_animation_renderer.cpp @@ -6,89 +6,273 @@ #ifndef FOLDHAUS_ANIMATION_RENDERER_CPP internal pixel -LedBlend_Overwrite(pixel PixelA, pixel PixelB) +LedBlend_Overwrite(pixel PixelA, pixel PixelB, u8* UserData) { - return PixelB; + r32 MagB = (r32)(PixelB.R + PixelB.G + PixelB.B) / (255 * 3); + + pixel Result = {}; + Result.R = (u8)LerpR32(MagB, PixelA.R, PixelB.R); + Result.G = (u8)LerpR32(MagB, PixelA.G, PixelB.G); + Result.B = (u8)LerpR32(MagB, PixelA.B, PixelB.B); + +#if 0 + pixel Result = PixelB; + if (PixelB.R == 0 && + PixelB.G == 0 && + PixelB.B == 0) + { + Result = PixelA; + } +#endif + return Result; } internal pixel -LedBlend_Overwrite(pixel PixelA, pixel PixelB, r32 Opacity) +LedBlend_Lerp(pixel PixelA, pixel PixelB, u8* UserData) { - pixel Result = {}; - - r32 BOpacity = 1.0f - Opacity; - Result.R = (u8)((PixelA.R * Opacity) + (PixelB.R * BOpacity)); - Result.G = (u8)((PixelA.G * Opacity) + (PixelB.G * BOpacity)); - Result.B = (u8)((PixelA.B * Opacity) + (PixelB.B * BOpacity)); - return Result; + r32 BOpacity = *(r32*)UserData; + + pixel Result = {}; + + r32 AOpacity = 1.0f - BOpacity; + Result.R = (u8)((PixelA.R * AOpacity) + (PixelB.R * BOpacity)); + Result.G = (u8)((PixelA.G * AOpacity) + (PixelB.G * BOpacity)); + Result.B = (u8)((PixelA.B * AOpacity) + (PixelB.B * BOpacity)); + return Result; } internal pixel -LedBlend_Add(pixel PixelA, pixel PixelB) +LedBlend_Add(pixel PixelA, pixel PixelB, u8* UserData) { - pixel Result = {}; - - u32 R = (u32)PixelA.R + (u32)PixelB.R; - u32 G = (u32)PixelA.G + (u32)PixelB.G; - u32 B = (u32)PixelA.B + (u32)PixelB.B; - - Result.R = (u8)Min(R, (u32)255); - Result.G = (u8)Min(G, (u32)255); - Result.B = (u8)Min(B, (u32)255); - - return Result; + pixel Result = {}; + + u32 R = (u32)PixelA.R + (u32)PixelB.R; + u32 G = (u32)PixelA.G + (u32)PixelB.G; + u32 B = (u32)PixelA.B + (u32)PixelB.B; + + Result.R = (u8)Min(R, (u32)255); + Result.G = (u8)Min(G, (u32)255); + Result.B = (u8)Min(B, (u32)255); + + return Result; } internal pixel -LedBlend_Multiply(pixel PixelA, pixel PixelB) +LedBlend_Multiply(pixel PixelA, pixel PixelB, u8* UserData) { - pixel Result = {}; - - r32 DR = (r32)PixelA.R / 255.f; - r32 DG = (r32)PixelA.G / 255.f; - r32 DB = (r32)PixelA.B / 255.f; - - r32 SR = (r32)PixelB.R / 255.f; - r32 SG = (r32)PixelB.G / 255.f; - r32 SB = (r32)PixelB.B / 255.f; - - Result.R = (u8)((DR * SR) * 255.f); - Result.G = (u8)((DG * SG) * 255.f); - Result.B = (u8)((DB * SB) * 255.f); - - return Result; + pixel Result = {}; + + r32 DR = (r32)PixelA.R / 255.f; + r32 DG = (r32)PixelA.G / 255.f; + r32 DB = (r32)PixelA.B / 255.f; + + r32 SR = (r32)PixelB.R / 255.f; + r32 SG = (r32)PixelB.G / 255.f; + r32 SB = (r32)PixelB.B / 255.f; + + Result.R = (u8)((DR * SR) * 255.f); + Result.G = (u8)((DG * SG) * 255.f); + Result.B = (u8)((DB * SB) * 255.f); + + return Result; } internal pixel -LedBlend_Overlay(pixel PixelA, pixel PixelB) +LedBlend_Overlay(pixel PixelA, pixel PixelB, u8* UserData) { - pixel Result = {}; - return Result; + pixel Result = {}; + return Result; } internal led_blend_proc* LedBlend_GetProc(blend_mode BlendMode) { - led_blend_proc* Result = 0; - switch (BlendMode) + led_blend_proc* Result = 0; + switch (BlendMode) + { + case BlendMode_Overwrite: { Result = LedBlend_Overwrite; }break; + case BlendMode_Add: { Result = LedBlend_Add; }break; + case BlendMode_Multiply: { Result = LedBlend_Multiply; }break; + InvalidDefaultCase; + } + return Result; +} + +struct pattern_args +{ + assembly Assembly; + gs_memory_arena* Transient; + u8* UserData; +}; + +struct render_anim_to_led_buffer_job_data +{ + animation_pattern Pattern; + led_buffer Buffer; + led_buffer_range BufferRange; + pattern_args PatternArgs; + r32 SecondsIntoBlock; +}; + +internal void +AnimationSystem_RenderAnimationToLedBufferJob(gs_thread_context Context, gs_data Data) +{ + render_anim_to_led_buffer_job_data JobData = *(render_anim_to_led_buffer_job_data*)Data.Memory; + JobData.Pattern.Proc(&JobData.Buffer, + JobData.BufferRange, + JobData.PatternArgs.Assembly, + JobData.SecondsIntoBlock, + JobData.PatternArgs.Transient, + JobData.PatternArgs.UserData); +} + +#define MULTITHREAD_PATTERN_RENDERING 1 + +internal void +AnimationSystem_BeginRenderBlockToLedBuffer(animation_system* System, animation_block Block, led_buffer* Buffer, animation_pattern_array Patterns, pattern_args PatternArgs, + context Context) +{ + DEBUG_TRACK_FUNCTION; + + u32 FramesIntoBlock = System->CurrentFrame - Block.Range.Min; + r32 SecondsIntoBlock = FramesIntoBlock * System->SecondsPerFrame; + + animation_pattern Pattern = Patterns_GetPattern(Patterns, Block.AnimationProcHandle); + Assert(Pattern.Proc); + + if (System->Multithreaded && Pattern.Multithreaded) + { + u32 JobsCount = 4; + u32 LedsPerJob = Buffer->LedCount / JobsCount; + + for (u32 i = 0; i < JobsCount; i++) { - case BlendMode_Overwrite: { Result = LedBlend_Overwrite; }break; - case BlendMode_Add: { Result = LedBlend_Add; }break; - case BlendMode_Multiply: { Result = LedBlend_Multiply; }break; - InvalidDefaultCase; + gs_data Data = PushSize(Context.ThreadContext.Transient, sizeof(render_anim_to_led_buffer_job_data)); + render_anim_to_led_buffer_job_data* JobData = (render_anim_to_led_buffer_job_data*)Data.Memory; + JobData->Pattern = Pattern; + JobData->Buffer = *Buffer; + JobData->BufferRange.First = LedsPerJob * i; + JobData->BufferRange.OnePastLast = LedsPerJob * (i + 1); + JobData->PatternArgs = PatternArgs; + JobData->SecondsIntoBlock = SecondsIntoBlock; + + Context.GeneralWorkQueue->PushWorkOnQueue(Context.GeneralWorkQueue, + (thread_proc*)AnimationSystem_RenderAnimationToLedBufferJob, + Data, + ConstString("Render Pattern To Buffer")); } - return Result; + } + else + { + led_buffer_range Range = {}; + Range.First = 0; + Range.OnePastLast = Buffer->LedCount; + + Pattern.Proc(Buffer, Range, PatternArgs.Assembly, SecondsIntoBlock, PatternArgs.Transient, PatternArgs.UserData); + } } internal void -AnimationSystem_RenderBlockToLedBuffer(animation_system* System, animation_block Block, led_buffer* Buffer, assembly Assembly, animation_pattern_array Patterns, gs_memory_arena* Transient, - u8* UserData) +AnimationSystem_EndRenderBlockToLedBuffer (animation_system* System, context Context) { - u32 FramesIntoBlock = System->CurrentFrame - Block.Range.Min; - r32 SecondsIntoBlock = FramesIntoBlock * System->SecondsPerFrame; + if (System->Multithreaded) + { + Context.GeneralWorkQueue->CompleteQueueWork(Context.GeneralWorkQueue, Context.ThreadContext); + } +} + +// NOTE(pjs): This mirrors animation_layer_frame to account +// for overlapping +struct layer_led_buffer +{ + led_buffer HotBuffer; + led_buffer NextHotBuffer; +}; + +internal led_buffer +RenderAnimationToLedBuffer (animation_system* System, + pattern_args PatternArgs, + animation_frame CurrFrame, + layer_led_buffer* LayerBuffers, + led_buffer* AssemblyLedBuffer, + animation_pattern_array Patterns, + gs_memory_arena* Transient, + context Context) +{ + DEBUG_TRACK_FUNCTION; + + led_buffer AccBuffer = LedBuffer_CreateCopyCleared(*AssemblyLedBuffer, Transient); + + // Create the LayerLEDBuffers + for (u32 Layer = 0; Layer < CurrFrame.LayersCount; Layer++) + { + layer_led_buffer TempBuffer = {}; - animation_pattern Pattern = Patterns_GetPattern(Patterns, Block.AnimationProcHandle); - Pattern.Proc(Buffer, Assembly, SecondsIntoBlock, Transient, UserData); + if (CurrFrame.Layers[Layer].HasHot) + { + TempBuffer.HotBuffer = LedBuffer_CreateCopyCleared(*AssemblyLedBuffer, Transient); + + if (CurrFrame.Layers[Layer].HasNextHot) + { + TempBuffer.NextHotBuffer = LedBuffer_CreateCopyCleared(*AssemblyLedBuffer, Transient); + } + } + + LayerBuffers[Layer] = TempBuffer; + } + + // Render Each layer's block to the appropriate temp buffer + for (u32 Layer = 0; Layer < CurrFrame.LayersCount; Layer++) + { + animation_layer_frame LayerFrame = CurrFrame.Layers[Layer]; + if (LayerFrame.HasHot) + { + led_buffer TempBuffer = LayerBuffers[Layer].HotBuffer; + animation_block Block = LayerFrame.Hot; + AnimationSystem_BeginRenderBlockToLedBuffer(System, Block, &TempBuffer, Patterns, PatternArgs, Context); + } + + if (LayerFrame.HasNextHot) + { + led_buffer TempBuffer = LayerBuffers[Layer].NextHotBuffer; + animation_block Block = LayerFrame.NextHot; + AnimationSystem_BeginRenderBlockToLedBuffer(System, Block, &TempBuffer, Patterns, PatternArgs, Context); + } + + AnimationSystem_EndRenderBlockToLedBuffer(System, Context); + } + + // Blend together any layers that have a hot and next hot buffer + for (u32 Layer = 0; Layer < CurrFrame.LayersCount; Layer++) + { + animation_layer_frame LayerFrame = CurrFrame.Layers[Layer]; + layer_led_buffer LayerBuffer = LayerBuffers[Layer]; + if (LayerFrame.HasNextHot) + { + LedBuffer_Blend(LayerBuffer.HotBuffer, + LayerBuffer.NextHotBuffer, + &LayerBuffer.HotBuffer, + LedBlend_Lerp, + (u8*)&LayerFrame.NextHotOpacity); + } + } + + // Consolidate Temp Buffers back into AssemblyLedBuffer + // We do this in reverse order so that they go from top to bottom + for (u32 Layer = 0; Layer < CurrFrame.LayersCount; Layer++) + { + if (CurrFrame.Layers[Layer].HasHot) + { + led_blend_proc* Blend = LedBlend_GetProc(CurrFrame.Layers[Layer].BlendMode); + LedBuffer_Blend(AccBuffer, + LayerBuffers[Layer].HotBuffer, + &AccBuffer, + Blend, + 0); + } + } + + return AccBuffer; } internal void @@ -96,106 +280,95 @@ AnimationSystem_RenderToLedBuffers(animation_system* System, assembly_array Asse led_system* LedSystem, animation_pattern_array Patterns, gs_memory_arena* Transient, + context Context, u8* UserData) { - s32 CurrentFrame = System->CurrentFrame; - r32 FrameTime = CurrentFrame * System->SecondsPerFrame; + DEBUG_TRACK_FUNCTION; + + r32 FrameTime = AnimationSystem_GetCurrentTime(*System); + +#if 1 + animation_array Animations = System->Animations; + animation_fade_group FadeGroup = System->ActiveFadeGroup; + + animation* FromAnim = AnimationArray_Get(Animations, FadeGroup.From); + animation_frame FromFrame = AnimationSystem_CalculateAnimationFrame(System, FromAnim, Transient); + layer_led_buffer* FromLayerBuffers = PushArray(Transient, layer_led_buffer, FromFrame.LayersCount); + + animation* ToAnim = AnimationArray_Get(Animations, FadeGroup.To); + animation_frame ToFrame = {0}; + layer_led_buffer* ToLayerBuffers = 0; + if (ToAnim) + { + ToFrame = AnimationSystem_CalculateAnimationFrame(System, ToAnim, Transient); + ToLayerBuffers = PushArray(Transient, layer_led_buffer, ToFrame.LayersCount); + } + + for (u32 AssemblyIndex = 0; AssemblyIndex < Assemblies.Count; AssemblyIndex++) + { + assembly Assembly = Assemblies.Values[AssemblyIndex]; + led_buffer* AssemblyLedBuffer = LedSystemGetBuffer(LedSystem, Assembly.LedBufferIndex); - animation* ActiveAnim = AnimationSystem_GetActiveAnimation(System); - animation_frame CurrFrame = AnimationSystem_CalculateAnimationFrame(System, Transient); + pattern_args PatternArgs = {}; + PatternArgs.Assembly = Assembly; + PatternArgs.Transient = Transient; + PatternArgs.UserData = UserData; - // NOTE(pjs): This mirrors animation_layer_frame to account - // for overlapping - struct layer_led_buffer - { - led_buffer HotBuffer; - led_buffer NextHotBuffer; - }; + led_buffer FromBuffer = RenderAnimationToLedBuffer(System, + PatternArgs, + FromFrame, + FromLayerBuffers, + AssemblyLedBuffer, + Patterns, + Transient, + Context); + led_buffer ConsolidatedBuffer = FromBuffer; - layer_led_buffer* LayerBuffers = PushArray(Transient, layer_led_buffer, CurrFrame.LayersCount); - - for (u32 AssemblyIndex = 0; AssemblyIndex < Assemblies.Count; AssemblyIndex++) - { - assembly* Assembly = &Assemblies.Values[AssemblyIndex]; - led_buffer* AssemblyLedBuffer = LedSystemGetBuffer(LedSystem, Assembly->LedBufferIndex); - - // Create the LayerLEDBuffers - for (u32 Layer = 0; Layer < CurrFrame.LayersCount; Layer++) - { - layer_led_buffer TempBuffer = {}; - if (CurrFrame.Layers[Layer].HasHot) - { - TempBuffer.HotBuffer.LedCount = AssemblyLedBuffer->LedCount; - TempBuffer.HotBuffer.Positions = AssemblyLedBuffer->Positions; - TempBuffer.HotBuffer.Colors = PushArray(Transient, pixel, TempBuffer.HotBuffer.LedCount); - LedBuffer_ClearToBlack(&TempBuffer.HotBuffer); - } - - if (CurrFrame.Layers[Layer].HasNextHot) - { - TempBuffer.NextHotBuffer.LedCount = AssemblyLedBuffer->LedCount; - TempBuffer.NextHotBuffer.Positions = AssemblyLedBuffer->Positions; - TempBuffer.NextHotBuffer.Colors = PushArray(Transient, pixel, TempBuffer.HotBuffer.LedCount); - LedBuffer_ClearToBlack(&TempBuffer.NextHotBuffer); - } - - LayerBuffers[Layer] = TempBuffer; - } - - // Render Each layer's block to the appropriate temp buffer - for (u32 Layer = 0; Layer < CurrFrame.LayersCount; Layer++) - { - animation_layer_frame LayerFrame = CurrFrame.Layers[Layer]; - if (LayerFrame.HasHot) - { - led_buffer TempBuffer = LayerBuffers[Layer].HotBuffer; - animation_block Block = LayerFrame.Hot; - AnimationSystem_RenderBlockToLedBuffer(System, Block, &TempBuffer, *Assembly, Patterns, Transient, UserData); - } - - if (LayerFrame.HasNextHot) - { - led_buffer TempBuffer = LayerBuffers[Layer].NextHotBuffer; - animation_block Block = LayerFrame.NextHot; - AnimationSystem_RenderBlockToLedBuffer(System, Block, &TempBuffer, *Assembly, Patterns, Transient, UserData); - } - } - - // Blend together any layers that have a hot and next hot buffer - for (u32 Layer = 0; Layer < CurrFrame.LayersCount; Layer++) - { - animation_layer_frame LayerFrame = CurrFrame.Layers[Layer]; - layer_led_buffer LayerBuffer = LayerBuffers[Layer]; - if (LayerFrame.HasNextHot) - { - for (u32 LED = 0; LED < AssemblyLedBuffer->LedCount; LED++) - { - pixel A = LayerBuffer.HotBuffer.Colors[LED]; - pixel B = LayerBuffer.NextHotBuffer.Colors[LED]; - LayerBuffer.HotBuffer.Colors[LED] = LedBlend_Overwrite(A, B, LayerFrame.HotOpacity); - } - } - } - - // Consolidate Temp Buffers - // We do this in reverse order so that they go from top to bottom - for (u32 Layer = 0; Layer < CurrFrame.LayersCount; Layer++) - { - if (CurrFrame.Layers[Layer].HasHot) - { - led_blend_proc* Blend = LedBlend_GetProc(ActiveAnim->Layers.Values[Layer].BlendMode); - Assert(Blend != 0); - for (u32 LED = 0; LED < AssemblyLedBuffer->LedCount; LED++) - { - pixel A = AssemblyLedBuffer->Colors[LED]; - pixel B = LayerBuffers[Layer].HotBuffer.Colors[LED]; - AssemblyLedBuffer->Colors[LED] = Blend(A, B); - } - } - } + if (ToAnim) { + led_buffer ToBuffer = RenderAnimationToLedBuffer(System, + PatternArgs, + ToFrame, + ToLayerBuffers, + AssemblyLedBuffer, + Patterns, + Transient, + Context); + + r32 BlendPercent = FadeGroup.FadeElapsed / FadeGroup.FadeDuration; + LedBuffer_Blend(FromBuffer, ToBuffer, &ConsolidatedBuffer, LedBlend_Lerp, (u8*)&BlendPercent); } - System->LastUpdatedFrame = System->CurrentFrame; + LedBuffer_Copy(ConsolidatedBuffer, AssemblyLedBuffer); + } + +#else + + animation* ActiveAnim = AnimationSystem_GetActiveAnimation(System); + animation_frame CurrFrame = AnimationSystem_CalculateAnimationFrame(System, ActiveAnim, Transient); + + for (u32 AssemblyIndex = 0; AssemblyIndex < Assemblies.Count; AssemblyIndex++) + { + assembly Assembly = Assemblies.Values[AssemblyIndex]; + led_buffer* AssemblyLedBuffer = LedSystemGetBuffer(LedSystem, Assembly.LedBufferIndex); + + pattern_args PatternArgs = {}; + PatternArgs.Assembly = Assembly; + PatternArgs.Transient = Transient; + PatternArgs.UserData = UserData; + + led_buffer AccBuffer = RenderAnimationToLedBuffer(System, + PatternArgs, + CurrFrame, + LayerBuffers, + AssemblyLedBuffer, + Patterns, + Transient); + LedBuffer_Copy(AccBuffer, AssemblyLedBuffer); + } + +#endif + + System->LastUpdatedFrame = System->CurrentFrame; } #define FOLDHAUS_ANIMATION_RENDERER_CPP diff --git a/src/app/engine/animation/foldhaus_animation_serializer.cpp b/src/app/engine/animation/foldhaus_animation_serializer.cpp index 7e688f2..55a4422 100644 --- a/src/app/engine/animation/foldhaus_animation_serializer.cpp +++ b/src/app/engine/animation/foldhaus_animation_serializer.cpp @@ -32,7 +32,7 @@ AnimSerializer_Serialize(animation Anim, animation_pattern_array Patterns, gs_me Serializer_OpenStruct(&Serializer, AnimField_Layer); { Serializer_WriteStringValue(&Serializer, AnimField_LayerName, LayerAt.Name.ConstString); - Serializer_WriteStringValue(&Serializer, AnimField_LayerBlendMode, BlendModeStrings[LayerAt.BlendMode]); + Serializer_WriteStringValue(&Serializer, AnimField_LayerBlendMode, BlendModeStrings[LayerAt.BlendMode].ConstString); } Serializer_CloseStruct(&Serializer); } @@ -82,12 +82,10 @@ AnimParser_Parse(gs_string File, gs_memory_arena* Arena, animation_pattern_array { Result.Name = Parser_ReadStringValue(&Parser, AnimField_AnimName); - Result.Layers.CountMax = Parser_ReadU32Value(&Parser, AnimField_LayersCount); - Result.Layers.Values = PushArray(Arena, anim_layer, Result.Layers.CountMax); - - Result.Blocks_.CountMax = Parser_ReadU32Value(&Parser, AnimField_BlocksCount); - Result.Blocks_.Generations = PushArray(Arena, u32, Result.Blocks_.CountMax); - Result.Blocks_.Values = PushArray(Arena, animation_block, Result.Blocks_.CountMax); + u32 LayersNeeded = Parser_ReadU32Value(&Parser, AnimField_LayersCount); + u32 BlocksNeeded = Parser_ReadU32Value(&Parser, AnimField_BlocksCount); + Result.Layers = AnimLayerArray_Create(Arena, LayersNeeded); + Result.Blocks_ = AnimBlockArray_Create(Arena, BlocksNeeded); if (Parser_ReadOpenStruct(&Parser, AnimField_PlayableRange)) { @@ -116,7 +114,7 @@ AnimParser_Parse(gs_string File, gs_memory_arena* Arena, animation_pattern_array gs_string BlendModeName = Parser_ReadStringValue(&Parser, AnimField_LayerBlendMode); for (u32 i = 0; i < BlendMode_Count; i++) { - if (StringsEqual(BlendModeName.ConstString, BlendModeStrings[i])) + if (StringsEqual(BlendModeName, BlendModeStrings[i])) { Layer.BlendMode = (blend_mode)i; break; @@ -169,7 +167,7 @@ AnimParser_Parse(gs_string File, gs_memory_arena* Arena, animation_pattern_array break; } } - + Assert(IsValid(Block.AnimationProcHandle)); if (Parser_ReadCloseStruct(&Parser)) { AnimBlockArray_Push(&Result.Blocks_, Block); @@ -182,9 +180,28 @@ AnimParser_Parse(gs_string File, gs_memory_arena* Arena, animation_pattern_array } } } - return Result; } +internal animation +AnimParser_Parse(gs_data File, gs_memory_arena* Arena, animation_pattern_array AnimPatterns) +{ + gs_string FileString = MakeString((char*)File.Memory, File.Size); + return AnimParser_Parse(FileString, Arena, AnimPatterns); +} +internal animation_handle +AnimationSystem_LoadAnimationFromFile(animation_system* System, animation_pattern_array AnimPatterns, context Context, gs_const_string FilePath) +{ + animation_handle NewAnimHandle = InvalidAnimHandle(); + gs_file AnimFile = ReadEntireFile(Context.ThreadContext.FileHandler, FilePath); + if (AnimFile.Size > 0) + { + animation NewAnim = AnimParser_Parse(AnimFile.Data, System->Storage, AnimPatterns); + NewAnim.FileInfo = AnimFile.FileInfo; + NewAnim.FileInfo.Path = PushStringF(System->Storage, AnimFile.FileInfo.Path.Length, "%S", AnimFile.FileInfo.Path).ConstString; + NewAnimHandle = AnimationArray_Push(&System->Animations, NewAnim); + } + return NewAnimHandle; +} #define FOLDHAUS_ANIMATION_SERIALIZER_CPP #endif // FOLDHAUS_ANIMATION_SERIALIZER_CPP \ No newline at end of file diff --git a/src/app/engine/assembly/foldhaus_assembly.cpp b/src/app/engine/assembly/foldhaus_assembly.cpp index 4ae1a6c..0e383f0 100644 --- a/src/app/engine/assembly/foldhaus_assembly.cpp +++ b/src/app/engine/assembly/foldhaus_assembly.cpp @@ -14,34 +14,35 @@ internal assembly_array AssemblyArray_Create(u32 CountMax, gs_memory_arena* Storage) { - assembly_array Result = {0}; - Result.CountMax = CountMax; - Result.Values = PushArray(Storage, assembly, Result.CountMax); - return Result; + assembly_array Result = {0}; + Result.CountMax = CountMax; + Result.Values = PushArray(Storage, assembly, Result.CountMax); + return Result; } internal u32 AssemblyArray_Push(assembly_array* Array, assembly Assembly) { - Assert(Array->Count < Array->CountMax); - u32 Index = Array->Count++; - Array->Values[Index] = Assembly; - return Index; + Assert(Array->Count < Array->CountMax); + u32 Index = Array->Count++; + Array->Values[Index] = Assembly; + Array->Values[Index].AssemblyIndex = Index; + return Index; } internal assembly* AssemblyArray_Take(assembly_array* Array) { - u32 Index = AssemblyArray_Push(Array, {}); - assembly* Result = Array->Values + Index; - return Result; + u32 Index = AssemblyArray_Push(Array, {}); + assembly* Result = Array->Values + Index; + return Result; } internal void AssemblyArray_RemoveAt(assembly_array* Array, u32 Index) { - u32 LastAssemblyIndex = --Array->Count; - Array->Values[Index] = Array->Values[LastAssemblyIndex]; + u32 LastAssemblyIndex = --Array->Count; + Array->Values[Index] = Array->Values[LastAssemblyIndex]; } typedef bool assembly_array_filter_proc(assembly A); @@ -51,18 +52,18 @@ bool AssemblyFilter_OutputsViaUART(assembly A) { return A.OutputMode == NetworkP internal assembly_array AssemblyArray_Filter(assembly_array Array, assembly_array_filter_proc* Filter, gs_memory_arena* Storage) { - assembly_array Result = AssemblyArray_Create(Array.Count, Storage); - - for (u32 i = 0; i < Array.Count; i++) + assembly_array Result = AssemblyArray_Create(Array.Count, Storage); + + for (u32 i = 0; i < Array.Count; i++) + { + assembly At = Array.Values[i]; + if (Filter(At)) { - assembly At = Array.Values[i]; - if (Filter(At)) - { - AssemblyArray_Push(&Result, At); - } + AssemblyArray_Push(&Result, At); } - - return Result; + } + + return Result; } /////////////////////////// @@ -74,173 +75,177 @@ AssemblyArray_Filter(assembly_array Array, assembly_array_filter_proc* Filter, g internal led_system LedSystem_Create(gs_allocator PlatformMemory, u32 BuffersMax) { - led_system Result = {}; - Result.PlatformMemory = PlatformMemory; - // TODO(Peter): Since we have access to PlatformMemory, just realloc Buffers when we fill it up - Result.BuffersCountMax = BuffersMax; - Result.Buffers = AllocatorAllocArray(PlatformMemory, led_buffer, Result.BuffersCountMax); - return Result; + led_system Result = {}; + Result.PlatformMemory = PlatformMemory; + // TODO(Peter): Since we have access to PlatformMemory, just realloc Buffers when we fill it up + Result.BuffersCountMax = BuffersMax; + Result.Buffers = AllocArray(PlatformMemory, led_buffer, Result.BuffersCountMax, "led system"); + return Result; } internal u32 LedSystemTakeFreeBuffer(led_system* System, u32 LedCount) { - s32 Result = -1; - - if (System->BuffersCount < System->BuffersCountMax) + s32 Result = -1; + + if (System->BuffersCount < System->BuffersCountMax) + { + Result = System->BuffersCount++; + } + else + { + // NOTE(Peter): Look for a buffer that's flagged as empty + for (u32 i = 0; i < System->BuffersCount; i++) { - Result = System->BuffersCount++; + if (System->Buffers[i].LedCount == 0 + && System->Buffers[i].Colors == 0 + && System->Buffers[i].Positions == 0) + { + Result = i; + break; + } } - else - { - // NOTE(Peter): Look for a buffer that's flagged as empty - for (u32 i = 0; i < System->BuffersCount; i++) - { - if (System->Buffers[i].LedCount == 0 - && System->Buffers[i].Colors == 0 - && System->Buffers[i].Positions == 0) - { - Result = i; - break; - } - } - Assert(Result >= 0); // NOTE(Peter): We ran out of room for led buffers - } - - led_buffer* Buffer = &System->Buffers[Result]; - Buffer->LedCount = LedCount; - Buffer->Colors = AllocatorAllocArray(System->PlatformMemory, pixel, Buffer->LedCount); - Buffer->Positions = AllocatorAllocArray(System->PlatformMemory, v4, Buffer->LedCount); - - System->LedsCountTotal += LedCount; - - return (u32)Result; + Assert(Result >= 0); // NOTE(Peter): We ran out of room for led buffers + } + + led_buffer* Buffer = &System->Buffers[Result]; + Buffer->A = MemoryArenaCreate(KB(16),Bytes(8),System->PlatformMemory,0,0,"Led Buffer Arena"); + Buffer->LedCount = LedCount; + Buffer->Colors = PushArray(&Buffer->A, pixel, Buffer->LedCount); + Buffer->Positions = PushArray(&Buffer->A, v4, Buffer->LedCount); + + System->LedsCountTotal += LedCount; + + return (u32)Result; } internal void LedSystemFreeBuffer(led_system* System, u32 BufferIndex) { - Assert(BufferIndex < System->BuffersCountMax); - led_buffer* Buffer = &System->Buffers[BufferIndex]; - AllocatorFreeArray(System->PlatformMemory, Buffer->Colors, pixel, Buffer->LedCount); - AllocatorFreeArray(System->PlatformMemory, Buffer->Positions, v4, Buffer->LedCount); - System->LedsCountTotal -= Buffer->LedCount; - *Buffer = {}; + Assert(BufferIndex < System->BuffersCountMax); + led_buffer* Buffer = &System->Buffers[BufferIndex]; + MemoryArenaFree(&Buffer->A); + System->LedsCountTotal -= Buffer->LedCount; + *Buffer = {}; } internal void LedBufferSetLed(led_buffer* Buffer, u32 Led, v4 Position) { - Assert(Led < Buffer->LedCount); - Buffer->Positions[Led] = Position; + Assert(Led < Buffer->LedCount); + Buffer->Positions[Led] = Position; } internal u32 Assembly_ConstructStrip(assembly* Assembly, led_buffer* LedBuffer, v2_strip* StripAt, strip_gen_data GenData, v4 RootPosition, u32 LedStartIndex, u32 LedLUTStartIndex) { - u32 LedsAdded = 0; - - switch (GenData.Method) + u32 LedsAdded = 0; + + switch (GenData.Method) + { + case StripGeneration_InterpolatePoints: { - case StripGeneration_InterpolatePoints: - { - strip_gen_interpolate_points InterpPoints = GenData.InterpolatePoints; - v4 WS_StripStart = RootPosition + ToV4Point(InterpPoints.StartPosition * Assembly->Scale); - v4 WS_StripEnd = RootPosition + ToV4Point(InterpPoints.EndPosition * Assembly->Scale); - - v4 SingleStep = (WS_StripEnd - WS_StripStart) / (r32)InterpPoints.LedCount; - for (u32 Step = 0; Step < InterpPoints.LedCount; Step++) - { - s32 LedIndex = LedStartIndex + LedsAdded++; - v4 LedPosition = WS_StripStart + (SingleStep * Step); - LedBufferSetLed(LedBuffer, LedIndex, LedPosition); - StripAt->LedLUT[Step + LedLUTStartIndex] = LedIndex; - } - }break; - - case StripGeneration_Sequence: - { - strip_gen_sequence Sequence = GenData.Sequence; - for (u32 i = 0; i < Sequence.ElementsCount; i++) - { - strip_gen_data SegmentGenData = Sequence.Elements[i]; - LedsAdded += Assembly_ConstructStrip(Assembly, LedBuffer, StripAt, SegmentGenData, RootPosition, LedStartIndex + LedsAdded, LedsAdded); - } - }break; - - InvalidDefaultCase; - } + strip_gen_interpolate_points InterpPoints = GenData.InterpolatePoints; + v4 WS_StripStart = RootPosition + ToV4Point(InterpPoints.StartPosition * Assembly->Scale); + v4 WS_StripEnd = RootPosition + ToV4Point(InterpPoints.EndPosition * Assembly->Scale); + + v4 SingleStep = (WS_StripEnd - WS_StripStart) / (r32)InterpPoints.LedCount; + for (u32 Step = 0; Step < InterpPoints.LedCount; Step++) + { + s32 LedIndex = LedStartIndex + LedsAdded++; + v4 LedPosition = WS_StripStart + (SingleStep * Step); + LedBufferSetLed(LedBuffer, LedIndex, LedPosition); + StripAt->LedLUT[Step + LedLUTStartIndex] = LedIndex; + } + }break; - return LedsAdded; + case StripGeneration_Sequence: + { + strip_gen_sequence Sequence = GenData.Sequence; + for (u32 i = 0; i < Sequence.ElementsCount; i++) + { + strip_gen_data SegmentGenData = Sequence.Elements[i]; + LedsAdded += Assembly_ConstructStrip(Assembly, LedBuffer, StripAt, SegmentGenData, RootPosition, LedStartIndex + LedsAdded, LedsAdded); + } + }break; + + InvalidDefaultCase; + } + + return LedsAdded; } internal void ConstructAssemblyFromDefinition (assembly* Assembly, led_system* LedSystem) { - Assembly->LedBufferIndex = LedSystemTakeFreeBuffer(LedSystem, Assembly->LedCountTotal); - led_buffer* LedBuffer = LedSystemGetBuffer(LedSystem, Assembly->LedBufferIndex); + Assembly->LedBufferIndex = LedSystemTakeFreeBuffer(LedSystem, Assembly->LedCountTotal); + led_buffer* LedBuffer = LedSystemGetBuffer(LedSystem, Assembly->LedBufferIndex); + + v4 RootPosition = ToV4Vec(Assembly->Center); + + // Add Leds + u32 LedsAdded = 0; + for (u32 StripIdx = 0; StripIdx < Assembly->StripCount; StripIdx++) + { + v2_strip* StripAt = &Assembly->Strips[StripIdx]; + StripAt->LedLUT = PushArray(&Assembly->Arena, u32, StripAt->LedCount); - v4 RootPosition = ToV4Vec(Assembly->Center); - - // Add Leds - u32 LedsAdded = 0; - for (u32 StripIdx = 0; StripIdx < Assembly->StripCount; StripIdx++) - { - v2_strip* StripAt = &Assembly->Strips[StripIdx]; - StripAt->LedLUT = PushArray(&Assembly->Arena, u32, StripAt->LedCount); - - strip_gen_data GenData = StripAt->GenerationData; - LedsAdded += Assembly_ConstructStrip(Assembly, LedBuffer, StripAt, GenData, RootPosition, LedsAdded, 0); - } + strip_gen_data GenData = StripAt->GenerationData; + LedsAdded += Assembly_ConstructStrip(Assembly, LedBuffer, StripAt, GenData, RootPosition, LedsAdded, 0); + } } -internal void -LoadAssembly (assembly_array* Assemblies, led_system* LedSystem, gs_memory_arena* Scratch, context Context, gs_const_string Path, event_log* GlobalLog) +internal assembly* +LoadAssembly (assembly_array* Assemblies, led_system* LedSystem, gs_memory_arena* Scratch, context Context, gs_const_string Path, log_buffer* GlobalLog) { - gs_file AssemblyFile = ReadEntireFile(Context.ThreadContext.FileHandler, Path); - if (FileNoError(AssemblyFile)) + assembly* NewAssembly = 0; + + gs_file AssemblyFile = ReadEntireFile(Context.ThreadContext.FileHandler, Path); + if (FileNoError(AssemblyFile)) + { + gs_string AssemblyFileText = MakeString((char*)AssemblyFile.Memory); + + s32 IndexOfLastSlash = FindLast(Path, '\\'); + gs_const_string FileName = Substring(Path, IndexOfLastSlash + 1, Path.Length); + + NewAssembly = AssemblyArray_Take(Assemblies); + NewAssembly->Arena = MemoryArenaCreate(MB(4), Bytes(8), Context.ThreadContext.Allocator, 0, 0, "Assembly Arena"); + + parser AssemblyParser = ParseAssemblyFile(NewAssembly, FileName, AssemblyFileText, Scratch); + if (AssemblyParser.Success) { - gs_string AssemblyFileText = MakeString((char*)AssemblyFile.Memory); - - s32 IndexOfLastSlash = FindLast(Path, '\\'); - gs_const_string FileName = Substring(Path, IndexOfLastSlash + 1, Path.Length); - - assembly* NewAssembly = AssemblyArray_Take(Assemblies); - NewAssembly->Arena = CreateMemoryArena(Context.ThreadContext.Allocator); - - parser AssemblyParser = ParseAssemblyFile(NewAssembly, FileName, AssemblyFileText, Scratch); - if (AssemblyParser.Success) - { - ConstructAssemblyFromDefinition(NewAssembly, LedSystem); - } - else - { - FreeMemoryArena(&NewAssembly->Arena); - Assemblies->Count -= 1; - } - - for (parser_error* ErrorAt = AssemblyParser.ErrorsRoot; - ErrorAt != 0; - ErrorAt = ErrorAt->Next) - { - OutputDebugString(ErrorAt->Message.Str); - } - + ConstructAssemblyFromDefinition(NewAssembly, LedSystem); } else { - LogError(GlobalLog, "Unable to load assembly file"); + MemoryArenaFree(&NewAssembly->Arena); + Assemblies->Count -= 1; } + + for (parser_error* ErrorAt = AssemblyParser.ErrorsRoot; + ErrorAt != 0; + ErrorAt = ErrorAt->Next) + { + Log_Error(GlobalLogBuffer, ErrorAt->Message.Str); + } + + } + else + { + Log_Error(GlobalLog, "Unable to load assembly file"); + } + + return NewAssembly; } internal void UnloadAssembly (u32 AssemblyIndex, app_state* State, context Context) { - Assert(AssemblyIndex < State->Assemblies.Count); - assembly* Assembly = &State->Assemblies.Values[AssemblyIndex]; - LedSystemFreeBuffer(&State->LedSystem, Assembly->LedBufferIndex); - FreeMemoryArena(&Assembly->Arena); - AssemblyArray_RemoveAt(&State->Assemblies, AssemblyIndex); + Assert(AssemblyIndex < State->Assemblies.Count); + assembly* Assembly = &State->Assemblies.Values[AssemblyIndex]; + LedSystemFreeBuffer(&State->LedSystem, Assembly->LedBufferIndex); + MemoryArenaFree(&Assembly->Arena); + AssemblyArray_RemoveAt(&State->Assemblies, AssemblyIndex); } // Querying Assemblies @@ -248,30 +253,30 @@ UnloadAssembly (u32 AssemblyIndex, app_state* State, context Context) internal led_strip_list AssemblyStripsGetWithTagValue(assembly Assembly, gs_const_string TagName, gs_const_string TagValue, gs_memory_arena* Storage) { - led_strip_list Result = {0}; - // TODO(pjs): @Optimization - // We can probably come back here and do this allocation procedurally, or in buckets, or with - // a linked list. But for now, I just want to get this up and running - Result.CountMax = Assembly.StripCount; - Result.StripIndices = PushArray(Storage, u32, Result.CountMax); - - u64 NameHash = HashDJB2ToU32(StringExpand(TagName)); - u64 ValueHash = 0; - if (TagValue.Length > 0) + led_strip_list Result = {0}; + // TODO(pjs): @Optimization + // We can probably come back here and do this allocation procedurally, or in buckets, or with + // a linked list. But for now, I just want to get this up and running + Result.CountMax = Assembly.StripCount; + Result.StripIndices = PushArray(Storage, u32, Result.CountMax); + + u64 NameHash = HashDJB2ToU32(StringExpand(TagName)); + u64 ValueHash = 0; + if (TagValue.Length > 0) + { + ValueHash = HashDJB2ToU32(StringExpand(TagValue)); + } + + for (u32 StripIndex = 0; StripIndex < Assembly.StripCount; StripIndex++) + { + v2_strip StripAt = Assembly.Strips[StripIndex]; + if (AssemblyStrip_HasTagValue(StripAt, NameHash, ValueHash)) { - ValueHash = HashDJB2ToU32(StringExpand(TagValue)); + Result.StripIndices[Result.Count++] = StripIndex; } - - for (u32 StripIndex = 0; StripIndex < Assembly.StripCount; StripIndex++) - { - v2_strip StripAt = Assembly.Strips[StripIndex]; - if (AssemblyStrip_HasTagValue(StripAt, NameHash, ValueHash)) - { - Result.StripIndices[Result.Count++] = StripIndex; - } - } - - return Result; + } + + return Result; } #define FOLDHAUS_ASSEMBLY_CPP diff --git a/src/app/engine/assembly/foldhaus_assembly.h b/src/app/engine/assembly/foldhaus_assembly.h index 677d4ff..b1b9db9 100644 --- a/src/app/engine/assembly/foldhaus_assembly.h +++ b/src/app/engine/assembly/foldhaus_assembly.h @@ -7,230 +7,291 @@ enum network_protocol { - NetworkProtocol_SACN, - NetworkProtocol_ArtNet, - NetworkProtocol_UART, - - NetworkProtocol_Count, + NetworkProtocol_SACN, + NetworkProtocol_ArtNet, + NetworkProtocol_UART, + + NetworkProtocol_Count, }; union pixel { - struct - { - u8 R; - u8 G; - u8 B; - }; - u8 Channels[3]; + struct + { + u8 R; + u8 G; + u8 B; + }; + u8 Channels[3]; }; struct led_buffer { - u32 LedCount; - pixel* Colors; - v4* Positions; + // NOTE(PS): This is just a tracking structure, + // that enables allocations for a particular buffer + // to occur all in contiguous memory + // and should not be pushed to after the initial + // allocation + gs_memory_arena A; + + u32 LedCount; + pixel* Colors; + v4* Positions; +}; + +struct led_buffer_range +{ + u32 First; + u32 OnePastLast; }; struct led_system { - gs_allocator PlatformMemory; - - u32 BuffersCountMax; - u32 BuffersCount; - led_buffer* Buffers; - - u32 LedsCountTotal; + gs_allocator PlatformMemory; + + u32 BuffersCountMax; + u32 BuffersCount; + led_buffer* Buffers; + + u32 LedsCountTotal; }; struct v2_tag { - u64 NameHash; - u64 ValueHash; + u64 NameHash; + u64 ValueHash; }; struct strip_sacn_addr { - s32 StartUniverse; - s32 StartChannel; + s32 StartUniverse; + s32 StartChannel; }; struct strip_uart_addr { - u8 Channel; - - gs_string ComPort; - // This may not be used based on the value of the parent - // assembly's NetworkPortMode field + u8 Channel; + + gs_string ComPort; + // This may not be used based on the value of the parent + // assembly's NetworkPortMode field }; enum strip_gen_method { - StripGeneration_InterpolatePoints, - StripGeneration_Sequence, - - StripGeneration_Count, + StripGeneration_InterpolatePoints, + StripGeneration_Sequence, + + StripGeneration_Count, }; typedef struct strip_gen_data strip_gen_data; struct strip_gen_interpolate_points { - v3 StartPosition; - v3 EndPosition; - u32 LedCount; + v3 StartPosition; + v3 EndPosition; + u32 LedCount; }; struct strip_gen_sequence { - strip_gen_data* Elements; - u32 ElementsCount; + strip_gen_data* Elements; + u32 ElementsCount; }; struct strip_gen_data { - strip_gen_method Method; - - strip_gen_interpolate_points InterpolatePoints; - strip_gen_sequence Sequence; + strip_gen_method Method; + + strip_gen_interpolate_points InterpolatePoints; + strip_gen_sequence Sequence; }; struct v2_strip { - s32 ControlBoxID; // TODO(Peter): I don't think we need this anymore - - strip_sacn_addr SACNAddr; - strip_uart_addr UARTAddr; - - strip_gen_data GenerationData; - - u32 LedCount; - u32* LedLUT; - - u32 TagsCount; - v2_tag* Tags; + s32 ControlBoxID; // TODO(Peter): I don't think we need this anymore + + strip_sacn_addr SACNAddr; + strip_uart_addr UARTAddr; + + strip_gen_data GenerationData; + + u32 LedCount; + u32* LedLUT; + + u32 TagsCount; + v2_tag* Tags; }; struct led_strip_list { - u32 Count; - u32 CountMax; - u32* StripIndices; + u32 Count; + u32 CountMax; + u32* StripIndices; }; enum network_port_mode { - // This enum defines the scope which contains what network - // port each address should be sent over. - - NetworkPortMode_GlobalPort, - // GlobalPort means that the port is defined in the assembly structure - - NetworkPortMode_PortPerStrip, - // PortPerStrip means that the address stored in the strip structure - // should be used, and each strip might have a different port - - NetworkPortMode_Count, + // This enum defines the scope which contains what network + // port each address should be sent over. + + NetworkPortMode_GlobalPort, + // GlobalPort means that the port is defined in the assembly structure + + NetworkPortMode_PortPerStrip, + // PortPerStrip means that the address stored in the strip structure + // should be used, and each strip might have a different port + + NetworkPortMode_Count, }; struct assembly { - gs_memory_arena Arena; - - gs_string Name; - gs_string FilePath; - - r32 Scale; - v3 Center; - s32 LedCountTotal; - u32 LedBufferIndex; - - u32 StripCount; - v2_strip* Strips; - - network_protocol OutputMode; - network_port_mode NetPortMode; - gs_string UARTComPort; + gs_memory_arena Arena; + + u32 AssemblyIndex; + gs_string Name; + gs_string FilePath; + + r32 Scale; + v3 Center; + v3 MinLedPos, MaxLedPos; + s32 LedCountTotal; + u32 LedBufferIndex; + + u32 StripCount; + v2_strip* Strips; + + network_protocol OutputMode; + network_port_mode NetPortMode; + gs_string UARTComPort; }; struct assembly_array { - u32 CountMax; - u32 Count; - assembly* Values; + u32 CountMax; + u32 Count; + assembly* Values; }; +typedef pixel led_blend_proc(pixel A, pixel B, u8* UserData); + internal led_buffer* LedSystemGetBuffer(led_system* System, u32 Index) { - led_buffer* Result = &System->Buffers[Index]; - return Result; + led_buffer* Result = &System->Buffers[Index]; + return Result; } internal void LedBuffer_ClearToBlack(led_buffer* Buffer) { - for (u32 i = 0; i < Buffer->LedCount; i++) - { - Buffer->Colors[i].R = 0; - Buffer->Colors[i].G = 0; - Buffer->Colors[i].B = 0; - } + for (u32 i = 0; i < Buffer->LedCount; i++) + { + Buffer->Colors[i].R = 0; + Buffer->Colors[i].G = 0; + Buffer->Colors[i].B = 0; + } +} + +internal void +LedBuffer_Copy(led_buffer From, led_buffer* To) +{ + DEBUG_TRACK_FUNCTION; + + Assert(From.LedCount == To->LedCount); + u32 LedCount = To->LedCount; + for (u32 i = 0; i < LedCount; i++) + { + To->Colors[i] = From.Colors[i]; + } +} + +internal void +LedBuffer_Blend(led_buffer A, led_buffer B, led_buffer* Dest, led_blend_proc* BlendProc, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + + Assert(A.LedCount == B.LedCount); + Assert(Dest->LedCount == A.LedCount); + Assert(BlendProc); + + u32 LedCount = Dest->LedCount; + for (u32 i = 0; i < LedCount; i++) + { + pixel PA = A.Colors[i]; + pixel PB = B.Colors[i]; + Dest->Colors[i] = BlendProc(PA, PB, UserData); + } +} + +internal led_buffer +LedBuffer_CreateCopyCleared (led_buffer Buffer, gs_memory_arena* Arena) +{ + DEBUG_TRACK_FUNCTION; + + led_buffer Result = {}; + Result.LedCount = Buffer.LedCount; + Result.Positions = Buffer.Positions; + Result.Colors = PushArray(Arena, pixel, Buffer.LedCount); + LedBuffer_ClearToBlack(&Result); + return Result; } internal u32 StripGenData_CountLeds(strip_gen_data Data) { - u32 Result = 0; - - switch (Data.Method) + u32 Result = 0; + + switch (Data.Method) + { + case StripGeneration_InterpolatePoints: { - case StripGeneration_InterpolatePoints: - { - Result += Data.InterpolatePoints.LedCount; - }break; - - case StripGeneration_Sequence: - { - for (u32 i = 0; i < Data.Sequence.ElementsCount; i++) - { - Result += StripGenData_CountLeds(Data.Sequence.Elements[i]); - } - }break; - - InvalidDefaultCase; - } + Result += Data.InterpolatePoints.LedCount; + }break; - return Result; + case StripGeneration_Sequence: + { + for (u32 i = 0; i < Data.Sequence.ElementsCount; i++) + { + Result += StripGenData_CountLeds(Data.Sequence.Elements[i]); + } + }break; + + InvalidDefaultCase; + } + + return Result; } internal bool AssemblyStrip_HasTagValue(v2_strip Strip, u64 NameHash, u64 ValueHash) { - bool Result = false; - for (u32 i = 0; i < Strip.TagsCount; i++) + bool Result = false; + for (u32 i = 0; i < Strip.TagsCount; i++) + { + v2_tag TagAt = Strip.Tags[i]; + if (TagAt.NameHash == NameHash) { - v2_tag TagAt = Strip.Tags[i]; - if (TagAt.NameHash == NameHash) - { - // NOTE(pjs): We can pass an empty string to the Value parameter, - // and it will match all values of Tag - if (ValueHash == 0 || ValueHash == TagAt.ValueHash) - { - Result = true; - break; - } - } + // NOTE(pjs): We can pass an empty string to the Value parameter, + // and it will match all values of Tag + if (ValueHash == 0 || ValueHash == TagAt.ValueHash) + { + Result = true; + break; + } } - return Result; + } + return Result; } internal bool AssemblyStrip_HasTagValueSLOW(v2_strip Strip, char* Name, char* Value) { - u64 NameHash = HashDJB2ToU32(Name); - u64 ValueHash = HashDJB2ToU32(Value); - return AssemblyStrip_HasTagValue(Strip, NameHash, ValueHash); + u64 NameHash = HashDJB2ToU32(Name); + u64 ValueHash = HashDJB2ToU32(Value); + return AssemblyStrip_HasTagValue(Strip, NameHash, ValueHash); } #define FOLDHAUS_ASSEMBLY_H diff --git a/src/app/engine/assembly/foldhaus_assembly_debug.h b/src/app/engine/assembly/foldhaus_assembly_debug.h index 07a3685..ffe33ed 100644 --- a/src/app/engine/assembly/foldhaus_assembly_debug.h +++ b/src/app/engine/assembly/foldhaus_assembly_debug.h @@ -16,6 +16,7 @@ enum override_type ADS_Override_AllBlue, ADS_Override_AllOff, ADS_Override_AllWhite, + ADS_Override_AllHue, ADS_Override_TagWhite, ADS_Override_TagStripWhite, ADS_Override_ChannelWhite, @@ -32,6 +33,7 @@ global gs_const_string OverrideTypeStrings[] = { LitString("Override_AllBlue" ), LitString("ADS_Override_AllOff" ), LitString("ADS_Override_AllWhite" ), + LitString("ADS_Override_AllHue" ), LitString("ADS_Override_TagWhite" ), LitString("ADS_Override_TagStripWhite" ), LitString("ADS_Override_ChannelWhite," ), @@ -42,12 +44,14 @@ struct assembly_debug_state { override_type Override; + bool AllAssemblies; u32 TargetAssembly; u32 TargetStrip; gs_string TagName; gs_string TagValue; + u32 TargetHue; pixel TargetColor; u32 TargetChannel; @@ -101,12 +105,9 @@ AssemblyDebug_OverrideTagValueWithColor(assembly Assembly, led_buffer LedBuffer, } internal void -AssemblyDebug_OverrideOutput(assembly_debug_state State, assembly_array Assemblies, led_system LedSystem) +AssemblyDebug_OverrideOutputForAssembly(assembly_debug_state State, led_system LedSystem, + assembly Assembly) { - if (State.Override == ADS_Override_None) return; - State.TargetColor = pixel{255,255,255}; - - assembly Assembly = Assemblies.Values[State.TargetAssembly]; led_buffer LedBuffer = LedSystem.Buffers[Assembly.LedBufferIndex]; u8 V = State.Brightness; @@ -160,6 +161,14 @@ AssemblyDebug_OverrideOutput(assembly_debug_state State, assembly_array Assembli AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{V, V, V}); }break; + case ADS_Override_AllHue: + { + v4 HSV = v4{(r32)State.TargetHue, 1, 1, 1}; + v4 RGB = HSVToRGB(HSV); + pixel P = V4ToRGBPixel(RGB); + AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, P); + }break; + case ADS_Override_TagWhite: { AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{0, 0, 0}); @@ -201,10 +210,26 @@ AssemblyDebug_OverrideOutput(assembly_debug_state State, assembly_array Assembli InvalidDefaultCase; } +} + +internal void +AssemblyDebug_OverrideOutput(assembly_debug_state State, assembly_array Assemblies, led_system LedSystem) +{ + if (State.Override == ADS_Override_None) return; + State.TargetColor = pixel{255,255,255}; - if (State.Override ) + if (State.AllAssemblies) { - + for (u32 i = 0; i < Assemblies.Count; i++) + { + assembly Assembly = Assemblies.Values[i]; + AssemblyDebug_OverrideOutputForAssembly(State, LedSystem, Assembly); + } + } + else + { + assembly Assembly = Assemblies.Values[State.TargetAssembly]; + AssemblyDebug_OverrideOutputForAssembly(State, LedSystem, Assembly); } } diff --git a/src/app/engine/assembly/foldhaus_assembly_parser.cpp b/src/app/engine/assembly/foldhaus_assembly_parser.cpp index 5024fb6..dbeb890 100644 --- a/src/app/engine/assembly/foldhaus_assembly_parser.cpp +++ b/src/app/engine/assembly/foldhaus_assembly_parser.cpp @@ -276,7 +276,7 @@ ParseAssemblyFile(assembly* Assembly, gs_const_string FileName, gs_string FileTe Assembly->Name = Parser_ReadStringValue(&Parser, AssemblyField_AssemblyName); Assembly->Scale = Parser_ReadR32Value(&Parser, AssemblyField_AssemblyScale); - Assembly->Center = Parser_ReadV3Value(&Parser, AssemblyField_AssemblyCenter); + Assembly->Center = Parser_ReadV3Value(&Parser, AssemblyField_AssemblyCenter) * Assembly->Scale; Assembly->StripCount = Parser_ReadU32Value(&Parser, AssemblyField_LedStripCount); Assembly->Strips = PushArray(&Assembly->Arena, v2_strip, Assembly->StripCount); diff --git a/src/app/engine/foldhaus_addressed_data.h b/src/app/engine/foldhaus_addressed_data.h index c27bd59..e2db91e 100644 --- a/src/app/engine/foldhaus_addressed_data.h +++ b/src/app/engine/foldhaus_addressed_data.h @@ -11,97 +11,97 @@ enum data_buffer_address_type { - AddressType_NetworkIP, - AddressType_ComPort, - AddressType_Invalid, + AddressType_NetworkIP, + AddressType_ComPort, + AddressType_Invalid, }; struct addressed_data_buffer { - union + union + { + struct { - struct - { - u8* Memory; - u32 MemorySize; - }; - gs_data Data; + u8* Memory; + u32 MemorySize; }; - - data_buffer_address_type AddressType; - - // IP Address - platform_socket_handle SendSocket; - u32 V4SendAddress; - u32 SendPort; - - // COM - gs_const_string ComPort; - - addressed_data_buffer* Next; + gs_data Data; + }; + + data_buffer_address_type AddressType; + + // IP Address + platform_socket_handle SendSocket; + u32 V4SendAddress; + u32 SendPort; + + // COM + gs_const_string ComPort; + + addressed_data_buffer* Next; }; struct addressed_data_buffer_list { - gs_memory_arena* Arena; - addressed_data_buffer* Root; - addressed_data_buffer* Head; + gs_memory_arena* Arena; + addressed_data_buffer* Root; + addressed_data_buffer* Head; }; internal void AddressedDataBufferList_Clear(addressed_data_buffer_list* List) { - List->Root = 0; - List->Head = 0; - ClearArena(List->Arena); + List->Root = 0; + List->Head = 0; + MemoryArenaClear(List->Arena); } internal addressed_data_buffer* AddressedDataBufferList_PushEmpty(addressed_data_buffer_list* List) { - addressed_data_buffer* Result = PushStruct(List->Arena, addressed_data_buffer); - *Result = {0}; - Result->Next = 0; - Result->MemorySize = 0; - Result->Memory = 0; - - SLLPushOrInit(List->Root, List->Head, Result); - - return Result; + addressed_data_buffer* Result = PushStruct(List->Arena, addressed_data_buffer); + *Result = {0}; + Result->Next = 0; + Result->MemorySize = 0; + Result->Memory = 0; + + SLLPushOrInit(List->Root, List->Head, Result); + + return Result; } internal addressed_data_buffer* AddressedDataBufferList_Push(addressed_data_buffer_list* List, u32 BufferSize) { - addressed_data_buffer* Result = AddressedDataBufferList_PushEmpty(List); - Result->MemorySize = BufferSize; - Result->Memory = PushArray(List->Arena, u8, Result->MemorySize); - return Result; + addressed_data_buffer* Result = AddressedDataBufferList_PushEmpty(List); + Result->MemorySize = BufferSize; + Result->Memory = PushArray(List->Arena, u8, Result->MemorySize); + return Result; } internal void AddressedDataBuffer_SetNetworkAddress(addressed_data_buffer* Buffer, platform_socket_handle SendSocket, u32 V4SendAddress, u32 SendPort) { - Buffer->AddressType = AddressType_NetworkIP; - Buffer->SendSocket = SendSocket; - Buffer->V4SendAddress = V4SendAddress; - Buffer->SendPort = SendPort; + Buffer->AddressType = AddressType_NetworkIP; + Buffer->SendSocket = SendSocket; + Buffer->V4SendAddress = V4SendAddress; + Buffer->SendPort = SendPort; } internal void AddressedDataBuffer_SetCOMPort(addressed_data_buffer* Buffer, gs_const_string ComPort) { - Buffer->AddressType = AddressType_ComPort; - Buffer->ComPort = ComPort; + Buffer->AddressType = AddressType_ComPort; + Buffer->ComPort = ComPort; } internal addressed_data_buffer_list AddressedDataBufferList_Create(gs_thread_context TC) { - addressed_data_buffer_list Result = {}; - Result.Arena = AllocatorAllocStruct(TC.Allocator, gs_memory_arena); - *Result.Arena = CreateMemoryArena(TC.Allocator); - return Result; + addressed_data_buffer_list Result = {}; + Result.Arena = AllocStruct(TC.Allocator, gs_memory_arena, "Addressed Data"); + *Result.Arena = MemoryArenaCreate(KB(256), Bytes(8), TC.Allocator, 0, 0, "Addressed Data Buffer List Arena"); + return Result; } #define FOLDHAUS_ADDRESSED_DATA_H diff --git a/src/app/engine/foldhaus_log.h b/src/app/engine/foldhaus_log.h new file mode 100644 index 0000000..3d538b2 --- /dev/null +++ b/src/app/engine/foldhaus_log.h @@ -0,0 +1,126 @@ +/* date = April 12th 2021 4:25 pm */ + +#ifndef FOLDHAUS_LOG_H +#define FOLDHAUS_LOG_H + +enum log_entry_type +{ + LogEntry_Message, + LogEntry_Error, +}; + +struct log_entry +{ + log_entry_type Type; + gs_string String; +}; + +struct log_buffer +{ + gs_memory_arena* Arena; + + u64 EntriesCount; + u64 NextEntry; + log_entry* Entries; +}; + +struct log_buffer_iter +{ + log_buffer* Buffer; + u64 Start; + u64 IndexAt; + log_entry* At; +}; + +internal log_buffer +Log_Init(gs_memory_arena* A, u64 Count) +{ + log_buffer Result = {}; + Result.Arena = A; + Result.EntriesCount = Count; + Result.Entries = PushArray(A, log_entry, Result.EntriesCount); + + u64 LogStringLength = 512; + u64 LogStringBufferSize = LogStringLength * Result.EntriesCount; + char* LogStringBuffer = PushArray(A, char, LogStringBufferSize); + char* LogStringBufferAt = LogStringBuffer; + for (u32 i = 0; i < Result.EntriesCount; i++) + { + Result.Entries[i].String = MakeString(LogStringBufferAt, 0, LogStringLength); + LogStringBufferAt += LogStringLength; + } + + return Result; +} + +internal u64 +Log_GetNextIndex(log_buffer Log, u64 At) +{ + u64 Result = At + 1; + if (Result >= Log.EntriesCount) + { + Result = 0; + } + return Result; +} + +internal log_entry* +Log_TakeNextEntry(log_buffer* Log) +{ + log_entry* Result = Log->Entries + Log->NextEntry; + Log->NextEntry = Log_GetNextIndex(*Log, Log->NextEntry); + return Result; +} + +internal void +Log_PrintFVarArgs(log_buffer* Log, log_entry_type Type, char* Format, va_list Args) +{ + log_entry* NextEntry = Log_TakeNextEntry(Log); + NextEntry->String.Length = 0; + NextEntry->Type = Type; + PrintFArgsList(&NextEntry->String, Format, Args); + NullTerminate(&NextEntry->String); + +#if DEBUG + OutputDebugStringA(NextEntry->String.Str); +#endif +} + +#define Log_Message(log, fmt, ...) Log_PrintF(log, LogEntry_Message, fmt, __VA_ARGS__) +#define Log_Error(log, fmt, ...) Log_PrintF(log, LogEntry_Error, fmt, __VA_ARGS__) +internal void +Log_PrintF(log_buffer* Log, log_entry_type Type, char* Format, ...) +{ + va_list Args; + va_start(Args, Format); + Log_PrintFVarArgs(Log, Type, Format, Args); + va_end(Args); +} + +internal log_buffer_iter +Log_GetIter(log_buffer* Buffer) +{ + log_buffer_iter Result = {}; + Result.Buffer = Buffer; + Result.Start = Buffer->NextEntry; + Result.IndexAt = Result.Start; + Result.At = Result.Buffer->Entries + Result.IndexAt; + return Result; +} + +internal bool +LogIter_CanAdvance(log_buffer_iter Iter) +{ + u64 Next = Log_GetNextIndex(*Iter.Buffer, Iter.IndexAt); + bool Result = Next != Iter.Start; + return Result; +} + +internal void +LogIter_Advance(log_buffer_iter* Iter) +{ + Iter->IndexAt = Log_GetNextIndex(*Iter->Buffer, Iter->IndexAt); + Iter->At = Iter->Buffer->Entries + Iter->IndexAt; +} + +#endif //FOLDHAUS_LOG_H diff --git a/src/app/engine/foldhaus_network_ordering.h b/src/app/engine/foldhaus_network_ordering.h index 05e5afd..cc9634d 100644 --- a/src/app/engine/foldhaus_network_ordering.h +++ b/src/app/engine/foldhaus_network_ordering.h @@ -10,7 +10,7 @@ inline u8* PackB1(u8* ptr, u8 val) { *ptr = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u8 from a known big endian buffer @@ -25,7 +25,7 @@ inline u8* PackL1(u8* ptr, u8 val) { *ptr = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u8 from a known little endian buffer @@ -39,19 +39,19 @@ UpackL1(const u8* ptr) inline u16 PackB2(u16 Value) { - u16 Result = 0; - u8* Array = (u8*)&Result; - Array[1] = (u8)(Value & 0xFF); - Array[0] = (u8)((Value & 0xFF00) >> 8); - return Result; + u16 Result = 0; + u8* Array = (u8*)&Result; + Array[1] = (u8)(Value & 0xFF); + Array[0] = (u8)((Value & 0xFF00) >> 8); + return Result; } inline u8* PackB2(u8* ptr, u16 val) { - ptr[1] = (u8)(val & 0xff); + ptr[1] = (u8)(val & 0xff); ptr[0] = (u8)((val & 0xff00) >> 8); - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u16 from a known big endian buffer @@ -66,7 +66,7 @@ inline u8* PackL2(u8* ptr, u16 val) { *((u16*)ptr) = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u16 from a known little endian buffer @@ -84,7 +84,7 @@ PackB4(u8* ptr, u32 val) ptr[2] = (u8)((val & 0xff00) >> 8); ptr[1] = (u8)((val & 0xff0000) >> 16); ptr[0] = (u8)((val & 0xff000000) >> 24); - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u32 from a known big endian buffer @@ -99,7 +99,7 @@ inline u8* PackL4(u8* ptr, u32 val) { *((u32*)ptr) = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u32 from a known little endian buffer @@ -121,7 +121,7 @@ PackB8(u8* ptr, u64 val) ptr[2] = (u8)((val & 0xff0000000000) >> 40); ptr[1] = (u8)((val & 0xff000000000000) >> 48); ptr[0] = (u8)((val & 0xff00000000000000) >> 56); - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a uint64 from a known big endian buffer @@ -129,9 +129,9 @@ inline u64 UpackB8(const u8* ptr) { return ((u64)ptr[7]) | (((u64)ptr[6]) << 8) | (((u64)ptr[5]) << 16) | - (((u64)ptr[4]) << 24) | (((u64)ptr[3]) << 32) | - (((u64)ptr[2]) << 40) | (((u64)ptr[1]) << 48) | - (((u64)ptr[0]) << 56); + (((u64)ptr[4]) << 24) | (((u64)ptr[3]) << 32) | + (((u64)ptr[2]) << 40) | (((u64)ptr[1]) << 48) | + (((u64)ptr[0]) << 56); } //Packs a u64 to a known little endian buffer @@ -139,7 +139,7 @@ inline u8* PackL8(u8* ptr, u64 val) { *((u64*)ptr) = val; - return ptr + sizeof(val); + return ptr + sizeof(val); } //Unpacks a u64 from a known little endian buffer diff --git a/src/app/engine/sacn/foldhaus_sacn.h b/src/app/engine/sacn/foldhaus_sacn.h index 6004361..ae29913 100644 --- a/src/app/engine/sacn/foldhaus_sacn.h +++ b/src/app/engine/sacn/foldhaus_sacn.h @@ -81,14 +81,14 @@ const u8 VHD_D_FLAG = 0x10; #define CID_Bytes 16 struct cid { - u8 Bytes[CID_Bytes]; + u8 Bytes[CID_Bytes]; }; struct streaming_acn { - platform_socket_handle SendSocket; - cid CID; - s32 SequenceIterator; + platform_socket_handle SendSocket; + cid CID; + s32 SequenceIterator; }; /////////////////////////////////////////////// @@ -100,100 +100,100 @@ struct streaming_acn internal void SetStreamHeaderSequence_ (u8* Buffer, u8 Sequence, b32 Draft) { - DEBUG_TRACK_FUNCTION; - PackB1(Buffer + SEQ_NUM_ADDR, Sequence); + DEBUG_TRACK_FUNCTION; + PackB1(Buffer + SEQ_NUM_ADDR, Sequence); } internal void VHD_PackFlags_(u8* Buffer, b32 InheritVec, b32 InheritHead, b32 InheritData) { - u8* Cursor = Buffer; - u8 NewByte = UpackB1(Cursor) & 0x8f; - - if (!InheritVec) { NewByte |= VHD_V_FLAG; } - if (!InheritHead) { NewByte |= VHD_H_FLAG; } - if (!InheritData) { NewByte |= VHD_D_FLAG; } - - PackB1(Cursor, NewByte); + u8* Cursor = Buffer; + u8 NewByte = UpackB1(Cursor) & 0x8f; + + if (!InheritVec) { NewByte |= VHD_V_FLAG; } + if (!InheritHead) { NewByte |= VHD_H_FLAG; } + if (!InheritData) { NewByte |= VHD_D_FLAG; } + + PackB1(Cursor, NewByte); } internal u8* VHD_PackLength_(u8* Buffer, u32 Length, b32 IncludeLength) { - u8* Cursor = Buffer; - u32 AdjustedLength = Length; - if (IncludeLength) + u8* Cursor = Buffer; + u32 AdjustedLength = Length; + if (IncludeLength) + { + if (Length + 1 > VHD_MAXMINLENGTH) { - if (Length + 1 > VHD_MAXMINLENGTH) - { - AdjustedLength += 2; - } - else - { - AdjustedLength += 1; - } - } - - // Mask out the length bits to keep flags intact - u8 NewByte = UpackB1(Cursor) & 0x70; - if (AdjustedLength > VHD_MAXMINLENGTH) - { - NewByte |= VHD_L_FLAG; - } - - u8 PackBuffer[4]; - PackB4(PackBuffer, AdjustedLength); - if (AdjustedLength <= VHD_MAXMINLENGTH) - { - NewByte |= (PackBuffer[2] & 0x0f); - Cursor = PackB1(Cursor, NewByte); - Cursor = PackB1(Cursor, PackBuffer[3]); + AdjustedLength += 2; } else { - NewByte |= (PackBuffer[1] & 0x0f); - Cursor = PackB1(Cursor, PackBuffer[2]); - Cursor = PackB1(Cursor, PackBuffer[3]); + AdjustedLength += 1; } - - return Cursor; + } + + // Mask out the length bits to keep flags intact + u8 NewByte = UpackB1(Cursor) & 0x70; + if (AdjustedLength > VHD_MAXMINLENGTH) + { + NewByte |= VHD_L_FLAG; + } + + u8 PackBuffer[4]; + PackB4(PackBuffer, AdjustedLength); + if (AdjustedLength <= VHD_MAXMINLENGTH) + { + NewByte |= (PackBuffer[2] & 0x0f); + Cursor = PackB1(Cursor, NewByte); + Cursor = PackB1(Cursor, PackBuffer[3]); + } + else + { + NewByte |= (PackBuffer[1] & 0x0f); + Cursor = PackB1(Cursor, PackBuffer[2]); + Cursor = PackB1(Cursor, PackBuffer[3]); + } + + return Cursor; } internal cid gs_stringToCID_ (const char* gs_string) { - cid Result = {}; + cid Result = {}; + + const char* Src = gs_string; + u8* Dest = &Result.Bytes[0]; + b32 FirstNibble = true; + + while(*Src && (Dest - &Result.Bytes[0] < CID_Bytes)) + { + u8 Offset = 0; + if ((*Src >= 0x30) && (*Src <= 0x39)){ Offset = 0x30; } + else if ((*Src >= 0x41) && (*Src <= 0x46)) { Offset = 0x37; } + else if ((*Src >= 0x61) && (*Src <= 0x66)) { Offset = 0x66; } - const char* Src = gs_string; - u8* Dest = &Result.Bytes[0]; - b32 FirstNibble = true; - - while(*Src && (Dest - &Result.Bytes[0] < CID_Bytes)) + if (Offset != 0) { - u8 Offset = 0; - if ((*Src >= 0x30) && (*Src <= 0x39)){ Offset = 0x30; } - else if ((*Src >= 0x41) && (*Src <= 0x46)) { Offset = 0x37; } - else if ((*Src >= 0x61) && (*Src <= 0x66)) { Offset = 0x66; } - - if (Offset != 0) - { - if (FirstNibble) - { - *Dest = (u8)(*Src - Offset); - *Dest <<= 4; - FirstNibble = false; - } - else - { - *Dest |= (*Src - Offset); - Dest++; - FirstNibble = true; - } - } - Src++; + if (FirstNibble) + { + *Dest = (u8)(*Src - Offset); + *Dest <<= 4; + FirstNibble = false; + } + else + { + *Dest |= (*Src - Offset); + Dest++; + FirstNibble = true; + } } - - return Result; + Src++; + } + + return Result; } internal void @@ -208,85 +208,85 @@ InitStreamHeader (u8* Buffer, s32 BufferSize, cid CID ) { - // TODO(pjs): Replace packing with gs_memory_cursor - - u8* Cursor = Buffer; - - // Preamble Size - Cursor = PackB2(Cursor, RLP_PREAMBLE_SIZE); - Cursor = PackB2(Cursor, RLP_POSTAMBLE_SIZE); - - CopyMemoryTo(ACN_IDENTIFIER, Cursor, ACN_IDENTIFIER_SIZE); - Cursor += ACN_IDENTIFIER_SIZE; - - // TODO(Peter): If you never use this anywhere else, go back and remove the parameters - VHD_PackFlags_(Cursor, false, false, false); - Cursor = VHD_PackLength_(Cursor, - STREAM_HEADER_SIZE - RLP_PREAMBLE_SIZE + SlotCount, - false); - - // root vector - Cursor = PackB4(Cursor, ROOT_VECTOR); - - // CID Pack - for (s32 i = 0; i < CID_Bytes; i++) - { - *Cursor++ = CID.Bytes[i]; - } - - VHD_PackFlags_(Cursor, false, false, false); - Cursor = VHD_PackLength_(Cursor, - STREAM_HEADER_SIZE - FRAMING_FLAGS_AND_LENGTH_ADDR + SlotCount, - false); - - // framing vector - Cursor = PackB4(Cursor, FRAMING_VECTOR); - - // framing source name - // :Check - CopyMemoryTo(SourceName, (char*)Cursor, SOURCE_NAME_SIZE); - Cursor[SOURCE_NAME_SIZE - 1] = '\0'; - Cursor += SOURCE_NAME_SIZE; - - // priority - Cursor = PackB1(Cursor, Priority); - - // reserved - Cursor = PackB2(Cursor, Reserved); - - // Sequence # is always set to 0/NONE at the beginning, but it is incremented when sending data - Cursor = PackB1(Cursor, 0); - - // Options - Cursor = PackB1(Cursor, Options); - - // Universe - Cursor = PackB2(Cursor, Universe); - - VHD_PackFlags_(Cursor, false, false, false); - Cursor = VHD_PackLength_(Cursor, - STREAM_HEADER_SIZE - DMP_FLAGS_AND_LENGTH_ADDR + SlotCount, - false); - - // DMP Vector - Cursor = PackB1(Cursor, DMP_VECTOR); - - // DMP Address and data type - Cursor = PackB1(Cursor, ADDRESS_AND_DATA_FORMAT); - - // DMP first property address - Cursor = PackB2(Cursor, 0); - - // DMP Address Increment - Cursor = PackB2(Cursor, ADDRESS_INC); - - // Property Value Count -- Includes one byte for start code - Cursor = PackB2(Cursor, SlotCount + 1); - - Cursor = PackB1(Cursor, StartCode); - - Assert(Cursor - Buffer == STREAM_HEADER_SIZE); - + // TODO(pjs): Replace packing with gs_memory_cursor + + u8* Cursor = Buffer; + + // Preamble Size + Cursor = PackB2(Cursor, RLP_PREAMBLE_SIZE); + Cursor = PackB2(Cursor, RLP_POSTAMBLE_SIZE); + + CopyMemoryTo(ACN_IDENTIFIER, Cursor, ACN_IDENTIFIER_SIZE); + Cursor += ACN_IDENTIFIER_SIZE; + + // TODO(Peter): If you never use this anywhere else, go back and remove the parameters + VHD_PackFlags_(Cursor, false, false, false); + Cursor = VHD_PackLength_(Cursor, + STREAM_HEADER_SIZE - RLP_PREAMBLE_SIZE + SlotCount, + false); + + // root vector + Cursor = PackB4(Cursor, ROOT_VECTOR); + + // CID Pack + for (s32 i = 0; i < CID_Bytes; i++) + { + *Cursor++ = CID.Bytes[i]; + } + + VHD_PackFlags_(Cursor, false, false, false); + Cursor = VHD_PackLength_(Cursor, + STREAM_HEADER_SIZE - FRAMING_FLAGS_AND_LENGTH_ADDR + SlotCount, + false); + + // framing vector + Cursor = PackB4(Cursor, FRAMING_VECTOR); + + // framing source name + // :Check + CopyMemoryTo(SourceName, (char*)Cursor, SOURCE_NAME_SIZE); + Cursor[SOURCE_NAME_SIZE - 1] = '\0'; + Cursor += SOURCE_NAME_SIZE; + + // priority + Cursor = PackB1(Cursor, Priority); + + // reserved + Cursor = PackB2(Cursor, Reserved); + + // Sequence # is always set to 0/NONE at the beginning, but it is incremented when sending data + Cursor = PackB1(Cursor, 0); + + // Options + Cursor = PackB1(Cursor, Options); + + // Universe + Cursor = PackB2(Cursor, Universe); + + VHD_PackFlags_(Cursor, false, false, false); + Cursor = VHD_PackLength_(Cursor, + STREAM_HEADER_SIZE - DMP_FLAGS_AND_LENGTH_ADDR + SlotCount, + false); + + // DMP Vector + Cursor = PackB1(Cursor, DMP_VECTOR); + + // DMP Address and data type + Cursor = PackB1(Cursor, ADDRESS_AND_DATA_FORMAT); + + // DMP first property address + Cursor = PackB1(Cursor, 0); + + // DMP Address Increment + Cursor = PackB1(Cursor, ADDRESS_INC); + + // Property Value Count -- Includes one byte for start code + Cursor = PackB2(Cursor, SlotCount + 1); + + Cursor = PackB1(Cursor, StartCode); + + Assert(Cursor - Buffer == STREAM_HEADER_SIZE); + } // @@ -296,13 +296,13 @@ InitStreamHeader (u8* Buffer, s32 BufferSize, internal streaming_acn SACN_Initialize (context Context) { - streaming_acn SACN = {}; - - s32 Multicast_TimeToLive = 20; - SACN.SendSocket = Context.PlatformGetSocketHandle(Multicast_TimeToLive); - SACN.CID = gs_stringToCID_ ("{67F9D986-544E-4abb-8986-D5F79382586C}"); - - return SACN; + streaming_acn SACN = {}; + + s32 Multicast_TimeToLive = 20; + SACN.SendSocket = Context.PlatformGetSocketHandle(Multicast_TimeToLive); + SACN.CID = gs_stringToCID_ ("{67F9D986-544E-4abb-8986-D5F79382586C}"); + + return SACN; } internal void @@ -313,82 +313,98 @@ SACN_Cleanup(streaming_acn* SACN, context Context) internal void SACN_UpdateSequence (streaming_acn* SACN) { - // Never use 0 after the first one - if (++SACN->SequenceIterator == 0) - { - ++SACN->SequenceIterator; - } + // Never use 0 after the first one + if (++SACN->SequenceIterator == 0) + { + ++SACN->SequenceIterator; + } } internal void SACN_PrepareBufferHeader (s32 Universe, u8* Buffer, s32 BufferSize, s32 SizeReservedForHeader, streaming_acn SACN) { - Assert(SizeReservedForHeader == STREAM_HEADER_SIZE); - Assert(Buffer && BufferSize > 0); - - s32 Priority = 0; - InitStreamHeader(Buffer, BufferSize, STREAM_BODY_SIZE, STARTCODE_DMX, Universe, Priority, 0, 0, "Lumenarium", SACN.CID); - SetStreamHeaderSequence_(Buffer, SACN.SequenceIterator, false); + Assert(SizeReservedForHeader == STREAM_HEADER_SIZE); + Assert(Buffer && BufferSize > 0); + + s32 Priority = 0; + InitStreamHeader(Buffer, BufferSize, STREAM_BODY_SIZE, STARTCODE_DMX, Universe, Priority, 0, 0, "Lumenarium", SACN.CID); + SetStreamHeaderSequence_(Buffer, SACN.SequenceIterator, false); } internal u32 SACN_GetUniverseSendAddress(s32 Universe) { - u8 MulticastAddressBuffer[4] = {}; - MulticastAddressBuffer[0] = 239; - MulticastAddressBuffer[1] = 255; - MulticastAddressBuffer[2] = (u8)((Universe & 0xff00) >> 8); // high bit - MulticastAddressBuffer[3] = (u8)((Universe & 0x00ff)); // low bit - - u32 V4Address = (u32)UpackB4(MulticastAddressBuffer); - return V4Address; + u8 MulticastAddressBuffer[4] = {}; + MulticastAddressBuffer[0] = 239; + MulticastAddressBuffer[1] = 255; + MulticastAddressBuffer[2] = (u8)((Universe & 0xff00) >> 8); // high bit + MulticastAddressBuffer[3] = (u8)((Universe & 0x00ff)); // low bit + + u32 V4Address = (u32)UpackB4(MulticastAddressBuffer); + return V4Address; } -internal void -SACN_FillBufferWithLeds(u8* BufferStart, u32 BufferSize, v2_strip Strip, led_buffer LedBuffer) +internal u64 +SACN_FillBufferWithLeds(u8* BufferStart, u32 BufferSize, v2_strip Strip, u64 LedsPlaced, led_buffer LedBuffer) { - u8* DestChannel = BufferStart; - for (u32 i = 0; i < Strip.LedCount; i++) - { - u32 LedIndex = Strip.LedLUT[i]; - pixel Color = LedBuffer.Colors[LedIndex]; - - DestChannel[0] = Color.R; - DestChannel[1] = Color.G; - DestChannel[2] = Color.B; - DestChannel += 3; - } + u8* DestChannel = BufferStart; + u64 FirstLed = LedsPlaced; + u64 LedsToAdd = Min(Strip.LedCount - LedsPlaced, STREAM_BODY_SIZE / 3); + u64 OnePastLastLed = FirstLed + LedsToAdd; + for (u32 i = FirstLed; i < OnePastLastLed; i++) + { + u32 LedIndex = Strip.LedLUT[i]; + pixel Color = LedBuffer.Colors[LedIndex]; + + DestChannel[0] = Color.R; + DestChannel[1] = Color.G; + DestChannel[2] = Color.B; + DestChannel += 3; + } + return LedsToAdd; } internal void SACN_BuildOutputData(streaming_acn* SACN, addressed_data_buffer_list* Output, assembly_array Assemblies, led_system* LedSystem) { - SACN_UpdateSequence(SACN); + SACN_UpdateSequence(SACN); + + // TODO(pjs): 512 is a magic number - make it a constant? + s32 BufferHeaderSize = STREAM_HEADER_SIZE; + s32 BufferBodySize = STREAM_BODY_SIZE; + s32 BufferSize = BufferHeaderSize + BufferBodySize; + + for (u32 AssemblyIdx = 0; AssemblyIdx < Assemblies.Count; AssemblyIdx++) + { + assembly Assembly = Assemblies.Values[AssemblyIdx]; + led_buffer* LedBuffer = LedSystemGetBuffer(LedSystem, Assembly.LedBufferIndex); - // TODO(pjs): 512 is a magic number - make it a constant? - s32 BufferHeaderSize = STREAM_HEADER_SIZE; - s32 BufferBodySize = 512; - s32 BufferSize = BufferHeaderSize + BufferBodySize; - - for (u32 AssemblyIdx = 0; AssemblyIdx < Assemblies.Count; AssemblyIdx++) + for (u32 StripIdx = 0; StripIdx < Assembly.StripCount; StripIdx++) { - assembly Assembly = Assemblies.Values[AssemblyIdx]; - led_buffer* LedBuffer = LedSystemGetBuffer(LedSystem, Assembly.LedBufferIndex); + v2_strip StripAt = Assembly.Strips[StripIdx]; + + // NOTE(PS): This isn't actually invalid, we just haven't needed to implement + // something more complex than only allowing strips to start at the first + // channel of a universe + Assert(StripAt.SACNAddr.StartChannel == 1); + + u32 UniverseAt = StripAt.SACNAddr.StartUniverse; + u64 LedsPlaced = 0; + while (LedsPlaced < StripAt.LedCount) + { + u32 V4SendAddress = SACN_GetUniverseSendAddress(UniverseAt); + u32 SendPort = DEFAULT_STREAMING_ACN_PORT; - for (u32 StripIdx = 0; StripIdx < Assembly.StripCount; StripIdx++) - { - v2_strip StripAt = Assembly.Strips[StripIdx]; - - u32 V4SendAddress = SACN_GetUniverseSendAddress(StripAt.SACNAddr.StartUniverse); - u32 SendPort = DEFAULT_STREAMING_ACN_PORT; - - addressed_data_buffer* Data = AddressedDataBufferList_Push(Output, BufferSize); - AddressedDataBuffer_SetNetworkAddress(Data, SACN->SendSocket, V4SendAddress, SendPort); - - SACN_PrepareBufferHeader(StripAt.SACNAddr.StartUniverse, Data->Memory, Data->MemorySize, BufferHeaderSize, *SACN); - SACN_FillBufferWithLeds(Data->Memory + BufferHeaderSize, BufferBodySize, StripAt, *LedBuffer); - } + addressed_data_buffer* Data = AddressedDataBufferList_Push(Output, BufferSize); + AddressedDataBuffer_SetNetworkAddress(Data, SACN->SendSocket, V4SendAddress, SendPort); + + SACN_PrepareBufferHeader(UniverseAt, Data->Memory, Data->MemorySize, BufferHeaderSize, *SACN); + LedsPlaced += SACN_FillBufferWithLeds(Data->Memory + BufferHeaderSize, BufferBodySize, StripAt, LedsPlaced, *LedBuffer); + + UniverseAt += 1; + } } + } } #define SACN_H diff --git a/src/app/engine/uart/foldhaus_uart.cpp b/src/app/engine/uart/foldhaus_uart.cpp index f18360f..b6ea3fb 100644 --- a/src/app/engine/uart/foldhaus_uart.cpp +++ b/src/app/engine/uart/foldhaus_uart.cpp @@ -9,163 +9,163 @@ internal void UART_SetChannelBuffer_Create(gs_memory_cursor* WriteCursor, uart_channel ChannelSettings, v2_strip Strip, led_buffer LedBuffer) { - // NOTE(pjs): This is just here because the information is duplicated and I want to be sure - // to catch the error where they are different - Assert(ChannelSettings.PixelsCount == Strip.LedCount); + // NOTE(pjs): This is just here because the information is duplicated and I want to be sure + // to catch the error where they are different + Assert(ChannelSettings.PixelsCount == Strip.LedCount); + + uart_header* Header = MemoryCursorPushStruct(WriteCursor, uart_header); + UART_FillHeader(Header, Strip.UARTAddr.Channel, UART_SET_CHANNEL_WS2812); + + uart_channel* Channel = MemoryCursorPushStruct(WriteCursor, uart_channel); + *Channel = ChannelSettings; + + for (u32 i = 0; i < Channel->PixelsCount; i++) + { + u32 LedIndex = Strip.LedLUT[i]; + pixel Color = LedBuffer.Colors[LedIndex]; - uart_header* Header = PushStructOnCursor(WriteCursor, uart_header); - UART_FillHeader(Header, Strip.UARTAddr.Channel, UART_SET_CHANNEL_WS2812); + u8* OutputPixel = MemoryCursorPushArray(WriteCursor, u8, 3); - uart_channel* Channel = PushStructOnCursor(WriteCursor, uart_channel); - *Channel = ChannelSettings; - - for (u32 i = 0; i < Channel->PixelsCount; i++) - { - u32 LedIndex = Strip.LedLUT[i]; - pixel Color = LedBuffer.Colors[LedIndex]; - - u8* OutputPixel = PushArrayOnCursor(WriteCursor, u8, 3); - - // TODO(pjs): Use the Output mask + // TODO(pjs): Use the Output mask #if 1 - OutputPixel[0] = Color.R; - OutputPixel[1] = Color.G; - OutputPixel[2] = Color.B; + OutputPixel[0] = Color.R; + OutputPixel[1] = Color.G; + OutputPixel[2] = Color.B; #else - OutputPixel[0] = 255; - OutputPixel[1] = 255; - OutputPixel[2] = 255; + OutputPixel[0] = 255; + OutputPixel[1] = 255; + OutputPixel[2] = 255; #endif - if (Channel->ElementsCount == 4) - { - // TODO(pjs): Calculate white from the RGB components? - // Generally we just need a good way to handle the white channel, - // both in the renderer and in output - - //OutputPixel[Channel->WhiteIndex] = Color.W; - } + if (Channel->ElementsCount == 4) + { + // TODO(pjs): Calculate white from the RGB components? + // Generally we just need a good way to handle the white channel, + // both in the renderer and in output + + //OutputPixel[Channel->WhiteIndex] = Color.W; } - - uart_footer* Footer = PushStructOnCursor(WriteCursor, uart_footer); - UART_FillFooter(Footer, (u8*)Header); + } + + uart_footer* Footer = MemoryCursorPushStruct(WriteCursor, uart_footer); + UART_FillFooter(Footer, (u8*)Header); } internal void UART_DrawAll_Create(gs_memory_cursor* WriteCursor) { - uart_header* Header = PushStructOnCursor(WriteCursor, uart_header); - UART_FillHeader(Header, 1, UART_DRAW_ALL); - - uart_footer* Footer = PushStructOnCursor(WriteCursor, uart_footer); - UART_FillFooter(Footer, (u8*)Header); + uart_header* Header = MemoryCursorPushStruct(WriteCursor, uart_header); + UART_FillHeader(Header, 1, UART_DRAW_ALL); + + uart_footer* Footer = MemoryCursorPushStruct(WriteCursor, uart_footer); + UART_FillFooter(Footer, (u8*)Header); } internal void UART_BuildOutputData(addressed_data_buffer_list* Output, assembly_array Assemblies, led_system* LedSystem, gs_memory_arena* Transient) { - uart_channel ChannelSettings = {0}; - ChannelSettings.ElementsCount = 3; - ChannelSettings.ColorPackingOrder = 36; + uart_channel ChannelSettings = {0}; + ChannelSettings.ElementsCount = 3; + ChannelSettings.ColorPackingOrder = 36; + + // NOTE(pjs): This is the minimum size of every UART message. SetChannelBuffer messages will + // be bigger than this, but their size is based on the number of pixels in each channel + u32 MessageBaseSize = UART_MESSAGE_MIN_SIZE; + + for (u32 AssemblyIdx = 0; AssemblyIdx < Assemblies.Count; AssemblyIdx++) + { + assembly Assembly = Assemblies.Values[AssemblyIdx]; + led_buffer* LedBuffer = LedSystemGetBuffer(LedSystem, Assembly.LedBufferIndex); - // NOTE(pjs): This is the minimum size of every UART message. SetChannelBuffer messages will - // be bigger than this, but their size is based on the number of pixels in each channel - u32 MessageBaseSize = UART_MESSAGE_MIN_SIZE; - - for (u32 AssemblyIdx = 0; AssemblyIdx < Assemblies.Count; AssemblyIdx++) + struct strips_to_data_buffer { - assembly Assembly = Assemblies.Values[AssemblyIdx]; - led_buffer* LedBuffer = LedSystemGetBuffer(LedSystem, Assembly.LedBufferIndex); - - struct strips_to_data_buffer + gs_const_string ComPort; + + u32* StripIndices; + u32 StripIndicesCount; + u32 StripIndicesCountMax; + + u64 LedCount; + + u8** ChannelsStart; + + strips_to_data_buffer* Next; + }; + + u32 BuffersNeededCount = 0; + strips_to_data_buffer* BuffersNeededHead = 0; + strips_to_data_buffer* BuffersNeededTail = 0; + + for (u32 StripIdx = 0; StripIdx < Assembly.StripCount; StripIdx++) + { + v2_strip StripAt = Assembly.Strips[StripIdx]; + + // If there is a buffer for this com port already created + // we use that + strips_to_data_buffer* BufferSelected = 0; + for (strips_to_data_buffer* At = BuffersNeededHead; + At!= 0; + At = At->Next) + { + if (StringsEqual(At->ComPort, StripAt.UARTAddr.ComPort.ConstString)) { - gs_const_string ComPort; - - u32* StripIndices; - u32 StripIndicesCount; - u32 StripIndicesCountMax; - - u64 LedCount; - - u8** ChannelsStart; - - strips_to_data_buffer* Next; - }; - - u32 BuffersNeededCount = 0; - strips_to_data_buffer* BuffersNeededHead = 0; - strips_to_data_buffer* BuffersNeededTail = 0; - - for (u32 StripIdx = 0; StripIdx < Assembly.StripCount; StripIdx++) - { - v2_strip StripAt = Assembly.Strips[StripIdx]; - - // If there is a buffer for this com port already created - // we use that - strips_to_data_buffer* BufferSelected = 0; - for (strips_to_data_buffer* At = BuffersNeededHead; - At!= 0; - At = At->Next) - { - if (StringsEqual(At->ComPort, StripAt.UARTAddr.ComPort.ConstString)) - { - BufferSelected = At; - break; - } - } - - // if no existing buffer for this com port - // create a new one - if (!BufferSelected) - { - BufferSelected = PushStruct(Transient, strips_to_data_buffer); - *BufferSelected = {}; - BufferSelected->ComPort = StripAt.UARTAddr.ComPort.ConstString; - // we don't know at this point how many indices per - // com port so just make enough room to fit all the strips - // if necessary - BufferSelected->StripIndicesCountMax = Assembly.StripCount; - BufferSelected->StripIndices = PushArray(Transient, u32, BufferSelected->StripIndicesCountMax); - BufferSelected->LedCount = 0; - BufferSelected->Next = 0; - - SLLPushOrInit(BuffersNeededHead, BuffersNeededTail, BufferSelected); - BuffersNeededCount += 1; - } - - Assert(BufferSelected->StripIndicesCount < BufferSelected->StripIndicesCountMax); - u32 Index = BufferSelected->StripIndicesCount++; - BufferSelected->StripIndices[Index] = StripIdx; - BufferSelected->LedCount += StripAt.LedCount; + BufferSelected = At; + break; } + } + + // if no existing buffer for this com port + // create a new one + if (!BufferSelected) + { + BufferSelected = PushStruct(Transient, strips_to_data_buffer); + *BufferSelected = {}; + BufferSelected->ComPort = StripAt.UARTAddr.ComPort.ConstString; + // we don't know at this point how many indices per + // com port so just make enough room to fit all the strips + // if necessary + BufferSelected->StripIndicesCountMax = Assembly.StripCount; + BufferSelected->StripIndices = PushArray(Transient, u32, BufferSelected->StripIndicesCountMax); + BufferSelected->LedCount = 0; + BufferSelected->Next = 0; - for (strips_to_data_buffer* At = BuffersNeededHead; - At!= 0; - At = At->Next) - { - u32 TotalBufferSize = MessageBaseSize * Assembly.StripCount; // SetChannelBuffer messages - TotalBufferSize += MessageBaseSize; // DrawAll message - TotalBufferSize += ChannelSettings.ElementsCount * At->LedCount; // pixels * channels per pixel - - At->ChannelsStart = PushArray(Transient, u8*, At->StripIndicesCount); - - addressed_data_buffer* Buffer = AddressedDataBufferList_Push(Output, TotalBufferSize); - gs_const_string ComPort = At->ComPort; - AddressedDataBuffer_SetCOMPort(Buffer, ComPort); - - gs_memory_cursor WriteCursor = CreateMemoryCursor(Buffer->Data); - - for (u32 i = 0; i < At->StripIndicesCount; i++) - { - u32 StripIdx = At->StripIndices[i]; - v2_strip StripAt = Assembly.Strips[StripIdx]; - - ChannelSettings.PixelsCount = StripAt.LedCount; - UART_SetChannelBuffer_Create(&WriteCursor, ChannelSettings, StripAt, *LedBuffer); - } - - UART_DrawAll_Create(&WriteCursor); - } + SLLPushOrInit(BuffersNeededHead, BuffersNeededTail, BufferSelected); + BuffersNeededCount += 1; + } + + Assert(BufferSelected->StripIndicesCount < BufferSelected->StripIndicesCountMax); + u32 Index = BufferSelected->StripIndicesCount++; + BufferSelected->StripIndices[Index] = StripIdx; + BufferSelected->LedCount += StripAt.LedCount; } + + for (strips_to_data_buffer* At = BuffersNeededHead; + At!= 0; + At = At->Next) + { + u32 TotalBufferSize = MessageBaseSize * Assembly.StripCount; // SetChannelBuffer messages + TotalBufferSize += MessageBaseSize; // DrawAll message + TotalBufferSize += ChannelSettings.ElementsCount * At->LedCount; // pixels * channels per pixel + + At->ChannelsStart = PushArray(Transient, u8*, At->StripIndicesCount); + + addressed_data_buffer* Buffer = AddressedDataBufferList_Push(Output, TotalBufferSize); + gs_const_string ComPort = At->ComPort; + AddressedDataBuffer_SetCOMPort(Buffer, ComPort); + + gs_memory_cursor WriteCursor = MemoryCursorCreate(Buffer->Memory, Buffer->MemorySize); + + for (u32 i = 0; i < At->StripIndicesCount; i++) + { + u32 StripIdx = At->StripIndices[i]; + v2_strip StripAt = Assembly.Strips[StripIdx]; + + ChannelSettings.PixelsCount = StripAt.LedCount; + UART_SetChannelBuffer_Create(&WriteCursor, ChannelSettings, StripAt, *LedBuffer); + } + + UART_DrawAll_Create(&WriteCursor); + } + } } diff --git a/src/app/engine/user_space.cpp b/src/app/engine/user_space.cpp index 752435a..7e401df 100644 --- a/src/app/engine/user_space.cpp +++ b/src/app/engine/user_space.cpp @@ -32,6 +32,16 @@ US_CustomUpdate(user_space_desc* Desc, app_state* State, context* Context) } } +internal void +US_CustomDebugUI(user_space_desc* Desc, panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, + app_state* State, context Context) +{ + if (Desc->CustomDebugUI) + { + Desc->CustomDebugUI(Desc->UserData, Panel, PanelBounds, RenderBuffer, State, Context); + } +} + internal void US_CustomCleanup(user_space_desc* Desc, app_state* State, context Context) { diff --git a/src/app/engine/user_space.h b/src/app/engine/user_space.h index 8dc5f8a..5373fcb 100644 --- a/src/app/engine/user_space.h +++ b/src/app/engine/user_space.h @@ -14,6 +14,9 @@ typedef US_CUSTOM_INIT(us_custom_init_proc); #define US_CUSTOM_UPDATE(name) void name(gs_data UserData, app_state* State, context* Context) typedef US_CUSTOM_UPDATE(us_custom_update_proc); +#define US_CUSTOM_DEBUG_UI(name) void name(gs_data UserData, panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) +typedef US_CUSTOM_DEBUG_UI(us_custom_debug_ui); + #define US_CUSTOM_CLEANUP(name) void name(gs_data UserData, app_state* State, context Context) typedef US_CUSTOM_CLEANUP(us_custom_cleanup_proc); @@ -22,6 +25,7 @@ typedef struct user_space_desc us_load_patterns_proc* LoadPatterns; us_custom_init_proc* CustomInit; us_custom_update_proc* CustomUpdate; + us_custom_debug_ui* CustomDebugUI; us_custom_cleanup_proc* CustomCleanup; gs_data UserData; diff --git a/src/app/foldhaus_app.cpp b/src/app/foldhaus_app.cpp index 47590c0..94d8073 100644 --- a/src/app/foldhaus_app.cpp +++ b/src/app/foldhaus_app.cpp @@ -10,34 +10,45 @@ RELOAD_STATIC_DATA(ReloadStaticData) { + GlobalDebugServices = DebugServices; + GlobalLogBuffer = LogBuffer; + if (AppReady) + { app_state* State = (app_state*)Context.MemoryBase; - - GlobalDebugServices = DebugServices; State->PanelSystem.PanelDefs = GlobalPanelDefs; State->PanelSystem.PanelDefsCount = GlobalPanelDefsCount; + gs_data UserData = State->UserSpaceDesc.UserData; + State->UserSpaceDesc = BlumenLumen_UserSpaceCreate(); + if (UserData.Memory && !State->UserSpaceDesc.UserData.Memory) + { + State->UserSpaceDesc.UserData = UserData; + } US_LoadPatterns(&State->UserSpaceDesc, State, Context); + } } INITIALIZE_APPLICATION(InitializeApplication) { - app_state* State = (app_state*)Context.MemoryBase; - *State = {}; - - State->Permanent = CreateMemoryArena(Context.ThreadContext.Allocator); - State->Transient = Context.ThreadContext.Transient; - State->Assemblies = AssemblyArray_Create(8, &State->Permanent); - - State->GlobalLog = PushStruct(&State->Permanent, event_log); - - State->CommandQueue = CommandQueue_Create(&State->Permanent, 32); - - animation_system_desc AnimSysDesc = {}; - AnimSysDesc.Storage = &State->Permanent; - AnimSysDesc.AnimArrayCount = 32; - AnimSysDesc.SecondsPerFrame = 1.0f / 24.0f; - State->AnimationSystem = AnimationSystem_Init(AnimSysDesc); - + Context->MemorySize = sizeof(app_state); + Context->MemoryBase = Alloc(Context->ThreadContext.Allocator, Context->MemorySize, "Memory Base"); + app_state* State = (app_state*)Context->MemoryBase; + *State = {}; + + State->Permanent = MemoryArenaCreate(MB(4), Bytes(8), Context->ThreadContext.Allocator,0, 0, "Permanent"); + State->Transient = Context->ThreadContext.Transient; + State->Assemblies = AssemblyArray_Create(8, &State->Permanent); + + State->CommandQueue = CommandQueue_Create(&State->Permanent, 32); + + animation_system_desc AnimSysDesc = {}; + AnimSysDesc.Storage = &State->Permanent; + AnimSysDesc.AnimArrayCount = 32; + AnimSysDesc.SecondsPerFrame = 1.0f / 24.0f; + State->AnimationSystem = AnimationSystem_Init(AnimSysDesc); + + if (!Context->Headless) + { interface_config IConfig = {0}; IConfig.FontSize = 14; IConfig.PanelBG = v4{ .3f, .3f, .3f, 1.f }; @@ -50,92 +61,139 @@ INITIALIZE_APPLICATION(InitializeApplication) IConfig.ListBGHover = v4{ .22f, .22f, .22f, 1.f }; IConfig.ListBGSelected = v4{ .44f, .44f, .44f, 1.f }; IConfig.Margin = v2{5, 5}; - State->Interface = ui_InterfaceCreate(Context, IConfig, &State->Permanent); - - State->SACN = SACN_Initialize(Context); - - State->LedSystem = LedSystem_Create(Context.ThreadContext.Allocator, 128); - State->AssemblyDebugState = AssemblyDebug_Create(&State->Permanent); - State->AssemblyDebugState.Brightness = 255; - State->AssemblyDebugState.Override = ADS_Override_AllRed; - - GlobalDebugServices->Interface.RenderSculpture = true; + State->Interface = ui_InterfaceCreate(*Context, IConfig, &State->Permanent); PanelSystem_Init(&State->PanelSystem, GlobalPanelDefs, GlobalPanelDefsCount, &State->Permanent); - { - panel* RootPanel = PanelSystem_PushPanel(&State->PanelSystem, PanelType_SculptureView, State, Context); - SplitPanel(RootPanel, .25f, PanelSplit_Horizontal, &State->PanelSystem, State, Context); - - panel* AnimPanel = RootPanel->Bottom; - Panel_SetType(AnimPanel, &State->PanelSystem, PanelType_AnimationTimeline, State, Context); - - panel* TopPanel = RootPanel->Top; - SplitPanel(TopPanel, .5f, PanelSplit_Vertical, &State->PanelSystem, State, Context); - - panel* LeftPanel = TopPanel->Left; - SplitPanel(LeftPanel, .5f, PanelSplit_Vertical, &State->PanelSystem, State, Context); - - panel* Profiler = LeftPanel->Right; - Panel_SetType(Profiler, &State->PanelSystem, PanelType_ProfilerView, State, Context); - - panel* Hierarchy = LeftPanel->Left; - Panel_SetType(Hierarchy, &State->PanelSystem, PanelType_HierarchyView, State, Context); - - } - State->Modes = OperationModeSystemInit(&State->Permanent, Context.ThreadContext); + } + + State->SACN = SACN_Initialize(*Context); + + State->LedSystem = LedSystem_Create(Context->ThreadContext.Allocator, 128); + State->AssemblyDebugState = AssemblyDebug_Create(&State->Permanent); + State->AssemblyDebugState.Brightness = 255; + State->AssemblyDebugState.Override = ADS_Override_None; + + State->Modes = OperationModeSystemInit(&State->Permanent, Context->ThreadContext); + + ReloadStaticData(*Context, GlobalDebugServices, GlobalLogBuffer, true); + US_CustomInit(&State->UserSpaceDesc, State, *Context); + + if (!Context->Headless) + { + // NOTE(pjs): This just sets up the default panel layout + panel* RootPanel = PanelSystem_PushPanel(&State->PanelSystem, PanelType_SculptureView, State, *Context); + SplitPanel(RootPanel, .25f, PanelSplit_Horizontal, &State->PanelSystem, State, *Context); - State->UserSpaceDesc = BlumenLumen_UserSpaceCreate(); + panel* AnimPanel = RootPanel->Bottom; + Panel_SetType(AnimPanel, &State->PanelSystem, PanelType_AnimationTimeline, State, *Context); - ReloadStaticData(Context, GlobalDebugServices); - US_CustomInit(&State->UserSpaceDesc, State, Context); + panel* TopPanel = RootPanel->Top; + SplitPanel(TopPanel, .5f, PanelSplit_Vertical, &State->PanelSystem, State, *Context); + + panel* LeftPanel = TopPanel->Left; + SplitPanel(LeftPanel, .5f, PanelSplit_Vertical, &State->PanelSystem, State, *Context); + + panel* Profiler = LeftPanel->Right; + Panel_SetType(Profiler, &State->PanelSystem, PanelType_MessageLog, State, *Context); + + panel* Hierarchy = LeftPanel->Left; + Panel_SetType(Hierarchy, &State->PanelSystem, PanelType_AssemblyDebug, State, *Context); + + } + + State->RunEditor = !Context->Headless; +} + +internal void +BuildAssemblyData (app_state* State, context Context, addressed_data_buffer_list* OutputData) +{ + +#define SEND_DATA +#ifdef SEND_DATA + // NOTE(pjs): Building data buffers to be sent out to the sculpture + // This array is used on the platform side to actually send the information + assembly_array SACNAssemblies = AssemblyArray_Filter(State->Assemblies, AssemblyFilter_OutputsViaSACN, State->Transient); + assembly_array UARTAssemblies = AssemblyArray_Filter(State->Assemblies, AssemblyFilter_OutputsViaUART, State->Transient); + SACN_BuildOutputData(&State->SACN, OutputData, SACNAssemblies, &State->LedSystem); + UART_BuildOutputData(OutputData, UARTAssemblies, &State->LedSystem, State->Transient); +#endif } UPDATE_AND_RENDER(UpdateAndRender) { - DEBUG_TRACK_FUNCTION; - app_state* State = (app_state*)Context->MemoryBase; - - // NOTE(Peter): We do this at the beginning because all the render commands are stored in Transient, - // and need to persist beyond the end of the UpdateAndRender call. In the release version, we won't - // zero the Transient arena when we clear it so it wouldn't be a problem, but it is technically - // incorrect to clear the arena, and then access the memory later. - ClearArena(State->Transient); - + DEBUG_TRACK_FUNCTION; + app_state* State = (app_state*)Context->MemoryBase; + + // NOTE(Peter): We do this at the beginning because all the render commands are stored in Transient, + // and need to persist beyond the end of the UpdateAndRender call. In the release version, we won't + // zero the Transient arena when we clear it so it wouldn't be a problem, but it is technically + // incorrect to clear the arena, and then access the memory later. + MemoryArenaClear(State->Transient); + Assert(State->UserSpaceDesc.UserData.Memory != 0); + + if (State->RunEditor) + { Editor_Update(State, Context, InputQueue); - - AnimationSystem_Update(&State->AnimationSystem); - if (AnimationSystem_NeedsRender(State->AnimationSystem)) - { - AnimationSystem_RenderToLedBuffers(&State->AnimationSystem, - State->Assemblies, - &State->LedSystem, - State->Patterns, - State->Transient, - State->UserSpaceDesc.UserData.Memory); - } - - US_CustomUpdate(&State->UserSpaceDesc, State, Context); - - AssemblyDebug_OverrideOutput(State->AssemblyDebugState, - State->Assemblies, - State->LedSystem); - + } + + AnimationSystem_Update(&State->AnimationSystem, Context->DeltaTime); + if (AnimationSystem_NeedsRender(State->AnimationSystem)) + { + Assert(State->UserSpaceDesc.UserData.Memory != 0); + AnimationSystem_RenderToLedBuffers(&State->AnimationSystem, + State->Assemblies, + &State->LedSystem, + State->Patterns, + State->Transient, + *Context, + State->UserSpaceDesc.UserData.Memory); + } + + Assert(State->UserSpaceDesc.UserData.Memory != 0); + US_CustomUpdate(&State->UserSpaceDesc, State, Context); + Assert(State->UserSpaceDesc.UserData.Memory != 0); + + AssemblyDebug_OverrideOutput(State->AssemblyDebugState, + State->Assemblies, + State->LedSystem); + + if (State->RunEditor) + { Editor_Render(State, Context, RenderBuffer); - - // NOTE(pjs): Building data buffers to be sent out to the sculpture - // This array is used on the platform side to actually send the information - assembly_array SACNAssemblies = AssemblyArray_Filter(State->Assemblies, AssemblyFilter_OutputsViaSACN, State->Transient); - assembly_array UARTAssemblies = AssemblyArray_Filter(State->Assemblies, AssemblyFilter_OutputsViaUART, State->Transient); - SACN_BuildOutputData(&State->SACN, OutputData, SACNAssemblies, &State->LedSystem); - UART_BuildOutputData(OutputData, UARTAssemblies, &State->LedSystem, State->Transient); + } + ResetWorkQueue(Context->GeneralWorkQueue); + + Assert(State->UserSpaceDesc.UserData.Memory != 0); + BuildAssemblyData(State, *Context, OutputData); + + // NOTE(PS): We introduced this in order to test some things on the + // blumen lumen circuit boards, to see if they were getting out + // of sync + if (State->SendEmptyPackets) { + for (addressed_data_buffer* At = OutputData->Root; + At != 0; + At = At->Next) + { + ZeroMemoryBlock(At->Memory, At->MemorySize); + } + } } CLEANUP_APPLICATION(CleanupApplication) { - app_state* State = (app_state*)Context.MemoryBase; - US_CustomCleanup(&State->UserSpaceDesc, State, Context); - SACN_Cleanup(&State->SACN, Context); + app_state* State = (app_state*)Context.MemoryBase; + + for (u32 i = 0; i < State->Assemblies.Count; i++) + { + assembly Assembly = State->Assemblies.Values[i]; + led_buffer LedBuffer = State->LedSystem.Buffers[Assembly.LedBufferIndex]; + AssemblyDebug_OverrideWithColor(Assembly, LedBuffer, pixel{0, 0, 0}); + } + BuildAssemblyData(State, Context, OutputData); + + US_CustomCleanup(&State->UserSpaceDesc, State, Context); + SACN_Cleanup(&State->SACN, Context); } #define FOLDHAUS_APP_CPP diff --git a/src/app/foldhaus_app.h b/src/app/foldhaus_app.h index 43ded68..5666c95 100644 --- a/src/app/foldhaus_app.h +++ b/src/app/foldhaus_app.h @@ -11,13 +11,15 @@ #include "engine/foldhaus_serializer.h" #include "../gs_libs/gs_font.h" -#include "foldhaus_log.h" -#include "interface.h" +#include "editor/interface.h" #include "engine/foldhaus_network_ordering.h" #include "engine/assembly/foldhaus_assembly.h" + +#include "ss_blumen_lumen/gfx_math.h" + #include "engine/assembly/foldhaus_assembly_parser.cpp" #include "engine/assembly/foldhaus_assembly_debug.h" @@ -42,7 +44,8 @@ typedef struct panel panel; #include "engine/animation/foldhaus_animation_renderer.cpp" #include "engine/user_space.h" -#include "blumen_lumen.h" +#include "ss_blumen_lumen/phrase_hue_map.h" +#include "ss_blumen_lumen/blumen_lumen.h" struct app_state { @@ -57,7 +60,6 @@ struct app_state assembly_array Assemblies; assembly_debug_state AssemblyDebugState; animation_system AnimationSystem; - event_log* GlobalLog; animation_pattern_array Patterns; // Interface @@ -72,16 +74,32 @@ struct app_state panel* HotPanel; user_space_desc UserSpaceDesc; + bool ShowingUserSpaceDebug; + + bool RunEditor; + bool SendEmptyPackets; }; internal void OpenColorPicker(app_state* State, v4* Address); #include "engine/assembly/foldhaus_assembly.cpp" +internal assembly* +LoadAssembly(gs_const_string Path, app_state* State, context Context) +{ + return LoadAssembly(&State->Assemblies, + &State->LedSystem, + State->Transient, + Context, + Path, + GlobalLogBuffer); +} + #include "engine/user_space.cpp" +#include "ss_blumen_lumen/sdf.h" #include "patterns/blumen_patterns.h" -#include "blumen_lumen.cpp" +#include "ss_blumen_lumen/blumen_lumen.cpp" internal void EndCurrentOperationMode(app_state* State) @@ -98,6 +116,7 @@ EndCurrentOperationMode(app_state* State) #include "editor/panels/foldhaus_panel_animation_timeline.h" #include "editor/panels/foldhaus_panel_hierarchy.h" #include "editor/panels/foldhaus_panel_assembly_debug.h" +#include "editor/panels/foldhaus_panel_message_log.h" #include "editor/panels/foldhaus_panel_types.cpp" diff --git a/src/app/foldhaus_debug.h b/src/app/foldhaus_debug.h index 7acdfcc..8a66201 100644 --- a/src/app/foldhaus_debug.h +++ b/src/app/foldhaus_debug.h @@ -11,70 +11,71 @@ #define SCOPE_NAME_LENGTH 256 struct scope_record { - u32 NameHash; - s64 StartCycles; - s64 EndCycles; - s32 CallDepth; + u32 NameHash; + s64 StartCycles; + s64 EndCycles; + s32 CallDepth; }; struct collated_scope_record { - u32 NameHash; - s64 TotalCycles; - s32 CallCount; - - r32 PercentFrameTime; - r32 TotalSeconds; - - r32 AverageSecondsPerCall; + u32 NameHash; + s64 TotalCycles; + s32 CallCount; + + r32 PercentFrameTime; + r32 TotalSeconds; + + r32 AverageSecondsPerCall; }; #define SCOPE_NAME_BUFFER_LENGTH 128 struct scope_name { - u32 Hash; - gs_string Name; - char Buffer[SCOPE_NAME_BUFFER_LENGTH]; + u32 Hash; + gs_string Name; + char Buffer[SCOPE_NAME_BUFFER_LENGTH]; }; struct debug_scope_record_list { - s32 ThreadId; - s32 Max; - s32 Count; - scope_record* Calls; - - s32 CurrentScopeCallDepth; + s32 ThreadId; + s32 Max; + s32 Count; + scope_record* Calls; + + s32 CurrentScopeCallDepth; }; #define DEBUG_FRAME_GROW_SIZE 8102 struct debug_frame { - s64 FrameStartCycles; - s64 FrameEndCycles; - - s32 ScopeNamesMax; - s32 ScopeNamesCount; - scope_name* ScopeNamesHash; - - s32 ThreadCount; - debug_scope_record_list* ThreadCalls; - - s32 CollatedScopesMax; - collated_scope_record* CollatedScopes; + s64 FrameStartCycles; + s64 FrameEndCycles; + + s32 ScopeNamesMax; + s32 ScopeNamesCount; + scope_name* ScopeNamesHash; + + s32 ThreadCount; + debug_scope_record_list* ThreadCalls; + + s32 CollatedScopesMax; + collated_scope_record* CollatedScopes; }; -#define FRAME_VIEW_PROFILER 0 -#define FRAME_VIEW_SCOPE_LIST 1 +enum debug_ui_view +{ + DebugUI_Profiler, + DebugUI_ScopeList, + DebugUI_MemoryView, + + DebugUI_Count, +}; struct debug_interface { - b32 ShowCameraMouse; - b32 ShowTrackedScopes; - b32 RenderSculpture; - b32 SendSACNData; - - s32 FrameView; + s32 FrameView; }; typedef s32 debug_get_thread_id(); @@ -85,327 +86,353 @@ typedef u8* debug_realloc(u8* Memory, s32 OldSize, s32 NewSize); #define HISTOGRAM_DEPTH 10 struct debug_histogram_entry { - char ScopeName_[SCOPE_NAME_LENGTH]; - gs_string ScopeName; - - u32 PerFrame_Cycles[HISTOGRAM_DEPTH]; - u32 PerFrame_CallCount[HISTOGRAM_DEPTH]; - s32 CurrentFrame; - - // NOTE(Peter): Cached Values, recalculated ever frame - u32 Average_Cycles; - u32 Average_CallCount; - u32 Total_Cycles; - u32 Total_CallCount; + char ScopeName_[SCOPE_NAME_LENGTH]; + gs_string ScopeName; + + u32 PerFrame_Cycles[HISTOGRAM_DEPTH]; + u32 PerFrame_CallCount[HISTOGRAM_DEPTH]; + s32 CurrentFrame; + + // NOTE(Peter): Cached Values, recalculated ever frame + u32 Average_Cycles; + u32 Average_CallCount; + u32 Total_Cycles; + u32 Total_CallCount; }; -#define DEBUG_FRAME_COUNT 128 +#if DEBUG +# define DEBUG_FRAME_COUNT 128 +#else +# define DEBUG_FRAME_COUNT 0 +#endif + struct debug_services { - s64 PerformanceCountFrequency; - - b32 RecordFrames; - s32 CurrentDebugFrame; - debug_frame Frames[DEBUG_FRAME_COUNT]; - - debug_interface Interface; - - debug_get_thread_id* GetThreadId; - debug_timing_proc* GetWallClock; - debug_alloc* Alloc; - debug_realloc* Realloc; + s64 PerformanceCountFrequency; + + b32 RecordFrames; + s32 CurrentDebugFrame; + debug_frame* Frames; + + debug_interface Interface; + + gs_thread_context Ctx; + gs_memory_arena A; + + debug_get_thread_id* GetThreadId; + debug_timing_proc* GetWallClock; }; internal void InitializeDebugFrame (debug_frame* Frame, s32 NameHashMax, s32 ThreadCount, s32 ScopeCallsMax, debug_services* Services) { - Frame->ScopeNamesMax = NameHashMax; - Frame->ScopeNamesHash = (scope_name*)Services->Alloc(sizeof(scope_name), NameHashMax); - - // NOTE(Peter): We use the same size as scope names because we're only storing a single instance - // per scope. If ScopeNamesMax can't hold all the scopes, this will never get filled and - // we should assert and recompile with a resized NameHashMax - Frame->CollatedScopesMax = NameHashMax; - Frame->CollatedScopes = (collated_scope_record*)Services->Alloc(sizeof(collated_scope_record), NameHashMax); - - for (s32 i = 0; i < Frame->ScopeNamesMax; i++) - { - scope_name* Entry = Frame->ScopeNamesHash + i; - Entry->Name = MakeString(Entry->Buffer, 0, SCOPE_NAME_BUFFER_LENGTH); - } - - Frame->ThreadCount = ThreadCount; - Frame->ThreadCalls = (debug_scope_record_list*)Services->Alloc(sizeof(debug_scope_record_list), - ThreadCount); - - for (s32 i = 0; i < ThreadCount; i++) - { - Frame->ThreadCalls[i].Max = ScopeCallsMax; - Frame->ThreadCalls[i].Count = 0; - Frame->ThreadCalls[i].Calls = (scope_record*)Services->Alloc(sizeof(scope_record), ScopeCallsMax); - Frame->ThreadCalls[i].CurrentScopeCallDepth = 0; - Frame->ThreadCalls[i].ThreadId = 0; - } - - for (s32 c = 0; c < Frame->CollatedScopesMax; c++) - { - Frame->CollatedScopes[c].NameHash = 0; - } + Frame->ScopeNamesMax = NameHashMax; + Frame->ScopeNamesHash = PushArray(&Services->A, scope_name, NameHashMax); + + // NOTE(Peter): We use the same size as scope names because we're only storing a single instance + // per scope. If ScopeNamesMax can't hold all the scopes, this will never get filled and + // we should assert and recompile with a resized NameHashMax + Frame->CollatedScopesMax = NameHashMax; + Frame->CollatedScopes = PushArray(&Services->A, collated_scope_record, NameHashMax); + + for (s32 i = 0; i < Frame->ScopeNamesMax; i++) + { + scope_name* Entry = Frame->ScopeNamesHash + i; + Entry->Name = MakeString(Entry->Buffer, 0, SCOPE_NAME_BUFFER_LENGTH); + } + + Frame->ThreadCount = ThreadCount; + Frame->ThreadCalls = PushArray(&Services->A, debug_scope_record_list, ThreadCount); + + for (s32 i = 0; i < ThreadCount; i++) + { + Frame->ThreadCalls[i].Max = ScopeCallsMax; + Frame->ThreadCalls[i].Count = 0; + Frame->ThreadCalls[i].Calls = PushArray(&Services->A, scope_record, ScopeCallsMax); + Frame->ThreadCalls[i].CurrentScopeCallDepth = 0; + Frame->ThreadCalls[i].ThreadId = 0; + } + + for (s32 c = 0; c < Frame->CollatedScopesMax; c++) + { + Frame->CollatedScopes[c].NameHash = 0; + } } internal void StartDebugFrame(debug_frame* Frame, debug_services* Services) { - Frame->FrameStartCycles = Services->GetWallClock(); - for (s32 i = 0; i < Frame->ThreadCount; i++) - { - Frame->ThreadCalls[i].Count = 0; - Frame->ThreadCalls[i].CurrentScopeCallDepth = 0; - } - - for (s32 c = 0; c < Frame->CollatedScopesMax; c++) - { - s32 Hash = Frame->CollatedScopes[c].NameHash; - Frame->CollatedScopes[c] = {}; - Frame->CollatedScopes[c].NameHash = Hash; - } + Frame->FrameStartCycles = Services->GetWallClock(); + for (s32 i = 0; i < Frame->ThreadCount; i++) + { + Frame->ThreadCalls[i].Count = 0; + Frame->ThreadCalls[i].CurrentScopeCallDepth = 0; + } + + for (s32 c = 0; c < Frame->CollatedScopesMax; c++) + { + s32 Hash = Frame->CollatedScopes[c].NameHash; + Frame->CollatedScopes[c] = {}; + Frame->CollatedScopes[c].NameHash = Hash; + } } internal void -InitDebugServices (debug_services* Services, - s64 PerformanceCountFrequency, - debug_alloc* Alloc, - debug_realloc* Realloc, - debug_timing_proc* GetWallClock, - debug_get_thread_id* GetThreadId, - s32 ThreadCount) +InitDebugServices_OffMode (debug_services* Services, + s64 PerformanceCountFrequency, + debug_timing_proc* GetWallClock, + debug_get_thread_id* GetThreadId, + gs_thread_context Ctx, + s32 ThreadCount) { - Services->Alloc = Alloc; - Services->Realloc = Realloc; - Services->GetWallClock = GetWallClock; - Services->GetThreadId = GetThreadId; - - Services->RecordFrames = true; - - Services->CurrentDebugFrame = 0; - s32 NameHashMax = 4096; - s32 ScopeCallsMax = 4096; - for (s32 i = 0; i < DEBUG_FRAME_COUNT; i++) - { - InitializeDebugFrame(&Services->Frames[i], NameHashMax, ThreadCount, ScopeCallsMax, Services); - } - - Services->Interface.RenderSculpture = true; - - Services->PerformanceCountFrequency = PerformanceCountFrequency; - - Services->Interface.ShowCameraMouse = false; - Services->Interface.ShowTrackedScopes = false; - Services->Interface.RenderSculpture = true; - Services->Interface.SendSACNData = false; + *Services = {0}; + + Services->Ctx = Ctx; + Services->GetWallClock = GetWallClock; + Services->GetThreadId = GetThreadId; + + Services->RecordFrames = false; + Services->Frames = 0; + + Services->CurrentDebugFrame = 0; + Services->PerformanceCountFrequency = PerformanceCountFrequency; +} + + +internal void +InitDebugServices_DebugMode (debug_services* Services, + s64 PerformanceCountFrequency, + debug_timing_proc* GetWallClock, + debug_get_thread_id* GetThreadId, + gs_thread_context Ctx, + s32 ThreadCount) +{ + Services->Ctx = Ctx; + Services->GetWallClock = GetWallClock; + Services->GetThreadId = GetThreadId; + + Services->RecordFrames = true; + + Services->CurrentDebugFrame = 0; + Services->A = MemoryArenaCreate(MB(64), Bytes(8), Ctx.Allocator, 0, 0, "Debug Services Allocator"); + + s32 NameHashMax = 4096; + s32 ScopeCallsMax = 4096; + Services->Frames = PushArray(&Services->A, debug_frame, DEBUG_FRAME_COUNT); + for (s32 i = 0; i < DEBUG_FRAME_COUNT; i++) + { + InitializeDebugFrame(&Services->Frames[i], NameHashMax, ThreadCount, ScopeCallsMax, Services); + } + + Services->PerformanceCountFrequency = PerformanceCountFrequency; } internal debug_frame* GetCurrentDebugFrame (debug_services* Services) { - debug_frame* Result = Services->Frames + Services->CurrentDebugFrame; - return Result; + debug_frame* Result = Services->Frames + Services->CurrentDebugFrame; + return Result; } internal debug_frame* GetLastDebugFrame(debug_services* Services) { - s32 Index = (Services->CurrentDebugFrame - 1); - if (Index < 0) { Index += DEBUG_FRAME_COUNT; } - debug_frame* Result = Services->Frames + Index; - return Result; + if (!Services->Frames) return 0; + + s32 Index = (Services->CurrentDebugFrame - 1); + if (Index < 0) { Index += DEBUG_FRAME_COUNT; } + debug_frame* Result = Services->Frames + Index; + return Result; } internal s32 GetIndexForNameHash(debug_frame* Frame, u32 NameHash) { - s32 Result = -1; - - for (s32 Offset = 0; Offset < Frame->ScopeNamesMax; Offset++) + s32 Result = -1; + + for (s32 Offset = 0; Offset < Frame->ScopeNamesMax; Offset++) + { + u32 Index = (NameHash + Offset) % Frame->ScopeNamesMax; + if (Frame->ScopeNamesHash[Index].Hash == NameHash) { - u32 Index = (NameHash + Offset) % Frame->ScopeNamesMax; - if (Frame->ScopeNamesHash[Index].Hash == NameHash) - { - Result = Index; - break; - } + Result = Index; + break; } - - // NOTE(Peter): Its not technically wrong to return a -1 here, just means we didn't find it. - // At the time of writing however, this function is only being called in contexts where we - // know there should be an entry in the Name table, so a -1 actually indicates a problem. - Assert(Result >= 0); - return Result; + } + + // NOTE(Peter): Its not technically wrong to return a -1 here, just means we didn't find it. + // At the time of writing however, this function is only being called in contexts where we + // know there should be an entry in the Name table, so a -1 actually indicates a problem. + Assert(Result >= 0); + return Result; } internal debug_scope_record_list* GetScopeListForThreadInFrame(debug_services* Services, debug_frame* Frame) { - debug_scope_record_list* List = 0; - - s32 CurrentThreadId = Services->GetThreadId(); - for (s32 Offset = 0; Offset < Frame->ThreadCount; Offset++) + debug_scope_record_list* List = 0; + + s32 CurrentThreadId = Services->GetThreadId(); + for (s32 Offset = 0; Offset < Frame->ThreadCount; Offset++) + { + s32 Index = (CurrentThreadId + Offset) % Frame->ThreadCount; + if (Frame->ThreadCalls[Index].ThreadId == CurrentThreadId) { - s32 Index = (CurrentThreadId + Offset) % Frame->ThreadCount; - if (Frame->ThreadCalls[Index].ThreadId == CurrentThreadId) - { - List = Frame->ThreadCalls + Index; - break; - } - else if (Frame->ThreadCalls[Index].ThreadId == 0) - { - Frame->ThreadCalls[Index].ThreadId = CurrentThreadId; - List = Frame->ThreadCalls + Index; - break; - } + List = Frame->ThreadCalls + Index; + break; } - - Assert(List); - return List; + else if (Frame->ThreadCalls[Index].ThreadId == 0) + { + Frame->ThreadCalls[Index].ThreadId = CurrentThreadId; + List = Frame->ThreadCalls + Index; + break; + } + } + + Assert(List); + return List; } internal void CollateThreadScopeCalls (debug_scope_record_list* ThreadRecords, debug_frame* Frame) { - for (s32 i = 0; i < ThreadRecords->Count; i++) + for (s32 i = 0; i < ThreadRecords->Count; i++) + { + scope_record Record = ThreadRecords->Calls[i]; + s32 Index = GetIndexForNameHash (Frame, Record.NameHash); + collated_scope_record* CollatedRecord = Frame->CollatedScopes + Index; + + if (CollatedRecord->NameHash != Record.NameHash) { - scope_record Record = ThreadRecords->Calls[i]; - s32 Index = GetIndexForNameHash (Frame, Record.NameHash); - collated_scope_record* CollatedRecord = Frame->CollatedScopes + Index; - - if (CollatedRecord->NameHash != Record.NameHash) - { - CollatedRecord->NameHash = Record.NameHash; - CollatedRecord->TotalCycles = 0; - CollatedRecord->CallCount = 0; - } - - CollatedRecord->TotalCycles += Record.EndCycles - Record.StartCycles; - CollatedRecord->CallCount += 1; + CollatedRecord->NameHash = Record.NameHash; + CollatedRecord->TotalCycles = 0; + CollatedRecord->CallCount = 0; } + + CollatedRecord->TotalCycles += Record.EndCycles - Record.StartCycles; + CollatedRecord->CallCount += 1; + } } internal void EndDebugFrame (debug_services* Services) { - debug_frame* ClosingFrame = GetCurrentDebugFrame(Services); - ClosingFrame->FrameEndCycles = Services->GetWallClock(); - - s64 FrameTotalCycles = ClosingFrame->FrameEndCycles - ClosingFrame->FrameStartCycles; - - for (s32 t = 0; t < ClosingFrame->ThreadCount; t++) + debug_frame* ClosingFrame = GetCurrentDebugFrame(Services); + ClosingFrame->FrameEndCycles = Services->GetWallClock(); + + s64 FrameTotalCycles = ClosingFrame->FrameEndCycles - ClosingFrame->FrameStartCycles; + + for (s32 t = 0; t < ClosingFrame->ThreadCount; t++) + { + CollateThreadScopeCalls(ClosingFrame->ThreadCalls + t, ClosingFrame); + } + + s32 ScopeNamesCount = 0; + for (s32 n = 0; n < ClosingFrame->ScopeNamesMax; n++) + { + if (ClosingFrame->ScopeNamesHash[n].Hash != 0) { - CollateThreadScopeCalls(ClosingFrame->ThreadCalls + t, ClosingFrame); + collated_scope_record* CollatedRecord = ClosingFrame->CollatedScopes + n; + CollatedRecord->TotalSeconds = (r32)CollatedRecord->TotalCycles / (r32)Services->PerformanceCountFrequency; + CollatedRecord->PercentFrameTime = (r32)CollatedRecord->TotalCycles / (r32)FrameTotalCycles; + CollatedRecord->AverageSecondsPerCall = CollatedRecord->TotalSeconds / CollatedRecord->CallCount; + ScopeNamesCount += 1; } - - s32 ScopeNamesCount = 0; - for (s32 n = 0; n < ClosingFrame->ScopeNamesMax; n++) - { - if (ClosingFrame->ScopeNamesHash[n].Hash != 0) - { - collated_scope_record* CollatedRecord = ClosingFrame->CollatedScopes + n; - CollatedRecord->TotalSeconds = (r32)CollatedRecord->TotalCycles / (r32)Services->PerformanceCountFrequency; - CollatedRecord->PercentFrameTime = (r32)CollatedRecord->TotalCycles / (r32)FrameTotalCycles; - CollatedRecord->AverageSecondsPerCall = CollatedRecord->TotalSeconds / CollatedRecord->CallCount; - ScopeNamesCount += 1; - } - } - ClosingFrame->ScopeNamesCount = ScopeNamesCount; - - Services->CurrentDebugFrame = (Services->CurrentDebugFrame + 1) % DEBUG_FRAME_COUNT; - StartDebugFrame(&Services->Frames[Services->CurrentDebugFrame], Services); + } + ClosingFrame->ScopeNamesCount = ScopeNamesCount; + + s32 FramesCount = DEBUG_FRAME_COUNT; + if (FramesCount > 0) + { + Services->CurrentDebugFrame = (Services->CurrentDebugFrame + 1) % FramesCount; + } + StartDebugFrame(&Services->Frames[Services->CurrentDebugFrame], Services); } internal u32 HashScopeName (char* ScopeName) { - // djb2 hash - u32 Hash = 5381; - char* C = ScopeName; - while(*C) - { - Hash = ((Hash << 5) + Hash) + *C; - C++; - } - return Hash; + // djb2 hash + u32 Hash = 5381; + char* C = ScopeName; + while(*C) + { + Hash = ((Hash << 5) + Hash) + *C; + C++; + } + return Hash; } internal scope_name* GetOrAddNameHashEntry(debug_frame* Frame, u32 NameHash) { - scope_name* Result = 0; - - for (s32 Offset = 0; Offset < Frame->ScopeNamesMax; Offset++) + scope_name* Result = 0; + + for (s32 Offset = 0; Offset < Frame->ScopeNamesMax; Offset++) + { + u32 Index = (NameHash + Offset) % Frame->ScopeNamesMax; + if ((Frame->ScopeNamesHash[Index].Hash == 0) || (Frame->ScopeNamesHash[Index].Hash == NameHash)) { - u32 Index = (NameHash + Offset) % Frame->ScopeNamesMax; - if ((Frame->ScopeNamesHash[Index].Hash == 0) || (Frame->ScopeNamesHash[Index].Hash == NameHash)) - { - Result = Frame->ScopeNamesHash + Index; - break; - } + Result = Frame->ScopeNamesHash + Index; + break; } - - return Result; + } + + return Result; } internal u32 BeginTrackingScopeAndGetNameHash (debug_services* Services, char* ScopeName) { - debug_frame* CurrentFrame = GetCurrentDebugFrame(Services); - debug_scope_record_list* ThreadList = GetScopeListForThreadInFrame(Services, CurrentFrame); - - ThreadList->CurrentScopeCallDepth++; - - u32 NameHash = HashScopeName(ScopeName); - scope_name* Entry = GetOrAddNameHashEntry(CurrentFrame, NameHash); - if (Entry->Hash == 0) // If its new - { - Entry->Hash = NameHash; - // TODO(Peter): need to initialize all entry name gs_strings to point at the buffer - // This will break eventually. when it does, do this ^^^^ when on startup - PrintF(&Entry->Name, "%s", ScopeName); - } - - return NameHash; + debug_frame* CurrentFrame = GetCurrentDebugFrame(Services); + debug_scope_record_list* ThreadList = GetScopeListForThreadInFrame(Services, CurrentFrame); + + ThreadList->CurrentScopeCallDepth++; + + u32 NameHash = HashScopeName(ScopeName); + scope_name* Entry = GetOrAddNameHashEntry(CurrentFrame, NameHash); + if (Entry->Hash == 0) // If its new + { + Entry->Hash = NameHash; + // TODO(Peter): need to initialize all entry name gs_strings to point at the buffer + // This will break eventually. when it does, do this ^^^^ when on startup + PrintF(&Entry->Name, "%s", ScopeName); + } + + return NameHash; } internal void PushScopeTimeOnFrame (debug_services* Services, s32 NameHash, u64 StartCycles, u64 EndCycles) { - debug_frame* CurrentFrame = GetCurrentDebugFrame(Services); - debug_scope_record_list* ThreadList = GetScopeListForThreadInFrame(Services, CurrentFrame); - - if (ThreadList->Count >= ThreadList->Max) - { - s32 CurrentSize = ThreadList->Max * sizeof(scope_record); - s32 NewMax = (ThreadList->Max + DEBUG_FRAME_GROW_SIZE); - s32 NewSize = NewMax * sizeof(scope_record); - ThreadList->Calls = (scope_record*)Services->Realloc((u8*)ThreadList->Calls, CurrentSize, NewSize); - ThreadList->Max = NewMax; - } - - Assert(ThreadList->Count < ThreadList->Max); - - s32 EntryIndex = ThreadList->Count++; - scope_record* Record = ThreadList->Calls + EntryIndex; - Record->NameHash = NameHash; - Record->StartCycles = StartCycles; - Record->EndCycles = EndCycles; - Record->CallDepth = --ThreadList->CurrentScopeCallDepth; + debug_frame* CurrentFrame = GetCurrentDebugFrame(Services); + debug_scope_record_list* ThreadList = GetScopeListForThreadInFrame(Services, CurrentFrame); + + if (ThreadList->Count >= ThreadList->Max) + { + s32 NewMax = (ThreadList->Max + DEBUG_FRAME_GROW_SIZE); + FreeArray(Services->Ctx.Allocator, ThreadList->Calls, scope_record, ThreadList->Max); + ThreadList->Calls = AllocArray(Services->Ctx.Allocator, scope_record, NewMax, "Debug Frame"); + ThreadList->Max = NewMax; + } + + Assert(ThreadList->Count < ThreadList->Max); + + s32 EntryIndex = ThreadList->Count++; + scope_record* Record = ThreadList->Calls + EntryIndex; + Record->NameHash = NameHash; + Record->StartCycles = StartCycles; + Record->EndCycles = EndCycles; + Record->CallDepth = --ThreadList->CurrentScopeCallDepth; } internal r32 DEBUGGetSecondsElapsed (s64 Start, s64 End, r32 PerformanceCountFrequency) { - r32 Result = ((r32)(End - Start) / (r32)PerformanceCountFrequency); - return Result; + r32 Result = ((r32)(End - Start) / (r32)PerformanceCountFrequency); + return Result; } -#ifdef DEBUG +#if DEBUG #define DEBUG_TRACK_FUNCTION scope_tracker ScopeTracker ((char*)__func__, GlobalDebugServices) #define DEBUG_TRACK_SCOPE(name) scope_tracker ScopeTracker_##name (#name, GlobalDebugServices) #else @@ -414,32 +441,32 @@ internal r32 DEBUGGetSecondsElapsed (s64 Start, s64 End, r32 PerformanceCountFre #endif struct scope_tracker { - s64 ScopeStart; - u32 ScopeNameHash; - debug_services* DebugServices; - - scope_tracker(char* ScopeName, debug_services* DebugServices) + s64 ScopeStart; + u32 ScopeNameHash; + debug_services* DebugServices; + + scope_tracker(char* ScopeName, debug_services* DebugServices) + { + if (DebugServices->RecordFrames) { - if (DebugServices->RecordFrames) - { - this->ScopeNameHash = BeginTrackingScopeAndGetNameHash(DebugServices, ScopeName); - this->ScopeStart = DebugServices->GetWallClock(); - this->DebugServices = DebugServices; - } - else - { - this->DebugServices = 0; - } + this->ScopeNameHash = BeginTrackingScopeAndGetNameHash(DebugServices, ScopeName); + this->ScopeStart = DebugServices->GetWallClock(); + this->DebugServices = DebugServices; } - - ~scope_tracker() + else { - if (this->DebugServices) // NOTE(Peter): If DebugServices == 0, then we werent' recording this frame - { - s64 ScopeEnd = this->DebugServices->GetWallClock(); - PushScopeTimeOnFrame(this->DebugServices, this->ScopeNameHash, this->ScopeStart, ScopeEnd); - } + this->DebugServices = 0; } + } + + ~scope_tracker() + { + if (this->DebugServices) // NOTE(Peter): If DebugServices == 0, then we werent' recording this frame + { + s64 ScopeEnd = this->DebugServices->GetWallClock(); + PushScopeTimeOnFrame(this->DebugServices, this->ScopeNameHash, this->ScopeStart, ScopeEnd); + } + } }; diff --git a/src/app/foldhaus_log.h b/src/app/foldhaus_log.h index 5d1c936..dea66da 100644 --- a/src/app/foldhaus_log.h +++ b/src/app/foldhaus_log.h @@ -42,8 +42,5 @@ PushLogEntry(event_log* Log, gs_string Message, log_entry_type Type) NewEntry->Type = Type; } - - - #define FOLDHAUS_LOG_H #endif // FOLDHAUS_LOG_H \ No newline at end of file diff --git a/src/app/foldhaus_platform.h b/src/app/foldhaus_platform.h index 7f10ab0..14e1ae5 100644 --- a/src/app/foldhaus_platform.h +++ b/src/app/foldhaus_platform.h @@ -11,21 +11,26 @@ #include "..\gs_libs\gs_types.h" #include "..\gs_libs\gs_types.cpp" +#include "..\gs_libs\gs_path.h" struct handle { - u32 Generation; - u32 Index; + u32 Generation; + u32 Index; }; inline bool Handle_IsValid(handle Handle) { - bool Result = (Handle.Generation != 0); - return Result; + bool Result = (Handle.Generation != 0); + return Result; } #include "..\gs_libs\gs_string.h" +#include "..\gs_libs\gs_csv.h" + +#include "engine/foldhaus_log.h" +global log_buffer* GlobalLogBuffer; #include "foldhaus_debug.h" global debug_services* GlobalDebugServices; @@ -35,9 +40,9 @@ global debug_services* GlobalDebugServices; struct platform_network_address { - s32 Family; - u16 Port; - u32 Address; + s32 Family; + u16 Port; + u32 Address; }; typedef s32 platform_socket_handle; @@ -54,37 +59,37 @@ typedef struct context context; typedef void temp_job_req_proc(gs_thread_context* Ctx, u8* Memory); struct temp_job_req { - temp_job_req_proc* Proc; - u8* Memory; + temp_job_req_proc* Proc; + u8* Memory; }; // This isn't necessarily temp but I'm not sure it goes here #define PACKETS_MAX 32 struct packet_ringbuffer { - gs_data Values[PACKETS_MAX]; - u32 ReadHead; - u32 WriteHead; + gs_data Values[PACKETS_MAX]; + u32 ReadHead; + u32 WriteHead; }; -#define INITIALIZE_APPLICATION(name) void name(context Context) +#define INITIALIZE_APPLICATION(name) void name(context* Context) typedef INITIALIZE_APPLICATION(initialize_application); #define UPDATE_AND_RENDER(name) void name(context* Context, input_queue InputQueue, render_command_buffer* RenderBuffer, addressed_data_buffer_list* OutputData) typedef UPDATE_AND_RENDER(update_and_render); -#define RELOAD_STATIC_DATA(name) void name(context Context, debug_services* DebugServices) +#define RELOAD_STATIC_DATA(name) void name(context Context, debug_services* DebugServices, log_buffer* LogBuffer, bool AppReady) typedef RELOAD_STATIC_DATA(reload_static_data); -#define CLEANUP_APPLICATION(name) void name(context Context) +#define CLEANUP_APPLICATION(name) void name(context Context, addressed_data_buffer_list* OutputData) typedef CLEANUP_APPLICATION(cleanup_application); // Platform Functions struct window_info { - char* Name; - s32 Width; - s32 Height; + char* Name; + s32 Width; + s32 Height; }; typedef struct window window; @@ -92,38 +97,38 @@ typedef struct window window; #define PLATFORM_MEMORY_NO_ERROR 0 enum platform_memory_error { - PlatformMemory_NoError, - PlatformMemory_FileNotFound, - - PlatformMemory_UnknownError, // You should implement handling this when you see it + PlatformMemory_NoError, + PlatformMemory_FileNotFound, + + PlatformMemory_UnknownError, // You should implement handling this when you see it }; struct data { - u8* Base; - u64 Size; + u8* Base; + u64 Size; }; struct platform_memory_result { - data Data; - platform_memory_error Error; + data Data; + platform_memory_error Error; }; struct system_path { - char* Path; - s32 PathLength; - s32 IndexOfLastSlash; + char* Path; + s32 PathLength; + s32 IndexOfLastSlash; }; struct texture_buffer { - u8* Memory; - s32 Width; - s32 Height; - s32 Pitch; - s32 BytesPerPixel; + u8* Memory; + s32 Width; + s32 Height; + s32 Pitch; + s32 BytesPerPixel; }; #define PLATFORM_GET_GPU_TEXTURE_HANDLE(name) s32 name(u8* Memory, s32 Width, s32 Height) @@ -135,25 +140,25 @@ typedef PLATFORM_GET_SOCKET_HANDLE(platform_get_socket_handle); // Font struct platform_font_info { - s32 PixelHeight; - s32 Ascent, Descent, Leading; - s32 MaxCharWidth; - s32 CodepointStart; - s32 CodepointOnePastLast; + s32 PixelHeight; + s32 Ascent, Descent, Leading; + s32 MaxCharWidth; + s32 CodepointStart; + s32 CodepointOnePastLast; }; enum font_weight { - FontWeight_Invalid = 0, - FontWeight_Thin = 100, - FontWeight_ExtraLight = 200, - FontWeight_Light = 300, - FontWeight_Normal = 400, - FontWeight_Medium = 500, - FontWeight_SemiBold = 600, - FontWeight_Bold = 700, - FontWeight_ExtraBold = 800, - FontWeight_Heavy = 900, + FontWeight_Invalid = 0, + FontWeight_Thin = 100, + FontWeight_ExtraLight = 200, + FontWeight_Light = 300, + FontWeight_Normal = 400, + FontWeight_Medium = 500, + FontWeight_SemiBold = 600, + FontWeight_Bold = 700, + FontWeight_ExtraBold = 800, + FontWeight_Heavy = 900, }; #define GET_FONT_INFO(name) platform_font_info name(char* FontName, s32 PixelHeight, font_weight FontWeight, b32 Italic, b32 Underline, b32 Strikeout) @@ -168,15 +173,15 @@ typedef DRAW_FONT_CODEPOINT(platform_draw_font_codepoint); RESET_WORK_QUEUE(ResetWorkQueue) { - for (u32 i = 0; i < Queue->JobsMax; i++) - { - Queue->Jobs[i].Data = {0}; - Queue->Jobs[i].WorkProc = 0; - } - - Queue->JobsCount = 0; - Queue->NextJobIndex = 0; - Queue->JobsCompleted = 0; + for (u32 i = 0; i < Queue->JobsMax; i++) + { + Queue->Jobs[i].Data = {0}; + Queue->Jobs[i].WorkProc = 0; + } + + Queue->JobsCount = 0; + Queue->NextJobIndex = 0; + Queue->JobsCompleted = 0; } // Time @@ -184,39 +189,66 @@ RESET_WORK_QUEUE(ResetWorkQueue) internal r32 GetSecondsElapsed (s64 Start, s64 End, s64 PerformanceCountFrequency) { - r32 Result = ((r32)(End - Start) / (r32) PerformanceCountFrequency); - return Result; + r32 Result = ((r32)(End - Start) / (r32) PerformanceCountFrequency); + return Result; +} + +typedef struct system_time +{ + u64 NanosSinceEpoch; + + s32 Year; + s32 Month; + s32 Day; + s32 Hour; // [0:23] + s32 Minute; + s32 Second; +} system_time; + +internal r64 +SecondsElapsed(system_time Start, system_time End) +{ + u64 N = End.NanosSinceEpoch - Start.NanosSinceEpoch; + r64 S = (r64)N * NanosToSeconds; + return S; } struct context { - gs_thread_context ThreadContext; - - u8* MemoryBase; - u32 MemorySize; - - b32 WindowIsVisible; - rect2 WindowBounds; - r32 DeltaTime; - mouse_state Mouse; - - // Application Services - initialize_application* InitializeApplication; - reload_static_data* ReloadStaticData; - update_and_render* UpdateAndRender; - cleanup_application* CleanupApplication; - - platform_thread_manager* ThreadManager; - platform_socket_manager* SocketManager; - - // Platform Services - gs_work_queue* GeneralWorkQueue; - - platform_get_gpu_texture_handle* PlatformGetGPUTextureHandle; - platform_get_font_info* PlatformGetFontInfo; - platform_draw_font_codepoint* PlatformDrawFontCodepoint; - - platform_get_socket_handle* PlatformGetSocketHandle; + gs_thread_context ThreadContext; + + u8* MemoryBase; + u32 MemorySize; + + b32 WindowIsVisible; + rect2 WindowBounds; + r64 TotalTime; + r32 DeltaTime; + mouse_state Mouse; + + // Application Services + initialize_application* InitializeApplication; + reload_static_data* ReloadStaticData; + update_and_render* UpdateAndRender; + cleanup_application* CleanupApplication; + + platform_thread_manager* ThreadManager; + platform_socket_manager* SocketManager; + + // Platform Services + gs_work_queue* GeneralWorkQueue; + + platform_get_gpu_texture_handle* PlatformGetGPUTextureHandle; + platform_get_font_info* PlatformGetFontInfo; + platform_draw_font_codepoint* PlatformDrawFontCodepoint; + + platform_get_socket_handle* PlatformGetSocketHandle; + + system_time SystemTime_Last; + system_time SystemTime_Current; + + // + bool Headless; }; #define FOLDHAUS_PLATFORM_H diff --git a/src/app/foldhaus_renderer.cpp b/src/app/foldhaus_renderer.cpp index bfd6522..51c2579 100644 --- a/src/app/foldhaus_renderer.cpp +++ b/src/app/foldhaus_renderer.cpp @@ -6,192 +6,192 @@ #ifndef FOLDHAUS_RENDERER_CPP internal render_command_buffer -AllocateRenderCommandBuffer (u8* Memory, s32 Size, renderer_realloc* Realloc) +AllocateRenderCommandBuffer (u8* Memory, s32 Size, gs_thread_context Ctx) { - render_command_buffer Result = {}; - Result.CommandMemory = Memory; - Result.CommandMemorySize = Size; - Result.CommandMemoryUsed = 0; - Result.Realloc = Realloc; - return Result; + render_command_buffer Result = {}; + Result.CommandMemory = Memory; + Result.CommandMemorySize = Size; + Result.CommandMemoryUsed = 0; + Result.Ctx = Ctx; + return Result; } internal render_command_buffer AllocateRenderCommandBuffer(u32 MemorySize, gs_memory_arena* Arena, - renderer_realloc* Realloc) + gs_thread_context Ctx) { - u8* Memory = PushSize(Arena, MemorySize); - return AllocateRenderCommandBuffer(Memory, MemorySize, Realloc); + u8* Memory = PushSize(Arena, MemorySize).Memory; + return AllocateRenderCommandBuffer(Memory, MemorySize, Ctx); } internal void Render3DQuadBatch (u8* CommandData, s32 TriCount) { - DEBUG_TRACK_FUNCTION; - - v4* Vertecies = (v4*)(CommandData + BATCH_3D_VERTECIES_OFFSET(TriCount)); - v2* UVs = (v2*)(CommandData + BATCH_3D_UVS_OFFSET(TriCount)); - v4* Colors = (v4*)(CommandData + BATCH_3D_COLORS_OFFSET(TriCount)); - + DEBUG_TRACK_FUNCTION; + + v4* Vertecies = (v4*)(CommandData + BATCH_3D_VERTECIES_OFFSET(TriCount)); + v2* UVs = (v2*)(CommandData + BATCH_3D_UVS_OFFSET(TriCount)); + v4* Colors = (v4*)(CommandData + BATCH_3D_COLORS_OFFSET(TriCount)); + #if IMMEDIATE_MODE_RENDERING + + for (s32 Tri = 0; Tri < TriCount; Tri++) + { + v4 P0 = Vertecies[BATCH_3D_VERTEX_INDEX(Tri, 0)]; + v4 P1 = Vertecies[BATCH_3D_VERTEX_INDEX(Tri, 1)]; + v4 P2 = Vertecies[BATCH_3D_VERTEX_INDEX(Tri, 2)]; + v2 UV0 = UVs[BATCH_3D_UV_INDEX(Tri, 0)]; + v2 UV1 = UVs[BATCH_3D_UV_INDEX(Tri, 1)]; + v2 UV2 = UVs[BATCH_3D_UV_INDEX(Tri, 2)]; + v4 C0 = Colors[BATCH_3D_COLOR_INDEX(Tri, 0)]; + v4 C1 = Colors[BATCH_3D_COLOR_INDEX(Tri, 1)]; + v4 C2 = Colors[BATCH_3D_COLOR_INDEX(Tri, 2)]; - for (s32 Tri = 0; Tri < TriCount; Tri++) - { - v4 P0 = Vertecies[BATCH_3D_VERTEX_INDEX(Tri, 0)]; - v4 P1 = Vertecies[BATCH_3D_VERTEX_INDEX(Tri, 1)]; - v4 P2 = Vertecies[BATCH_3D_VERTEX_INDEX(Tri, 2)]; - v2 UV0 = UVs[BATCH_3D_UV_INDEX(Tri, 0)]; - v2 UV1 = UVs[BATCH_3D_UV_INDEX(Tri, 1)]; - v2 UV2 = UVs[BATCH_3D_UV_INDEX(Tri, 2)]; - v4 C0 = Colors[BATCH_3D_COLOR_INDEX(Tri, 0)]; - v4 C1 = Colors[BATCH_3D_COLOR_INDEX(Tri, 1)]; - v4 C2 = Colors[BATCH_3D_COLOR_INDEX(Tri, 2)]; - - OpenGLDraw3DTri(P0, P1, P2, UV0, UV1, UV2, C0, C1, C2); - } + OpenGLDraw3DTri(P0, P1, P2, UV0, UV1, UV2, C0, C1, C2); + } #else - OpenGLRenderTriBuffer((u8*)Vertecies, 4, (u8*)UVs, 2, (u8*)Colors, 4, TriCount * 3); + OpenGLRenderTriBuffer((u8*)Vertecies, 4, (u8*)UVs, 2, (u8*)Colors, 4, TriCount * 3); #endif } internal void Render2DQuadBatch (u8* CommandData, s32 QuadCount) { - DEBUG_TRACK_FUNCTION; - - v2* Vertecies = (v2*)(CommandData + BATCH_2D_VERTECIES_OFFSET(QuadCount)); - v2* UVs = (v2*)(CommandData + BATCH_2D_UVS_OFFSET(QuadCount)); - v4* Colors = (v4*)(CommandData + BATCH_2D_COLORS_OFFSET(QuadCount)); - + DEBUG_TRACK_FUNCTION; + + v2* Vertecies = (v2*)(CommandData + BATCH_2D_VERTECIES_OFFSET(QuadCount)); + v2* UVs = (v2*)(CommandData + BATCH_2D_UVS_OFFSET(QuadCount)); + v4* Colors = (v4*)(CommandData + BATCH_2D_COLORS_OFFSET(QuadCount)); + #if IMMEDIATE_MODE_RENDERING - for (s32 Quad = 0; Quad < QuadCount; Quad++) + for (s32 Quad = 0; Quad < QuadCount; Quad++) + { + for (s32 Tri = 0; Tri < 2; Tri++) { - for (s32 Tri = 0; Tri < 2; Tri++) - { - v2 P0 = Vertecies[BATCH_2D_VERTEX_INDEX(Quad, Tri, 0)]; - v2 P1 = Vertecies[BATCH_2D_VERTEX_INDEX(Quad, Tri, 1)]; - v2 P2 = Vertecies[BATCH_2D_VERTEX_INDEX(Quad, Tri, 2)]; - v2 UV0 = UVs[BATCH_2D_UV_INDEX(Quad, Tri, 0)]; - v2 UV1 = UVs[BATCH_2D_UV_INDEX(Quad, Tri, 1)]; - v2 UV2 = UVs[BATCH_2D_UV_INDEX(Quad, Tri, 2)]; - v4 C0 = Colors[BATCH_2D_COLOR_INDEX(Quad, Tri, 0)]; - v4 C1 = Colors[BATCH_2D_COLOR_INDEX(Quad, Tri, 1)]; - v4 C2 = Colors[BATCH_2D_COLOR_INDEX(Quad, Tri, 2)]; - - OpenGLDraw2DTri(P0, P1, P2, UV0, UV1, UV2, C0, C1, C2); - } + v2 P0 = Vertecies[BATCH_2D_VERTEX_INDEX(Quad, Tri, 0)]; + v2 P1 = Vertecies[BATCH_2D_VERTEX_INDEX(Quad, Tri, 1)]; + v2 P2 = Vertecies[BATCH_2D_VERTEX_INDEX(Quad, Tri, 2)]; + v2 UV0 = UVs[BATCH_2D_UV_INDEX(Quad, Tri, 0)]; + v2 UV1 = UVs[BATCH_2D_UV_INDEX(Quad, Tri, 1)]; + v2 UV2 = UVs[BATCH_2D_UV_INDEX(Quad, Tri, 2)]; + v4 C0 = Colors[BATCH_2D_COLOR_INDEX(Quad, Tri, 0)]; + v4 C1 = Colors[BATCH_2D_COLOR_INDEX(Quad, Tri, 1)]; + v4 C2 = Colors[BATCH_2D_COLOR_INDEX(Quad, Tri, 2)]; + + OpenGLDraw2DTri(P0, P1, P2, UV0, UV1, UV2, C0, C1, C2); } + } #else - OpenGLRenderTriBuffer((u8*)Vertecies, 2, (u8*)UVs, 2, (u8*)Colors, 4, QuadCount * 2 * 3); + OpenGLRenderTriBuffer((u8*)Vertecies, 2, (u8*)UVs, 2, (u8*)Colors, 4, QuadCount * 2 * 3); #endif } internal void RenderCommandBuffer (render_command_buffer CommandBuffer) { - DEBUG_TRACK_FUNCTION; - - glMatrixMode(GL_TEXTURE_2D); - glLoadIdentity(); - - glClearColor(0.1f, 0.1f, 0.1f, 1); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glDisable(GL_TEXTURE_2D); - b32 GLTextureEnabled = false; - - u8* CurrentPosition = CommandBuffer.CommandMemory; - while(CurrentPosition < CommandBuffer.CommandMemory + CommandBuffer.CommandMemoryUsed) + DEBUG_TRACK_FUNCTION; + + glMatrixMode(GL_TEXTURE_2D); + glLoadIdentity(); + + glClearColor(0.1f, 0.1f, 0.1f, 1); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glDisable(GL_TEXTURE_2D); + b32 GLTextureEnabled = false; + + u8* CurrentPosition = CommandBuffer.CommandMemory; + while(CurrentPosition < CommandBuffer.CommandMemory + CommandBuffer.CommandMemoryUsed) + { + render_command_header* CommandHeader = (render_command_header*)CurrentPosition; + CurrentPosition += sizeof(render_command_header); + switch (CommandHeader->Type) { - render_command_header* CommandHeader = (render_command_header*)CurrentPosition; - CurrentPosition += sizeof(render_command_header); - switch (CommandHeader->Type) + case RenderCommand_render_command_set_render_mode: + { + DEBUG_TRACK_SCOPE(SetRenderMode); + + render_command_set_render_mode* Command = (render_command_set_render_mode*)(CommandHeader + 1); + + glViewport(Command->ViewOffsetX, Command->ViewOffsetY, + Command->ViewWidth, Command->ViewHeight); + + LoadModelView(Command->ModelView.Array); + LoadProjection(Command->Projection.Array); + + if (Command->UseDepthBuffer) { - case RenderCommand_render_command_set_render_mode: - { - DEBUG_TRACK_SCOPE(SetRenderMode); - - render_command_set_render_mode* Command = (render_command_set_render_mode*)(CommandHeader + 1); - - glViewport(Command->ViewOffsetX, Command->ViewOffsetY, - Command->ViewWidth, Command->ViewHeight); - - LoadModelView(Command->ModelView.Array); - LoadProjection(Command->Projection.Array); - - if (Command->UseDepthBuffer) - { - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - } - else - { - glDisable(GL_DEPTH_TEST); - } - - CurrentPosition += sizeof(render_command_set_render_mode); - }break; - - case RenderCommand_render_command_clear_screen: - { - DEBUG_TRACK_SCOPE(RendererClearScreen); - - render_command_clear_screen* Command = (render_command_clear_screen*)(CommandHeader + 1); - - ClearRenderBuffer(); - - CurrentPosition += sizeof(render_command_clear_screen); - }break; - - case RenderCommand_render_batch_command_quad_2d: - { - render_batch_command_quad_2d* Command = (render_batch_command_quad_2d*)(CommandHeader + 1); - - if (GLTextureEnabled) { glDisable(GL_TEXTURE_2D); GLTextureEnabled = false; } - u8* CommandData = (u8*)(Command + 1); - Render2DQuadBatch(CommandData, Command->QuadCount); - - CurrentPosition += sizeof(render_batch_command_quad_2d) + Command->DataSize; - }break; - - case RenderCommand_render_batch_command_quad_3d: - { - render_batch_command_quad_3d* Command = (render_batch_command_quad_3d*)(CommandHeader + 1); - - if (GLTextureEnabled) { glDisable(GL_TEXTURE_2D); GLTextureEnabled = false; } - u8* CommandData = (u8*)(Command + 1); - Render3DQuadBatch(CommandData, Command->QuadCount * 2); - - CurrentPosition += sizeof(render_batch_command_quad_3d) + Command->DataSize; - }break; - - case RenderCommand_render_batch_command_texture_2d: - { - render_batch_command_texture_2d* Command = (render_batch_command_texture_2d*)(CommandHeader + 1); - - if (!GLTextureEnabled) { glEnable(GL_TEXTURE_2D); GLTextureEnabled = true; } - Assert(Command->Texture.Handle > 0); - glBindTexture(GL_TEXTURE_2D, Command->Texture.Handle); - u8* CommandData = (u8*)(Command + 1); - Render2DQuadBatch(CommandData, Command->QuadCount); - - CurrentPosition += sizeof(render_batch_command_texture_2d) + Command->DataSize; - }break; - - default: - { - InvalidCodePath; - }break; + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); } + else + { + glDisable(GL_DEPTH_TEST); + } + + CurrentPosition += sizeof(render_command_set_render_mode); + }break; + + case RenderCommand_render_command_clear_screen: + { + DEBUG_TRACK_SCOPE(RendererClearScreen); + + render_command_clear_screen* Command = (render_command_clear_screen*)(CommandHeader + 1); + + ClearRenderBuffer(); + + CurrentPosition += sizeof(render_command_clear_screen); + }break; + + case RenderCommand_render_batch_command_quad_2d: + { + render_batch_command_quad_2d* Command = (render_batch_command_quad_2d*)(CommandHeader + 1); + + if (GLTextureEnabled) { glDisable(GL_TEXTURE_2D); GLTextureEnabled = false; } + u8* CommandData = (u8*)(Command + 1); + Render2DQuadBatch(CommandData, Command->QuadCount); + + CurrentPosition += sizeof(render_batch_command_quad_2d) + Command->DataSize; + }break; + + case RenderCommand_render_batch_command_quad_3d: + { + render_batch_command_quad_3d* Command = (render_batch_command_quad_3d*)(CommandHeader + 1); + + if (GLTextureEnabled) { glDisable(GL_TEXTURE_2D); GLTextureEnabled = false; } + u8* CommandData = (u8*)(Command + 1); + Render3DQuadBatch(CommandData, Command->QuadCount * 2); + + CurrentPosition += sizeof(render_batch_command_quad_3d) + Command->DataSize; + }break; + + case RenderCommand_render_batch_command_texture_2d: + { + render_batch_command_texture_2d* Command = (render_batch_command_texture_2d*)(CommandHeader + 1); + + if (!GLTextureEnabled) { glEnable(GL_TEXTURE_2D); GLTextureEnabled = true; } + Assert(Command->Texture.Handle > 0); + glBindTexture(GL_TEXTURE_2D, Command->Texture.Handle); + u8* CommandData = (u8*)(Command + 1); + Render2DQuadBatch(CommandData, Command->QuadCount); + + CurrentPosition += sizeof(render_batch_command_texture_2d) + Command->DataSize; + }break; + + default: + { + InvalidCodePath; + }break; } + } } internal void ClearRenderBuffer (render_command_buffer* Buffer) { - Buffer->CommandMemoryUsed = 0; + Buffer->CommandMemoryUsed = 0; } #define FOLDHAUS_RENDERER_CPP diff --git a/src/app/foldhaus_renderer.h b/src/app/foldhaus_renderer.h index a40c0f4..6e48836 100644 --- a/src/app/foldhaus_renderer.h +++ b/src/app/foldhaus_renderer.h @@ -9,104 +9,104 @@ struct camera { - r32 FieldOfView; - r32 AspectRatio; - r32 Near, Far; - v3 Position; - v3 LookAt; + r32 FieldOfView; + r32 AspectRatio; + r32 Near, Far; + v3 Position; + v3 LookAt; }; inline m44 GetCameraModelViewMatrix (camera Camera) { - m44 RotationMatrix = M44LookAt(ToV4Point(Camera.Position), ToV4Point(Camera.LookAt)); - m44 PositionMatrix = M44Translation(ToV4Point(-Camera.Position)); - m44 ModelViewMatrix = RotationMatrix * PositionMatrix; - return ModelViewMatrix; + m44 RotationMatrix = M44LookAt(ToV4Point(Camera.Position), ToV4Point(Camera.LookAt)); + m44 PositionMatrix = M44Translation(ToV4Point(-Camera.Position)); + m44 ModelViewMatrix = RotationMatrix * PositionMatrix; + return ModelViewMatrix; } inline m44 GetCameraPerspectiveProjectionMatrix(camera Camera) { - m44 Result = M44ProjectionPerspective(Camera.FieldOfView, Camera.AspectRatio, Camera.Near, Camera.Far); - return Result; + m44 Result = M44ProjectionPerspective(Camera.FieldOfView, Camera.AspectRatio, Camera.Near, Camera.Far); + return Result; } internal m44 GetCameraMatrix(camera Camera) { - m44 ModelView = GetCameraModelViewMatrix(Camera); - m44 Projection = GetCameraPerspectiveProjectionMatrix(Camera); - m44 Result = Projection * ModelView; - return Result; + m44 ModelView = GetCameraModelViewMatrix(Camera); + m44 Projection = GetCameraPerspectiveProjectionMatrix(Camera); + m44 Result = Projection * ModelView; + return Result; } internal v2 ProjectWorldPointToScreen(v4 WorldSpacePoint, camera Camera, rect2 WindowBounds) { - v2 WindowExtents = v2{Rect2Width(WindowBounds), Rect2Height(WindowBounds)}; - v4 ProjectedPosition = GetCameraMatrix(Camera) * WorldSpacePoint; - ProjectedPosition.xyz /= ProjectedPosition.w; - v2 ScreenPosition = V2MultiplyPairwise(ProjectedPosition.xy, (WindowExtents / 2)) + (WindowExtents / 2); - - return ScreenPosition; + v2 WindowExtents = v2{Rect2Width(WindowBounds), Rect2Height(WindowBounds)}; + v4 ProjectedPosition = GetCameraMatrix(Camera) * WorldSpacePoint; + ProjectedPosition.xyz /= ProjectedPosition.w; + v2 ScreenPosition = V2MultiplyPairwise(ProjectedPosition.xy, (WindowExtents / 2)) + (WindowExtents / 2); + + return ScreenPosition; } internal v4_ray ProjectScreenPointToWorldRay(v2 ScreenPoint, camera Camera, rect2 WindowBounds) { - v4_ray Result = {0}; - - r32 TanFOVOverTwo = TanR32(DegToRadR32(Camera.FieldOfView / 2.0f)); - r32 Aspect = RectAspectRatio(WindowBounds); - - r32 NormalizedX = ScreenPoint.x / Rect2Width(WindowBounds); - r32 NormalizedY = ScreenPoint.y / Rect2Height(WindowBounds); - - r32 CenteredX = (2.0f * NormalizedX) - 1.0f; - r32 CenteredY = (2.0f * NormalizedY) - 1.0f; - - r32 ScaledX = CenteredX * Aspect; - r32 ScaledY = CenteredY; - - r32 CameraX = ScaledX * TanFOVOverTwo; - r32 CameraY = ScaledY * TanFOVOverTwo; - - r32 Near = Camera.Near; - r32 Far = Camera.Far; - v3 MousePointOnNearPlane = v3{CameraX, CameraY, -1} * Near; - v3 MousePointOnFarPlane = v3{CameraX, CameraY, -1} * Far; - - v4 MouseRayDirection = ToV4Vec(V3Normalize(MousePointOnFarPlane - MousePointOnNearPlane)); - m44 CameraTransform = M44Transpose(M44LookAt(ToV4Point(Camera.Position), ToV4Point(Camera.LookAt))); - - Result.Origin = ToV4Point(Camera.Position); - Result.Direction = CameraTransform * MouseRayDirection; - - return Result; + v4_ray Result = {0}; + + r32 TanFOVOverTwo = TanR32(DegToRadR32(Camera.FieldOfView / 2.0f)); + r32 Aspect = RectAspectRatio(WindowBounds); + + r32 NormalizedX = ScreenPoint.x / Rect2Width(WindowBounds); + r32 NormalizedY = ScreenPoint.y / Rect2Height(WindowBounds); + + r32 CenteredX = (2.0f * NormalizedX) - 1.0f; + r32 CenteredY = (2.0f * NormalizedY) - 1.0f; + + r32 ScaledX = CenteredX * Aspect; + r32 ScaledY = CenteredY; + + r32 CameraX = ScaledX * TanFOVOverTwo; + r32 CameraY = ScaledY * TanFOVOverTwo; + + r32 Near = Camera.Near; + r32 Far = Camera.Far; + v3 MousePointOnNearPlane = v3{CameraX, CameraY, -1} * Near; + v3 MousePointOnFarPlane = v3{CameraX, CameraY, -1} * Far; + + v4 MouseRayDirection = ToV4Vec(V3Normalize(MousePointOnFarPlane - MousePointOnNearPlane)); + m44 CameraTransform = M44Transpose(M44LookAt(ToV4Point(Camera.Position), ToV4Point(Camera.LookAt))); + + Result.Origin = ToV4Point(Camera.Position); + Result.Direction = CameraTransform * MouseRayDirection; + + return Result; } // Render Commands // Discriminated Union enum render_command_type { - RenderCommand_Invalid, - - RenderCommand_render_command_clear_screen, - RenderCommand_render_command_set_render_mode, - - RenderCommand_render_batch_command_quad_2d, - RenderCommand_render_batch_command_quad_3d, - RenderCommand_render_batch_command_texture_2d, - - RenderCommand_render_command_texture_3d, - - RenderCommand_Count + RenderCommand_Invalid, + + RenderCommand_render_command_clear_screen, + RenderCommand_render_command_set_render_mode, + + RenderCommand_render_batch_command_quad_2d, + RenderCommand_render_batch_command_quad_3d, + RenderCommand_render_batch_command_texture_2d, + + RenderCommand_render_command_texture_3d, + + RenderCommand_Count }; struct render_command_header { - render_command_type Type; + render_command_type Type; }; // NOTE(Peter): Just to keep with the rest of the system @@ -114,23 +114,22 @@ struct render_command_clear_screen {}; struct render_quad_2d { - v2 Min, Max; + v2 Min, Max; }; struct render_quad_3d { - v4 P0, P1, P2, P3; + v4 P0, P1, P2, P3; }; struct render_texture { - // TODO(Peter): Is all this necessary? - u8* Memory; - s32 Handle; - s32 Width; - s32 Height; - s32 BytesPerPixel; - s32 Stride; + u8* Memory; + s32 Handle; + s32 Width; + s32 Height; + s32 BytesPerPixel; + s32 Stride; }; #define BATCH_3D_SIZE(tricount) (((sizeof(v4) + sizeof(v2) + sizeof(v4)) * 3) * tricount) @@ -151,57 +150,57 @@ struct render_texture struct render_quad_batch_constructor { - s32 Max; - s32 Count; - - v4* Vertecies; - v2* UVs; - v4* ColorsV; + s32 Max; + s32 Count; + + v4* Vertecies; + v2* UVs; + v4* ColorsV; }; struct render_batch_command_quad_2d { - s32 QuadCount; - s32 DataSize; - // NOTE(Peter): The data immediately follows the command in memory + s32 QuadCount; + s32 DataSize; + // NOTE(Peter): The data immediately follows the command in memory }; struct render_batch_command_quad_3d { - s32 QuadCount; - s32 DataSize; - // NOTE(Peter): The data immediately follows the command in memory + s32 QuadCount; + s32 DataSize; + // NOTE(Peter): The data immediately follows the command in memory }; struct render_command_texture_2d { - render_quad_2d Quad; - render_quad_2d UV; - v4 Color; - render_texture Texture; + render_quad_2d Quad; + render_quad_2d UV; + v4 Color; + render_texture Texture; }; struct render_batch_command_texture_2d { - s32 QuadCount; - s32 DataSize; - render_texture Texture; + s32 QuadCount; + s32 DataSize; + render_texture Texture; }; struct render_command_texture_3d { - render_quad_3d Quad; - v4 Color; - render_texture Texture; + render_quad_3d Quad; + v4 Color; + render_texture Texture; }; struct render_command_set_render_mode { - m44 ModelView; - m44 Projection; - r32 ViewOffsetX, ViewOffsetY; - r32 ViewWidth, ViewHeight; - b32 UseDepthBuffer; + m44 ModelView; + m44 Projection; + r32 ViewOffsetX, ViewOffsetY; + r32 ViewWidth, ViewHeight; + b32 UseDepthBuffer; }; typedef u8* renderer_realloc(u8* Base, s32 CurrentSize, s32 NewSize); @@ -210,14 +209,14 @@ typedef u8* renderer_realloc(u8* Base, s32 CurrentSize, s32 NewSize); struct render_command_buffer { - u8* CommandMemory; - s32 CommandMemoryUsed; - s32 CommandMemorySize; - - renderer_realloc* Realloc; - - s32 ViewWidth; - s32 ViewHeight; + u8* CommandMemory; + s32 CommandMemoryUsed; + s32 CommandMemorySize; + + gs_thread_context Ctx; + + s32 ViewWidth; + s32 ViewHeight; }; /// @@ -227,49 +226,49 @@ struct render_command_buffer internal u32 PackColorStructU8 (u8 R, u8 G, u8 B, u8 A) { - u32 Result = (u32)(A << 24 | - R << 16 | - G << 8 | - B<< 0); - return Result; + u32 Result = (u32)(A << 24 | + R << 16 | + G << 8 | + B<< 0); + return Result; } internal u32 PackColorStructR32 (r32 In_R, r32 In_G, r32 In_B, r32 In_A) { - Assert ((In_R >= 0.0f && In_R <= 1.0f) && - (In_G >= 0.0f && In_G <= 1.0f) && - (In_B >= 0.0f && In_B <= 1.0f) && - (In_A >= 0.0f && In_A <= 1.0f)); - - u8 R = (u8)(255 * In_R); - u8 G = (u8)(255 * In_G); - u8 B = (u8)(255 * In_B); - u8 A = (u8)(255 * In_A); - - u32 Result = (u32)(A << 24 | - R << 16 | - G << 8 | - B<< 0); - return Result; + Assert ((In_R >= 0.0f && In_R <= 1.0f) && + (In_G >= 0.0f && In_G <= 1.0f) && + (In_B >= 0.0f && In_B <= 1.0f) && + (In_A >= 0.0f && In_A <= 1.0f)); + + u8 R = (u8)(255 * In_R); + u8 G = (u8)(255 * In_G); + u8 B = (u8)(255 * In_B); + u8 A = (u8)(255 * In_A); + + u32 Result = (u32)(A << 24 | + R << 16 | + G << 8 | + B<< 0); + return Result; } internal void ResizeBufferIfNecessary(render_command_buffer* Buffer, s32 DataSize) { - if (Buffer->CommandMemoryUsed + DataSize > Buffer->CommandMemorySize) - { - // NOTE(Peter): If this becomes a problem just go back to the original solution of - // NewSize = Buffer->CommandMemorySize + (2 * DataSize); - s32 SpaceAvailable = Buffer->CommandMemorySize - Buffer->CommandMemoryUsed; - s32 SpaceNeeded = DataSize - SpaceAvailable; // This is known to be positive at this point - s32 AdditionSize = Max(SpaceNeeded, COMMAND_BUFFER_MIN_GROW_SIZE); - s32 NewSize = Buffer->CommandMemorySize + AdditionSize; - Buffer->CommandMemory = Buffer->Realloc(Buffer->CommandMemory, - Buffer->CommandMemorySize, - NewSize); - Buffer->CommandMemorySize = NewSize; - } + if (Buffer->CommandMemoryUsed + DataSize > Buffer->CommandMemorySize) + { + // NOTE(Peter): If this becomes a problem just go back to the original solution of + // NewSize = Buffer->CommandMemorySize + (2 * DataSize); + s32 SpaceAvailable = Buffer->CommandMemorySize - Buffer->CommandMemoryUsed; + s32 SpaceNeeded = DataSize - SpaceAvailable; // This is known to be positive at this point + s32 AdditionSize = Max(SpaceNeeded, COMMAND_BUFFER_MIN_GROW_SIZE); + s32 NewSize = Buffer->CommandMemorySize + AdditionSize; + + Free(Buffer->Ctx.Allocator, Buffer->CommandMemory, Buffer->CommandMemorySize); + Buffer->CommandMemory = Alloc(Buffer->Ctx.Allocator, NewSize, "Renderer"); + Buffer->CommandMemorySize = NewSize; + } } // Batch @@ -277,68 +276,68 @@ ResizeBufferIfNecessary(render_command_buffer* Buffer, s32 DataSize) internal s32 PushQuad3DBatch (render_command_buffer* Buffer, render_quad_batch_constructor* Constructor, u8* MemStart, s32 TriCount, s32 DataSize, b32 UseIntegerColor = false) { - Constructor->Max = TriCount; - Constructor->Count = 0; - - Constructor->Vertecies = (v4*)(MemStart + BATCH_3D_VERTECIES_OFFSET(TriCount)); - Constructor->UVs = (v2*)(MemStart + BATCH_3D_UVS_OFFSET(TriCount)); - Constructor->ColorsV = (v4*)(MemStart + BATCH_3D_COLORS_OFFSET(TriCount)); - - Buffer->CommandMemoryUsed += DataSize; - return DataSize; + Constructor->Max = TriCount; + Constructor->Count = 0; + + Constructor->Vertecies = (v4*)(MemStart + BATCH_3D_VERTECIES_OFFSET(TriCount)); + Constructor->UVs = (v2*)(MemStart + BATCH_3D_UVS_OFFSET(TriCount)); + Constructor->ColorsV = (v4*)(MemStart + BATCH_3D_COLORS_OFFSET(TriCount)); + + Buffer->CommandMemoryUsed += DataSize; + return DataSize; } internal s32 PushQuad2DBatch (render_command_buffer* Buffer, render_quad_batch_constructor* Constructor, s32 QuadCount, s32 DataSize, u8* MemStart) { - ZeroMemoryBlock(MemStart, DataSize); - - Constructor->Max = QuadCount; - Constructor->Count = 0; - - Constructor->Vertecies = (v4*)(MemStart + BATCH_2D_VERTECIES_OFFSET(QuadCount)); - Constructor->UVs = (v2*)(MemStart + BATCH_2D_UVS_OFFSET(QuadCount)); - Constructor->ColorsV = (v4*)(MemStart + BATCH_2D_COLORS_OFFSET(QuadCount)); - - Buffer->CommandMemoryUsed += DataSize; - return DataSize; + ZeroMemoryBlock(MemStart, DataSize); + + Constructor->Max = QuadCount; + Constructor->Count = 0; + + Constructor->Vertecies = (v4*)(MemStart + BATCH_2D_VERTECIES_OFFSET(QuadCount)); + Constructor->UVs = (v2*)(MemStart + BATCH_2D_UVS_OFFSET(QuadCount)); + Constructor->ColorsV = (v4*)(MemStart + BATCH_2D_COLORS_OFFSET(QuadCount)); + + Buffer->CommandMemoryUsed += DataSize; + return DataSize; } internal s32 ThreadSafeIncrementQuadConstructorCount (render_quad_batch_constructor* Constructor) { - s32 Result = InterlockedIncrement((long*)&Constructor->Count); - // NOTE(Peter): Have to decrement the value by one. - // Interlocked Increment acts as (++Constructor->Count), not (Constructor->Count++) which - // is what we wanted; - // This was causing the first triangle to be garbage data. - Result -= 1; - return Result; + s32 Result = InterlockedIncrement((long*)&Constructor->Count); + // NOTE(Peter): Have to decrement the value by one. + // Interlocked Increment acts as (++Constructor->Count), not (Constructor->Count++) which + // is what we wanted; + // This was causing the first triangle to be garbage data. + Result -= 1; + return Result; } struct quad_batch_constructor_reserved_range { - s32 Start; - s32 OnePastLast; + s32 Start; + s32 OnePastLast; }; internal quad_batch_constructor_reserved_range ReserveRangeInQuadConstructor(render_quad_batch_constructor* Constructor, s32 TrisNeeded) { - quad_batch_constructor_reserved_range Result = {}; - Result.OnePastLast = Constructor->Count + TrisNeeded; - Constructor->Count = Result.OnePastLast; - Result.Start = Result.OnePastLast - TrisNeeded; - return Result; + quad_batch_constructor_reserved_range Result = {}; + Result.OnePastLast = Constructor->Count + TrisNeeded; + Constructor->Count = Result.OnePastLast; + Result.Start = Result.OnePastLast - TrisNeeded; + return Result; } internal quad_batch_constructor_reserved_range ThreadSafeReserveRangeInQuadConstructor(render_quad_batch_constructor* Constructor, s32 TrisNeeded) { - quad_batch_constructor_reserved_range Result = {}; - Result.OnePastLast = InterlockedAdd((long*)&Constructor->Count, TrisNeeded); - Result.Start = Result.OnePastLast - TrisNeeded; - return Result; + quad_batch_constructor_reserved_range Result = {}; + Result.OnePastLast = InterlockedAdd((long*)&Constructor->Count, TrisNeeded); + Result.Start = Result.OnePastLast - TrisNeeded; + return Result; } inline void @@ -347,22 +346,22 @@ SetTri3DInBatch (render_quad_batch_constructor* Constructor, s32 TriIndex, v2 UV0, v2 UV1, v2 UV2, v4 C0, v4 C1, v4 C2) { - //Assert(P0.w != 0 && P1.w != 0 && P2.w != 0); // Passing vectors, rather than positions. Will draw wrong - - // Vertecies - Constructor->Vertecies[BATCH_3D_VERTEX_INDEX(TriIndex, 0)] = P0; - Constructor->Vertecies[BATCH_3D_VERTEX_INDEX(TriIndex, 1)] = P1; - Constructor->Vertecies[BATCH_3D_VERTEX_INDEX(TriIndex, 2)] = P2; - - // UVs - Constructor->UVs[BATCH_3D_UV_INDEX(TriIndex, 0)] = UV0; - Constructor->UVs[BATCH_3D_UV_INDEX(TriIndex, 1)] = UV1; - Constructor->UVs[BATCH_3D_UV_INDEX(TriIndex, 2)] = UV1; - - // Color V0 - Constructor->ColorsV[BATCH_3D_COLOR_INDEX(TriIndex, 0)] = C0; - Constructor->ColorsV[BATCH_3D_COLOR_INDEX(TriIndex, 1)] = C1; - Constructor->ColorsV[BATCH_3D_COLOR_INDEX(TriIndex, 2)] = C2; + //Assert(P0.w != 0 && P1.w != 0 && P2.w != 0); // Passing vectors, rather than positions. Will draw wrong + + // Vertecies + Constructor->Vertecies[BATCH_3D_VERTEX_INDEX(TriIndex, 0)] = P0; + Constructor->Vertecies[BATCH_3D_VERTEX_INDEX(TriIndex, 1)] = P1; + Constructor->Vertecies[BATCH_3D_VERTEX_INDEX(TriIndex, 2)] = P2; + + // UVs + Constructor->UVs[BATCH_3D_UV_INDEX(TriIndex, 0)] = UV0; + Constructor->UVs[BATCH_3D_UV_INDEX(TriIndex, 1)] = UV1; + Constructor->UVs[BATCH_3D_UV_INDEX(TriIndex, 2)] = UV1; + + // Color V0 + Constructor->ColorsV[BATCH_3D_COLOR_INDEX(TriIndex, 0)] = C0; + Constructor->ColorsV[BATCH_3D_COLOR_INDEX(TriIndex, 1)] = C1; + Constructor->ColorsV[BATCH_3D_COLOR_INDEX(TriIndex, 2)] = C2; } @@ -372,18 +371,18 @@ PushTri3DOnBatch (render_quad_batch_constructor* Constructor, v2 UV0, v2 UV1, v2 UV2, v4 C0, v4 C1, v4 C2) { - DEBUG_TRACK_FUNCTION; - // TODO(Peter): I think we avoid doing cross thread filling of a batch so do we need this? - s32 Tri = ThreadSafeIncrementQuadConstructorCount(Constructor); - SetTri3DInBatch(Constructor, Tri, P0, P1, P2, UV0, UV1, UV2, C0, C1, C2); + DEBUG_TRACK_FUNCTION; + // TODO(Peter): I think we avoid doing cross thread filling of a batch so do we need this? + s32 Tri = ThreadSafeIncrementQuadConstructorCount(Constructor); + SetTri3DInBatch(Constructor, Tri, P0, P1, P2, UV0, UV1, UV2, C0, C1, C2); }; internal void PushQuad3DOnBatch (render_quad_batch_constructor* Constructor, v4 P0, v4 P1, v4 P2, v4 P3, v2 UVMin, v2 UVMax, v4 Color) { - Assert(Constructor->Count + 2 <= Constructor->Max); - PushTri3DOnBatch(Constructor, P0, P1, P2, UVMin, v2{UVMax.x, UVMin.y}, UVMax, Color, Color, Color); - PushTri3DOnBatch(Constructor, P0, P2, P3, UVMin, UVMax, v2{UVMin.x, UVMax.y}, Color, Color, Color); + Assert(Constructor->Count + 2 <= Constructor->Max); + PushTri3DOnBatch(Constructor, P0, P1, P2, UVMin, v2{UVMax.x, UVMin.y}, UVMax, Color, Color, Color); + PushTri3DOnBatch(Constructor, P0, P2, P3, UVMin, UVMax, v2{UVMin.x, UVMax.y}, Color, Color, Color); } internal void @@ -392,15 +391,15 @@ PushQuad3DOnBatch (render_quad_batch_constructor* Constructor, v2 UV0, v2 UV1, v2 UV2, v2 UV3, v4 C0, v4 C1, v4 C2, v4 C3) { - Assert(Constructor->Count <= Constructor->Max); - PushTri3DOnBatch(Constructor, P0, P1, P2, UV0, UV1, UV2, C0, C1, C2); - PushTri3DOnBatch(Constructor, P0, P2, P3, UV0, UV2, UV3, C0, C2, C3); + Assert(Constructor->Count <= Constructor->Max); + PushTri3DOnBatch(Constructor, P0, P1, P2, UV0, UV1, UV2, C0, C1, C2); + PushTri3DOnBatch(Constructor, P0, P2, P3, UV0, UV2, UV3, C0, C2, C3); } internal void PushQuad3DOnBatch (render_quad_batch_constructor* Constructor, v4 P0, v4 P1, v4 P2, v4 P3, v4 Color) { - PushQuad3DOnBatch(Constructor, P0, P1, P2, P3, v2{0, 0}, v2{1, 1}, Color); + PushQuad3DOnBatch(Constructor, P0, P1, P2, P3, v2{0, 0}, v2{1, 1}, Color); } internal void @@ -409,92 +408,99 @@ PushQuad2DOnBatch (render_quad_batch_constructor* Constructor, v2 UV0, v2 UV1, v2 UV2, v2 UV3, v4 C0, v4 C1, v4 C2, v4 C3) { - DEBUG_TRACK_FUNCTION; - - s32 Quad = ThreadSafeIncrementQuadConstructorCount(Constructor); - v2* Vertecies = (v2*)Constructor->Vertecies; - - // Tri 1 - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 0)] = P0; - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 1)] = P1; - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 2)] = P2; - - // Tri 2 - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 0)] = P0; - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 1)] = P2; - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 2)] = P3; - - // Tri 1 UVs - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 0)] = UV0; - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 1)] = UV1; - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 2)] = UV2; - // Tri 2 UVs - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 0)] = UV0; - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 1)] = UV2; - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 2)] = UV3; - - // Tri 1 Colors - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 0)] = C0; - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 1)] = C1; - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 2)] = C2; - // Tri 2 Colors - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 0)] = C0; - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 1)] = C2; - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 2)] = C3; + DEBUG_TRACK_FUNCTION; + + s32 Quad = ThreadSafeIncrementQuadConstructorCount(Constructor); + v2* Vertecies = (v2*)Constructor->Vertecies; + + // Tri 1 + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 0)] = P0; + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 1)] = P1; + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 2)] = P2; + + // Tri 2 + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 0)] = P0; + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 1)] = P2; + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 2)] = P3; + + // Tri 1 UVs + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 0)] = UV0; + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 1)] = UV1; + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 2)] = UV2; + // Tri 2 UVs + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 0)] = UV0; + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 1)] = UV2; + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 2)] = UV3; + + // Tri 1 Colors + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 0)] = C0; + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 1)] = C1; + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 2)] = C2; + // Tri 2 Colors + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 0)] = C0; + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 1)] = C2; + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 2)] = C3; } internal void PushQuad2DOnBatch (render_quad_batch_constructor* Constructor, v2 P0, v2 P1, v2 P2, v2 P3, v2 UVMin, v2 UVMax, v4 Color) { - DEBUG_TRACK_FUNCTION; - - s32 Quad = ThreadSafeIncrementQuadConstructorCount(Constructor); - v2* Vertecies = (v2*)Constructor->Vertecies; - - // Tri 1 - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 0)] = P0; - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 1)] = P1; - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 2)] = P2; - - // Tri 2 - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 0)] = P0; - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 1)] = P2; - Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 2)] = P3; - - // Tri 1 UVs - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 0)] = UVMin; - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 1)] = v2{UVMax.x, UVMin.y}; - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 2)] = UVMax; - // Tri 2 UVs - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 0)] = UVMin; - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 1)] = UVMax; - Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 2)] = v2{UVMin.x, UVMax.y}; - - // Tri 1 Colors - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 0)] = Color; - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 1)] = Color; - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 2)] = Color; - // Tri 2 Colors - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 0)] = Color; - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 1)] = Color; - Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 2)] = Color; + DEBUG_TRACK_FUNCTION; + + s32 Quad = ThreadSafeIncrementQuadConstructorCount(Constructor); + v2* Vertecies = (v2*)Constructor->Vertecies; + + // Tri 1 + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 0)] = P0; + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 1)] = P1; + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 0, 2)] = P2; + + // Tri 2 + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 0)] = P0; + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 1)] = P2; + Vertecies[BATCH_2D_VERTEX_INDEX(Quad, 1, 2)] = P3; + + // Tri 1 UVs + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 0)] = UVMin; + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 1)] = v2{UVMax.x, UVMin.y}; + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 0, 2)] = UVMax; + // Tri 2 UVs + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 0)] = UVMin; + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 1)] = UVMax; + Constructor->UVs[BATCH_2D_UV_INDEX(Quad, 1, 2)] = v2{UVMin.x, UVMax.y}; + + // Tri 1 Colors + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 0)] = Color; + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 1)] = Color; + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 0, 2)] = Color; + // Tri 2 Colors + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 0)] = Color; + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 1)] = Color; + Constructor->ColorsV[BATCH_2D_COLOR_INDEX(Quad, 1, 2)] = Color; } internal void PushQuad2DOnBatch (render_quad_batch_constructor* Constructor, v2 Min, v2 Max, v4 Color) { - PushQuad2DOnBatch(Constructor, v2{Min.x, Min.y}, v2{Max.x, Min.y}, v2{Max.x, Max.y}, v2{Min.x, Max.y}, - v2{0, 0}, v2{1, 1}, Color); + PushQuad2DOnBatch(Constructor, v2{Min.x, Min.y}, v2{Max.x, Min.y}, v2{Max.x, Max.y}, v2{Min.x, Max.y}, + v2{0, 0}, v2{1, 1}, Color); +} + +internal void +PushQuad2DOnBatch (render_quad_batch_constructor* Constructor, rect2 Rect, v4 Color) +{ + PushQuad2DOnBatch(Constructor, v2{Rect.Min.x, Rect.Min.y}, v2{Rect.Max.x, Rect.Min.y}, v2{Rect.Max.x, Rect.Max.y}, v2{Rect.Min.x, Rect.Max.y}, + v2{0, 0}, v2{1, 1}, Color); } internal void PushLine2DOnBatch (render_quad_batch_constructor* Constructor, v2 P0, v2 P1, r32 Thickness, v4 Color) { - r32 HalfThickness = Thickness / 2.0f; - v2 Perpendicular = V2Normalize(V2PerpendicularCCW(P1 - P0)) * HalfThickness; - - PushQuad2DOnBatch(Constructor, P0 - Perpendicular, P1 - Perpendicular, P1 + Perpendicular, P0 + Perpendicular, - v2{0, 0}, v2{1, 1}, Color); + r32 HalfThickness = Thickness / 2.0f; + v2 Perpendicular = V2Normalize(V2PerpendicularCCW(P1 - P0)) * HalfThickness; + + PushQuad2DOnBatch(Constructor, P0 - Perpendicular, P1 - Perpendicular, P1 + Perpendicular, P0 + Perpendicular, + v2{0, 0}, v2{1, 1}, Color); } // Commands @@ -503,174 +509,174 @@ PushLine2DOnBatch (render_quad_batch_constructor* Constructor, v2 P0, v2 P1, r32 internal u8* PushRenderCommand_ (render_command_buffer* CommandBuffer, render_command_type CommandType, s32 CommandSize) { - ResizeBufferIfNecessary(CommandBuffer, CommandSize); - Assert(CommandBuffer->CommandMemoryUsed + CommandSize <= CommandBuffer->CommandMemorySize); - - render_command_header* Header = (render_command_header*)(CommandBuffer->CommandMemory + CommandBuffer->CommandMemoryUsed); - Header->Type = CommandType; - - u8* Result = (u8*)(Header + 1); - CommandBuffer->CommandMemoryUsed += CommandSize; - - return Result; + ResizeBufferIfNecessary(CommandBuffer, CommandSize); + Assert(CommandBuffer->CommandMemoryUsed + CommandSize <= CommandBuffer->CommandMemorySize); + + render_command_header* Header = (render_command_header*)(CommandBuffer->CommandMemory + CommandBuffer->CommandMemoryUsed); + Header->Type = CommandType; + + u8* Result = (u8*)(Header + 1); + CommandBuffer->CommandMemoryUsed += CommandSize; + + return Result; } internal render_command_set_render_mode* PushRenderPerspective (render_command_buffer* Buffer, s32 OffsetX, s32 OffsetY, s32 ViewWidth, s32 ViewHeight, camera Camera) { - render_command_set_render_mode* Command = PushRenderCommand(Buffer, render_command_set_render_mode); - - Command->ModelView = M44Transpose(GetCameraModelViewMatrix(Camera)); - Command->Projection = M44Transpose(GetCameraPerspectiveProjectionMatrix(Camera)); - - Command->ViewOffsetX = (r32)OffsetX; - Command->ViewOffsetY = (r32)OffsetY; - Command->ViewWidth = (r32)ViewWidth; - Command->ViewHeight = (r32)ViewHeight; - - Command->UseDepthBuffer = true; - - return Command; + render_command_set_render_mode* Command = PushRenderCommand(Buffer, render_command_set_render_mode); + + Command->ModelView = M44Transpose(GetCameraModelViewMatrix(Camera)); + Command->Projection = M44Transpose(GetCameraPerspectiveProjectionMatrix(Camera)); + + Command->ViewOffsetX = (r32)OffsetX; + Command->ViewOffsetY = (r32)OffsetY; + Command->ViewWidth = (r32)ViewWidth; + Command->ViewHeight = (r32)ViewHeight; + + Command->UseDepthBuffer = true; + + return Command; } internal void PushRenderPerspective(render_command_buffer* Buffer, rect2 Viewport, camera Camera) { - PushRenderPerspective(Buffer, Viewport.Min.x, Viewport.Min.y, Rect2Width(Viewport), Rect2Height(Viewport), Camera); + PushRenderPerspective(Buffer, Viewport.Min.x, Viewport.Min.y, Rect2Width(Viewport), Rect2Height(Viewport), Camera); } internal void PushRenderOrthographic (render_command_buffer* Buffer, s32 OffsetX, s32 OffsetY, s32 ViewWidth, s32 ViewHeight) { - render_command_set_render_mode* Command = PushRenderCommand(Buffer, render_command_set_render_mode); - Command->ModelView = M44Identity(); - Command->Projection = M44ProjectionOrtho((r32)ViewWidth, (r32)ViewHeight, 0, 100, ViewWidth, 0, ViewHeight, 0); - - Command->ViewOffsetX = (r32)OffsetX; - Command->ViewOffsetY = (r32)OffsetY; - Command->ViewWidth = ViewWidth; - Command->ViewHeight = ViewHeight; - - Command->UseDepthBuffer = false;; + render_command_set_render_mode* Command = PushRenderCommand(Buffer, render_command_set_render_mode); + Command->ModelView = M44Identity(); + Command->Projection = M44ProjectionOrtho((r32)ViewWidth, (r32)ViewHeight, 0, 100, ViewWidth, 0, ViewHeight, 0); + + Command->ViewOffsetX = (r32)OffsetX; + Command->ViewOffsetY = (r32)OffsetY; + Command->ViewWidth = ViewWidth; + Command->ViewHeight = ViewHeight; + + Command->UseDepthBuffer = false;; } internal void PushRenderOrthographic(render_command_buffer* Buffer, rect2 Viewport) { - PushRenderOrthographic(Buffer, Viewport.Min.x, Viewport.Min.y, Rect2Width(Viewport), Rect2Height(Viewport)); + PushRenderOrthographic(Buffer, Viewport.Min.x, Viewport.Min.y, Rect2Width(Viewport), Rect2Height(Viewport)); } internal void PushRenderClearScreen (render_command_buffer* Buffer) { - render_command_clear_screen* Command = PushRenderCommand(Buffer, render_command_clear_screen); + render_command_clear_screen* Command = PushRenderCommand(Buffer, render_command_clear_screen); } internal render_quad_batch_constructor PushRenderQuad2DBatch(render_command_buffer* Buffer, s32 QuadCount) { - s32 DataSize = BATCH_2D_SIZE(QuadCount); - ResizeBufferIfNecessary(Buffer, DataSize + sizeof(render_batch_command_quad_2d)); - Assert(Buffer->CommandMemoryUsed + DataSize <= Buffer->CommandMemorySize); - - render_quad_batch_constructor Result = {}; - - render_batch_command_quad_2d* Command = PushRenderCommand(Buffer, render_batch_command_quad_2d); - Command->QuadCount = QuadCount; - Command->DataSize = PushQuad2DBatch(Buffer, &Result, QuadCount, DataSize, (u8*)(Command + 1)); - - return Result; + s32 DataSize = BATCH_2D_SIZE(QuadCount); + ResizeBufferIfNecessary(Buffer, DataSize + sizeof(render_batch_command_quad_2d)); + Assert(Buffer->CommandMemoryUsed + DataSize <= Buffer->CommandMemorySize); + + render_quad_batch_constructor Result = {}; + + render_batch_command_quad_2d* Command = PushRenderCommand(Buffer, render_batch_command_quad_2d); + Command->QuadCount = QuadCount; + Command->DataSize = PushQuad2DBatch(Buffer, &Result, QuadCount, DataSize, (u8*)(Command + 1)); + + return Result; } internal void PushRenderQuad2D (render_command_buffer* Buffer, v2 Min, v2 Max, v4 Color) { - render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 1); - PushQuad2DOnBatch(&Batch, Min, Max, Color); + render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 1); + PushQuad2DOnBatch(&Batch, Min, Max, Color); } internal void PushRenderQuad2D (render_command_buffer* Buffer, rect2 Rect, v4 Color) { - render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 1); - PushQuad2DOnBatch(&Batch, Rect.Min, Rect.Max, Color); + render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 1); + PushQuad2DOnBatch(&Batch, Rect.Min, Rect.Max, Color); } internal void PushRenderQuad2DClipped (render_command_buffer* Buffer, rect2 Rect, rect2 ClippingBox, v4 Color) { - rect2 Clipped = Rect2Union(Rect, ClippingBox); - render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 1); - PushQuad2DOnBatch(&Batch, Clipped.Min, Clipped.Max, Color); + rect2 Clipped = Rect2Union(Rect, ClippingBox); + render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 1); + PushQuad2DOnBatch(&Batch, Clipped.Min, Clipped.Max, Color); } internal void PushRenderQuad2D(render_command_buffer* Buffer, v2 P0, v2 P1, v2 P2, v2 P3, v4 Color) { - render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 1); - PushQuad2DOnBatch(&Batch, P0, P1, P2, P3, v2{0,0}, v2{1,1}, Color); + render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 1); + PushQuad2DOnBatch(&Batch, P0, P1, P2, P3, v2{0,0}, v2{1,1}, Color); } internal void PushRenderLine2D (render_command_buffer* Buffer, v2 P0, v2 P1, r32 Thickness, v4 Color) { - render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 1); - PushLine2DOnBatch(&Batch, P0, P1, Thickness, Color); + render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 1); + PushLine2DOnBatch(&Batch, P0, P1, Thickness, Color); } internal render_quad_batch_constructor PushRenderQuad3DBatch(render_command_buffer* Buffer, s32 QuadCount) { - s32 TriCount = QuadCount * 2; - s32 DataSize = BATCH_3D_SIZE(TriCount); - ResizeBufferIfNecessary(Buffer, DataSize + sizeof(render_batch_command_quad_3d)); - Assert(Buffer->CommandMemoryUsed + DataSize <= Buffer->CommandMemorySize); - - render_quad_batch_constructor Result = {}; - - render_batch_command_quad_3d* Command = PushRenderCommand(Buffer, render_batch_command_quad_3d); - Command->QuadCount = QuadCount; - Command->DataSize = PushQuad3DBatch(Buffer, &Result, (u8*)(Command + 1), TriCount, DataSize); - - return Result; + s32 TriCount = QuadCount * 2; + s32 DataSize = BATCH_3D_SIZE(TriCount); + ResizeBufferIfNecessary(Buffer, DataSize + sizeof(render_batch_command_quad_3d)); + Assert(Buffer->CommandMemoryUsed + DataSize <= Buffer->CommandMemorySize); + + render_quad_batch_constructor Result = {}; + + render_batch_command_quad_3d* Command = PushRenderCommand(Buffer, render_batch_command_quad_3d); + Command->QuadCount = QuadCount; + Command->DataSize = PushQuad3DBatch(Buffer, &Result, (u8*)(Command + 1), TriCount, DataSize); + + return Result; } internal void PushRenderQuad3D (render_command_buffer* Buffer, v4 A, v4 B, v4 C, v4 D, v4 Color) { - render_quad_batch_constructor Batch = PushRenderQuad3DBatch(Buffer, 1); - PushQuad3DOnBatch(&Batch, A, B, C, D, Color); + render_quad_batch_constructor Batch = PushRenderQuad3DBatch(Buffer, 1); + PushQuad3DOnBatch(&Batch, A, B, C, D, Color); } internal void PushRenderCameraFacingQuad (render_command_buffer* Buffer, v4 Center, v2 Dimensions, v4 Color) { - // TODO(Peter): Turn this into an actual camera facing quad - v4 A = v4{Center.x - Dimensions.x, Center.y - Dimensions.y, Center.z, Center.w}; - v4 B = v4{Center.x + Dimensions.x, Center.y - Dimensions.y, Center.z, Center.w}; - v4 C = v4{Center.x + Dimensions.x, Center.y + Dimensions.y, Center.z, Center.w}; - v4 D = v4{Center.x - Dimensions.x, Center.y + Dimensions.y, Center.z, Center.w}; - - PushRenderQuad3D(Buffer, A, B, C, D, Color); + // TODO(Peter): Turn this into an actual camera facing quad + v4 A = v4{Center.x - Dimensions.x, Center.y - Dimensions.y, Center.z, Center.w}; + v4 B = v4{Center.x + Dimensions.x, Center.y - Dimensions.y, Center.z, Center.w}; + v4 C = v4{Center.x + Dimensions.x, Center.y + Dimensions.y, Center.z, Center.w}; + v4 D = v4{Center.x - Dimensions.x, Center.y + Dimensions.y, Center.z, Center.w}; + + PushRenderQuad3D(Buffer, A, B, C, D, Color); } internal render_quad_batch_constructor PushRenderTexture2DBatch(render_command_buffer* Buffer, s32 QuadCount, render_texture Texture) { - s32 DataSize = BATCH_2D_SIZE(QuadCount); - ResizeBufferIfNecessary(Buffer, DataSize); - Assert(Buffer->CommandMemoryUsed + DataSize <= Buffer->CommandMemorySize); - - render_quad_batch_constructor Result = {}; - - render_batch_command_texture_2d* Command = PushRenderCommand(Buffer, render_batch_command_texture_2d); - Command->QuadCount = QuadCount; - Command->DataSize = PushQuad2DBatch(Buffer, &Result, QuadCount, DataSize, (u8*)(Command + 1)); - Command->Texture = Texture; - - return Result; + s32 DataSize = BATCH_2D_SIZE(QuadCount); + ResizeBufferIfNecessary(Buffer, DataSize); + Assert(Buffer->CommandMemoryUsed + DataSize <= Buffer->CommandMemorySize); + + render_quad_batch_constructor Result = {}; + + render_batch_command_texture_2d* Command = PushRenderCommand(Buffer, render_batch_command_texture_2d); + Command->QuadCount = QuadCount; + Command->DataSize = PushQuad2DBatch(Buffer, &Result, QuadCount, DataSize, (u8*)(Command + 1)); + Command->Texture = Texture; + + return Result; } internal render_quad_batch_constructor @@ -678,14 +684,14 @@ PushRenderTexture2DBatch (render_command_buffer* Buffer, s32 QuadCount, u8* TextureMemory, s32 TextureHandle, s32 TextureWidth, s32 TextureHeight, s32 TextureBytesPerPixel, s32 TextureStride) { - render_texture Texture = render_texture{ - TextureMemory, - TextureHandle, - TextureWidth, - TextureHeight, - TextureBytesPerPixel, - TextureStride}; - return PushRenderTexture2DBatch(Buffer, QuadCount, Texture); + render_texture Texture = render_texture{ + TextureMemory, + TextureHandle, + TextureWidth, + TextureHeight, + TextureBytesPerPixel, + TextureStride}; + return PushRenderTexture2DBatch(Buffer, QuadCount, Texture); } internal void @@ -693,19 +699,19 @@ PushRenderTexture2D (render_command_buffer* Buffer, v2 Min, v2 Max, v4 Color, v2 UVMin, v2 UVMax, render_texture* Texture) { - render_quad_batch_constructor Batch = PushRenderTexture2DBatch(Buffer, 1, *Texture); - PushQuad2DOnBatch(&Batch, v2{Min.x, Min.y}, v2{Max.x, Min.y}, v2{Max.x, Max.y}, v2{Min.x, Max.y}, - UVMin, UVMax, Color); + render_quad_batch_constructor Batch = PushRenderTexture2DBatch(Buffer, 1, *Texture); + PushQuad2DOnBatch(&Batch, v2{Min.x, Min.y}, v2{Max.x, Min.y}, v2{Max.x, Max.y}, v2{Min.x, Max.y}, + UVMin, UVMax, Color); } internal void PushRenderBoundingBox2D (render_command_buffer* Buffer, v2 Min, v2 Max, r32 Thickness, v4 Color) { - render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 4); - PushQuad2DOnBatch(&Batch, Min, v2{Min.x + Thickness, Max.y}, Color); - PushQuad2DOnBatch(&Batch, v2{Min.x, Max.y - Thickness}, Max, Color); - PushQuad2DOnBatch(&Batch, v2{Max.x - Thickness, Min.y}, Max, Color); - PushQuad2DOnBatch(&Batch, Min, v2{Max.x, Min.y + Thickness}, Color); + render_quad_batch_constructor Batch = PushRenderQuad2DBatch(Buffer, 4); + PushQuad2DOnBatch(&Batch, Min, v2{Min.x + Thickness, Max.y}, Color); + PushQuad2DOnBatch(&Batch, v2{Min.x, Max.y - Thickness}, Max, Color); + PushQuad2DOnBatch(&Batch, v2{Max.x - Thickness, Min.y}, Max, Color); + PushQuad2DOnBatch(&Batch, Min, v2{Max.x, Min.y + Thickness}, Color); } diff --git a/src/app/handmade_math.h b/src/app/handmade_math.h deleted file mode 100644 index 049dfdb..0000000 --- a/src/app/handmade_math.h +++ /dev/null @@ -1,3239 +0,0 @@ -/* - HandmadeMath.h v1.11.0 - - This is a single header file with a bunch of useful functions for game and - graphics math operations. - - ============================================================================= - - You MUST - - #define HANDMADE_MATH_IMPLEMENTATION - - in EXACTLY one C or C++ file that includes this header, BEFORE the - include, like this: - - #define HANDMADE_MATH_IMPLEMENTATION - #include "HandmadeMath.h" - - All other files should just #include "HandmadeMath.h" without the #define. - - ============================================================================= - - To disable SSE intrinsics, you MUST - - #define HANDMADE_MATH_NO_SSE - - in EXACTLY one C or C++ file that includes this header, BEFORE the - include, like this: - - #define HANDMADE_MATH_IMPLEMENTATION - #define HANDMADE_MATH_NO_SSE - #include "HandmadeMath.h" - - ============================================================================= - - If you would prefer not to use the HMM_ prefix on function names, you can - - #define HMM_PREFIX - - To use a custom prefix instead, you can - - #define HMM_PREFIX(name) YOUR_PREFIX_##name - - ============================================================================= - - To use HandmadeMath without the CRT, you MUST - - #define HMM_SINF MySinF - #define HMM_COSF MyCosF - #define HMM_TANF MyTanF - #define HMM_SQRTF MySqrtF - #define HMM_EXPF MyExpF - #define HMM_LOGF MyLogF - #define HMM_ACOSF MyACosF - #define HMM_ATANF MyATanF - #define HMM_ATAN2F MYATan2F - - Provide your own implementations of SinF, CosF, TanF, ACosF, ATanF, ATan2F, - ExpF, and LogF in EXACTLY one C or C++ file that includes this header, - BEFORE the include, like this: - - #define HMM_SINF MySinF - #define HMM_COSF MyCosF - #define HMM_TANF MyTanF - #define HMM_SQRTF MySqrtF - #define HMM_EXPF MyExpF - #define HMM_LOGF MyLogF - #define HMM_ACOSF MyACosF - #define HMM_ATANF MyATanF - #define HMM_ATAN2F MyATan2F - #define HANDMADE_MATH_IMPLEMENTATION - #include "HandmadeMath.h" - - If you do not define all of these, HandmadeMath.h will use the - versions of these functions that are provided by the CRT. - - ============================================================================= - - LICENSE - - This software is in the public domain. Where that dedication is not - recognized, you are granted a perpetual, irrevocable license to copy, - distribute, and modify this file as you see fit. - - CREDITS - - Written by Zakary Strange (strangezak@gmail.com && @strangezak) - - Functionality: - Matt Mascarenhas (@miblo_) - Aleph - FieryDrake (@fierydrake) - Gingerbill (@TheGingerBill) - Ben Visness (@bvisness) - Trinton Bullard (@Peliex_Dev) - @AntonDan - - Fixes: - Jeroen van Rijn (@J_vanRijn) - Kiljacken (@Kiljacken) - Insofaras (@insofaras) - Daniel Gibson (@DanielGibson) -*/ - -// Dummy macros for when test framework is not present. -#ifndef COVERAGE -#define COVERAGE(a, b) -#endif - -#ifndef ASSERT_COVERED -#define ASSERT_COVERED(a) -#endif - -/* let's figure out if SSE is really available (unless disabled anyway) - (it isn't on non-x86/x86_64 platforms or even x86 without explicit SSE support) - => only use "#ifdef HANDMADE_MATH__USE_SSE" to check for SSE support below this block! */ -#ifndef HANDMADE_MATH_NO_SSE - -# ifdef _MSC_VER -/* MSVC supports SSE in amd64 mode or _M_IX86_FP >= 1 (2 means SSE2) */ -# if defined(_M_AMD64) || ( defined(_M_IX86_FP) && _M_IX86_FP >= 1 ) -# define HANDMADE_MATH__USE_SSE 1 -# endif -# else /* not MSVC, probably GCC, clang, icc or something that doesn't support SSE anyway */ -# ifdef __SSE__ /* they #define __SSE__ if it's supported */ -# define HANDMADE_MATH__USE_SSE 1 -# endif /* __SSE__ */ -# endif /* not _MSC_VER */ - -#endif /* #ifndef HANDMADE_MATH_NO_SSE */ - -#ifdef HANDMADE_MATH__USE_SSE -#include -#endif - -#ifndef HANDMADE_MATH_H -#define HANDMADE_MATH_H - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" -#if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 8) -#pragma GCC diagnostic ignored "-Wmissing-braces" -#endif -#ifdef __clang__ -#pragma GCC diagnostic ignored "-Wgnu-anonymous-struct" -#endif -#endif - -#if defined(__GNUC__) || defined(__clang__) -#define HMM_DEPRECATED(msg) __attribute__((deprecated(msg))) -#elif defined(_MSC_VER) -#define HMM_DEPRECATED(msg) __declspec(deprecated(msg)) -#else -#define HMM_DEPRECATED(msg) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define HMM_INLINE static inline -#define HMM_EXTERN extern - -#if !defined(HMM_SINF) || !defined(HMM_COSF) || !defined(HMM_TANF) || \ - !defined(HMM_SQRTF) || !defined(HMM_EXPF) || !defined(HMM_LOGF) || \ - !defined(HMM_ACOSF) || !defined(HMM_ATANF)|| !defined(HMM_ATAN2F) -#include -#endif - -#ifndef HMM_SINF -#define HMM_SINF sinf -#endif - -#ifndef HMM_COSF -#define HMM_COSF cosf -#endif - -#ifndef HMM_TANF -#define HMM_TANF tanf -#endif - -#ifndef HMM_SQRTF -#define HMM_SQRTF sqrtf -#endif - -#ifndef HMM_EXPF -#define HMM_EXPF expf -#endif - -#ifndef HMM_LOGF -#define HMM_LOGF logf -#endif - -#ifndef HMM_ACOSF -#define HMM_ACOSF acosf -#endif - -#ifndef HMM_ATANF -#define HMM_ATANF atanf -#endif - -#ifndef HMM_ATAN2F -#define HMM_ATAN2F atan2f -#endif - -#define HMM_PI32 3.14159265359f -#define HMM_PI 3.14159265358979323846 - -#define HMM_MIN(a, b) (a) > (b) ? (b) : (a) -#define HMM_MAX(a, b) (a) < (b) ? (b) : (a) -#define HMM_ABS(a) ((a) > 0 ? (a) : -(a)) -#define HMM_MOD(a, m) ((a) % (m)) >= 0 ? ((a) % (m)) : (((a) % (m)) + (m)) -#define HMM_SQUARE(x) ((x) * (x)) - -#ifndef HMM_PREFIX -#define HMM_PREFIX(name) HMM_##name -#endif - - typedef union hmm_vec2 - { - struct - { - float X, Y; - }; - - struct - { - float U, V; - }; - - struct - { - float Left, Right; - }; - - struct - { - float Width, Height; - }; - - float Elements[2]; - -#ifdef __cplusplus - inline float &operator[](const int &Index) - { - return Elements[Index]; - } -#endif - } hmm_vec2; - - typedef union hmm_vec3 - { - struct - { - float X, Y, Z; - }; - - struct - { - float U, V, W; - }; - - struct - { - float R, G, B; - }; - - struct - { - hmm_vec2 XY; - float Ignored0_; - }; - - struct - { - float Ignored1_; - hmm_vec2 YZ; - }; - - struct - { - hmm_vec2 UV; - float Ignored2_; - }; - - struct - { - float Ignored3_; - hmm_vec2 VW; - }; - - float Elements[3]; - -#ifdef __cplusplus - inline float &operator[](const int &Index) - { - return Elements[Index]; - } -#endif - } hmm_vec3; - - typedef union hmm_vec4 - { - struct - { - union - { - hmm_vec3 XYZ; - struct - { - float X, Y, Z; - }; - }; - - float W; - }; - struct - { - union - { - hmm_vec3 RGB; - struct - { - float R, G, B; - }; - }; - - float A; - }; - - struct - { - hmm_vec2 XY; - float Ignored0_; - float Ignored1_; - }; - - struct - { - float Ignored2_; - hmm_vec2 YZ; - float Ignored3_; - }; - - struct - { - float Ignored4_; - float Ignored5_; - hmm_vec2 ZW; - }; - - float Elements[4]; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 InternalElementsSSE; -#endif - -#ifdef __cplusplus - inline float &operator[](const int &Index) - { - return Elements[Index]; - } -#endif - } hmm_vec4; - - typedef union hmm_mat4 - { - float Elements[4][4]; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 Columns[4]; - - HMM_DEPRECATED("Our matrices are column-major, so this was named incorrectly. Use Columns instead.") - __m128 Rows[4]; -#endif - -#ifdef __cplusplus - inline hmm_vec4 operator[](const int &Index) - { - float* col = Elements[Index]; - - hmm_vec4 result; - result.Elements[0] = col[0]; - result.Elements[1] = col[1]; - result.Elements[2] = col[2]; - result.Elements[3] = col[3]; - - return result; - } -#endif - } hmm_mat4; - - typedef union hmm_quaternion - { - struct - { - union - { - hmm_vec3 XYZ; - struct - { - float X, Y, Z; - }; - }; - - float W; - }; - - float Elements[4]; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 InternalElementsSSE; -#endif - } hmm_quaternion; - - typedef signed int hmm_bool; - - typedef hmm_vec2 hmm_v2; - typedef hmm_vec3 hmm_v3; - typedef hmm_vec4 hmm_v4; - typedef hmm_mat4 hmm_m4; - - - /* - * Floating-point math functions - */ - - COVERAGE(HMM_SinF, 1) - HMM_INLINE float HMM_PREFIX(SinF)(float Radians) - { - ASSERT_COVERED(HMM_SinF); - - float Result = HMM_SINF(Radians); - - return (Result); - } - - COVERAGE(HMM_CosF, 1) - HMM_INLINE float HMM_PREFIX(CosF)(float Radians) - { - ASSERT_COVERED(HMM_CosF); - - float Result = HMM_COSF(Radians); - - return (Result); - } - - COVERAGE(HMM_TanF, 1) - HMM_INLINE float HMM_PREFIX(TanF)(float Radians) - { - ASSERT_COVERED(HMM_TanF); - - float Result = HMM_TANF(Radians); - - return (Result); - } - - COVERAGE(HMM_ACosF, 1) - HMM_INLINE float HMM_PREFIX(ACosF)(float Radians) - { - ASSERT_COVERED(HMM_ACosF); - - float Result = HMM_ACOSF(Radians); - - return (Result); - } - - COVERAGE(HMM_ATanF, 1) - HMM_INLINE float HMM_PREFIX(ATanF)(float Radians) - { - ASSERT_COVERED(HMM_ATanF); - - float Result = HMM_ATANF(Radians); - - return (Result); - } - - COVERAGE(HMM_ATan2F, 1) - HMM_INLINE float HMM_PREFIX(ATan2F)(float Left, float Right) - { - ASSERT_COVERED(HMM_ATan2F); - - float Result = HMM_ATAN2F(Left, Right); - - return (Result); - } - - COVERAGE(HMM_ExpF, 1) - HMM_INLINE float HMM_PREFIX(ExpF)(float Float) - { - ASSERT_COVERED(HMM_ExpF); - - float Result = HMM_EXPF(Float); - - return (Result); - } - - COVERAGE(HMM_LogF, 1) - HMM_INLINE float HMM_PREFIX(LogF)(float Float) - { - ASSERT_COVERED(HMM_LogF); - - float Result = HMM_LOGF(Float); - - return (Result); - } - - COVERAGE(HMM_SquareRootF, 1) - HMM_INLINE float HMM_PREFIX(SquareRootF)(float Float) - { - ASSERT_COVERED(HMM_SquareRootF); - - float Result; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 In = _mm_set_ss(Float); - __m128 Out = _mm_sqrt_ss(In); - Result = _mm_cvtss_f32(Out); -#else - Result = HMM_SQRTF(Float); -#endif - - return(Result); - } - - COVERAGE(HMM_RSquareRootF, 1) - HMM_INLINE float HMM_PREFIX(RSquareRootF)(float Float) - { - ASSERT_COVERED(HMM_RSquareRootF); - - float Result; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 In = _mm_set_ss(Float); - __m128 Out = _mm_rsqrt_ss(In); - Result = _mm_cvtss_f32(Out); -#else - Result = 1.0f/HMM_PREFIX(SquareRootF)(Float); -#endif - - return(Result); - } - - HMM_EXTERN float HMM_PREFIX(Power)(float Base, int Exponent); - - COVERAGE(HMM_PowerF, 1) - HMM_INLINE float HMM_PREFIX(PowerF)(float Base, float Exponent) - { - ASSERT_COVERED(HMM_PowerF); - - float Result = HMM_EXPF(Exponent * HMM_LOGF(Base)); - - return (Result); - } - - - /* - * Utility functions - */ - - COVERAGE(HMM_ToRadians, 1) - HMM_INLINE float HMM_PREFIX(ToRadians)(float Degrees) - { - ASSERT_COVERED(HMM_ToRadians); - - float Result = Degrees * (HMM_PI32 / 180.0f); - - return (Result); - } - - COVERAGE(HMM_Lerp, 1) - HMM_INLINE float HMM_PREFIX(Lerp)(float A, float Time, float B) - { - ASSERT_COVERED(HMM_Lerp); - - float Result = (1.0f - Time) * A + Time * B; - - return (Result); - } - - COVERAGE(HMM_Clamp, 1) - HMM_INLINE float HMM_PREFIX(Clamp)(float Min, float Value, float Max) - { - ASSERT_COVERED(HMM_Clamp); - - float Result = Value; - - if(Result < Min) - { - Result = Min; - } - else if(Result > Max) - { - Result = Max; - } - - return (Result); - } - - - /* - * Vector initialization - */ - - COVERAGE(HMM_Vec2, 1) - HMM_INLINE hmm_vec2 HMM_PREFIX(Vec2)(float X, float Y) - { - ASSERT_COVERED(HMM_Vec2); - - hmm_vec2 Result; - - Result.X = X; - Result.Y = Y; - - return (Result); - } - - COVERAGE(HMM_Vec2i, 1) - HMM_INLINE hmm_vec2 HMM_PREFIX(Vec2i)(int X, int Y) - { - ASSERT_COVERED(HMM_Vec2i); - - hmm_vec2 Result; - - Result.X = (float)X; - Result.Y = (float)Y; - - return (Result); - } - - COVERAGE(HMM_Vec3, 1) - HMM_INLINE hmm_vec3 HMM_PREFIX(Vec3)(float X, float Y, float Z) - { - ASSERT_COVERED(HMM_Vec3); - - hmm_vec3 Result; - - Result.X = X; - Result.Y = Y; - Result.Z = Z; - - return (Result); - } - - COVERAGE(HMM_Vec3i, 1) - HMM_INLINE hmm_vec3 HMM_PREFIX(Vec3i)(int X, int Y, int Z) - { - ASSERT_COVERED(HMM_Vec3i); - - hmm_vec3 Result; - - Result.X = (float)X; - Result.Y = (float)Y; - Result.Z = (float)Z; - - return (Result); - } - - COVERAGE(HMM_Vec4, 1) - HMM_INLINE hmm_vec4 HMM_PREFIX(Vec4)(float X, float Y, float Z, float W) - { - ASSERT_COVERED(HMM_Vec4); - - hmm_vec4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = _mm_setr_ps(X, Y, Z, W); -#else - Result.X = X; - Result.Y = Y; - Result.Z = Z; - Result.W = W; -#endif - - return (Result); - } - - COVERAGE(HMM_Vec4i, 1) - HMM_INLINE hmm_vec4 HMM_PREFIX(Vec4i)(int X, int Y, int Z, int W) - { - ASSERT_COVERED(HMM_Vec4i); - - hmm_vec4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = _mm_setr_ps((float)X, (float)Y, (float)Z, (float)W); -#else - Result.X = (float)X; - Result.Y = (float)Y; - Result.Z = (float)Z; - Result.W = (float)W; -#endif - - return (Result); - } - - COVERAGE(HMM_Vec4v, 1) - HMM_INLINE hmm_vec4 HMM_PREFIX(Vec4v)(hmm_vec3 Vector, float W) - { - ASSERT_COVERED(HMM_Vec4v); - - hmm_vec4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = _mm_setr_ps(Vector.X, Vector.Y, Vector.Z, W); -#else - Result.XYZ = Vector; - Result.W = W; -#endif - - return (Result); - } - - - /* - * Binary vector operations - */ - - COVERAGE(HMM_AddVec2, 1) - HMM_INLINE hmm_vec2 HMM_PREFIX(AddVec2)(hmm_vec2 Left, hmm_vec2 Right) - { - ASSERT_COVERED(HMM_AddVec2); - - hmm_vec2 Result; - - Result.X = Left.X + Right.X; - Result.Y = Left.Y + Right.Y; - - return (Result); - } - - COVERAGE(HMM_AddVec3, 1) - HMM_INLINE hmm_vec3 HMM_PREFIX(AddVec3)(hmm_vec3 Left, hmm_vec3 Right) - { - ASSERT_COVERED(HMM_AddVec3); - - hmm_vec3 Result; - - Result.X = Left.X + Right.X; - Result.Y = Left.Y + Right.Y; - Result.Z = Left.Z + Right.Z; - - return (Result); - } - - COVERAGE(HMM_AddVec4, 1) - HMM_INLINE hmm_vec4 HMM_PREFIX(AddVec4)(hmm_vec4 Left, hmm_vec4 Right) - { - ASSERT_COVERED(HMM_AddVec4); - - hmm_vec4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = _mm_add_ps(Left.InternalElementsSSE, Right.InternalElementsSSE); -#else - Result.X = Left.X + Right.X; - Result.Y = Left.Y + Right.Y; - Result.Z = Left.Z + Right.Z; - Result.W = Left.W + Right.W; -#endif - - return (Result); - } - - COVERAGE(HMM_SubtractVec2, 1) - HMM_INLINE hmm_vec2 HMM_PREFIX(SubtractVec2)(hmm_vec2 Left, hmm_vec2 Right) - { - ASSERT_COVERED(HMM_SubtractVec2); - - hmm_vec2 Result; - - Result.X = Left.X - Right.X; - Result.Y = Left.Y - Right.Y; - - return (Result); - } - - COVERAGE(HMM_SubtractVec3, 1) - HMM_INLINE hmm_vec3 HMM_PREFIX(SubtractVec3)(hmm_vec3 Left, hmm_vec3 Right) - { - ASSERT_COVERED(HMM_SubtractVec3); - - hmm_vec3 Result; - - Result.X = Left.X - Right.X; - Result.Y = Left.Y - Right.Y; - Result.Z = Left.Z - Right.Z; - - return (Result); - } - - COVERAGE(HMM_SubtractVec4, 1) - HMM_INLINE hmm_vec4 HMM_PREFIX(SubtractVec4)(hmm_vec4 Left, hmm_vec4 Right) - { - ASSERT_COVERED(HMM_SubtractVec4); - - hmm_vec4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = _mm_sub_ps(Left.InternalElementsSSE, Right.InternalElementsSSE); -#else - Result.X = Left.X - Right.X; - Result.Y = Left.Y - Right.Y; - Result.Z = Left.Z - Right.Z; - Result.W = Left.W - Right.W; -#endif - - return (Result); - } - - COVERAGE(HMM_MultiplyVec2, 1) - HMM_INLINE hmm_vec2 HMM_PREFIX(MultiplyVec2)(hmm_vec2 Left, hmm_vec2 Right) - { - ASSERT_COVERED(HMM_MultiplyVec2); - - hmm_vec2 Result; - - Result.X = Left.X * Right.X; - Result.Y = Left.Y * Right.Y; - - return (Result); - } - - COVERAGE(HMM_MultiplyVec2f, 1) - HMM_INLINE hmm_vec2 HMM_PREFIX(MultiplyVec2f)(hmm_vec2 Left, float Right) - { - ASSERT_COVERED(HMM_MultiplyVec2f); - - hmm_vec2 Result; - - Result.X = Left.X * Right; - Result.Y = Left.Y * Right; - - return (Result); - } - - COVERAGE(HMM_MultiplyVec3, 1) - HMM_INLINE hmm_vec3 HMM_PREFIX(MultiplyVec3)(hmm_vec3 Left, hmm_vec3 Right) - { - ASSERT_COVERED(HMM_MultiplyVec3); - - hmm_vec3 Result; - - Result.X = Left.X * Right.X; - Result.Y = Left.Y * Right.Y; - Result.Z = Left.Z * Right.Z; - - return (Result); - } - - COVERAGE(HMM_MultiplyVec3f, 1) - HMM_INLINE hmm_vec3 HMM_PREFIX(MultiplyVec3f)(hmm_vec3 Left, float Right) - { - ASSERT_COVERED(HMM_MultiplyVec3f); - - hmm_vec3 Result; - - Result.X = Left.X * Right; - Result.Y = Left.Y * Right; - Result.Z = Left.Z * Right; - - return (Result); - } - - COVERAGE(HMM_MultiplyVec4, 1) - HMM_INLINE hmm_vec4 HMM_PREFIX(MultiplyVec4)(hmm_vec4 Left, hmm_vec4 Right) - { - ASSERT_COVERED(HMM_MultiplyVec4); - - hmm_vec4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = _mm_mul_ps(Left.InternalElementsSSE, Right.InternalElementsSSE); -#else - Result.X = Left.X * Right.X; - Result.Y = Left.Y * Right.Y; - Result.Z = Left.Z * Right.Z; - Result.W = Left.W * Right.W; -#endif - - return (Result); - } - - COVERAGE(HMM_MultiplyVec4f, 1) - HMM_INLINE hmm_vec4 HMM_PREFIX(MultiplyVec4f)(hmm_vec4 Left, float Right) - { - ASSERT_COVERED(HMM_MultiplyVec4f); - - hmm_vec4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 Scalar = _mm_set1_ps(Right); - Result.InternalElementsSSE = _mm_mul_ps(Left.InternalElementsSSE, Scalar); -#else - Result.X = Left.X * Right; - Result.Y = Left.Y * Right; - Result.Z = Left.Z * Right; - Result.W = Left.W * Right; -#endif - - return (Result); - } - - COVERAGE(HMM_DivideVec2, 1) - HMM_INLINE hmm_vec2 HMM_PREFIX(DivideVec2)(hmm_vec2 Left, hmm_vec2 Right) - { - ASSERT_COVERED(HMM_DivideVec2); - - hmm_vec2 Result; - - Result.X = Left.X / Right.X; - Result.Y = Left.Y / Right.Y; - - return (Result); - } - - COVERAGE(HMM_DivideVec2f, 1) - HMM_INLINE hmm_vec2 HMM_PREFIX(DivideVec2f)(hmm_vec2 Left, float Right) - { - ASSERT_COVERED(HMM_DivideVec2f); - - hmm_vec2 Result; - - Result.X = Left.X / Right; - Result.Y = Left.Y / Right; - - return (Result); - } - - COVERAGE(HMM_DivideVec3, 1) - HMM_INLINE hmm_vec3 HMM_PREFIX(DivideVec3)(hmm_vec3 Left, hmm_vec3 Right) - { - ASSERT_COVERED(HMM_DivideVec3); - - hmm_vec3 Result; - - Result.X = Left.X / Right.X; - Result.Y = Left.Y / Right.Y; - Result.Z = Left.Z / Right.Z; - - return (Result); - } - - COVERAGE(HMM_DivideVec3f, 1) - HMM_INLINE hmm_vec3 HMM_PREFIX(DivideVec3f)(hmm_vec3 Left, float Right) - { - ASSERT_COVERED(HMM_DivideVec3f); - - hmm_vec3 Result; - - Result.X = Left.X / Right; - Result.Y = Left.Y / Right; - Result.Z = Left.Z / Right; - - return (Result); - } - - COVERAGE(HMM_DivideVec4, 1) - HMM_INLINE hmm_vec4 HMM_PREFIX(DivideVec4)(hmm_vec4 Left, hmm_vec4 Right) - { - ASSERT_COVERED(HMM_DivideVec4); - - hmm_vec4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = _mm_div_ps(Left.InternalElementsSSE, Right.InternalElementsSSE); -#else - Result.X = Left.X / Right.X; - Result.Y = Left.Y / Right.Y; - Result.Z = Left.Z / Right.Z; - Result.W = Left.W / Right.W; -#endif - - return (Result); - } - - COVERAGE(HMM_DivideVec4f, 1) - HMM_INLINE hmm_vec4 HMM_PREFIX(DivideVec4f)(hmm_vec4 Left, float Right) - { - ASSERT_COVERED(HMM_DivideVec4f); - - hmm_vec4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 Scalar = _mm_set1_ps(Right); - Result.InternalElementsSSE = _mm_div_ps(Left.InternalElementsSSE, Scalar); -#else - Result.X = Left.X / Right; - Result.Y = Left.Y / Right; - Result.Z = Left.Z / Right; - Result.W = Left.W / Right; -#endif - - return (Result); - } - - COVERAGE(HMM_EqualsVec2, 1) - HMM_INLINE hmm_bool HMM_PREFIX(EqualsVec2)(hmm_vec2 Left, hmm_vec2 Right) - { - ASSERT_COVERED(HMM_EqualsVec2); - - hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y); - - return (Result); - } - - COVERAGE(HMM_EqualsVec3, 1) - HMM_INLINE hmm_bool HMM_PREFIX(EqualsVec3)(hmm_vec3 Left, hmm_vec3 Right) - { - ASSERT_COVERED(HMM_EqualsVec3); - - hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z); - - return (Result); - } - - COVERAGE(HMM_EqualsVec4, 1) - HMM_INLINE hmm_bool HMM_PREFIX(EqualsVec4)(hmm_vec4 Left, hmm_vec4 Right) - { - ASSERT_COVERED(HMM_EqualsVec4); - - hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z && Left.W == Right.W); - - return (Result); - } - - COVERAGE(HMM_DotVec2, 1) - HMM_INLINE float HMM_PREFIX(DotVec2)(hmm_vec2 VecOne, hmm_vec2 VecTwo) - { - ASSERT_COVERED(HMM_DotVec2); - - float Result = (VecOne.X * VecTwo.X) + (VecOne.Y * VecTwo.Y); - - return (Result); - } - - COVERAGE(HMM_DotVec3, 1) - HMM_INLINE float HMM_PREFIX(DotVec3)(hmm_vec3 VecOne, hmm_vec3 VecTwo) - { - ASSERT_COVERED(HMM_DotVec3); - - float Result = (VecOne.X * VecTwo.X) + (VecOne.Y * VecTwo.Y) + (VecOne.Z * VecTwo.Z); - - return (Result); - } - - COVERAGE(HMM_DotVec4, 1) - HMM_INLINE float HMM_PREFIX(DotVec4)(hmm_vec4 VecOne, hmm_vec4 VecTwo) - { - ASSERT_COVERED(HMM_DotVec4); - - float Result; - - // NOTE(zak): IN the future if we wanna check what version SSE is support - // we can use _mm_dp_ps (4.3) but for now we will use the old way. - // Or a r = _mm_mul_ps(v1, v2), r = _mm_hadd_ps(r, r), r = _mm_hadd_ps(r, r) for SSE3 -#ifdef HANDMADE_MATH__USE_SSE - __m128 SSEResultOne = _mm_mul_ps(VecOne.InternalElementsSSE, VecTwo.InternalElementsSSE); - __m128 SSEResultTwo = _mm_shuffle_ps(SSEResultOne, SSEResultOne, _MM_SHUFFLE(2, 3, 0, 1)); - SSEResultOne = _mm_add_ps(SSEResultOne, SSEResultTwo); - SSEResultTwo = _mm_shuffle_ps(SSEResultOne, SSEResultOne, _MM_SHUFFLE(0, 1, 2, 3)); - SSEResultOne = _mm_add_ps(SSEResultOne, SSEResultTwo); - _mm_store_ss(&Result, SSEResultOne); -#else - Result = (VecOne.X * VecTwo.X) + (VecOne.Y * VecTwo.Y) + (VecOne.Z * VecTwo.Z) + (VecOne.W * VecTwo.W); -#endif - - return (Result); - } - - COVERAGE(HMM_Cross, 1) - HMM_INLINE hmm_vec3 HMM_PREFIX(Cross)(hmm_vec3 VecOne, hmm_vec3 VecTwo) - { - ASSERT_COVERED(HMM_Cross); - - hmm_vec3 Result; - - Result.X = (VecOne.Y * VecTwo.Z) - (VecOne.Z * VecTwo.Y); - Result.Y = (VecOne.Z * VecTwo.X) - (VecOne.X * VecTwo.Z); - Result.Z = (VecOne.X * VecTwo.Y) - (VecOne.Y * VecTwo.X); - - return (Result); - } - - - /* - * Unary vector operations - */ - - COVERAGE(HMM_LengthSquaredVec2, 1) - HMM_INLINE float HMM_PREFIX(LengthSquaredVec2)(hmm_vec2 A) - { - ASSERT_COVERED(HMM_LengthSquaredVec2); - - float Result = HMM_PREFIX(DotVec2)(A, A); - - return (Result); - } - - COVERAGE(HMM_LengthSquaredVec3, 1) - HMM_INLINE float HMM_PREFIX(LengthSquaredVec3)(hmm_vec3 A) - { - ASSERT_COVERED(HMM_LengthSquaredVec3); - - float Result = HMM_PREFIX(DotVec3)(A, A); - - return (Result); - } - - COVERAGE(HMM_LengthSquaredVec4, 1) - HMM_INLINE float HMM_PREFIX(LengthSquaredVec4)(hmm_vec4 A) - { - ASSERT_COVERED(HMM_LengthSquaredVec4); - - float Result = HMM_PREFIX(DotVec4)(A, A); - - return (Result); - } - - COVERAGE(HMM_LengthVec2, 1) - HMM_INLINE float HMM_PREFIX(LengthVec2)(hmm_vec2 A) - { - ASSERT_COVERED(HMM_LengthVec2); - - float Result = HMM_PREFIX(SquareRootF)(HMM_PREFIX(LengthSquaredVec2)(A)); - - return (Result); - } - - COVERAGE(HMM_LengthVec3, 1) - HMM_INLINE float HMM_PREFIX(LengthVec3)(hmm_vec3 A) - { - ASSERT_COVERED(HMM_LengthVec3); - - float Result = HMM_PREFIX(SquareRootF)(HMM_PREFIX(LengthSquaredVec3)(A)); - - return (Result); - } - - COVERAGE(HMM_LengthVec4, 1) - HMM_INLINE float HMM_PREFIX(LengthVec4)(hmm_vec4 A) - { - ASSERT_COVERED(HMM_LengthVec4); - - float Result = HMM_PREFIX(SquareRootF)(HMM_PREFIX(LengthSquaredVec4)(A)); - - return(Result); - } - - COVERAGE(HMM_NormalizeVec2, 2) - HMM_INLINE hmm_vec2 HMM_PREFIX(NormalizeVec2)(hmm_vec2 A) - { - ASSERT_COVERED(HMM_NormalizeVec2); - - hmm_vec2 Result = {0}; - - float VectorLength = HMM_PREFIX(LengthVec2)(A); - - /* NOTE(kiljacken): We need a zero check to not divide-by-zero */ - if (VectorLength != 0.0f) - { - ASSERT_COVERED(HMM_NormalizeVec2); - - Result.X = A.X * (1.0f / VectorLength); - Result.Y = A.Y * (1.0f / VectorLength); - } - - return (Result); - } - - COVERAGE(HMM_NormalizeVec3, 2) - HMM_INLINE hmm_vec3 HMM_PREFIX(NormalizeVec3)(hmm_vec3 A) - { - ASSERT_COVERED(HMM_NormalizeVec3); - - hmm_vec3 Result = {0}; - - float VectorLength = HMM_PREFIX(LengthVec3)(A); - - /* NOTE(kiljacken): We need a zero check to not divide-by-zero */ - if (VectorLength != 0.0f) - { - ASSERT_COVERED(HMM_NormalizeVec3); - - Result.X = A.X * (1.0f / VectorLength); - Result.Y = A.Y * (1.0f / VectorLength); - Result.Z = A.Z * (1.0f / VectorLength); - } - - return (Result); - } - - COVERAGE(HMM_NormalizeVec4, 2) - HMM_INLINE hmm_vec4 HMM_PREFIX(NormalizeVec4)(hmm_vec4 A) - { - ASSERT_COVERED(HMM_NormalizeVec4); - - hmm_vec4 Result = {0}; - - float VectorLength = HMM_PREFIX(LengthVec4)(A); - - /* NOTE(kiljacken): We need a zero check to not divide-by-zero */ - if (VectorLength != 0.0f) - { - ASSERT_COVERED(HMM_NormalizeVec4); - - float Multiplier = 1.0f / VectorLength; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 SSEMultiplier = _mm_set1_ps(Multiplier); - Result.InternalElementsSSE = _mm_mul_ps(A.InternalElementsSSE, SSEMultiplier); -#else - Result.X = A.X * Multiplier; - Result.Y = A.Y * Multiplier; - Result.Z = A.Z * Multiplier; - Result.W = A.W * Multiplier; -#endif - } - - return (Result); - } - - COVERAGE(HMM_FastNormalizeVec2, 1) - HMM_INLINE hmm_vec2 HMM_PREFIX(FastNormalizeVec2)(hmm_vec2 A) - { - ASSERT_COVERED(HMM_FastNormalizeVec2); - - return HMM_PREFIX(MultiplyVec2f)(A, HMM_PREFIX(RSquareRootF)(HMM_PREFIX(DotVec2)(A, A))); - } - - COVERAGE(HMM_FastNormalizeVec3, 1) - HMM_INLINE hmm_vec3 HMM_PREFIX(FastNormalizeVec3)(hmm_vec3 A) - { - ASSERT_COVERED(HMM_FastNormalizeVec3); - - return HMM_PREFIX(MultiplyVec3f)(A, HMM_PREFIX(RSquareRootF)(HMM_PREFIX(DotVec3)(A, A))); - } - - COVERAGE(HMM_FastNormalizeVec4, 1) - HMM_INLINE hmm_vec4 HMM_PREFIX(FastNormalizeVec4)(hmm_vec4 A) - { - ASSERT_COVERED(HMM_FastNormalizeVec4); - - return HMM_PREFIX(MultiplyVec4f)(A, HMM_PREFIX(RSquareRootF)(HMM_PREFIX(DotVec4)(A, A))); - } - - - /* - * SSE stuff - */ - -#ifdef HANDMADE_MATH__USE_SSE - COVERAGE(HMM_LinearCombineSSE, 1) - HMM_INLINE __m128 HMM_PREFIX(LinearCombineSSE)(__m128 Left, hmm_mat4 Right) - { - ASSERT_COVERED(HMM_LinearCombineSSE); - - __m128 Result; - Result = _mm_mul_ps(_mm_shuffle_ps(Left, Left, 0x00), Right.Columns[0]); - Result = _mm_add_ps(Result, _mm_mul_ps(_mm_shuffle_ps(Left, Left, 0x55), Right.Columns[1])); - Result = _mm_add_ps(Result, _mm_mul_ps(_mm_shuffle_ps(Left, Left, 0xaa), Right.Columns[2])); - Result = _mm_add_ps(Result, _mm_mul_ps(_mm_shuffle_ps(Left, Left, 0xff), Right.Columns[3])); - - return (Result); - } -#endif - - - /* - * Matrix functions - */ - - COVERAGE(HMM_Mat4, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(Mat4)(void) - { - ASSERT_COVERED(HMM_Mat4); - - hmm_mat4 Result = {0}; - - return (Result); - } - - COVERAGE(HMM_Mat4d, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(Mat4d)(float Diagonal) - { - ASSERT_COVERED(HMM_Mat4d); - - hmm_mat4 Result = HMM_PREFIX(Mat4)(); - - Result.Elements[0][0] = Diagonal; - Result.Elements[1][1] = Diagonal; - Result.Elements[2][2] = Diagonal; - Result.Elements[3][3] = Diagonal; - - return (Result); - } - -#ifdef HANDMADE_MATH__USE_SSE - COVERAGE(HMM_Transpose, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(Transpose)(hmm_mat4 Matrix) - { - ASSERT_COVERED(HMM_Transpose); - - hmm_mat4 Result = Matrix; - - _MM_TRANSPOSE4_PS(Result.Columns[0], Result.Columns[1], Result.Columns[2], Result.Columns[3]); - - return (Result); - } -#else - HMM_EXTERN hmm_mat4 HMM_PREFIX(Transpose)(hmm_mat4 Matrix); -#endif - -#ifdef HANDMADE_MATH__USE_SSE - COVERAGE(HMM_AddMat4, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(AddMat4)(hmm_mat4 Left, hmm_mat4 Right) - { - ASSERT_COVERED(HMM_AddMat4); - - hmm_mat4 Result; - - Result.Columns[0] = _mm_add_ps(Left.Columns[0], Right.Columns[0]); - Result.Columns[1] = _mm_add_ps(Left.Columns[1], Right.Columns[1]); - Result.Columns[2] = _mm_add_ps(Left.Columns[2], Right.Columns[2]); - Result.Columns[3] = _mm_add_ps(Left.Columns[3], Right.Columns[3]); - - return (Result); - } -#else - HMM_EXTERN hmm_mat4 HMM_PREFIX(AddMat4)(hmm_mat4 Left, hmm_mat4 Right); -#endif - -#ifdef HANDMADE_MATH__USE_SSE - COVERAGE(HMM_SubtractMat4, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(SubtractMat4)(hmm_mat4 Left, hmm_mat4 Right) - { - ASSERT_COVERED(HMM_SubtractMat4); - - hmm_mat4 Result; - - Result.Columns[0] = _mm_sub_ps(Left.Columns[0], Right.Columns[0]); - Result.Columns[1] = _mm_sub_ps(Left.Columns[1], Right.Columns[1]); - Result.Columns[2] = _mm_sub_ps(Left.Columns[2], Right.Columns[2]); - Result.Columns[3] = _mm_sub_ps(Left.Columns[3], Right.Columns[3]); - - return (Result); - } -#else - HMM_EXTERN hmm_mat4 HMM_PREFIX(SubtractMat4)(hmm_mat4 Left, hmm_mat4 Right); -#endif - - HMM_EXTERN hmm_mat4 HMM_PREFIX(MultiplyMat4)(hmm_mat4 Left, hmm_mat4 Right); - -#ifdef HANDMADE_MATH__USE_SSE - COVERAGE(HMM_MultiplyMat4f, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(MultiplyMat4f)(hmm_mat4 Matrix, float Scalar) - { - ASSERT_COVERED(HMM_MultiplyMat4f); - - hmm_mat4 Result; - - __m128 SSEScalar = _mm_set1_ps(Scalar); - Result.Columns[0] = _mm_mul_ps(Matrix.Columns[0], SSEScalar); - Result.Columns[1] = _mm_mul_ps(Matrix.Columns[1], SSEScalar); - Result.Columns[2] = _mm_mul_ps(Matrix.Columns[2], SSEScalar); - Result.Columns[3] = _mm_mul_ps(Matrix.Columns[3], SSEScalar); - - return (Result); - } -#else - HMM_EXTERN hmm_mat4 HMM_PREFIX(MultiplyMat4f)(hmm_mat4 Matrix, float Scalar); -#endif - - HMM_EXTERN hmm_vec4 HMM_PREFIX(MultiplyMat4ByVec4)(hmm_mat4 Matrix, hmm_vec4 Vector); - -#ifdef HANDMADE_MATH__USE_SSE - COVERAGE(HMM_DivideMat4f, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(DivideMat4f)(hmm_mat4 Matrix, float Scalar) - { - ASSERT_COVERED(HMM_DivideMat4f); - - hmm_mat4 Result; - - __m128 SSEScalar = _mm_set1_ps(Scalar); - Result.Columns[0] = _mm_div_ps(Matrix.Columns[0], SSEScalar); - Result.Columns[1] = _mm_div_ps(Matrix.Columns[1], SSEScalar); - Result.Columns[2] = _mm_div_ps(Matrix.Columns[2], SSEScalar); - Result.Columns[3] = _mm_div_ps(Matrix.Columns[3], SSEScalar); - - return (Result); - } -#else - HMM_EXTERN hmm_mat4 HMM_PREFIX(DivideMat4f)(hmm_mat4 Matrix, float Scalar); -#endif - - - /* - * Common graphics transformations - */ - - COVERAGE(HMM_Orthographic, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(Orthographic)(float Left, float Right, float Bottom, float Top, float Near, float Far) - { - ASSERT_COVERED(HMM_Orthographic); - - hmm_mat4 Result = HMM_PREFIX(Mat4)(); - - Result.Elements[0][0] = 2.0f / (Right - Left); - Result.Elements[1][1] = 2.0f / (Top - Bottom); - Result.Elements[2][2] = 2.0f / (Near - Far); - Result.Elements[3][3] = 1.0f; - - Result.Elements[3][0] = (Left + Right) / (Left - Right); - Result.Elements[3][1] = (Bottom + Top) / (Bottom - Top); - Result.Elements[3][2] = (Far + Near) / (Near - Far); - - return (Result); - } - - COVERAGE(HMM_Perspective, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(Perspective)(float FOV, float AspectRatio, float Near, float Far) - { - ASSERT_COVERED(HMM_Perspective); - - hmm_mat4 Result = HMM_PREFIX(Mat4)(); - - // See https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml - - float Cotangent = 1.0f / HMM_PREFIX(TanF)(FOV * (HMM_PI32 / 360.0f)); - - Result.Elements[0][0] = Cotangent / AspectRatio; - Result.Elements[1][1] = Cotangent; - Result.Elements[2][3] = -1.0f; - Result.Elements[2][2] = (Near + Far) / (Near - Far); - Result.Elements[3][2] = (2.0f * Near * Far) / (Near - Far); - Result.Elements[3][3] = 0.0f; - - return (Result); - } - - COVERAGE(HMM_Translate, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(Translate)(hmm_vec3 Translation) - { - ASSERT_COVERED(HMM_Translate); - - hmm_mat4 Result = HMM_PREFIX(Mat4d)(1.0f); - - Result.Elements[3][0] = Translation.X; - Result.Elements[3][1] = Translation.Y; - Result.Elements[3][2] = Translation.Z; - - return (Result); - } - - HMM_EXTERN hmm_mat4 HMM_PREFIX(Rotate)(float Angle, hmm_vec3 Axis); - - COVERAGE(HMM_Scale, 1) - HMM_INLINE hmm_mat4 HMM_PREFIX(Scale)(hmm_vec3 Scale) - { - ASSERT_COVERED(HMM_Scale); - - hmm_mat4 Result = HMM_PREFIX(Mat4d)(1.0f); - - Result.Elements[0][0] = Scale.X; - Result.Elements[1][1] = Scale.Y; - Result.Elements[2][2] = Scale.Z; - - return (Result); - } - - HMM_EXTERN hmm_mat4 HMM_PREFIX(LookAt)(hmm_vec3 Eye, hmm_vec3 Center, hmm_vec3 Up); - - - /* - * Quaternion operations - */ - - COVERAGE(HMM_Quaternion, 1) - HMM_INLINE hmm_quaternion HMM_PREFIX(Quaternion)(float X, float Y, float Z, float W) - { - ASSERT_COVERED(HMM_Quaternion); - - hmm_quaternion Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = _mm_setr_ps(X, Y, Z, W); -#else - Result.X = X; - Result.Y = Y; - Result.Z = Z; - Result.W = W; -#endif - - return (Result); - } - - COVERAGE(HMM_QuaternionV4, 1) - HMM_INLINE hmm_quaternion HMM_PREFIX(QuaternionV4)(hmm_vec4 Vector) - { - ASSERT_COVERED(HMM_QuaternionV4); - - hmm_quaternion Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = Vector.InternalElementsSSE; -#else - Result.X = Vector.X; - Result.Y = Vector.Y; - Result.Z = Vector.Z; - Result.W = Vector.W; -#endif - - return (Result); - } - - COVERAGE(HMM_AddQuaternion, 1) - HMM_INLINE hmm_quaternion HMM_PREFIX(AddQuaternion)(hmm_quaternion Left, hmm_quaternion Right) - { - ASSERT_COVERED(HMM_AddQuaternion); - - hmm_quaternion Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = _mm_add_ps(Left.InternalElementsSSE, Right.InternalElementsSSE); -#else - - Result.X = Left.X + Right.X; - Result.Y = Left.Y + Right.Y; - Result.Z = Left.Z + Right.Z; - Result.W = Left.W + Right.W; -#endif - - return (Result); - } - - COVERAGE(HMM_SubtractQuaternion, 1) - HMM_INLINE hmm_quaternion HMM_PREFIX(SubtractQuaternion)(hmm_quaternion Left, hmm_quaternion Right) - { - ASSERT_COVERED(HMM_SubtractQuaternion); - - hmm_quaternion Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = _mm_sub_ps(Left.InternalElementsSSE, Right.InternalElementsSSE); -#else - - Result.X = Left.X - Right.X; - Result.Y = Left.Y - Right.Y; - Result.Z = Left.Z - Right.Z; - Result.W = Left.W - Right.W; -#endif - - return (Result); - } - - COVERAGE(HMM_MultiplyQuaternion, 1) - HMM_INLINE hmm_quaternion HMM_PREFIX(MultiplyQuaternion)(hmm_quaternion Left, hmm_quaternion Right) - { - ASSERT_COVERED(HMM_MultiplyQuaternion); - - hmm_quaternion Result; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 SSEResultOne = _mm_xor_ps(_mm_shuffle_ps(Left.InternalElementsSSE, Left.InternalElementsSSE, _MM_SHUFFLE(0, 0, 0, 0)), _mm_setr_ps(0.f, -0.f, 0.f, -0.f)); - __m128 SSEResultTwo = _mm_shuffle_ps(Right.InternalElementsSSE, Right.InternalElementsSSE, _MM_SHUFFLE(0, 1, 2, 3)); - __m128 SSEResultThree = _mm_mul_ps(SSEResultTwo, SSEResultOne); - - SSEResultOne = _mm_xor_ps(_mm_shuffle_ps(Left.InternalElementsSSE, Left.InternalElementsSSE, _MM_SHUFFLE(1, 1, 1, 1)) , _mm_setr_ps(0.f, 0.f, -0.f, -0.f)); - SSEResultTwo = _mm_shuffle_ps(Right.InternalElementsSSE, Right.InternalElementsSSE, _MM_SHUFFLE(1, 0, 3, 2)); - SSEResultThree = _mm_add_ps(SSEResultThree, _mm_mul_ps(SSEResultTwo, SSEResultOne)); - - SSEResultOne = _mm_xor_ps(_mm_shuffle_ps(Left.InternalElementsSSE, Left.InternalElementsSSE, _MM_SHUFFLE(2, 2, 2, 2)), _mm_setr_ps(-0.f, 0.f, 0.f, -0.f)); - SSEResultTwo = _mm_shuffle_ps(Right.InternalElementsSSE, Right.InternalElementsSSE, _MM_SHUFFLE(2, 3, 0, 1)); - SSEResultThree = _mm_add_ps(SSEResultThree, _mm_mul_ps(SSEResultTwo, SSEResultOne)); - - SSEResultOne = _mm_shuffle_ps(Left.InternalElementsSSE, Left.InternalElementsSSE, _MM_SHUFFLE(3, 3, 3, 3)); - SSEResultTwo = _mm_shuffle_ps(Right.InternalElementsSSE, Right.InternalElementsSSE, _MM_SHUFFLE(3, 2, 1, 0)); - Result.InternalElementsSSE = _mm_add_ps(SSEResultThree, _mm_mul_ps(SSEResultTwo, SSEResultOne)); -#else - Result.X = (Left.X * Right.W) + (Left.Y * Right.Z) - (Left.Z * Right.Y) + (Left.W * Right.X); - Result.Y = (-Left.X * Right.Z) + (Left.Y * Right.W) + (Left.Z * Right.X) + (Left.W * Right.Y); - Result.Z = (Left.X * Right.Y) - (Left.Y * Right.X) + (Left.Z * Right.W) + (Left.W * Right.Z); - Result.W = (-Left.X * Right.X) - (Left.Y * Right.Y) - (Left.Z * Right.Z) + (Left.W * Right.W); -#endif - - return (Result); - } - - COVERAGE(HMM_MultiplyQuaternionF, 1) - HMM_INLINE hmm_quaternion HMM_PREFIX(MultiplyQuaternionF)(hmm_quaternion Left, float Multiplicative) - { - ASSERT_COVERED(HMM_MultiplyQuaternionF); - - hmm_quaternion Result; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 Scalar = _mm_set1_ps(Multiplicative); - Result.InternalElementsSSE = _mm_mul_ps(Left.InternalElementsSSE, Scalar); -#else - Result.X = Left.X * Multiplicative; - Result.Y = Left.Y * Multiplicative; - Result.Z = Left.Z * Multiplicative; - Result.W = Left.W * Multiplicative; -#endif - - return (Result); - } - - COVERAGE(HMM_DivideQuaternionF, 1) - HMM_INLINE hmm_quaternion HMM_PREFIX(DivideQuaternionF)(hmm_quaternion Left, float Dividend) - { - ASSERT_COVERED(HMM_DivideQuaternionF); - - hmm_quaternion Result; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 Scalar = _mm_set1_ps(Dividend); - Result.InternalElementsSSE = _mm_div_ps(Left.InternalElementsSSE, Scalar); -#else - Result.X = Left.X / Dividend; - Result.Y = Left.Y / Dividend; - Result.Z = Left.Z / Dividend; - Result.W = Left.W / Dividend; -#endif - - return (Result); - } - - HMM_EXTERN hmm_quaternion HMM_PREFIX(InverseQuaternion)(hmm_quaternion Left); - - COVERAGE(HMM_DotQuaternion, 1) - HMM_INLINE float HMM_PREFIX(DotQuaternion)(hmm_quaternion Left, hmm_quaternion Right) - { - ASSERT_COVERED(HMM_DotQuaternion); - - float Result; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 SSEResultOne = _mm_mul_ps(Left.InternalElementsSSE, Right.InternalElementsSSE); - __m128 SSEResultTwo = _mm_shuffle_ps(SSEResultOne, SSEResultOne, _MM_SHUFFLE(2, 3, 0, 1)); - SSEResultOne = _mm_add_ps(SSEResultOne, SSEResultTwo); - SSEResultTwo = _mm_shuffle_ps(SSEResultOne, SSEResultOne, _MM_SHUFFLE(0, 1, 2, 3)); - SSEResultOne = _mm_add_ps(SSEResultOne, SSEResultTwo); - _mm_store_ss(&Result, SSEResultOne); -#else - Result = (Left.X * Right.X) + (Left.Y * Right.Y) + (Left.Z * Right.Z) + (Left.W * Right.W); -#endif - - return (Result); - } - - COVERAGE(HMM_NormalizeQuaternion, 1) - HMM_INLINE hmm_quaternion HMM_PREFIX(NormalizeQuaternion)(hmm_quaternion Left) - { - ASSERT_COVERED(HMM_NormalizeQuaternion); - - hmm_quaternion Result; - - float Length = HMM_PREFIX(SquareRootF)(HMM_PREFIX(DotQuaternion)(Left, Left)); - Result = HMM_PREFIX(DivideQuaternionF)(Left, Length); - - return (Result); - } - - COVERAGE(HMM_NLerp, 1) - HMM_INLINE hmm_quaternion HMM_PREFIX(NLerp)(hmm_quaternion Left, float Time, hmm_quaternion Right) - { - ASSERT_COVERED(HMM_NLerp); - - hmm_quaternion Result; - -#ifdef HANDMADE_MATH__USE_SSE - __m128 ScalarLeft = _mm_set1_ps(1.0f - Time); - __m128 ScalarRight = _mm_set1_ps(Time); - __m128 SSEResultOne = _mm_mul_ps(Left.InternalElementsSSE, ScalarLeft); - __m128 SSEResultTwo = _mm_mul_ps(Right.InternalElementsSSE, ScalarRight); - Result.InternalElementsSSE = _mm_add_ps(SSEResultOne, SSEResultTwo); -#else - Result.X = HMM_PREFIX(Lerp)(Left.X, Time, Right.X); - Result.Y = HMM_PREFIX(Lerp)(Left.Y, Time, Right.Y); - Result.Z = HMM_PREFIX(Lerp)(Left.Z, Time, Right.Z); - Result.W = HMM_PREFIX(Lerp)(Left.W, Time, Right.W); -#endif - Result = HMM_PREFIX(NormalizeQuaternion)(Result); - - return (Result); - } - - HMM_EXTERN hmm_quaternion HMM_PREFIX(Slerp)(hmm_quaternion Left, float Time, hmm_quaternion Right); - HMM_EXTERN hmm_mat4 HMM_PREFIX(QuaternionToMat4)(hmm_quaternion Left); - HMM_EXTERN hmm_quaternion HMM_PREFIX(Mat4ToQuaternion)(hmm_mat4 Left); - HMM_EXTERN hmm_quaternion HMM_PREFIX(QuaternionFromAxisAngle)(hmm_vec3 Axis, float AngleOfRotation); - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus - -COVERAGE(HMM_LengthVec2CPP, 1) -HMM_INLINE float HMM_PREFIX(Length)(hmm_vec2 A) -{ - ASSERT_COVERED(HMM_LengthVec2CPP); - - float Result = HMM_PREFIX(LengthVec2)(A); - - return (Result); -} - -COVERAGE(HMM_LengthVec3CPP, 1) -HMM_INLINE float HMM_PREFIX(Length)(hmm_vec3 A) -{ - ASSERT_COVERED(HMM_LengthVec3CPP); - - float Result = HMM_PREFIX(LengthVec3)(A); - - return (Result); -} - -COVERAGE(HMM_LengthVec4CPP, 1) -HMM_INLINE float HMM_PREFIX(Length)(hmm_vec4 A) -{ - ASSERT_COVERED(HMM_LengthVec4CPP); - - float Result = HMM_PREFIX(LengthVec4)(A); - - return (Result); -} - -COVERAGE(HMM_LengthSquaredVec2CPP, 1) -HMM_INLINE float HMM_PREFIX(LengthSquared)(hmm_vec2 A) -{ - ASSERT_COVERED(HMM_LengthSquaredVec2CPP); - - float Result = HMM_PREFIX(LengthSquaredVec2)(A); - - return (Result); -} - -COVERAGE(HMM_LengthSquaredVec3CPP, 1) -HMM_INLINE float HMM_PREFIX(LengthSquared)(hmm_vec3 A) -{ - ASSERT_COVERED(HMM_LengthSquaredVec3CPP); - - float Result = HMM_PREFIX(LengthSquaredVec3)(A); - - return (Result); -} - -COVERAGE(HMM_LengthSquaredVec4CPP, 1) -HMM_INLINE float HMM_PREFIX(LengthSquared)(hmm_vec4 A) -{ - ASSERT_COVERED(HMM_LengthSquaredVec4CPP); - - float Result = HMM_PREFIX(LengthSquaredVec4)(A); - - return (Result); -} - -COVERAGE(HMM_NormalizeVec2CPP, 1) -HMM_INLINE hmm_vec2 HMM_PREFIX(Normalize)(hmm_vec2 A) -{ - ASSERT_COVERED(HMM_NormalizeVec2CPP); - - hmm_vec2 Result = HMM_PREFIX(NormalizeVec2)(A); - - return (Result); -} - -COVERAGE(HMM_NormalizeVec3CPP, 1) -HMM_INLINE hmm_vec3 HMM_PREFIX(Normalize)(hmm_vec3 A) -{ - ASSERT_COVERED(HMM_NormalizeVec3CPP); - - hmm_vec3 Result = HMM_PREFIX(NormalizeVec3)(A); - - return (Result); -} - -COVERAGE(HMM_NormalizeVec4CPP, 1) -HMM_INLINE hmm_vec4 HMM_PREFIX(Normalize)(hmm_vec4 A) -{ - ASSERT_COVERED(HMM_NormalizeVec4CPP); - - hmm_vec4 Result = HMM_PREFIX(NormalizeVec4)(A); - - return (Result); -} - -COVERAGE(HMM_FastNormalizeVec2CPP, 1) -HMM_INLINE hmm_vec2 HMM_PREFIX(FastNormalize)(hmm_vec2 A) -{ - ASSERT_COVERED(HMM_FastNormalizeVec2CPP); - - hmm_vec2 Result = HMM_PREFIX(FastNormalizeVec2)(A); - - return (Result); -} - -COVERAGE(HMM_FastNormalizeVec3CPP, 1) -HMM_INLINE hmm_vec3 HMM_PREFIX(FastNormalize)(hmm_vec3 A) -{ - ASSERT_COVERED(HMM_FastNormalizeVec3CPP); - - hmm_vec3 Result = HMM_PREFIX(FastNormalizeVec3)(A); - - return (Result); -} - -COVERAGE(HMM_FastNormalizeVec4CPP, 1) -HMM_INLINE hmm_vec4 HMM_PREFIX(FastNormalize)(hmm_vec4 A) -{ - ASSERT_COVERED(HMM_FastNormalizeVec4CPP); - - hmm_vec4 Result = HMM_PREFIX(FastNormalizeVec4)(A); - - return (Result); -} - -COVERAGE(HMM_NormalizeQuaternionCPP, 1) -HMM_INLINE hmm_quaternion HMM_PREFIX(Normalize)(hmm_quaternion A) -{ - ASSERT_COVERED(HMM_NormalizeQuaternionCPP); - - hmm_quaternion Result = HMM_PREFIX(NormalizeQuaternion)(A); - - return (Result); -} - -COVERAGE(HMM_DotVec2CPP, 1) -HMM_INLINE float HMM_PREFIX(Dot)(hmm_vec2 VecOne, hmm_vec2 VecTwo) -{ - ASSERT_COVERED(HMM_DotVec2CPP); - - float Result = HMM_PREFIX(DotVec2)(VecOne, VecTwo); - - return (Result); -} - -COVERAGE(HMM_DotVec3CPP, 1) -HMM_INLINE float HMM_PREFIX(Dot)(hmm_vec3 VecOne, hmm_vec3 VecTwo) -{ - ASSERT_COVERED(HMM_DotVec3CPP); - - float Result = HMM_PREFIX(DotVec3)(VecOne, VecTwo); - - return (Result); -} - -COVERAGE(HMM_DotVec4CPP, 1) -HMM_INLINE float HMM_PREFIX(Dot)(hmm_vec4 VecOne, hmm_vec4 VecTwo) -{ - ASSERT_COVERED(HMM_DotVec4CPP); - - float Result = HMM_PREFIX(DotVec4)(VecOne, VecTwo); - - return (Result); -} - -COVERAGE(HMM_DotQuaternionCPP, 1) -HMM_INLINE float HMM_PREFIX(Dot)(hmm_quaternion QuatOne, hmm_quaternion QuatTwo) -{ - ASSERT_COVERED(HMM_DotQuaternionCPP); - - float Result = HMM_PREFIX(DotQuaternion)(QuatOne, QuatTwo); - - return (Result); -} - -COVERAGE(HMM_AddVec2CPP, 1) -HMM_INLINE hmm_vec2 HMM_PREFIX(Add)(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_AddVec2CPP); - - hmm_vec2 Result = HMM_PREFIX(AddVec2)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_AddVec3CPP, 1) -HMM_INLINE hmm_vec3 HMM_PREFIX(Add)(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_AddVec3CPP); - - hmm_vec3 Result = HMM_PREFIX(AddVec3)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_AddVec4CPP, 1) -HMM_INLINE hmm_vec4 HMM_PREFIX(Add)(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_AddVec4CPP); - - hmm_vec4 Result = HMM_PREFIX(AddVec4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_AddMat4CPP, 1) -HMM_INLINE hmm_mat4 HMM_PREFIX(Add)(hmm_mat4 Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_AddMat4CPP); - - hmm_mat4 Result = HMM_PREFIX(AddMat4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_AddQuaternionCPP, 1) -HMM_INLINE hmm_quaternion HMM_PREFIX(Add)(hmm_quaternion Left, hmm_quaternion Right) -{ - ASSERT_COVERED(HMM_AddQuaternionCPP); - - hmm_quaternion Result = HMM_PREFIX(AddQuaternion)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_SubtractVec2CPP, 1) -HMM_INLINE hmm_vec2 HMM_PREFIX(Subtract)(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_SubtractVec2CPP); - - hmm_vec2 Result = HMM_PREFIX(SubtractVec2)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_SubtractVec3CPP, 1) -HMM_INLINE hmm_vec3 HMM_PREFIX(Subtract)(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_SubtractVec3CPP); - - hmm_vec3 Result = HMM_PREFIX(SubtractVec3)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_SubtractVec4CPP, 1) -HMM_INLINE hmm_vec4 HMM_PREFIX(Subtract)(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_SubtractVec4CPP); - - hmm_vec4 Result = HMM_PREFIX(SubtractVec4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_SubtractMat4CPP, 1) -HMM_INLINE hmm_mat4 HMM_PREFIX(Subtract)(hmm_mat4 Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_SubtractMat4CPP); - - hmm_mat4 Result = HMM_PREFIX(SubtractMat4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_SubtractQuaternionCPP, 1) -HMM_INLINE hmm_quaternion HMM_PREFIX(Subtract)(hmm_quaternion Left, hmm_quaternion Right) -{ - ASSERT_COVERED(HMM_SubtractQuaternionCPP); - - hmm_quaternion Result = HMM_PREFIX(SubtractQuaternion)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec2CPP, 1) -HMM_INLINE hmm_vec2 HMM_PREFIX(Multiply)(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec2CPP); - - hmm_vec2 Result = HMM_PREFIX(MultiplyVec2)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec2fCPP, 1) -HMM_INLINE hmm_vec2 HMM_PREFIX(Multiply)(hmm_vec2 Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyVec2fCPP); - - hmm_vec2 Result = HMM_PREFIX(MultiplyVec2f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec3CPP, 1) -HMM_INLINE hmm_vec3 HMM_PREFIX(Multiply)(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec3CPP); - - hmm_vec3 Result = HMM_PREFIX(MultiplyVec3)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec3fCPP, 1) -HMM_INLINE hmm_vec3 HMM_PREFIX(Multiply)(hmm_vec3 Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyVec3fCPP); - - hmm_vec3 Result = HMM_PREFIX(MultiplyVec3f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec4CPP, 1) -HMM_INLINE hmm_vec4 HMM_PREFIX(Multiply)(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec4CPP); - - hmm_vec4 Result = HMM_PREFIX(MultiplyVec4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec4fCPP, 1) -HMM_INLINE hmm_vec4 HMM_PREFIX(Multiply)(hmm_vec4 Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyVec4fCPP); - - hmm_vec4 Result = HMM_PREFIX(MultiplyVec4f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyMat4CPP, 1) -HMM_INLINE hmm_mat4 HMM_PREFIX(Multiply)(hmm_mat4 Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_MultiplyMat4CPP); - - hmm_mat4 Result = HMM_PREFIX(MultiplyMat4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyMat4fCPP, 1) -HMM_INLINE hmm_mat4 HMM_PREFIX(Multiply)(hmm_mat4 Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyMat4fCPP); - - hmm_mat4 Result = HMM_PREFIX(MultiplyMat4f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyMat4ByVec4CPP, 1) -HMM_INLINE hmm_vec4 HMM_PREFIX(Multiply)(hmm_mat4 Matrix, hmm_vec4 Vector) -{ - ASSERT_COVERED(HMM_MultiplyMat4ByVec4CPP); - - hmm_vec4 Result = HMM_PREFIX(MultiplyMat4ByVec4)(Matrix, Vector); - - return (Result); -} - -COVERAGE(HMM_MultiplyQuaternionCPP, 1) -HMM_INLINE hmm_quaternion HMM_PREFIX(Multiply)(hmm_quaternion Left, hmm_quaternion Right) -{ - ASSERT_COVERED(HMM_MultiplyQuaternionCPP); - - hmm_quaternion Result = HMM_PREFIX(MultiplyQuaternion)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyQuaternionFCPP, 1) -HMM_INLINE hmm_quaternion HMM_PREFIX(Multiply)(hmm_quaternion Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyQuaternionFCPP); - - hmm_quaternion Result = HMM_PREFIX(MultiplyQuaternionF)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec2CPP, 1) -HMM_INLINE hmm_vec2 HMM_PREFIX(Divide)(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_DivideVec2CPP); - - hmm_vec2 Result = HMM_PREFIX(DivideVec2)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec2fCPP, 1) -HMM_INLINE hmm_vec2 HMM_PREFIX(Divide)(hmm_vec2 Left, float Right) -{ - ASSERT_COVERED(HMM_DivideVec2fCPP); - - hmm_vec2 Result = HMM_PREFIX(DivideVec2f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec3CPP, 1) -HMM_INLINE hmm_vec3 HMM_PREFIX(Divide)(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_DivideVec3CPP); - - hmm_vec3 Result = HMM_PREFIX(DivideVec3)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec3fCPP, 1) -HMM_INLINE hmm_vec3 HMM_PREFIX(Divide)(hmm_vec3 Left, float Right) -{ - ASSERT_COVERED(HMM_DivideVec3fCPP); - - hmm_vec3 Result = HMM_PREFIX(DivideVec3f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec4CPP, 1) -HMM_INLINE hmm_vec4 HMM_PREFIX(Divide)(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_DivideVec4CPP); - - hmm_vec4 Result = HMM_PREFIX(DivideVec4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec4fCPP, 1) -HMM_INLINE hmm_vec4 HMM_PREFIX(Divide)(hmm_vec4 Left, float Right) -{ - ASSERT_COVERED(HMM_DivideVec4fCPP); - - hmm_vec4 Result = HMM_PREFIX(DivideVec4f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideMat4fCPP, 1) -HMM_INLINE hmm_mat4 HMM_PREFIX(Divide)(hmm_mat4 Left, float Right) -{ - ASSERT_COVERED(HMM_DivideMat4fCPP); - - hmm_mat4 Result = HMM_PREFIX(DivideMat4f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideQuaternionFCPP, 1) -HMM_INLINE hmm_quaternion HMM_PREFIX(Divide)(hmm_quaternion Left, float Right) -{ - ASSERT_COVERED(HMM_DivideQuaternionFCPP); - - hmm_quaternion Result = HMM_PREFIX(DivideQuaternionF)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_EqualsVec2CPP, 1) -HMM_INLINE hmm_bool HMM_PREFIX(Equals)(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_EqualsVec2CPP); - - hmm_bool Result = HMM_PREFIX(EqualsVec2)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_EqualsVec3CPP, 1) -HMM_INLINE hmm_bool HMM_PREFIX(Equals)(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_EqualsVec3CPP); - - hmm_bool Result = HMM_PREFIX(EqualsVec3)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_EqualsVec4CPP, 1) -HMM_INLINE hmm_bool HMM_PREFIX(Equals)(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_EqualsVec4CPP); - - hmm_bool Result = HMM_PREFIX(EqualsVec4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_AddVec2Op, 1) -HMM_INLINE hmm_vec2 operator+(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_AddVec2Op); - - hmm_vec2 Result = HMM_PREFIX(AddVec2)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_AddVec3Op, 1) -HMM_INLINE hmm_vec3 operator+(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_AddVec3Op); - - hmm_vec3 Result = HMM_PREFIX(AddVec3)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_AddVec4Op, 1) -HMM_INLINE hmm_vec4 operator+(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_AddVec4Op); - - hmm_vec4 Result = HMM_PREFIX(AddVec4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_AddMat4Op, 1) -HMM_INLINE hmm_mat4 operator+(hmm_mat4 Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_AddMat4Op); - - hmm_mat4 Result = HMM_PREFIX(AddMat4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_AddQuaternionOp, 1) -HMM_INLINE hmm_quaternion operator+(hmm_quaternion Left, hmm_quaternion Right) -{ - ASSERT_COVERED(HMM_AddQuaternionOp); - - hmm_quaternion Result = HMM_PREFIX(AddQuaternion)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_SubtractVec2Op, 1) -HMM_INLINE hmm_vec2 operator-(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_SubtractVec2Op); - - hmm_vec2 Result = HMM_PREFIX(SubtractVec2)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_SubtractVec3Op, 1) -HMM_INLINE hmm_vec3 operator-(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_SubtractVec3Op); - - hmm_vec3 Result = HMM_PREFIX(SubtractVec3)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_SubtractVec4Op, 1) -HMM_INLINE hmm_vec4 operator-(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_SubtractVec4Op); - - hmm_vec4 Result = HMM_PREFIX(SubtractVec4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_SubtractMat4Op, 1) -HMM_INLINE hmm_mat4 operator-(hmm_mat4 Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_SubtractMat4Op); - - hmm_mat4 Result = HMM_PREFIX(SubtractMat4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_SubtractQuaternionOp, 1) -HMM_INLINE hmm_quaternion operator-(hmm_quaternion Left, hmm_quaternion Right) -{ - ASSERT_COVERED(HMM_SubtractQuaternionOp); - - hmm_quaternion Result = HMM_PREFIX(SubtractQuaternion)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec2Op, 1) -HMM_INLINE hmm_vec2 operator*(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec2Op); - - hmm_vec2 Result = HMM_PREFIX(MultiplyVec2)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec3Op, 1) -HMM_INLINE hmm_vec3 operator*(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec3Op); - - hmm_vec3 Result = HMM_PREFIX(MultiplyVec3)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec4Op, 1) -HMM_INLINE hmm_vec4 operator*(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec4Op); - - hmm_vec4 Result = HMM_PREFIX(MultiplyVec4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyMat4Op, 1) -HMM_INLINE hmm_mat4 operator*(hmm_mat4 Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_MultiplyMat4Op); - - hmm_mat4 Result = HMM_PREFIX(MultiplyMat4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyQuaternionOp, 1) -HMM_INLINE hmm_quaternion operator*(hmm_quaternion Left, hmm_quaternion Right) -{ - ASSERT_COVERED(HMM_MultiplyQuaternionOp); - - hmm_quaternion Result = HMM_PREFIX(MultiplyQuaternion)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec2fOp, 1) -HMM_INLINE hmm_vec2 operator*(hmm_vec2 Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyVec2fOp); - - hmm_vec2 Result = HMM_PREFIX(MultiplyVec2f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec3fOp, 1) -HMM_INLINE hmm_vec3 operator*(hmm_vec3 Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyVec3fOp); - - hmm_vec3 Result = HMM_PREFIX(MultiplyVec3f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec4fOp, 1) -HMM_INLINE hmm_vec4 operator*(hmm_vec4 Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyVec4fOp); - - hmm_vec4 Result = HMM_PREFIX(MultiplyVec4f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyMat4fOp, 1) -HMM_INLINE hmm_mat4 operator*(hmm_mat4 Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyMat4fOp); - - hmm_mat4 Result = HMM_PREFIX(MultiplyMat4f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyQuaternionFOp, 1) -HMM_INLINE hmm_quaternion operator*(hmm_quaternion Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyQuaternionFOp); - - hmm_quaternion Result = HMM_PREFIX(MultiplyQuaternionF)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec2fOpLeft, 1) -HMM_INLINE hmm_vec2 operator*(float Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec2fOpLeft); - - hmm_vec2 Result = HMM_PREFIX(MultiplyVec2f)(Right, Left); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec3fOpLeft, 1) -HMM_INLINE hmm_vec3 operator*(float Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec3fOpLeft); - - hmm_vec3 Result = HMM_PREFIX(MultiplyVec3f)(Right, Left); - - return (Result); -} - -COVERAGE(HMM_MultiplyVec4fOpLeft, 1) -HMM_INLINE hmm_vec4 operator*(float Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec4fOpLeft); - - hmm_vec4 Result = HMM_PREFIX(MultiplyVec4f)(Right, Left); - - return (Result); -} - -COVERAGE(HMM_MultiplyMat4fOpLeft, 1) -HMM_INLINE hmm_mat4 operator*(float Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_MultiplyMat4fOpLeft); - - hmm_mat4 Result = HMM_PREFIX(MultiplyMat4f)(Right, Left); - - return (Result); -} - -COVERAGE(HMM_MultiplyQuaternionFOpLeft, 1) -HMM_INLINE hmm_quaternion operator*(float Left, hmm_quaternion Right) -{ - ASSERT_COVERED(HMM_MultiplyQuaternionFOpLeft); - - hmm_quaternion Result = HMM_PREFIX(MultiplyQuaternionF)(Right, Left); - - return (Result); -} - -COVERAGE(HMM_MultiplyMat4ByVec4Op, 1) -HMM_INLINE hmm_vec4 operator*(hmm_mat4 Matrix, hmm_vec4 Vector) -{ - ASSERT_COVERED(HMM_MultiplyMat4ByVec4Op); - - hmm_vec4 Result = HMM_PREFIX(MultiplyMat4ByVec4)(Matrix, Vector); - - return (Result); -} - -COVERAGE(HMM_DivideVec2Op, 1) -HMM_INLINE hmm_vec2 operator/(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_DivideVec2Op); - - hmm_vec2 Result = HMM_PREFIX(DivideVec2)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec3Op, 1) -HMM_INLINE hmm_vec3 operator/(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_DivideVec3Op); - - hmm_vec3 Result = HMM_PREFIX(DivideVec3)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec4Op, 1) -HMM_INLINE hmm_vec4 operator/(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_DivideVec4Op); - - hmm_vec4 Result = HMM_PREFIX(DivideVec4)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec2fOp, 1) -HMM_INLINE hmm_vec2 operator/(hmm_vec2 Left, float Right) -{ - ASSERT_COVERED(HMM_DivideVec2fOp); - - hmm_vec2 Result = HMM_PREFIX(DivideVec2f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec3fOp, 1) -HMM_INLINE hmm_vec3 operator/(hmm_vec3 Left, float Right) -{ - ASSERT_COVERED(HMM_DivideVec3fOp); - - hmm_vec3 Result = HMM_PREFIX(DivideVec3f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideVec4fOp, 1) -HMM_INLINE hmm_vec4 operator/(hmm_vec4 Left, float Right) -{ - ASSERT_COVERED(HMM_DivideVec4fOp); - - hmm_vec4 Result = HMM_PREFIX(DivideVec4f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideMat4fOp, 1) -HMM_INLINE hmm_mat4 operator/(hmm_mat4 Left, float Right) -{ - ASSERT_COVERED(HMM_DivideMat4fOp); - - hmm_mat4 Result = HMM_PREFIX(DivideMat4f)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_DivideQuaternionFOp, 1) -HMM_INLINE hmm_quaternion operator/(hmm_quaternion Left, float Right) -{ - ASSERT_COVERED(HMM_DivideQuaternionFOp); - - hmm_quaternion Result = HMM_PREFIX(DivideQuaternionF)(Left, Right); - - return (Result); -} - -COVERAGE(HMM_AddVec2Assign, 1) -HMM_INLINE hmm_vec2 &operator+=(hmm_vec2 &Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_AddVec2Assign); - - return (Left = Left + Right); -} - -COVERAGE(HMM_AddVec3Assign, 1) -HMM_INLINE hmm_vec3 &operator+=(hmm_vec3 &Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_AddVec3Assign); - - return (Left = Left + Right); -} - -COVERAGE(HMM_AddVec4Assign, 1) -HMM_INLINE hmm_vec4 &operator+=(hmm_vec4 &Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_AddVec4Assign); - - return (Left = Left + Right); -} - -COVERAGE(HMM_AddMat4Assign, 1) -HMM_INLINE hmm_mat4 &operator+=(hmm_mat4 &Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_AddMat4Assign); - - return (Left = Left + Right); -} - -COVERAGE(HMM_AddQuaternionAssign, 1) -HMM_INLINE hmm_quaternion &operator+=(hmm_quaternion &Left, hmm_quaternion Right) -{ - ASSERT_COVERED(HMM_AddQuaternionAssign); - - return (Left = Left + Right); -} - -COVERAGE(HMM_SubtractVec2Assign, 1) -HMM_INLINE hmm_vec2 &operator-=(hmm_vec2 &Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_SubtractVec2Assign); - - return (Left = Left - Right); -} - -COVERAGE(HMM_SubtractVec3Assign, 1) -HMM_INLINE hmm_vec3 &operator-=(hmm_vec3 &Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_SubtractVec3Assign); - - return (Left = Left - Right); -} - -COVERAGE(HMM_SubtractVec4Assign, 1) -HMM_INLINE hmm_vec4 &operator-=(hmm_vec4 &Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_SubtractVec4Assign); - - return (Left = Left - Right); -} - -COVERAGE(HMM_SubtractMat4Assign, 1) -HMM_INLINE hmm_mat4 &operator-=(hmm_mat4 &Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_SubtractMat4Assign); - - return (Left = Left - Right); -} - -COVERAGE(HMM_SubtractQuaternionAssign, 1) -HMM_INLINE hmm_quaternion &operator-=(hmm_quaternion &Left, hmm_quaternion Right) -{ - ASSERT_COVERED(HMM_SubtractQuaternionAssign); - - return (Left = Left - Right); -} - -COVERAGE(HMM_MultiplyVec2Assign, 1) -HMM_INLINE hmm_vec2 &operator*=(hmm_vec2 &Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec2Assign); - - return (Left = Left * Right); -} - -COVERAGE(HMM_MultiplyVec3Assign, 1) -HMM_INLINE hmm_vec3 &operator*=(hmm_vec3 &Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec3Assign); - - return (Left = Left * Right); -} - -COVERAGE(HMM_MultiplyVec4Assign, 1) -HMM_INLINE hmm_vec4 &operator*=(hmm_vec4 &Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_MultiplyVec4Assign); - - return (Left = Left * Right); -} - -COVERAGE(HMM_MultiplyVec2fAssign, 1) -HMM_INLINE hmm_vec2 &operator*=(hmm_vec2 &Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyVec2fAssign); - - return (Left = Left * Right); -} - -COVERAGE(HMM_MultiplyVec3fAssign, 1) -HMM_INLINE hmm_vec3 &operator*=(hmm_vec3 &Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyVec3fAssign); - - return (Left = Left * Right); -} - -COVERAGE(HMM_MultiplyVec4fAssign, 1) -HMM_INLINE hmm_vec4 &operator*=(hmm_vec4 &Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyVec4fAssign); - - return (Left = Left * Right); -} - -COVERAGE(HMM_MultiplyMat4fAssign, 1) -HMM_INLINE hmm_mat4 &operator*=(hmm_mat4 &Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyMat4fAssign); - - return (Left = Left * Right); -} - -COVERAGE(HMM_MultiplyQuaternionFAssign, 1) -HMM_INLINE hmm_quaternion &operator*=(hmm_quaternion &Left, float Right) -{ - ASSERT_COVERED(HMM_MultiplyQuaternionFAssign); - - return (Left = Left * Right); -} - -COVERAGE(HMM_DivideVec2Assign, 1) -HMM_INLINE hmm_vec2 &operator/=(hmm_vec2 &Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_DivideVec2Assign); - - return (Left = Left / Right); -} - -COVERAGE(HMM_DivideVec3Assign, 1) -HMM_INLINE hmm_vec3 &operator/=(hmm_vec3 &Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_DivideVec3Assign); - - return (Left = Left / Right); -} - -COVERAGE(HMM_DivideVec4Assign, 1) -HMM_INLINE hmm_vec4 &operator/=(hmm_vec4 &Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_DivideVec4Assign); - - return (Left = Left / Right); -} - -COVERAGE(HMM_DivideVec2fAssign, 1) -HMM_INLINE hmm_vec2 &operator/=(hmm_vec2 &Left, float Right) -{ - ASSERT_COVERED(HMM_DivideVec2fAssign); - - return (Left = Left / Right); -} - -COVERAGE(HMM_DivideVec3fAssign, 1) -HMM_INLINE hmm_vec3 &operator/=(hmm_vec3 &Left, float Right) -{ - ASSERT_COVERED(HMM_DivideVec3fAssign); - - return (Left = Left / Right); -} - -COVERAGE(HMM_DivideVec4fAssign, 1) -HMM_INLINE hmm_vec4 &operator/=(hmm_vec4 &Left, float Right) -{ - ASSERT_COVERED(HMM_DivideVec4fAssign); - - return (Left = Left / Right); -} - -COVERAGE(HMM_DivideMat4fAssign, 1) -HMM_INLINE hmm_mat4 &operator/=(hmm_mat4 &Left, float Right) -{ - ASSERT_COVERED(HMM_DivideMat4fAssign); - - return (Left = Left / Right); -} - -COVERAGE(HMM_DivideQuaternionFAssign, 1) -HMM_INLINE hmm_quaternion &operator/=(hmm_quaternion &Left, float Right) -{ - ASSERT_COVERED(HMM_DivideQuaternionFAssign); - - return (Left = Left / Right); -} - -COVERAGE(HMM_EqualsVec2Op, 1) -HMM_INLINE hmm_bool operator==(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_EqualsVec2Op); - - return HMM_PREFIX(EqualsVec2)(Left, Right); -} - -COVERAGE(HMM_EqualsVec3Op, 1) -HMM_INLINE hmm_bool operator==(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_EqualsVec3Op); - - return HMM_PREFIX(EqualsVec3)(Left, Right); -} - -COVERAGE(HMM_EqualsVec4Op, 1) -HMM_INLINE hmm_bool operator==(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_EqualsVec4Op); - - return HMM_PREFIX(EqualsVec4)(Left, Right); -} - -COVERAGE(HMM_EqualsVec2OpNot, 1) -HMM_INLINE hmm_bool operator!=(hmm_vec2 Left, hmm_vec2 Right) -{ - ASSERT_COVERED(HMM_EqualsVec2OpNot); - - return !HMM_PREFIX(EqualsVec2)(Left, Right); -} - -COVERAGE(HMM_EqualsVec3OpNot, 1) -HMM_INLINE hmm_bool operator!=(hmm_vec3 Left, hmm_vec3 Right) -{ - ASSERT_COVERED(HMM_EqualsVec3OpNot); - - return !HMM_PREFIX(EqualsVec3)(Left, Right); -} - -COVERAGE(HMM_EqualsVec4OpNot, 1) -HMM_INLINE hmm_bool operator!=(hmm_vec4 Left, hmm_vec4 Right) -{ - ASSERT_COVERED(HMM_EqualsVec4OpNot); - - return !HMM_PREFIX(EqualsVec4)(Left, Right); -} - -#endif /* __cplusplus */ - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - -#endif /* HANDMADE_MATH_H */ - -#ifdef HANDMADE_MATH_IMPLEMENTATION - -COVERAGE(HMM_Power, 2) -float HMM_PREFIX(Power)(float Base, int Exponent) -{ - ASSERT_COVERED(HMM_Power); - - float Result = 1.0f; - float Mul = Exponent < 0 ? 1.f / Base : Base; - int X = Exponent < 0 ? -Exponent : Exponent; - while (X) - { - if (X & 1) - { - ASSERT_COVERED(HMM_Power); - - Result *= Mul; - } - - Mul *= Mul; - X >>= 1; - } - - return (Result); -} - -#ifndef HANDMADE_MATH__USE_SSE -COVERAGE(HMM_Transpose, 1) -hmm_mat4 HMM_PREFIX(Transpose)(hmm_mat4 Matrix) -{ - ASSERT_COVERED(HMM_Transpose); - - hmm_mat4 Result; - - int Columns; - for(Columns = 0; Columns < 4; ++Columns) - { - int Rows; - for(Rows = 0; Rows < 4; ++Rows) - { - Result.Elements[Rows][Columns] = Matrix.Elements[Columns][Rows]; - } - } - - return (Result); -} -#endif - -#ifndef HANDMADE_MATH__USE_SSE -COVERAGE(HMM_AddMat4, 1) -hmm_mat4 HMM_PREFIX(AddMat4)(hmm_mat4 Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_AddMat4); - - hmm_mat4 Result; - - int Columns; - for(Columns = 0; Columns < 4; ++Columns) - { - int Rows; - for(Rows = 0; Rows < 4; ++Rows) - { - Result.Elements[Columns][Rows] = Left.Elements[Columns][Rows] + Right.Elements[Columns][Rows]; - } - } - - return (Result); -} -#endif - -#ifndef HANDMADE_MATH__USE_SSE -COVERAGE(HMM_SubtractMat4, 1) -hmm_mat4 HMM_PREFIX(SubtractMat4)(hmm_mat4 Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_SubtractMat4); - - hmm_mat4 Result; - - int Columns; - for(Columns = 0; Columns < 4; ++Columns) - { - int Rows; - for(Rows = 0; Rows < 4; ++Rows) - { - Result.Elements[Columns][Rows] = Left.Elements[Columns][Rows] - Right.Elements[Columns][Rows]; - } - } - - return (Result); -} -#endif - -COVERAGE(HMM_MultiplyMat4, 1) -hmm_mat4 HMM_PREFIX(MultiplyMat4)(hmm_mat4 Left, hmm_mat4 Right) -{ - ASSERT_COVERED(HMM_MultiplyMat4); - - hmm_mat4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.Columns[0] = HMM_PREFIX(LinearCombineSSE)(Right.Columns[0], Left); - Result.Columns[1] = HMM_PREFIX(LinearCombineSSE)(Right.Columns[1], Left); - Result.Columns[2] = HMM_PREFIX(LinearCombineSSE)(Right.Columns[2], Left); - Result.Columns[3] = HMM_PREFIX(LinearCombineSSE)(Right.Columns[3], Left); -#else - int Columns; - for(Columns = 0; Columns < 4; ++Columns) - { - int Rows; - for(Rows = 0; Rows < 4; ++Rows) - { - float Sum = 0; - int CurrentMatrice; - for(CurrentMatrice = 0; CurrentMatrice < 4; ++CurrentMatrice) - { - Sum += Left.Elements[CurrentMatrice][Rows] * Right.Elements[Columns][CurrentMatrice]; - } - - Result.Elements[Columns][Rows] = Sum; - } - } -#endif - - return (Result); -} - -#ifndef HANDMADE_MATH__USE_SSE -COVERAGE(HMM_MultiplyMat4f, 1) -hmm_mat4 HMM_PREFIX(MultiplyMat4f)(hmm_mat4 Matrix, float Scalar) -{ - ASSERT_COVERED(HMM_MultiplyMat4f); - - hmm_mat4 Result; - - int Columns; - for(Columns = 0; Columns < 4; ++Columns) - { - int Rows; - for(Rows = 0; Rows < 4; ++Rows) - { - Result.Elements[Columns][Rows] = Matrix.Elements[Columns][Rows] * Scalar; - } - } - - return (Result); -} -#endif - -COVERAGE(HMM_MultiplyMat4ByVec4, 1) -hmm_vec4 HMM_PREFIX(MultiplyMat4ByVec4)(hmm_mat4 Matrix, hmm_vec4 Vector) -{ - ASSERT_COVERED(HMM_MultiplyMat4ByVec4); - - hmm_vec4 Result; - -#ifdef HANDMADE_MATH__USE_SSE - Result.InternalElementsSSE = HMM_PREFIX(LinearCombineSSE)(Vector.InternalElementsSSE, Matrix); -#else - int Columns, Rows; - for(Rows = 0; Rows < 4; ++Rows) - { - float Sum = 0; - for(Columns = 0; Columns < 4; ++Columns) - { - Sum += Matrix.Elements[Columns][Rows] * Vector.Elements[Columns]; - } - - Result.Elements[Rows] = Sum; - } -#endif - - return (Result); -} - -#ifndef HANDMADE_MATH__USE_SSE -COVERAGE(HMM_DivideMat4f, 1); -hmm_mat4 HMM_PREFIX(DivideMat4f)(hmm_mat4 Matrix, float Scalar) -{ - ASSERT_COVERED(HMM_DivideMat4f); - - hmm_mat4 Result; - - int Columns; - for(Columns = 0; Columns < 4; ++Columns) - { - int Rows; - for(Rows = 0; Rows < 4; ++Rows) - { - Result.Elements[Columns][Rows] = Matrix.Elements[Columns][Rows] / Scalar; - } - } - - return (Result); -} -#endif - -COVERAGE(HMM_Rotate, 1) -hmm_mat4 HMM_PREFIX(Rotate)(float Angle, hmm_vec3 Axis) -{ - ASSERT_COVERED(HMM_Rotate); - - hmm_mat4 Result = HMM_PREFIX(Mat4d)(1.0f); - - Axis = HMM_PREFIX(NormalizeVec3)(Axis); - - float SinTheta = HMM_PREFIX(SinF)(HMM_PREFIX(ToRadians)(Angle)); - float CosTheta = HMM_PREFIX(CosF)(HMM_PREFIX(ToRadians)(Angle)); - float CosValue = 1.0f - CosTheta; - - Result.Elements[0][0] = (Axis.X * Axis.X * CosValue) + CosTheta; - Result.Elements[0][1] = (Axis.X * Axis.Y * CosValue) + (Axis.Z * SinTheta); - Result.Elements[0][2] = (Axis.X * Axis.Z * CosValue) - (Axis.Y * SinTheta); - - Result.Elements[1][0] = (Axis.Y * Axis.X * CosValue) - (Axis.Z * SinTheta); - Result.Elements[1][1] = (Axis.Y * Axis.Y * CosValue) + CosTheta; - Result.Elements[1][2] = (Axis.Y * Axis.Z * CosValue) + (Axis.X * SinTheta); - - Result.Elements[2][0] = (Axis.Z * Axis.X * CosValue) + (Axis.Y * SinTheta); - Result.Elements[2][1] = (Axis.Z * Axis.Y * CosValue) - (Axis.X * SinTheta); - Result.Elements[2][2] = (Axis.Z * Axis.Z * CosValue) + CosTheta; - - return (Result); -} - -COVERAGE(HMM_LookAt, 1) -hmm_mat4 HMM_PREFIX(LookAt)(hmm_vec3 Eye, hmm_vec3 Center, hmm_vec3 Up) -{ - ASSERT_COVERED(HMM_LookAt); - - hmm_mat4 Result; - - hmm_vec3 F = HMM_PREFIX(NormalizeVec3)(HMM_PREFIX(SubtractVec3)(Center, Eye)); - hmm_vec3 S = HMM_PREFIX(NormalizeVec3)(HMM_PREFIX(Cross)(F, Up)); - hmm_vec3 U = HMM_PREFIX(Cross)(S, F); - - Result.Elements[0][0] = S.X; - Result.Elements[0][1] = U.X; - Result.Elements[0][2] = -F.X; - Result.Elements[0][3] = 0.0f; - - Result.Elements[1][0] = S.Y; - Result.Elements[1][1] = U.Y; - Result.Elements[1][2] = -F.Y; - Result.Elements[1][3] = 0.0f; - - Result.Elements[2][0] = S.Z; - Result.Elements[2][1] = U.Z; - Result.Elements[2][2] = -F.Z; - Result.Elements[2][3] = 0.0f; - - Result.Elements[3][0] = -HMM_PREFIX(DotVec3)(S, Eye); - Result.Elements[3][1] = -HMM_PREFIX(DotVec3)(U, Eye); - Result.Elements[3][2] = HMM_PREFIX(DotVec3)(F, Eye); - Result.Elements[3][3] = 1.0f; - - return (Result); -} - -COVERAGE(HMM_InverseQuaternion, 1) -hmm_quaternion HMM_PREFIX(InverseQuaternion)(hmm_quaternion Left) -{ - ASSERT_COVERED(HMM_InverseQuaternion); - - hmm_quaternion Conjugate; - hmm_quaternion Result; - float Norm = 0; - float NormSquared = 0; - - Conjugate.X = -Left.X; - Conjugate.Y = -Left.Y; - Conjugate.Z = -Left.Z; - Conjugate.W = Left.W; - - Norm = HMM_PREFIX(SquareRootF)(HMM_PREFIX(DotQuaternion)(Left, Left)); - NormSquared = Norm * Norm; - - Result = HMM_PREFIX(DivideQuaternionF)(Conjugate, NormSquared); - - return (Result); -} - -COVERAGE(HMM_Slerp, 1) -hmm_quaternion HMM_PREFIX(Slerp)(hmm_quaternion Left, float Time, hmm_quaternion Right) -{ - ASSERT_COVERED(HMM_Slerp); - - hmm_quaternion Result; - hmm_quaternion QuaternionLeft; - hmm_quaternion QuaternionRight; - - float Cos_Theta = HMM_PREFIX(DotQuaternion)(Left, Right); - float Angle = HMM_PREFIX(ACosF)(Cos_Theta); - - float S1 = HMM_PREFIX(SinF)((1.0f - Time) * Angle); - float S2 = HMM_PREFIX(SinF)(Time * Angle); - float Is = 1.0f / HMM_PREFIX(SinF)(Angle); - - QuaternionLeft = HMM_PREFIX(MultiplyQuaternionF)(Left, S1); - QuaternionRight = HMM_PREFIX(MultiplyQuaternionF)(Right, S2); - - Result = HMM_PREFIX(AddQuaternion)(QuaternionLeft, QuaternionRight); - Result = HMM_PREFIX(MultiplyQuaternionF)(Result, Is); - - return (Result); -} - -COVERAGE(HMM_QuaternionToMat4, 1) -hmm_mat4 HMM_PREFIX(QuaternionToMat4)(hmm_quaternion Left) -{ - ASSERT_COVERED(HMM_QuaternionToMat4); - - hmm_mat4 Result; - - hmm_quaternion NormalizedQuaternion = HMM_PREFIX(NormalizeQuaternion)(Left); - - float XX, YY, ZZ, - XY, XZ, YZ, - WX, WY, WZ; - - XX = NormalizedQuaternion.X * NormalizedQuaternion.X; - YY = NormalizedQuaternion.Y * NormalizedQuaternion.Y; - ZZ = NormalizedQuaternion.Z * NormalizedQuaternion.Z; - XY = NormalizedQuaternion.X * NormalizedQuaternion.Y; - XZ = NormalizedQuaternion.X * NormalizedQuaternion.Z; - YZ = NormalizedQuaternion.Y * NormalizedQuaternion.Z; - WX = NormalizedQuaternion.W * NormalizedQuaternion.X; - WY = NormalizedQuaternion.W * NormalizedQuaternion.Y; - WZ = NormalizedQuaternion.W * NormalizedQuaternion.Z; - - Result.Elements[0][0] = 1.0f - 2.0f * (YY + ZZ); - Result.Elements[0][1] = 2.0f * (XY + WZ); - Result.Elements[0][2] = 2.0f * (XZ - WY); - Result.Elements[0][3] = 0.0f; - - Result.Elements[1][0] = 2.0f * (XY - WZ); - Result.Elements[1][1] = 1.0f - 2.0f * (XX + ZZ); - Result.Elements[1][2] = 2.0f * (YZ + WX); - Result.Elements[1][3] = 0.0f; - - Result.Elements[2][0] = 2.0f * (XZ + WY); - Result.Elements[2][1] = 2.0f * (YZ - WX); - Result.Elements[2][2] = 1.0f - 2.0f * (XX + YY); - Result.Elements[2][3] = 0.0f; - - Result.Elements[3][0] = 0.0f; - Result.Elements[3][1] = 0.0f; - Result.Elements[3][2] = 0.0f; - Result.Elements[3][3] = 1.0f; - - return (Result); -} - -// This method taken from Mike Day at Insomniac Games. -// https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2015/01/matrix-to-quat.pdf -// -// Note that as mentioned at the top of the paper, the paper assumes the matrix -// would be *post*-multiplied to a vector to rotate it, meaning the matrix is -// the transpose of what we're dealing with. But, because our matrices are -// stored in column-major order, the indices *appear* to match the paper. -// -// For example, m12 in the paper is row 1, column 2. We need to transpose it to -// row 2, column 1. But, because the column comes first when referencing -// elements, it looks like M.Elements[1][2]. -// -// Don't be confused! Or if you must be confused, at least trust this -// comment. :) -COVERAGE(HMM_Mat4ToQuaternion, 4) -hmm_quaternion HMM_PREFIX(Mat4ToQuaternion)(hmm_mat4 M) -{ - float T; - hmm_quaternion Q; - - if (M.Elements[2][2] < 0.0f) { - if (M.Elements[0][0] > M.Elements[1][1]) { - ASSERT_COVERED(HMM_Mat4ToQuaternion); - - T = 1 + M.Elements[0][0] - M.Elements[1][1] - M.Elements[2][2]; - Q = HMM_PREFIX(Quaternion)( - T, - M.Elements[0][1] + M.Elements[1][0], - M.Elements[2][0] + M.Elements[0][2], - M.Elements[1][2] - M.Elements[2][1] - ); - } else { - ASSERT_COVERED(HMM_Mat4ToQuaternion); - - T = 1 - M.Elements[0][0] + M.Elements[1][1] - M.Elements[2][2]; - Q = HMM_PREFIX(Quaternion)( - M.Elements[0][1] + M.Elements[1][0], - T, - M.Elements[1][2] + M.Elements[2][1], - M.Elements[2][0] - M.Elements[0][2] - ); - } - } else { - if (M.Elements[0][0] < -M.Elements[1][1]) { - ASSERT_COVERED(HMM_Mat4ToQuaternion); - - T = 1 - M.Elements[0][0] - M.Elements[1][1] + M.Elements[2][2]; - Q = HMM_PREFIX(Quaternion)( - M.Elements[2][0] + M.Elements[0][2], - M.Elements[1][2] + M.Elements[2][1], - T, - M.Elements[0][1] - M.Elements[1][0] - ); - } else { - ASSERT_COVERED(HMM_Mat4ToQuaternion); - - T = 1 + M.Elements[0][0] + M.Elements[1][1] + M.Elements[2][2]; - Q = HMM_PREFIX(Quaternion)( - M.Elements[1][2] - M.Elements[2][1], - M.Elements[2][0] - M.Elements[0][2], - M.Elements[0][1] - M.Elements[1][0], - T - ); - } - } - - Q = HMM_PREFIX(MultiplyQuaternionF)(Q, 0.5f / HMM_PREFIX(SquareRootF)(T)); - - return Q; -} - -COVERAGE(HMM_QuaternionFromAxisAngle, 1) -hmm_quaternion HMM_PREFIX(QuaternionFromAxisAngle)(hmm_vec3 Axis, float AngleOfRotation) -{ - ASSERT_COVERED(HMM_QuaternionFromAxisAngle); - - hmm_quaternion Result; - - hmm_vec3 AxisNormalized = HMM_PREFIX(NormalizeVec3)(Axis); - float SineOfRotation = HMM_PREFIX(SinF)(AngleOfRotation / 2.0f); - - Result.XYZ = HMM_PREFIX(MultiplyVec3f)(AxisNormalized, SineOfRotation); - Result.W = HMM_PREFIX(CosF)(AngleOfRotation / 2.0f); - - return (Result); -} - -#endif /* HANDMADE_MATH_IMPLEMENTATION */ \ No newline at end of file diff --git a/src/app/interface.h b/src/app/interface.h deleted file mode 100644 index f0942a7..0000000 --- a/src/app/interface.h +++ /dev/null @@ -1,1632 +0,0 @@ -// -// File: interface.h -// Author: Peter Slattery -// Creation Date: 2020-01-01 -// -#ifndef INTERFACE_H - -#define InterfaceAssert(IMemPtr) Assert(IMemPtr && (u64)IMemPtr != 0x5 && (u64)IMemPtr != 0xC) - -enum gs_string_alignment -{ - Align_Left, - Align_Center, - Align_Right, -}; - -internal void -ClipUVRect(rect2* Bounds, rect2* UVs, rect2 ClippingBox) -{ - rect2 NewBounds = Rect2Union(*Bounds, ClippingBox); - - r32 OldWidth = Rect2Width(*Bounds); - r32 OldHeight = Rect2Height(*Bounds); - - v2 MinInsetPercent = v2{ - (NewBounds.Min.x - Bounds->Min.x) / OldWidth, - (NewBounds.Min.y - Bounds->Min.y) / OldHeight, - }; - - v2 MaxInsetPercent = v2{ - (NewBounds.Max.x - Bounds->Min.x) / OldWidth, - (NewBounds.Max.y - Bounds->Min.y) / OldHeight, - }; - - UVs->Min.x = LerpR32(MinInsetPercent.x, UVs->Min.x, UVs->Max.x); - UVs->Min.y = LerpR32(MinInsetPercent.y, UVs->Min.y, UVs->Max.y); - UVs->Max.x = LerpR32(MaxInsetPercent.x, UVs->Min.x, UVs->Max.x); - UVs->Max.y = LerpR32(MaxInsetPercent.y, UVs->Min.y, UVs->Max.y); - - *Bounds = NewBounds; -} - -internal void -DrawCharacter_ (render_quad_batch_constructor* BatchConstructor, r32 MinX, r32 MinY, codepoint_bitmap CodepointInfo, rect2 ClippingBox, v4 Color) -{ - rect2 Bounds = {}; - Bounds.Min.x = FloorR32(MinX); - Bounds.Min.y = FloorR32(MinY); - Bounds.Max.x = Bounds.Min.x + (CodepointInfo.Width); - Bounds.Max.y = Bounds.Min.y + (CodepointInfo.Height); - - rect2 UVBounds = {}; - UVBounds.Min = CodepointInfo.UVMin; - UVBounds.Max = CodepointInfo.UVMax; - - ClipUVRect(&Bounds, &UVBounds, ClippingBox); - - s32 AlignedMinX = (s32)(MinX); - s32 AlignedMinY = (s32)(MinY); - s32 AlignedMaxX = AlignedMinX + (CodepointInfo.Width); - s32 AlignedMaxY = AlignedMinY + (CodepointInfo.Height); - - PushQuad2DOnBatch(BatchConstructor, - Rect2BottomLeft(Bounds), Rect2BottomRight(Bounds), - Rect2TopRight(Bounds), Rect2TopLeft(Bounds), - UVBounds.Min, UVBounds.Max, - Color); -} - -internal v2 -DrawCharacterLeftAligned (render_quad_batch_constructor* BatchConstructor, char C, bitmap_font Font, v2 Position, rect2 ClippingBox, v4 Color) -{ - s32 GlyphDataIndex = GetIndexForCodepoint(Font, C); - codepoint_bitmap CodepointInfo = Font.CodepointValues[GlyphDataIndex]; - - // NOTE(Peter): - r32 MinX = Position.x + CodepointInfo.XOffset; - r32 MinY = Position.y + CodepointInfo.YOffset; - DrawCharacter_(BatchConstructor, MinX, MinY, CodepointInfo, ClippingBox, Color); - - // NOTE(Peter): - v2 PointAfterCharacter = v2{Position.x + CodepointInfo.Width, Position.y}; - return PointAfterCharacter; -} - -internal v2 -DrawCharacterRightAligned (render_quad_batch_constructor* BatchConstructor, char C, bitmap_font Font, v2 Position, rect2 ClippingBox, v4 Color) -{ - s32 GlyphDataIndex = GetIndexForCodepoint(Font, C); - codepoint_bitmap CodepointInfo = Font.CodepointValues[GlyphDataIndex]; - - // NOTE(Peter): - r32 MinX = Position.x - (CodepointInfo.XOffset + CodepointInfo.Width); - r32 MinY = Position.y + CodepointInfo.YOffset + CodepointInfo.YOffset; - DrawCharacter_(BatchConstructor, MinX, MinY, CodepointInfo, ClippingBox, Color); - - // NOTE(Peter): - v2 PointAfterCharacter = v2{Position.x-(CodepointInfo.Width + CodepointInfo.XOffset), Position.y}; - return PointAfterCharacter; -} - -internal v2 -DrawStringLeftAligned (render_quad_batch_constructor* BatchConstructor, s32 Length, char* gs_string, v2 InitialRegisterPosition, bitmap_font* Font, rect2 ClippingBox, v4 Color) -{ - v2 RegisterPosition = InitialRegisterPosition; - char* C = gs_string; - for (s32 i = 0; i < Length; i++) - { - v2 PositionAfterCharacter = DrawCharacterLeftAligned(BatchConstructor, *C, *Font, RegisterPosition, ClippingBox, Color); - RegisterPosition.x = PositionAfterCharacter.x; - C++; - } - return RegisterPosition; -} - -internal v2 -DrawStringRightAligned (render_quad_batch_constructor* BatchConstructor, s32 Length, char* gs_string, v2 InitialRegisterPosition, bitmap_font* Font, rect2 ClippingBox, v4 Color) -{ - v2 RegisterPosition = InitialRegisterPosition; - char* C = gs_string + Length - 1; - for (s32 i = Length - 1; i >= 0; i--) - { - v2 PositionAfterCharacter = DrawCharacterRightAligned(BatchConstructor, *C, *Font, RegisterPosition, ClippingBox, Color); - RegisterPosition.x = PositionAfterCharacter.x; - C--; - } - return RegisterPosition; -} - -internal v2 -DrawString(render_command_buffer* RenderBuffer, gs_string String, bitmap_font* Font, v2 Position, v4 Color, gs_string_alignment Alignment = Align_Left) -{ - DEBUG_TRACK_FUNCTION; - v2 LowerRight = Position; - - render_quad_batch_constructor BatchConstructor = PushRenderTexture2DBatch(RenderBuffer, String.Length, - Font->BitmapMemory, - Font->BitmapTextureHandle, - Font->BitmapWidth, - Font->BitmapHeight, - Font->BitmapBytesPerPixel, - Font->BitmapStride); - - // TODO(pjs): I don't like this solution but it'll do for now and I want to focus on other problems - // especially since I think this one will go away once I finish the ui overhaul - rect2 InfiniteClipBox = {}; - InfiniteClipBox.Min.x = -100000; - InfiniteClipBox.Min.y = -100000; - InfiniteClipBox.Max.x = 100000; - InfiniteClipBox.Max.y = 100000; - - v2 RegisterPosition = Position; - if (Alignment == Align_Left) - { - RegisterPosition = DrawStringLeftAligned(&BatchConstructor, StringExpand(String), RegisterPosition, Font, InfiniteClipBox, Color); - } - else if (Alignment == Align_Right) - { - RegisterPosition = DrawStringRightAligned(&BatchConstructor, StringExpand(String), RegisterPosition, Font, InfiniteClipBox, Color); - } - else - { - InvalidCodePath; - } - - LowerRight.x = RegisterPosition.x; - - return LowerRight; -} - -internal void -DrawCursor (render_quad_batch_constructor* BatchConstructor, v2 Position, v4 Color, bitmap_font Font) -{ - v2 Min = Position; - v2 Max = Position + v2{(r32)Font.MaxCharWidth, (r32)(Font.Ascent + Font.Descent)}; - PushQuad2DOnBatch(BatchConstructor, Min, Max, Color); -} - -#if 0 -internal v2 -DrawStringWithCursor (render_command_buffer* RenderBuffer, gs_string String, s32 CursorPosition, bitmap_font* Font, v2 Position, v4 Color, v4 CursorColor, gs_string_alignment Alignment = Align_Left) -{ - DEBUG_TRACK_FUNCTION; - v2 LowerRight = Position; - - // NOTE(Peter): We push this on first so that the cursor will be drawn underneath any character it may overlap with - render_quad_batch_constructor CursorBatch = PushRenderQuad2DBatch(RenderBuffer, 1); - render_quad_batch_constructor BatchConstructor = PushRenderTexture2DBatch(RenderBuffer, String.Length, - Font->BitmapMemory, - Font->BitmapTextureHandle, - Font->BitmapWidth, - Font->BitmapHeight, - Font->BitmapBytesPerPixel, - Font->BitmapStride); - - v2 RegisterPosition = Position; - if (Alignment == Align_Left) - { - RegisterPosition = DrawStringLeftAligned(&BatchConstructor, StringExpand(String), RegisterPosition, Font, Color); - DrawCursor(&CursorBatch, RegisterPosition, GreenV4, *Font); - if (String.Length - CursorPosition > 0) - { - RegisterPosition = DrawStringLeftAligned(&BatchConstructor, - String.Length - CursorPosition, - String.Str + CursorPosition, - RegisterPosition, Font, Color); - } - } - else if (Alignment == Align_Right) - { - RegisterPosition = DrawStringRightAligned(&BatchConstructor, - CursorPosition, String.Str, - RegisterPosition, Font, Color); - DrawCursor(&CursorBatch, RegisterPosition, GreenV4, *Font); - if (String.Length - CursorPosition > 0) - { - RegisterPosition = DrawStringRightAligned(&BatchConstructor, - String.Length - CursorPosition, - String.Str + CursorPosition, - RegisterPosition, Font, Color); - } - } - else - { - InvalidCodePath; - } - - LowerRight.x = RegisterPosition.x; - return LowerRight; -} -#endif - -enum ui_widget_flag -{ - UIWidgetFlag_ExpandsToFitChildren, - - UIWidgetFlag_DrawBackground, - UIWidgetFlag_DrawString, - UIWidgetFlag_DrawOutline, - UIWidgetFlag_DrawHorizontalFill, - UIWidgetFlag_DrawVerticalFill, - UIWidgetFlag_DrawFillReversed, - UIWidgetFlag_DrawFillAsHandle, - - UIWidgetFlag_Clickable, - UIWidgetFlag_Selectable, - UIWidgetFlag_Typable, -}; - -struct ui_widget_id -{ - u64 Id; - u64 ZIndex; -}; - -enum ui_layout_direction -{ - LayoutDirection_TopDown, - LayoutDirection_BottomUp, - LayoutDirection_Inherit, -}; - -struct ui_column -{ - r32 XMin; - r32 XMax; -}; - -struct ui_widget -{ - ui_widget_id Id; - - gs_string String; - gs_string_alignment Alignment; - - rect2 Bounds; - u64 Flags; - - ui_widget* Next; - - // Slider - r32 FillPercent; - - // Layout - ui_widget* Parent; - - v2 Margin; - r32 RowHeight; - r32 RowYAt; - - ui_layout_direction FillDirection; - - ui_column* Columns; - u32 ColumnsCount; - u32 ColumnsFilled; - - // NOTE(pjs): I'm not sure this will stay but - // its here so that when we end things like a dropdown, - // we can check the retained state of that dropdown - ui_widget_id WidgetReference; - - u64 ChildZIndexOffset; - - ui_widget* ChildrenRoot; - ui_widget* ChildrenHead; - u32 ChildCount; -}; - -struct ui_eval_result -{ - bool Clicked; - bool Held; - v2 DragDelta; -}; - -struct interface_config -{ - v4 PanelBG; - - // TODO(pjs): Turn these into _Default, _Hot, _Active - v4 ButtonColor_Inactive, ButtonColor_Active, ButtonColor_Selected; - - v4 TextColor; - -#define LIST_BG_COLORS_COUNT 2 - v4 ListBGColors[LIST_BG_COLORS_COUNT]; - v4 ListBGHover; - v4 ListBGSelected; - - bitmap_font* Font; - r32 FontSize; - v2 Margin; - r32 RowHeight; -}; - -struct ui_widget_retained_state -{ - ui_widget_id Id; - bool Value; - r32 InitialValueR32; - u32 FramesSinceAccess; - - // For use in layouts that allow you to scroll / pan - v2 ChildrenDrawOffset; - - gs_string EditString; - - // For dropdowns and rows to be able to error check not closing - // a layout you open - u32 MaxChildren; -}; - -struct ui_interface -{ - interface_config Style; - - mouse_state Mouse; - rect2 WindowBounds; - - // A per-frame string of the characters which have been typed - gs_const_string TempInputString; - - render_command_buffer* RenderBuffer; - - ui_widget* Widgets; - u64 WidgetsCount; - u64 WidgetsCountMax; - - ui_widget* DrawOrderHead; - ui_widget* DrawOrderRoot; - - ui_widget_id HotWidget; - // This should really never get higher than 1 or 2 - u8 HotWidgetFramesSinceUpdate; - - ui_widget_id ActiveWidget; - ui_widget_id LastActiveWidget; - - ui_widget* ActiveLayout; - -#define RETAINED_STATE_MAX 128 - ui_widget_retained_state RetainedState[RETAINED_STATE_MAX]; - u64 RetainedStateCount; - - gs_memory_arena* PerFrameMemory; - - // TODO(pjs): DONT USE THIS - // Right now you only need this to create EditStrings for ui_widget_retained_state's - // and even for those, you eventually want a better solution than "create a string and it lives forever" - // TODO(pjs): Get rid of the need for this vvv - gs_memory_arena* Permanent; -}; - -internal void -ui_InterfaceReset(ui_interface* Interface) -{ - Interface->WidgetsCount = 0; - Interface->DrawOrderHead = 0; - Interface->DrawOrderRoot = 0; - ClearArena(Interface->PerFrameMemory); - InterfaceAssert(Interface->PerFrameMemory); - - for (u32 i = 0; i < Interface->RetainedStateCount; i++) - { - Interface->RetainedState[i].FramesSinceAccess += 1; - if (Interface->RetainedState[i].FramesSinceAccess > 1) - { - Interface->RetainedState[i] = {0}; - } - } - - Interface->LastActiveWidget = Interface->ActiveWidget; -} - -internal bool -ui_WidgetIdsEqual(ui_widget_id A, ui_widget_id B) -{ - bool Result = (A.Id == B.Id);// && (A.ParentId == B.ParentId); - return Result; -} - -internal void -ui_WidgetSetFlag(ui_widget* Widget, u64 Flag) -{ - u64 Value = ((u64)1 << Flag); - Widget->Flags = Widget->Flags | Value; -} - -internal void -ui_WidgetClearFlag(ui_widget* Widget, u64 Flag) -{ - u64 Value = ((u64)1 << Flag); - Widget->Flags = Widget->Flags & ~Value; -} - -internal bool -ui_WidgetIsFlagSet(ui_widget Widget, u64 Flag) -{ - u64 Value = ((u64)1 << Flag); - bool Result = (Widget.Flags & Value); - return Result; -} - -internal void -ui_WidgetSetChildrenPopover(ui_widget* Widget) -{ - Widget->ChildZIndexOffset = 1000; -} - -internal ui_widget* -ui_WidgetGetWidgetWithId(ui_widget* Parent, ui_widget_id Id) -{ - ui_widget* Result = 0; - - if (ui_WidgetIdsEqual(Parent->Id, Id)) - { - Result = Parent; - } - else if (Parent->ChildrenRoot != 0) - { - for (ui_widget* At = Parent->ChildrenRoot; At != 0; At = At->Next) - { - Result = ui_WidgetGetWidgetWithId(At, Id); - if (Result != 0) - { - break; - } - } - } - - return Result; -} - -internal ui_widget* -ui_InterfaceGetWidgetWithId(ui_interface* Interface, ui_widget_id Id) -{ - ui_widget* Result = 0; - - for (ui_widget* At = Interface->DrawOrderRoot; At != 0; At = At->Next) - { - Result = ui_WidgetGetWidgetWithId(At, Id); - if (Result != 0) - { - break; - } - } - - return Result; -} - -internal ui_widget_retained_state* -ui_GetRetainedState(ui_interface* Interface, ui_widget_id Id) -{ - ui_widget_retained_state* Result = 0; - for (u64 i = 0; i < Interface->RetainedStateCount; i++) - { - if (ui_WidgetIdsEqual(Interface->RetainedState[i].Id, Id)) - { - Interface->RetainedState[i].FramesSinceAccess = 0; - Result = Interface->RetainedState + i; - break; - } - } - return Result; -} - -internal ui_widget_retained_state* -ui_CreateRetainedState(ui_interface* Interface, ui_widget* Widget) -{ - u64 Index = Interface->RetainedStateCount++; - ui_widget_retained_state* Result = Interface->RetainedState + Index; - Result->Id = Widget->Id; - Result->EditString = PushString(Interface->Permanent, 256); - return Result; -} - -internal ui_widget_retained_state* -ui_GetOrCreateRetainedState(ui_interface* Interface, ui_widget* Widget) -{ - ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); - if (!State) - { - State = ui_CreateRetainedState(Interface, Widget); - } - return State; -} - -internal ui_widget* -ui_CreateWidget(ui_interface* Interface, gs_string String) -{ - InterfaceAssert(Interface->PerFrameMemory); - Assert(Interface->WidgetsCount < Interface->WidgetsCountMax); - u64 Index = Interface->WidgetsCount++; - ui_widget* Result = Interface->Widgets + Index; - ZeroStruct(Result); - - Result->Parent = Interface->ActiveLayout; - - u64 Id = HashDJB2ToU64(StringExpand(String)); - if (Result->Parent) - { - Id = HashAppendDJB2ToU32(Id, Result->Parent->Id.Id); - Id = HashAppendDJB2ToU32(Id, Result->Parent->ChildCount); - //Result->Id.ParentId = Result->Parent->Id.Id; - } - Result->Id.Id = Id; - - u64 ZIndex = Index + 1; - if (Result->Parent) - { - Result->ChildZIndexOffset += Result->Parent->ChildZIndexOffset; - ZIndex += Result->Parent->ChildZIndexOffset; - } - Result->Id.ZIndex = ZIndex; - - Result->String = PushStringCopy(Interface->PerFrameMemory, String.ConstString); - InterfaceAssert(Interface->PerFrameMemory); - Result->Alignment = Align_Left; - Result->Next = 0; - Result->ChildrenRoot = 0; - Result->ChildrenHead = 0; - Result->Flags = 0; - ui_WidgetSetFlag(Result, UIWidgetFlag_ExpandsToFitChildren); - - return Result; -} - -// -// Interaction -// - -internal b32 -ui_MouseClickedRect(ui_interface Interface, rect2 Rect) -{ - b32 Result = MouseButtonTransitionedDown(Interface.Mouse.LeftButtonState); - Result &= PointIsInRect(Rect, Interface.Mouse.Pos); - return Result; -} - -// Layout - -static rect2 -ui_ReserveBounds(ui_interface* Interface, ui_widget* Widget, bool Inset) -{ - Assert(Widget->ColumnsCount > 0); - rect2 Bounds = {0}; - u32 ColumnIndex = Widget->ChildCount % Widget->ColumnsCount; - - ui_column Column = Widget->Columns[ColumnIndex]; - Bounds.Min.x = Column.XMin; - Bounds.Min.y = Widget->RowYAt; - Bounds.Max.x = Column.XMax; - Bounds.Max.y = Bounds.Min.y + Widget->RowHeight; - - if (Inset) - { - Bounds.Min.x += Widget->Margin.x; - Bounds.Min.y += Widget->Margin.y; - Bounds.Max.x -= Widget->Margin.x; - Bounds.Max.y -= Widget->Margin.y; - } - - if (Widget->ChildCount == 0) - { - ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); - if (State) - { - Bounds = Rect2Translate(Bounds, State->ChildrenDrawOffset); - } - } - - return Bounds; -} - -internal void -ui_CommitBounds(ui_widget* Parent, rect2 Bounds) -{ - u32 ColumnIndex = Parent->ChildCount % Parent->ColumnsCount; - if (ColumnIndex == 0) - { - switch (Parent->FillDirection) - { - case LayoutDirection_BottomUp: - { - Parent->RowYAt = Bounds.Max.y; - if (ui_WidgetIsFlagSet(*Parent, UIWidgetFlag_ExpandsToFitChildren)) - { - Parent->Bounds.Max.y = Parent->RowYAt; - } - }break; - - case LayoutDirection_TopDown: - { - Parent->RowYAt = Bounds.Min.y - Parent->RowHeight; - if (ui_WidgetIsFlagSet(*Parent, UIWidgetFlag_ExpandsToFitChildren)) - { - Parent->Bounds.Min.y = Bounds.Min.y; - } - }break; - } - } -} - -internal void -ui_ExpandParentToFit(ui_widget* Widget) -{ - ui_widget* Parent = Widget->Parent; - switch (Widget->FillDirection) - { - case LayoutDirection_TopDown: - { - Parent->Bounds.Min.y = Min(Parent->Bounds.Min.y, Widget->Bounds.Min.y - Parent->Margin.y); - }break; - - case LayoutDirection_BottomUp: - { - Parent->Bounds.Max.y = Max(Parent->Bounds.Max.y, Widget->Bounds.Max.y + Parent->Margin.y); - }break; - - InvalidDefaultCase; - } -} - -internal void -ui_WidgetCreateColumns(ui_widget* Widget, u32 ColumnsCount, ui_interface* Interface) -{ - Widget->Columns = PushArray(Interface->PerFrameMemory, ui_column, ColumnsCount); - InterfaceAssert(Interface->PerFrameMemory); - Widget->ColumnsCount = ColumnsCount; - Widget->ColumnsFilled = 0; -} - -internal void -ui_WidgetInitUniformColumns(ui_widget* Widget) -{ - r32 CurrentRowWidth = Rect2Width(Widget->Bounds); - r32 ColumnWidth = CurrentRowWidth / Widget->ColumnsCount; - for (u32 i = 0; i < Widget->ColumnsCount; i++) - { - ui_column* Column = Widget->Columns + i; - Column->XMin = Widget->Bounds.Min.x + (ColumnWidth * i); - Column->XMax = Column->XMin + ColumnWidth; - } -} - -internal ui_widget* -ui_CreateLayoutWidget(ui_interface* Interface, rect2 Bounds, gs_string Name, ui_layout_direction FillDir = LayoutDirection_Inherit) -{ - ui_widget* Result = ui_CreateWidget(Interface, Name); - //ui_WidgetSetFlag(Result, UIWidgetFlag_DrawOutline); - - Result->Bounds = Bounds; - Result->Margin = Interface->Style.Margin; - Result->RowHeight = Interface->Style.RowHeight; - - // Single Column Layout - ui_WidgetCreateColumns(Result, 1, Interface); - ui_WidgetInitUniformColumns(Result); - - if (FillDir == LayoutDirection_Inherit && Result->Parent != 0) - { - Result->FillDirection = Result->Parent->FillDirection; - } - else - { - Result->FillDirection = FillDir; - } - - switch(Result->FillDirection) - { - case LayoutDirection_BottomUp: - { - Result->RowYAt = Bounds.Min.y; - }break; - - case LayoutDirection_TopDown: - { - Result->RowYAt = Bounds.Max.y - Result->RowHeight; - }break; - - InvalidDefaultCase; - } - - return Result; -} - -static ui_widget* -ui_PushOverlayLayout(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir, gs_string Name) -{ - ui_widget* Result = ui_CreateLayoutWidget(Interface, Bounds, Name, FillDir); - SLLPushOrInit(Interface->DrawOrderRoot, Interface->DrawOrderHead, Result); - Interface->ActiveLayout = Result; - return Result; -} - -static ui_widget* -ui_PushLayout(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir, gs_string Name) -{ - ui_widget* Result = ui_CreateLayoutWidget(Interface, Bounds, Name, FillDir); - - if (Interface->DrawOrderRoot) - { - SLLPushOrInit(Interface->ActiveLayout->ChildrenRoot, Interface->ActiveLayout->ChildrenHead, Result); - Interface->ActiveLayout->ChildCount++; - } - else - { - SLLPushOrInit(Interface->DrawOrderRoot, Interface->DrawOrderHead, Result); - } - - Interface->ActiveLayout = Result; - return Result; -} - -static ui_widget* -ui_PushLayout(ui_interface* Interface, gs_string Name, bool Inset = true) -{ - rect2 Bounds = {}; - ui_layout_direction Direction = LayoutDirection_TopDown; - if (Interface->ActiveLayout) - { - Bounds = ui_ReserveBounds(Interface, Interface->ActiveLayout, Inset); - Direction = Interface->ActiveLayout->FillDirection; - } - else - { - Bounds.Min.x = Interface->WindowBounds.Min.x; - Bounds.Min.y = Interface->WindowBounds.Max.y; - Bounds.Max.x = Interface->WindowBounds.Max.x; - Bounds.Max.y = Interface->WindowBounds.Max.y; - - if (Inset) - { - Bounds.Min.x += Interface->Style.Margin.x; - Bounds.Max.x -= Interface->Style.Margin.x; - } - - Direction = LayoutDirection_TopDown; - } - return ui_PushLayout(Interface, Bounds, Direction, Name); -} - -internal void -ui_ExpandToFitChildren(ui_widget* Parent) -{ - if (!ui_WidgetIsFlagSet(*Parent, UIWidgetFlag_ExpandsToFitChildren)) { return; } - - v2 Extents = { Parent->Bounds.Max.y, Parent->Bounds.Min.y }; - for (ui_widget* Child = Parent->ChildrenRoot; Child != 0; Child = Child->Next) - { - Extents.x = Min(Extents.x, Child->Bounds.Min.y); - Extents.y = Max(Extents.y, Child->Bounds.Max.y); - } - - switch(Parent->FillDirection) - { - case LayoutDirection_BottomUp: - { - Parent->Bounds.Max.y = Max(Extents.y + Parent->Margin.y, Parent->Bounds.Max.y); - }break; - - case LayoutDirection_TopDown: - { - Parent->Bounds.Min.y = Min(Extents.x - Parent->Margin.y, Parent->Bounds.Min.y); - }break; - - InvalidDefaultCase; - } -} - -static void -ui_PopLayout(ui_interface* Interface, gs_string LayoutName) -{ - Assert(Interface->ActiveLayout != 0); - - ui_widget* Layout = Interface->ActiveLayout; - - // NOTE(pjs): If this isn't true then a layout was opened without being closed - // Go check for ui_PushLayout, ui_BeginDropdown, ui_BeginRow, etc that don't have - // a corresponding ui_Pop/ui_End* - Assert(StringsEqual(Layout->String, LayoutName)); - - ui_ExpandToFitChildren(Layout); - - Interface->ActiveLayout = Interface->ActiveLayout->Parent; - - // NOTE(pjs): This indicates that the parent layout should - // expand to fit the layout that we just popped - if (Interface->ActiveLayout != 0 && - Interface->ActiveLayout->ChildrenHead == Layout) - { - ui_CommitBounds(Interface->ActiveLayout, Layout->Bounds); - } -} - -static ui_widget* -ui_BeginRow(ui_interface* Interface, u32 ColumnsMax) -{ - ui_widget* Layout = ui_PushLayout(Interface, MakeString("Row"), false); - ui_WidgetCreateColumns(Layout, ColumnsMax, Interface); - ui_WidgetInitUniformColumns(Layout); - return Layout; -} - -enum ui_column_size_rule -{ - UIColumnSize_Fixed, - UIColumnSize_Percent, - UIColumnSize_Fill, - UIColumnSize_MaxWidth, -}; - -struct ui_column_spec -{ - ui_column_size_rule Rule; - union - { - r32 Width; - r32 Percent; - }; -}; - -static ui_widget* -ui_BeginRow(ui_interface* Interface, u32 ColumnsMax, ui_column_spec* ColumnRules) -{ - ui_widget* Layout = ui_PushLayout(Interface, MakeString("Row"), false); - ui_WidgetCreateColumns(Layout, ColumnsMax, Interface); - - // First Pass, determine widths of each column, and how much space is left to be divided by the fill columns - // If a size is specified, it is stored in Column->XMax - r32 RowWidth = Rect2Width(Layout->Bounds); - r32 RemainingSpace = RowWidth; - u32 FillColumnsCount = 0; - for (u32 i = 0; i < Layout->ColumnsCount; i++) - { - ui_column_spec Spec = ColumnRules[i]; - ui_column* Column = Layout->Columns + i; - - switch (Spec.Rule) - { - case UIColumnSize_Fixed: - { - Column->XMax = Spec.Width; - RemainingSpace -= Column->XMax; - }break; - - case UIColumnSize_Percent: - { - Column->XMax = Spec.Percent * RowWidth; - RemainingSpace -= Column->XMax; - }break; - - case UIColumnSize_Fill: - { - FillColumnsCount += 1; - }break; - - case UIColumnSize_MaxWidth: - { - if (RemainingSpace >= Spec.Width) - { - Column->XMax = Spec.Width; - } - else - { - Column->XMax = RemainingSpace; - } - RemainingSpace -= Column->XMax; - }break; - - InvalidDefaultCase; - } - } - - r32 FillColumnWidth = RemainingSpace / FillColumnsCount; - - // Second Pass, specify the actual XMin and XMax of each column - r32 ColumnStartX = Layout->Bounds.Min.x; - for (u32 i = 0; i < Layout->ColumnsCount; i++) - { - ui_column_spec Spec = ColumnRules[i]; - ui_column* Column = Layout->Columns + i; - - r32 ColumnWidth = 0; - switch (Spec.Rule) - { - case UIColumnSize_Fixed: - case UIColumnSize_Percent: - case UIColumnSize_MaxWidth: - { - ColumnWidth = Column->XMax; - }break; - - case UIColumnSize_Fill: - { - ColumnWidth = FillColumnWidth; - }break; - } - - Column->XMin = ColumnStartX ; - Column->XMax = Column->XMin + Max(0, ColumnWidth); - ColumnStartX = Column->XMax; - } - - return Layout; -} - -static void -ui_EndRow(ui_interface* Interface) -{ - ui_PopLayout(Interface, MakeString("Row")); -} - -static rect2 -ui_LayoutRemaining(ui_widget Layout) -{ - rect2 Result = Layout.Bounds; - Result.Max.y = Layout.RowYAt; - return Result; -} - -// Widgets - -internal ui_eval_result -ui_EvaluateWidget(ui_interface* Interface, ui_widget* Widget, rect2 Bounds) -{ - ui_eval_result Result = {}; - - Widget->Bounds = Bounds; - SLLPushOrInit(Interface->ActiveLayout->ChildrenRoot, Interface->ActiveLayout->ChildrenHead, Widget); - Interface->ActiveLayout->ChildCount += 1; - ui_CommitBounds(Widget->Parent, Widget->Bounds); - - if (PointIsInRect(Widget->Parent->Bounds, Interface->Mouse.Pos) && - PointIsInRect(Widget->Bounds, Interface->Mouse.Pos)) - { - if (MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState)) - { - if (ui_WidgetIdsEqual(Interface->HotWidget, Widget->Id)) - { - Result.Clicked = true; - Interface->ActiveWidget = Widget->Id; - } - } - - if (Interface->HotWidget.ZIndex == 0 || - Interface->HotWidget.ZIndex <= Widget->Id.ZIndex) - { - Interface->HotWidget = Widget->Id; - Interface->HotWidgetFramesSinceUpdate = 0; - } - } - else - { - if (ui_WidgetIdsEqual(Interface->ActiveWidget, Widget->Id) && - MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState)) - { - Interface->ActiveWidget = {}; - } - } - - if (ui_WidgetIdsEqual(Interface->ActiveWidget, Widget->Id)) - { - // click & drag - if (MouseButtonHeldDown(Interface->Mouse.LeftButtonState)) - { - Result.Held = true; - Result.DragDelta = Interface->Mouse.Pos - Interface->Mouse.DownPos; - } - - if (ui_WidgetIsFlagSet(*Widget, UIWidgetFlag_Typable) && - Interface->TempInputString.Length > 0) - { - ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); - - for (u32 i = 0; i < Interface->TempInputString.Length; i++) - { - if (Interface->TempInputString.Str[i] == '\b' && - State->EditString.Length > 0) - { - State->EditString.Length -= 1; - } - else - { - OutChar(&State->EditString, Interface->TempInputString.Str[i]); - } - } - } - } - -#if 0 - // if you can click it - if (ui_WidgetIsFlagSet(*Widget, UIWidgetFlag_Clickable)) - { - // updating hot widget, and handling mouse clicks - if (PointIsInRect(Widget->Parent->Bounds, Interface->Mouse.Pos) && - PointIsInRect(Widget->Bounds, Interface->Mouse.Pos)) - { - if (ui_WidgetIdsEqual(Interface->HotWidget, Widget->Id) && MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState)) - { - Result.Clicked = true; - Interface->ActiveWidget = Widget->Id; - } - - Interface->HotWidget = Widget->Id; - } - - // click and drag - if (MouseButtonHeldDown(Interface->Mouse.LeftButtonState) && - PointIsInRect(Widget->Bounds, Interface->Mouse.DownPos)) - { - Result.Held = true; - Result.DragDelta = Interface->Mouse.Pos - Interface->Mouse.DownPos; - } - - // if this is the active widget (its been clicked) - if (ui_WidgetIdsEqual(Interface->ActiveWidget, Widget->Id)) - { - // if you can select it - if (ui_WidgetIsFlagSet(*Widget, UIWidgetFlag_Selectable)) - { - // - if (MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState) && - !PointIsInRect(Widget->Bounds, Interface->Mouse.Pos)) - { - Interface->ActiveWidget = {}; - } - - if (ui_WidgetIsFlagSet(*Widget, UIWidgetFlag_Typable) && - Interface->TempInputString.Length > 0) - { - ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); - - // TODO(pjs): Backspace? - for (u32 i = 0; i < Interface->TempInputString.Length; i++) - { - if (Interface->TempInputString.Str[i] == '\b') - { - State->EditString.Length -= 1; - } - else - { - OutChar(&State->EditString, Interface->TempInputString.Str[i]); - } - } - } - } - else if (MouseButtonTransitionedUp(Interface->Mouse.LeftButtonState)) - { - Interface->ActiveWidget = {}; - } - } - } -#endif - - Assert(Widget->Parent != 0); - return Result; -} - -internal ui_eval_result -ui_EvaluateWidget(ui_interface* Interface, ui_widget* Widget) -{ - ui_widget* Layout = Interface->ActiveLayout; - rect2 Bounds = ui_ReserveBounds(Interface, Layout, true); - return ui_EvaluateWidget(Interface, Widget, Bounds); -} - -// -// Drawing Functions -// - -static r32 -ui_GetTextLineHeight(ui_interface Interface) -{ - r32 Result = Interface.Style.Font->PixelHeight + (2 * Interface.Style.Margin.y); - return Result; -} - -static void -ui_FillRect(ui_interface* Interface, rect2 Bounds, v4 Color) -{ - PushRenderQuad2D(Interface->RenderBuffer, Bounds.Min, Bounds.Max, Color); -} - -static void -ui_OutlineRect(ui_interface* Interface, rect2 Bounds, r32 Thickness, v4 Color) -{ - PushRenderBoundingBox2D(Interface->RenderBuffer, Bounds.Min, Bounds.Max, Thickness, Color); -} - -internal void -ui_Label(ui_interface* Interface, gs_string String, rect2 Bounds, gs_string_alignment Alignment = Align_Left) -{ - DEBUG_TRACK_FUNCTION; - ui_widget* Widget = ui_CreateWidget(Interface, String); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); - ui_EvaluateWidget(Interface, Widget, Bounds); -} - -internal void -ui_Label(ui_interface* Interface, gs_string String, gs_string_alignment Alignment = Align_Left) -{ - DEBUG_TRACK_FUNCTION; - ui_widget* Widget = ui_CreateWidget(Interface, String); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); - ui_EvaluateWidget(Interface, Widget); -} - -internal void -ui_TextEntrySetFlags(ui_widget* Widget, gs_string EditString) -{ - Widget->String = EditString; - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); - ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); - ui_WidgetSetFlag(Widget, UIWidgetFlag_Selectable); - ui_WidgetSetFlag(Widget, UIWidgetFlag_Typable); -} - -internal bool -ui_TextEntry(ui_interface* Interface, gs_string Identifier, gs_string* Value) -{ - ui_widget* Widget = ui_CreateWidget(Interface, Identifier); - ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); - if (!State) - { - State = ui_CreateRetainedState(Interface, Widget); - } - PrintF(&State->EditString, "%S", *Value); - - ui_TextEntrySetFlags(Widget, State->EditString); - - ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); - bool StringEdited = !StringsEqual(*Value, State->EditString); - PrintF(Value, "%S", State->EditString); - - return StringEdited; -} - -internal u64 -ui_TextEntryU64(ui_interface* Interface, gs_string String, u64 CurrentValue) -{ - ui_widget* Widget = ui_CreateWidget(Interface, String); - ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); - if (!State) - { - State = ui_CreateRetainedState(Interface, Widget); - PrintF(&State->EditString, "%u", CurrentValue); - } - ui_TextEntrySetFlags(Widget, State->EditString); - - ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); - parse_uint_result ParseResult = ValidateAndParseUInt(State->EditString.ConstString); - u64 ValueResult = CurrentValue; - if (ParseResult.Success) - { - ValueResult = ParseResult.Value; - } - return ValueResult; -} - -internal r64 -ui_TextEntryR64(ui_interface* Interface, gs_string String, r64 CurrentValue) -{ - ui_widget* Widget = ui_CreateWidget(Interface, String); - ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); - if (!State) - { - State = ui_CreateRetainedState(Interface, Widget); - PrintF(&State->EditString, "%f", CurrentValue); - } - ui_TextEntrySetFlags(Widget, State->EditString); - ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); - parse_float_result ParseResult = ValidateAndParseFloat(State->EditString.ConstString); - r64 ValueResult = CurrentValue; - if (ParseResult.Success) - { - ValueResult = ParseResult.Value; - } - return ValueResult; -} - -internal ui_widget* -ui_CreateButtonWidget(ui_interface* Interface, gs_string Text) -{ - ui_widget* Widget = ui_CreateWidget(Interface, Text); - ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); - return Widget; -} - -internal b32 -ui_Button(ui_interface* Interface, gs_string Text) -{ - ui_widget* Widget = ui_CreateButtonWidget(Interface, Text); - ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); - return Result.Clicked; -} - -internal b32 -ui_Button(ui_interface* Interface, gs_string Text, rect2 Bounds) -{ - ui_widget* Widget = ui_CreateButtonWidget(Interface, Text); - ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds); - return Result.Clicked; -} - -struct list_item_colors -{ - v4 Hover; - v4 Selected; - v4 BGColor; -}; - -inline v4 -ui_GetListItemBGColor(interface_config Style, u32 ElementIndex) -{ - v4 Result = Style.ListBGColors[ElementIndex % LIST_BG_COLORS_COUNT]; - return Result; -} - -static list_item_colors -ui_GetListItemColors(ui_interface* Interface, u32 ListItemIndex) -{ - list_item_colors Result = {}; - Result.Hover = Interface->Style.ListBGHover; - Result.Selected = Interface->Style.ListBGSelected; - Result.BGColor = ui_GetListItemBGColor(Interface->Style, ListItemIndex); - return Result; -} - -static b32 -ui_ListButton(ui_interface* Interface, gs_string Text, rect2 Bounds, u32 ListItemIndex) -{ - ui_widget* Widget = ui_CreateWidget(Interface, Text); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); - ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); - // TODO(pjs): Reimplement alternating color backgrounds - Widget->Bounds = Bounds; - ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); - return Result.Clicked; -} - -static b32 -ui_LayoutListButton(ui_interface* Interface, gs_string Text, u32 ListItemIndex) -{ - // TODO(pjs): Reimplement alternating colors - return ui_Button(Interface, Text); -} - -internal bool -ui_EvaluateDropdown(ui_interface* Interface, ui_widget* Widget, ui_eval_result EvalResult) -{ - ui_widget_retained_state* State = ui_GetRetainedState(Interface, Widget->Id); - if (!State) - { - State = ui_CreateRetainedState(Interface, Widget); - } - - if (EvalResult.Clicked) - { - State->Value = !State->Value; - } - - if (State->Value) - { - ui_widget ParentLayout = *Interface->ActiveLayout; - - r32 SpaceAbove = Interface->WindowBounds.Max.y - Widget->Bounds.Max.y; - r32 SpaceBelow = Widget->Bounds.Min.y - Interface->WindowBounds.Min.y; - ui_layout_direction Direction = LayoutDirection_TopDown; - rect2 MenuBounds = {}; - - if (SpaceAbove > SpaceBelow) - { - r32 ParentLayoutMaxY = ParentLayout.Bounds.Max.y; - Direction = LayoutDirection_BottomUp; - MenuBounds = rect2{ - v2{ Widget->Bounds.Min.x - ParentLayout.Margin.x, Widget->Bounds.Max.y }, - v2{ Widget->Bounds.Max.x + ParentLayout.Margin.x, ParentLayoutMaxY } - }; - } - else - { - r32 ParentLayoutMinY = ParentLayout.Bounds.Min.y; - Direction = LayoutDirection_TopDown; - MenuBounds = rect2{ - v2{ Widget->Bounds.Min.x - ParentLayout.Margin.x, ParentLayoutMinY }, - v2{ Widget->Bounds.Max.x + ParentLayout.Margin.x, Widget->Bounds.Min.y } - }; - } - - ui_widget* Layout = ui_PushOverlayLayout(Interface, MenuBounds, Direction, MakeString("DropdownLayout")); - Layout->Margin.y = 0; - Layout->WidgetReference = Widget->Id; - ui_WidgetClearFlag(Layout, UIWidgetFlag_DrawOutline); - ui_WidgetSetChildrenPopover(Layout); - } - - return State->Value; -} - -internal bool -ui_BeginDropdown(ui_interface* Interface, gs_string Text, rect2 Bounds) -{ - ui_widget* Widget = ui_CreateWidget(Interface, Text); - ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); - - ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds); - return ui_EvaluateDropdown(Interface, Widget, Result); -} - -internal bool -ui_BeginDropdown(ui_interface* Interface, gs_string Text) -{ - ui_widget* Widget = ui_CreateWidget(Interface, Text); - ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); - ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); - return ui_EvaluateDropdown(Interface, Widget, Result); -} - -internal void -ui_EndDropdown(ui_interface* Interface) -{ - ui_widget* Layout = Interface->ActiveLayout; - ui_widget_retained_state* State = ui_GetRetainedState(Interface, Layout->WidgetReference); - if (State) - { - if (State->Value) - { - ui_PopLayout(Interface, MakeString("DropdownLayout")); - } - } -} - -internal r32 -ui_EvaluateRangeSlider(ui_interface* Interface, ui_widget* Widget, ui_eval_result EvalResult, r32 Value, r32 MinValue, r32 MaxValue) -{ - r32 NewValue = Value; - ui_widget_retained_state* State = ui_GetOrCreateRetainedState(Interface, Widget); - - if (EvalResult.Clicked) - { - State->InitialValueR32 = Value; - } - - if (EvalResult.Held) - { - r32 Percent = (Interface->Mouse.Pos.x - Widget->Bounds.Min.x) / Rect2Width(Widget->Bounds); - NewValue = LerpR32(Percent, MinValue, MaxValue); - } - - NewValue = Clamp(MinValue, NewValue, MaxValue); - Widget->FillPercent = RemapR32(NewValue, MinValue, MaxValue, 0, 1); - return NewValue; -} - -internal ui_widget* -ui_CreateRangeSliderWidget(ui_interface* Interface, gs_string Text, r32 Value) -{ - ui_widget* Widget = ui_CreateWidget(Interface, Text); - ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawString); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawHorizontalFill); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); - Widget->String = PushStringF(Interface->PerFrameMemory, 128, "%f", Value); - InterfaceAssert(Interface->PerFrameMemory); - return Widget; -} - -internal r32 -ui_RangeSlider(ui_interface* Interface, gs_string Text, r32 Value, r32 ValueMin, r32 ValueMax) -{ - ui_widget* Widget = ui_CreateRangeSliderWidget(Interface, Text, Value); - ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); - return ui_EvaluateRangeSlider(Interface, Widget, Result, Value, ValueMin, ValueMax); - -} - -internal r32 -ui_RangeSlider(ui_interface* Interface, gs_string Text, rect2 Bounds, r32 Value, r32 ValueMin, r32 ValueMax) -{ - ui_widget* Widget = ui_CreateRangeSliderWidget(Interface, Text, Value); - ui_eval_result Result = ui_EvaluateWidget(Interface, Widget, Bounds); - return ui_EvaluateRangeSlider(Interface, Widget, Result, Value, ValueMin, ValueMax); -} - -internal bool -ui_Toggle(ui_interface* Interface, gs_string Text, bool Value) -{ - ui_widget* Widget = ui_CreateWidget(Interface, Text); - ui_WidgetSetFlag(Widget, UIWidgetFlag_Clickable); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawBackground); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawHorizontalFill); - ui_WidgetSetFlag(Widget, UIWidgetFlag_DrawOutline); - ui_eval_result Eval = ui_EvaluateWidget(Interface, Widget); - - bool Result = Eval.Clicked ? !Value : Value; - Widget->FillPercent = Result ? 1.0f : 0.0f; - return Result; -} - -internal void -ui_BeginList(ui_interface* Interface, gs_string Text, u32 ViewportRows, u32 ElementCount) -{ - if (ElementCount < ViewportRows) - { - ViewportRows = ElementCount; - } - - ui_column_spec ColumnRules[] = { - { UIColumnSize_Fixed, 32 }, - { UIColumnSize_Fill, 0 }, - }; - ui_widget* Layout = ui_BeginRow(Interface, 2, ColumnRules); - ui_WidgetClearFlag(Layout, UIWidgetFlag_ExpandsToFitChildren); - - ui_widget_retained_state* State = ui_GetRetainedState(Interface, Layout->Id); - if (!State) - { - State = ui_CreateRetainedState(Interface, Layout); - State->InitialValueR32 = 1.0f; - } - - r32 LayoutHeight = Layout->RowHeight * ViewportRows; - switch (Layout->Parent->FillDirection) - { - case LayoutDirection_TopDown: - { - Layout->Bounds.Min.y = Layout->Bounds.Max.y - LayoutHeight; - }break; - - case LayoutDirection_BottomUp: - { - Layout->Bounds.Max.y = Layout->Bounds.Min.y + LayoutHeight; - }break; - - InvalidDefaultCase; - } - - // Create the scroll bar - // - // TODO(pjs): Maybe make this a vertical slider widget? - - ui_widget* SliderRegion = ui_CreateWidget(Interface, MakeString("Slider")); - ui_WidgetSetFlag(SliderRegion, UIWidgetFlag_DrawOutline); - ui_WidgetSetFlag(SliderRegion, UIWidgetFlag_DrawVerticalFill); - ui_WidgetSetFlag(SliderRegion, UIWidgetFlag_DrawFillAsHandle); - - ui_WidgetSetFlag(SliderRegion, UIWidgetFlag_Clickable); - - rect2 SliderBounds = ui_ReserveBounds(Interface, Layout, true); - SliderBounds.Min.y = Layout->Bounds.Min.y + Layout->Margin.y; - SliderBounds.Max.y = Layout->Bounds.Max.y - Layout->Margin.y; - - ui_eval_result SliderEval = ui_EvaluateWidget(Interface, SliderRegion, SliderBounds); - if (SliderEval.Clicked || SliderEval.Held) - { - r32 Percent = (Interface->Mouse.Pos.y - SliderRegion->Bounds.Min.y) / Rect2Height(SliderRegion->Bounds); - State->InitialValueR32 = Clamp01(Percent); - } - SliderRegion->FillPercent = State->InitialValueR32; - - // Create the viewport that offsets list contents (and at render time determines what is visible) - // - ui_widget* ViewportLayout = ui_PushLayout(Interface, MakeString("Contents")); - ui_WidgetClearFlag(ViewportLayout, UIWidgetFlag_ExpandsToFitChildren); - - ViewportLayout->Bounds.Min.y = SliderBounds.Min.y; - ViewportLayout->Bounds.Max.y = SliderBounds.Max.y; - - s32 ScrollableElements = Max(0, ElementCount - ViewportRows); - ui_widget_retained_state* ViewportState = ui_GetOrCreateRetainedState(Interface, ViewportLayout); - ViewportState->ChildrenDrawOffset.x = 0; - ViewportState->ChildrenDrawOffset.y = ((1.0f - State->InitialValueR32) * (r32)(ScrollableElements)) * ViewportLayout->RowHeight; -} - -internal void -ui_EndList(ui_interface* Interface) -{ - // Pop the Viewport Layout - ui_PopLayout(Interface, MakeString("Contents")); - // Pop the actual list layout - ui_EndRow(Interface); -} - -internal void -ui_BeginMousePopup(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir, gs_string Text) -{ - rect2 FollowMouseBounds = Rect2Translate(Bounds, Interface->Mouse.Pos); - ui_widget* Layout = ui_PushOverlayLayout(Interface, FollowMouseBounds, FillDir, MakeString("MousePopup")); - ui_WidgetSetFlag(Layout, UIWidgetFlag_DrawBackground); -} - -internal void -ui_EndMousePopup(ui_interface* Interface) -{ - ui_PopLayout(Interface, MakeString("MousePopup")); -} - -// -internal void -ui_BeginLabelRow(ui_interface* Interface, gs_string Label, u32 Count = 2) -{ - ui_BeginRow(Interface, Count); - ui_Label(Interface, Label); -} - -internal bool -ui_LabeledToggle(ui_interface* Interface, gs_string Label, bool Value) -{ - ui_BeginLabelRow(Interface, Label); - bool Result = ui_Toggle(Interface, Label, Value); - ui_EndRow(Interface); - return Result; -} - -internal r32 -ui_LabeledRangeSlider(ui_interface* Interface, gs_string Label, r32 Value, r32 ValueMin, r32 ValueMax) -{ - ui_BeginLabelRow(Interface, Label); - r32 Result = ui_RangeSlider(Interface, Label, Value, ValueMin, ValueMax); - ui_EndRow(Interface); - return Result; -} - -internal void -ui_LabeledTextEntry(ui_interface* Interface, gs_string Label, gs_string* Value) -{ - ui_BeginLabelRow(Interface, Label); - ui_TextEntry(Interface, Label, Value); - ui_EndRow(Interface); -} - - -internal u64 -ui_LabeledTextEntryU64(ui_interface* Interface, gs_string Label, u32 Value) -{ - ui_BeginLabelRow(Interface, Label); - u64 Result = ui_TextEntryU64(Interface, Label, Value); - ui_EndRow(Interface); - return Result; -} - -internal bool -ui_BeginLabeledDropdown(ui_interface* Interface, gs_string Label, gs_string DropdownValue) -{ - ui_BeginLabelRow(Interface, Label); - return ui_BeginDropdown(Interface, DropdownValue); -} - -internal void -ui_EndLabeledDropdown(ui_interface* Interface) -{ - ui_EndDropdown(Interface); - ui_EndRow(Interface); -} - -internal ui_interface -ui_InterfaceCreate(context Context, interface_config Style, gs_memory_arena* Permanent) -{ - ui_interface Result = {0}; - Result.Style = Style; - - gs_file FontFile = ReadEntireFile(Context.ThreadContext.FileHandler, ConstString("data/Anonymous Pro.ttf")); - Result.Style.Font = PushStruct(Permanent, bitmap_font); - *Result.Style.Font = TextFont_Create(FontFile, 512, Style.FontSize, Context, Permanent); - - Result.Style.RowHeight = ui_GetTextLineHeight(Result) + (2 * Result.Style.Margin.y); - - Result.WidgetsCountMax = 4096; - Result.Widgets = PushArray(Permanent, ui_widget, Result.WidgetsCountMax); - Result.PerFrameMemory = PushStruct(Permanent, gs_memory_arena); - *Result.PerFrameMemory = CreateMemoryArena(Context.ThreadContext.Allocator); - InterfaceAssert(Result.PerFrameMemory); - - Result.Permanent = Permanent; - - return Result; -} - -#define INTERFACE_H -#endif // INTERFACE_H \ No newline at end of file diff --git a/src/app/patterns/blumen_patterns.h b/src/app/patterns/blumen_patterns.h index 4345524..6530ccd 100644 --- a/src/app/patterns/blumen_patterns.h +++ b/src/app/patterns/blumen_patterns.h @@ -7,383 +7,73 @@ #define FLOWER_COLORS_COUNT 12 -pixel FlowerAColors[FLOWER_COLORS_COUNT] = { - { 232,219,88 }, - { 232,219,88 }, - { 232,219,88 }, - { 147,75,176 }, - { 193,187,197 }, - { 223,190,49 }, - { 198,76,65 }, - { 198,76,65 }, - { 198,76,65 }, - { 226,200,17 }, - { 116,126,39 }, - { 61,62,31 } -}; -pixel FlowerBColors[FLOWER_COLORS_COUNT] = { - { 62,56,139 }, - { 93,87,164 }, - { 93,87,164 }, - { 93,87,164 }, - { 155,140,184 }, - { 191,201,204 }, - { 45,31,116 }, - { 201,196,156 }, - { 191,175,109 }, - { 186,176,107 }, - { 89,77,17 }, - { 47,49,18 }, -}; -pixel FlowerCColors[FLOWER_COLORS_COUNT] = { - { 220,217,210 }, - { 220,217,210 }, - { 220,217,210 }, - { 225,193,110 }, - { 225,193,110 }, - { 227,221,214 }, - { 227,221,214 }, - { 230,218,187 }, - { 230,218,187 }, - { 172,190,211 }, - { 172,190,211 }, - { 172,190,211 }, -}; - -internal pixel -PixelMix(r32 T, pixel A, pixel B) +internal void +Pattern_None(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) { - pixel Result = { - LerpU8(T, A.R, B.R), - LerpU8(T, A.G, B.G), - LerpU8(T, A.B, B.B), - }; - return Result; -} - -internal pixel -GetColor(pixel* Colors, u32 ColorsCount, r32 Percent) -{ - Percent = Clamp01(Percent); - - u32 LowerIndex = Percent * ColorsCount; - - u32 HigherIndex = LowerIndex + 1; - if (HigherIndex >= ColorsCount) HigherIndex = 0; - - r32 LowerPercent = (r32)LowerIndex / (r32)ColorsCount; - r32 StepPercent = 1.f / (r32)ColorsCount; - r32 PercentLower = (Percent - LowerPercent) / StepPercent; - - pixel Result = PixelMix(PercentLower, Colors[LowerIndex], Colors[HigherIndex]); - - return Result; + // just here so you can fade in from black } internal void -SolidColorPattern(led_buffer* Leds, pixel Color) +Pattern_AltBloomMask(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) { - for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++) + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; + + v3 SphereCenter = Assembly.Center - v3{0, -150, 0}; + r32 SphereRadius = Time; + r32 SphereBrightness = 1; + + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) { - Leds->Colors[LedIndex] = Color; + v3 P = Leds->Positions[LedIndex].xyz; + r32 Sphere = SDF_SphereNormalized(P, SphereCenter, SphereRadius); + Sphere = Clamp01(-Sphere); + Leds->Colors[LedIndex] = V4ToRGBPixel(WhiteV4 * Sphere); } } internal void -Pattern_Blue(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +Pattern_HueShift(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) { - pixel Blue = pixel{0, 0, 255}; - SolidColorPattern(Leds, Blue); -} - -internal void -Pattern_Green(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ - pixel Green = pixel{0, 255, 0}; - SolidColorPattern(Leds, Green); -} - -internal void -Pattern_FlowerColors(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ - r32 CycleTime = 10; - r32 CyclePercent = ModR32(Time, CycleTime) / CycleTime; + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; - pixel CA = GetColor(FlowerAColors, FLOWER_COLORS_COUNT, CyclePercent); - pixel CB = GetColor(FlowerAColors, FLOWER_COLORS_COUNT, 1.0f - CyclePercent); - - for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++) - { - v4 P = Leds->Positions[LedIndex]; - r32 Pct = (Abs(ModR32(P.y, 150) / 150) + CycleTime) * PiR32; - - r32 APct = RemapR32(SinR32(Pct), -1, 1, 0, 1); - Leds->Colors[LedIndex] = PixelMix(APct, CA, CB); - } -} - -internal void -TestPatternOne(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ - led_strip_list BlumenStrips = AssemblyStripsGetWithTagValue(Assembly, ConstString("assembly"), ConstString("Blumen Lumen"), Transient); - led_strip_list RadiaStrips = AssemblyStripsGetWithTagValue(Assembly, ConstString("assembly"), ConstString("Radialumia"), Transient); - - for (u32 i = 0; i < BlumenStrips.Count; i++) - { - u32 StripIndex = BlumenStrips.StripIndices[i]; - v2_strip StripAt = Assembly.Strips[StripIndex]; - - for (u32 j = 0; j < StripAt.LedCount; j++) - { - u32 LedIndex = StripAt.LedLUT[j]; - Leds->Colors[LedIndex] = { 255, 0, 0 }; - - } - } - - for (u32 i = 0; i < RadiaStrips.Count; i++) - { - u32 StripIndex = RadiaStrips.StripIndices[i]; - v2_strip StripAt = Assembly.Strips[StripIndex]; - - for (u32 j = 0; j < StripAt.LedCount; j++) - { - u32 LedIndex = StripAt.LedLUT[j]; - Leds->Colors[LedIndex] = { 0, 255, 0 }; - } - } -} - -internal void -TestPatternTwo(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ - r32 PeriodicTime = (Time / PiR32) * 2; - - r32 ZeroOneSin = (SinR32(PeriodicTime) * .5f) + .5f; - r32 ZeroOneCos = (CosR32(PeriodicTime) * .5f) + .5f; - pixel Color = { (u8)(ZeroOneSin * 255), 0, (u8)(ZeroOneCos * 255) }; - - v4 Center = v4{0, 0, 0, 1}; - r32 ThetaZ = Time / 2; - v4 Normal = v4{CosR32(ThetaZ), 0, SinR32(ThetaZ), 0}; // NOTE(Peter): dont' need to normalize. Should always be 1 - v4 Right = V4Cross(Normal, v4{0, 1, 0, 0}); - - v4 FrontCenter = Center + (Normal * 25); - v4 BackCenter = Center - (Normal * 25); - - r32 OuterRadiusSquared = 1000000; - r32 InnerRadiusSquared = 0; - - for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++) - { - v4 Position = Leds->Positions[LedIndex]; - - v4 ToFront = Position + FrontCenter; - v4 ToBack = Position + BackCenter; - - r32 ToFrontDotNormal = V4Dot(ToFront, Normal); - r32 ToBackDotNormal = V4Dot(ToBack, Normal); - - ToFrontDotNormal = Clamp01(ToFrontDotNormal * 1000); - ToBackDotNormal = Clamp01(ToBackDotNormal * 1000); - - r32 SqDistToCenter = V4MagSquared(Position); - if (SqDistToCenter < OuterRadiusSquared && SqDistToCenter > InnerRadiusSquared) - { - if (XOR(ToFrontDotNormal > 0, ToBackDotNormal > 0)) - { - Leds->Colors[LedIndex] = Color; - } - else - { - //Leds->Colors[LedIndex] = {}; - } - } - else - { - //Leds->Colors[LedIndex] = {}; - } - } -} - -internal void -TestPatternThree(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ - v4 GreenCenter = v4{0, 0, 150, 1}; - r32 GreenRadius = Abs(SinR32(Time)) * 200; - - v4 TealCenter = v4{0, 0, 150, 1}; - r32 TealRadius = Abs(SinR32(Time + 1.5)) * 200; - - r32 FadeDist = 35; - - - for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++) - { - v4 LedPosition = Leds->Positions[LedIndex]; - u8 Red = 0; - u8 Green = 0; - u8 Blue = 0; - - r32 GreenDist = Abs(V4Mag(LedPosition - GreenCenter) - GreenRadius); - r32 GreenBrightness = Clamp(0.f, FadeDist - Abs(GreenDist), FadeDist); - Green = (u8)(GreenBrightness * 255); - - r32 TealDist = Abs(V4Mag(LedPosition - TealCenter) - TealRadius); - r32 TealBrightness = Clamp(0.f, FadeDist - Abs(TealDist), FadeDist); - Red = (u8)(TealBrightness * 255); - Blue = (u8)(TealBrightness * 255); - - Leds->Colors[LedIndex].R = Red; - Leds->Colors[LedIndex].B = Green; - Leds->Colors[LedIndex].G = Green; - } -} - -v4 RGBToHSV(v4 In) -{ - v4 Result = {}; - - r32 Min = Min(In.r, Min(In.g, In.b)); - r32 Max = Max(In.r, Max(In.g, In.b)); - - - r32 V = Max; - r32 Delta = Max - Min; - r32 S = 0; - r32 H = 0; - if( Max != 0 ) - { - S = Delta / Max; - - if( In.r == Max ) - { - H = ( In.g - In.b ) / Delta; // between yellow & magenta - } - else if( In.g == Max ) - { - H = 2 + ( In.b - In.r ) / Delta; // between cyan & yellow - } - else - { - H = 4 + ( In.r - In.g ) / Delta; // between magenta & cyan - } - H *= 60; // degrees - if( H < 0 ) - H += 360; - Assert(H); - //if ( isNaN(h) ) - //H = 0; - Result = v4{H, S, V, 1}; - } - else - { - // r = g = b = 0 - // s = 0, v is undefined - S = 0; - H = -1; - Result = v4{H, S, 1, 1}; - } - - return Result; -} - -v4 HSVToRGB (v4 In) -{ - float Hue = In.x; - /* -while (Hue > 360.0f) { Hue -= 360.0f; } - while (Hue < 0.0f) { Hue += 360.0f; } - */ - Hue = ModR32(Hue, 360.0f); - if (Hue < 0) { Hue += 360.0f; } - if (Hue == MinR32) { Hue = 0; } - if (Hue == MaxR32) { Hue = 360; } - Assert(Hue >= 0 && Hue < 360); - - float Sat = In.y; - float Value = In.z; - - float hh, p, q, t, ff; - long i; - v4 Result = {}; - Result.a = In.a; - - if(Sat <= 0.0f) { // < is bogus, just shuts up warnings - Result.r = Value; - Result.g = Value; - Result.b = Value; - return Result; - } - hh = Hue; - if(hh >= 360.0f) hh = 0.0f; - hh /= 60.0f; - i = (long)hh; - ff = hh - i; - p = Value * (1.0f - Sat); - q = Value * (1.0f - (Sat * ff)); - t = Value * (1.0f - (Sat * (1.0f - ff))); - - switch(i) { - case 0: - {Result.r = Value; - Result.g = t; - Result.b = p; - }break; - - case 1: - { - Result.r = q; - Result.g = Value; - Result.b = p; - }break; - - case 2: - { - Result.r = p; - Result.g = Value; - Result.b = t; - }break; - - case 3: - { - Result.r = p; - Result.g = q; - Result.b = Value; - }break; - - case 4: - { - Result.r = t; - Result.g = p; - Result.b = Value; - }break; - - case 5: - default: - { - Result.r = Value; - Result.g = p; - Result.b = q; - }break; - } - - return Result; -} - -internal void -Pattern_HueShift(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ r32 Height = SinR32(Time) * 25; r32 CycleLength = 5.0f; r32 CycleProgress = FractR32(Time / CycleLength); r32 CycleBlend = (SinR32(Time) * .5f) + .5f; +#if 0 + phrase_hue Hue = BLState->AssemblyColors[Assembly.AssemblyIndex % 3]; + v4 C0 = RGBFromPhraseHue(Hue.Hue0); + v4 C1 = RGBFromPhraseHue(Hue.Hue1); + v4 C2 = RGBFromPhraseHue(Hue.Hue2); + + v4 HSV = {}; + if (CycleProgress < .25f) + { + r32 P = CycleProgress * 4; + HSV = V4Lerp(C0, + } + else if (CycleProgress >= .25f && CycleProgress < .5f) + { + + } + else if (CycleProgress >= .5f && CycleProgress < .75f) + { + + } + else if (CycleProgress >= .75f) + { + + } +#endif + v4 HSV = { CycleProgress * 360, 1, 1, 1 }; v4 RGB = HSVToRGB(HSV); - for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++) + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) { v4 Pos = Leds->Positions[LedIndex]; r32 Dist = Pos.y - Height; @@ -401,26 +91,19 @@ Pattern_HueShift(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* } } -internal pixel -V4ToRGBPixel(v4 C) -{ - pixel Result = {}; - Result.R = (u8)(C.x * 255); - Result.G = (u8)(C.y * 255); - Result.B = (u8)(C.z * 255); - return Result; -} - internal void -Pattern_HueFade(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +Pattern_Rainbow(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) { + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; + r32 HueBase = ModR32(Time * 50, 360); r32 CycleLength = 5.0f; r32 CycleProgress = FractR32(Time / CycleLength); r32 CycleBlend = (SinR32(Time) * .5f) + .5f; - for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++) + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) { v4 Pos = Leds->Positions[LedIndex]; r32 Hue = HueBase + Pos.y + Pos.x; @@ -432,65 +115,13 @@ Pattern_HueFade(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* } internal void -Pattern_AllGreen(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +Pattern_RadialRainbow(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) { - for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++) - { - u32 I = LedIndex + 1; - Leds->Colors[LedIndex] = {}; - if (I % 3 == 0) - { - Leds->Colors[LedIndex].R = 255; - } - else if (I % 3 == 1) - { - Leds->Colors[LedIndex].G = 255; - } - else if (I % 3 == 2) - { - Leds->Colors[LedIndex].B = 255; - } - - } -} - -internal r32 -PatternHash(r32 Seed) -{ - return FractR32(Seed * 17.0 * FractR32(Seed * 0.3183099)); -} - -internal void -Pattern_Spots(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ - pixel ColorA = { 0, 255, 255 }; - pixel ColorB = { 255, 0, 255 }; + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; - r32 Speed = .5f; - Time *= Speed; - r32 ScaleA = 2 * SinR32(Time / 5); - r32 ScaleB = 2.4f * CosR32(Time / 2.5f); - for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++) - { - v4 P = Leds->Positions[LedIndex]; - r32 V = P.y; - r32 Noise = .3f * PatternHash(V); - r32 ThetaY = (Leds->Positions[LedIndex].y / 10) + Time + Noise; - r32 ThetaX = (Leds->Positions[LedIndex].x / 13) + Time + Noise; - r32 Fade = (ScaleA * SinR32(ThetaY)) + (ScaleB * CosR32(3 * ThetaX)); - Fade = RemapClampedR32(Fade, -1, 1, 0, 1); - - Leds->Colors[LedIndex].R = (u8)LerpR32(Fade, ColorA.R, ColorB.R); - Leds->Colors[LedIndex].G = (u8)LerpR32(Fade, ColorA.G, ColorB.G); - Leds->Colors[LedIndex].B = (u8)LerpR32(Fade, ColorA.B, ColorB.B); - } -} - -internal void -Pattern_LighthouseRainbow(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ v2 RefVector = V2Normalize(v2{ SinR32(Time), CosR32(Time) }); - for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++) + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) { v2 Vector = v2{ Leds->Positions[LedIndex].x, @@ -500,218 +131,27 @@ Pattern_LighthouseRainbow(led_buffer* Leds, assembly Assembly, r32 Time, gs_memo r32 Angle = V2Dot(RefVector, Vector); - v4 HSV = { (Angle * 30) + (Time * 10) + Leds->Positions[LedIndex].y, 1, 1, 1 }; + v4 HSV = { (Angle * 30) + (Time * 10), 1, 1, 1 }; v4 RGB = HSVToRGB(HSV); Leds->Colors[LedIndex] = V4ToRGBPixel(RGB); } } -internal r32 -Smoothstep(r32 T) -{ - r32 Result = (T * T * (3 - (2 * T))); - return Result; -} - internal void -Pattern_SmoothGrowRainbow(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +Pattern_BasicFlowers(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) { - r32 FillCycleTime = ModR32(Time, 7.0f) / 7.0f; - r32 ColorCycleTime = ModR32(Time, 21.0f) / 21.0f; + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; - v4 HSV = { 0, 1, 1, 1 }; - for (u32 s = 0; s < Assembly.StripCount; s++) - { - v2_strip Strip = Assembly.Strips[s]; - - v4 RGB0 = HSVToRGB(HSV); - for (u32 l = 0; l < Strip.LedCount; l++) - { - u32 LedIndex = Strip.LedLUT[l]; - Leds->Colors[LedIndex] = V4ToRGBPixel(RGB0); - } - - HSV.x += 15; - } -} - -internal void -Pattern_GrowAndFade(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ - r32 PercentCycle = ModR32(Time, 10) / 10; - v4 HSV = { PercentCycle * 360, 1, 1, 1 }; - v4 RGB = HSVToRGB(HSV); - - r32 RefHeight = -100 + (Smoothstep(PercentCycle * 1.4f) * 400); - r32 RefBrightness = 1.0f - Smoothstep(PercentCycle); - - for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++) - { - v4 P = Leds->Positions[LedIndex]; - - v4 RgbFaded = v4{}; - if (P.y < RefHeight) - { - RgbFaded = RGB * RefBrightness; - } - Leds->Colors[LedIndex] = V4ToRGBPixel(RgbFaded); - } -} - -internal void -Pattern_ColorToWhite(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ - r32 FadeBottomBase = 50; - r32 FadeTop = 125; + phrase_hue Hue = BLState->AssemblyColors[Assembly.AssemblyIndex % 3]; + v4 C0 = RGBFromPhraseHue(Hue.Hue0); + v4 C1 = RGBFromPhraseHue(Hue.Hue1); + v4 C2 = RGBFromPhraseHue(Hue.Hue2); for (u32 StripIndex = 0; StripIndex < Assembly.StripCount; StripIndex++) { v2_strip Strip = Assembly.Strips[StripIndex]; - - r32 FlowerSpread = .8f; - r32 FlowerOffset = 0; - if (AssemblyStrip_HasTagValueSLOW(Strip, "flower", "center")) - { - FlowerOffset = 1; - } - else if (AssemblyStrip_HasTagValueSLOW(Strip, "flower", "right")) - { - FlowerOffset = 2; - } - FlowerOffset *= FlowerSpread; - - r32 PercentCycle = ModR32(Time + FlowerOffset, 10) / 10; - - r32 FadeBottom = FadeBottomBase + RemapR32(SinR32((PercentCycle * 4) * TauR32), -1, 1, -50, 50); - - v4 TopRGB = WhiteV4; - pixel TopColor = V4ToRGBPixel(TopRGB); - - for (u32 i = 0; i < Strip.LedCount; i++) - { - u32 LedIndex = Strip.LedLUT[i]; - v4 P = Leds->Positions[LedIndex]; - - pixel FinalColor = {}; - if (P.y > FadeTop) - { - FinalColor = TopColor; - } - else - { - r32 B = RemapR32(SinR32((P.y / 15.f) + (PercentCycle * TauR32)), -1, 1, .5f, 1.f); - r32 HNoise = RemapR32(SinR32((P.y / 31.f) + (PercentCycle * TauR32)), -1, 1, -32.f, 32.f); - v4 BottomRGB = HSVToRGB(v4{ (PercentCycle * 360) + HNoise, 1, B, 1 }); - - if (P.y < FadeBottom) - { - FinalColor = V4ToRGBPixel(BottomRGB); - } - else if (P.y >= FadeBottom && P.y <= FadeTop) - { - r32 FadePct = RemapR32(P.y, FadeBottom, FadeTop, 0, 1); - v4 MixRGB = V4Lerp(FadePct, BottomRGB, TopRGB); - FinalColor = V4ToRGBPixel(MixRGB); - } - } - - Leds->Colors[LedIndex] = FinalColor; - } - } -} - -internal void -Pattern_FlowerColorToWhite(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ - r32 FadeBottomBase = 50; - r32 FadeTop = 125; - - for (u32 StripIndex = 0; StripIndex < Assembly.StripCount; StripIndex++) - { - v2_strip Strip = Assembly.Strips[StripIndex]; - -#if 0 - // All flowers same flower type - pixel* Colors = &FlowerAColors[0]; - r32 FlowerSpread = .8f; - r32 FlowerOffset = 0; - if (AssemblyStrip_HasTagValueSLOW(Strip, "flower", "center")) - { - FlowerOffset = 1; - } - else if (AssemblyStrip_HasTagValueSLOW(Strip, "flower", "right")) - { - FlowerOffset = 2; - } - FlowerOffset *= FlowerSpread; -#else - // Each flower different - pixel* Colors = &FlowerAColors[0]; - r32 FlowerOffset = 0; - if (AssemblyStrip_HasTagValueSLOW(Strip, "flower", "center")) - { - Colors = &FlowerBColors[0]; - } - else if (AssemblyStrip_HasTagValueSLOW(Strip, "flower", "right")) - { - Colors = &FlowerCColors[0]; - } -#endif - r32 PercentCycle = ModR32(Time + FlowerOffset, 10) / 10; - - r32 FadeBottom = FadeBottomBase + RemapR32(SinR32((PercentCycle * 4) * TauR32), -1, 1, -50, 50); - - for (u32 i = 0; i < Strip.LedCount; i++) - { - u32 LedIndex = Strip.LedLUT[i]; - v4 P = Leds->Positions[LedIndex]; - - pixel FinalColor = {}; - r32 B = RemapR32(SinR32((P.y / 15.f) + (PercentCycle * TauR32)), -1, 1, .5f, 1.f); - r32 HNoise = RemapR32(SinR32((P.y / 31.f) + (PercentCycle * TauR32)), -1, 1, 0.f, 1.f); - - pixel BottomColor = GetColor(Colors, FLOWER_COLORS_COUNT, (PercentCycle + HNoise) / 2); - - FinalColor = BottomColor; - - Leds->Colors[LedIndex] = FinalColor; - } - } -} - -r32 TLastFrame = 0; -pixel* FAC = &FlowerAColors[0]; -pixel* FBC = &FlowerBColors[0]; -pixel* FCC = &FlowerCColors[0]; - -internal void -Pattern_BasicFlowers(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) -{ - if (TLastFrame > Time) - { - pixel* Temp = FAC; - FAC = FBC; - FBC = FCC; - FCC = Temp; - } - TLastFrame = Time; - - for (u32 StripIndex = 0; StripIndex < Assembly.StripCount; StripIndex++) - { - v2_strip Strip = Assembly.Strips[StripIndex]; - - // Each flower different - pixel* Colors = FAC; - if (AssemblyStrip_HasTagValueSLOW(Strip, "flower", "center")) - { - Colors = FBC; - } - else if (AssemblyStrip_HasTagValueSLOW(Strip, "flower", "right")) - { - Colors = FCC; - } - r32 CycleT = ModR32(Time, 10) * 20; for (u32 i = 0; i < Strip.LedCount; i++) @@ -722,9 +162,718 @@ Pattern_BasicFlowers(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_ar r32 T = ModR32(P.y + CycleT, 200) / 200.f; T = Clamp01(T); - Leds->Colors[LedIndex] = GetColor(Colors, FLOWER_COLORS_COUNT, T); + v4 Color = {}; + if (T < 0.5f) + { + Color = V4Lerp(T * 2, C0, C1); + } + else + { + Color = V4Lerp((T - 0.5f) * 2, C1, C2); + } + Leds->Colors[LedIndex] = V4ToRGBPixel(Color); } } } + +internal void +Pattern_WavyOptions(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData, r32 Granularity, v4 C0, v4 C1, v4 C2) +{ + r32 Top = 120 + (SinR32(Time) * 10); + r32 Mid = 70 + (CosR32(Time * 2.13) * 20); + r32 Bot = 0; + + r32 TopD = Top - Mid; + r32 BotD = Mid - Bot; + r32 MidD = Min(TopD, BotD); + + //r32 MaxFadeDistance = 10; + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + v3 P = Leds->Positions[LedIndex].xyz; + + r32 PercentTop = Clamp01(1.0f - ((Top - P.y) / TopD)); + + r32 PercentMid = Clamp01(1.0f - Abs(P.y - Mid) / MidD); + r32 N = Noise3D((P / 17) + v3{Time, -Time, 0}); + N = Clamp01(N) * 2; + N = Smoothstep(N); + N *= N; + N = Smoothstep(N); + N *= 1.0f - PowR32(1.0f - PercentMid, 4); + PercentMid = Clamp01(PercentMid + N); + + r32 PercentBot = Clamp01(1.0f - ((P.y - Bot) / BotD)); + + v4 TopC = (C0 * PercentTop); + v4 MidC = (C1 * PercentMid); + v4 BotC = (C2 * PercentBot); + + v4 C = {}; + if (PercentTop > PercentMid && PercentTop > PercentBot) + { + C = C0; + } + else if (PercentMid > PercentBot) + { + C = C1; + } + else + { + C = C2; + } + + r32 ScaleFactor = PercentTop + PercentMid + PercentBot; + C = (TopC + MidC + BotC) / ScaleFactor; + Leds->Colors[LedIndex] = V4ToRGBPixel(C); + } +} + +internal void +Pattern_Wavy(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; + + phrase_hue Hue = BlumenLumen_GetCurrentHue(BLState, Assembly); + v4 C0 = RGBFromPhraseHue(Hue.Hue0); + v4 C1 = RGBFromPhraseHue(Hue.Hue1); + v4 C2 = RGBFromPhraseHue(Hue.Hue2); + + Pattern_WavyOptions(Leds, Range, Assembly, Time, Transient, UserData, 1, C0, C1, C2); +} + +internal void +Pattern_PatchyOptions(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData, r32 Granularity, v4 C0, v4 C1, v4 C2) +{ + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + + r32 BaseGA = 50.000f * (1 / Granularity); + r32 BaseGB = 135.20f * (1 / Granularity); + r32 BaseGC = 260.74f * (1 / Granularity); + + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + v4 P = Leds->Positions[LedIndex]; + r32 LedRange = 300.0f; + r32 ScaleFactor = 1.0f / LedRange; + v3 Pp = P.xyz + v3{150, 100, 0}; + + r32 NoiseA = Noise3D((Pp / BaseGA) + v3{0, 0, Time}); + NoiseA = PowR32(NoiseA, 3); + NoiseA = Smoothstep(NoiseA); + + r32 NoiseB = Noise3D((Pp / BaseGB) + v3{Time * 0.5f, 0, 0}); + NoiseB = PowR32(NoiseB, 3); + NoiseB = Smoothstep(NoiseB); + +#if 1 + r32 NoiseC = Noise3D((Pp / BaseGC) + v3{Time * 0.5f, 0, 0}); + NoiseC = PowR32(NoiseC, 3); + NoiseC = Smoothstep(NoiseC); +#else + r32 NoiseC = 0; +#endif + + v4 C = (C0 * NoiseA) + (C1 * NoiseB) + (C2 * NoiseC); + C /= (NoiseA + NoiseB + NoiseC); + Leds->Colors[LedIndex] = V4ToRGBPixel(C); + } +} + +internal void +Pattern_Patchy(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + phrase_hue Hue = BlumenLumen_GetCurrentHue(BLState, Assembly); + v4 C0 = RGBFromPhraseHue(Hue.Hue0); + v4 C1 = RGBFromPhraseHue(Hue.Hue1); + v4 C2 = RGBFromPhraseHue(Hue.Hue2); + Time = Time * BLState->PatternSpeed; + Pattern_PatchyOptions(Leds, Range, Assembly, Time, Transient, UserData, 5, C0, C1, C2); +} + +internal r32 +Leafy_BandSDF(v3 P, gs_random_series* Random, r32 Time) +{ + r32 MinBandThickness = 5; + r32 MaxBandThickness = 10; + r32 MaxTransitionPeriod = 120.0f; + + r32 BandTransitionPeriod = NextRandomUnilateral(Random) * MaxTransitionPeriod; + r32 BandTransitionBias = (1 - Clamp(0, (Time / (MaxTransitionPeriod / 2)), 0.7f)); // approaches 0.5 over time + BandTransitionPeriod *= BandTransitionBias; + + r32 BandPercent = ModR32(Time, BandTransitionPeriod) / BandTransitionPeriod; + BandPercent = Smoothstep(BandPercent); + r32 BandY = -150 + (BandPercent * 290); + + r32 ThickRand = NextRandomUnilateral(Random); + // 1 - 4((ThickRand - .5)^2) - distribution curve + ThickRand = 1.0f - ((4 * PowR32(ThickRand, 2)) - (4 * ThickRand) + 1); + r32 BandThickness = MinBandThickness + (ThickRand * (MaxBandThickness - MinBandThickness)); + + // BandBrightness = 1 - ((2x - 1) ^ 8) where x is BandPercent + r32 BandBrightness = 1.0f - PowR32((2 * BandPercent) - 1, 8); + BandBrightness *= RemapR32(NextRandomUnilateral(Random), 0, 1, .25f, 1); + r32 Result = 1 - Clamp01(Abs(P.y - BandY) / BandThickness); + Result *= BandBrightness; + return Result; +} + +internal void +Pattern_Leafy(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed * .3f; + + phrase_hue Hue = BlumenLumen_GetCurrentHue(BLState, Assembly); + v4 C0 = RGBFromPhraseHue(Hue.Hue0); + v4 C1 = RGBFromPhraseHue(Hue.Hue1); + v4 C2 = RGBFromPhraseHue(Hue.Hue2); + + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + v4 P = Leds->Positions[LedIndex]; + + v4 C = {}; + r32 B = 0; + + // NOTE(PS): initializing the Random seed inside the Led Loop + // so that the bands are consistently calculated for each led + // ie. each time you calculate a band, the random numbers requested + // will always be the same + gs_random_series Random = InitRandomSeries(24601); + u32 BandCount = 25; + for (u32 Band = 0; Band < BandCount; Band++) + { + B += Leafy_BandSDF(P.xyz, &Random, Time); + } + B = Clamp01(B); + + C = WhiteV4 * B; + Leds->Colors[LedIndex] = V4ToRGBPixel(C); + } +} + +internal void +Pattern_LeafyPatchy(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; + + phrase_hue Hue = BlumenLumen_GetCurrentHue(BLState, Assembly); + v4 C0 = RGBFromPhraseHue(Hue.Hue0); + v4 C1 = RGBFromPhraseHue(Hue.Hue1); + v4 C2 = RGBFromPhraseHue(Hue.Hue2); + + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + v4 P = Leds->Positions[LedIndex]; + v3 Pp = P.xyz + v3{150, 100, 0}; + + r32 NoiseA = Fbm3D((Pp / 18), Time * 0.25f); + NoiseA = Smoothstep(NoiseA); + + r32 NoiseB = Noise3D((Pp / 35) + v3{0, 0, Time * 0.5f}); + NoiseB = PowR32(NoiseB, 3); + NoiseB = Smoothstep(NoiseB); + + r32 NoiseC = Noise3D((Pp / 25) + v3{0, 0, Time * 4}); + r32 CPresence = SinR32((P.y / 50) - Time) + (0.8f * SinR32((P.y / 25) - (Time * 5.0f))); + CPresence = RemapR32(CPresence, -1.8, 1.8, 0, 1); + CPresence = PowR32(CPresence, 4); + NoiseC *= CPresence; + + v4 C = (C0 * NoiseA * 0.5f) + (C1 * NoiseB) + (C2 * NoiseC); + C *= 1.0f / (NoiseA + NoiseB + NoiseC); + Leds->Colors[LedIndex] = V4ToRGBPixel(C); + } +} + +internal void +Pattern_WavyPatchy(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; +} + +internal void +Pattern_VerticalLines(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; + + gs_random_series Random = InitRandomSeries(24601); + + r32 LightSpeedMin = 1; + r32 LightSpeedMax = 5; + + s32 LightTailLength = 60; + for (u32 StripIndex = 0; StripIndex < Assembly.StripCount; StripIndex++) + { + v2_strip Strip = Assembly.Strips[StripIndex]; + + r32 LightStartHeight = NextRandomUnilateral(&Random); + r32 LightSpeed = LerpR32(NextRandomUnilateral(&Random), + LightSpeedMin, + LightSpeedMax); + r32 LightCurrentHeight = LightStartHeight + (LightSpeed * Time * 0.1f); + s32 StartIndex = (s32)(LightCurrentHeight * (r32)Strip.LedCount) % Strip.LedCount; + + for (s32 i = 0; i < LightTailLength; i++) + { + s32 StripLedIndex = StartIndex + i; + if (StripLedIndex >= (s32)Strip.LedCount) continue; + + u32 LedIndex = Strip.LedLUT[StripLedIndex]; + r32 PctTail = ((r32)i / (r32)LightTailLength); + v4 C = WhiteV4 * PctTail; + Leds->Colors[LedIndex] = V4ToRGBPixel(C); + } + } +} + +internal void +Pattern_RotaryOptions(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData, r32 Granularity, v4 BGColor, v4 FGColor) +{ + DEBUG_TRACK_FUNCTION; + + gs_random_series Random = InitRandomSeries((u32)(24601 * (Assembly.Center.x + 1.032f))); + +#define SphereCount 32 + v3 SphereCenter[SphereCount]; + + r32 G = RemapR32(Granularity, 1, 5, .75f, 2); + r32 MaxHeightOffset = 250; + r32 MaxSpeed = 10; + r32 SphereRotationRadius = 3.0f; + r32 SphereRadius = 2.0f / G; + for (u32 i = 0; i < SphereCount; i++) + { + r32 SphereSeedA = NextRandomUnilateral(&Random); + SphereSeedA = PowR32(SphereSeedA, 2); + r32 SphereSeedB = NextRandomBilateral(&Random); + r32 SphereSpeed = NextRandomUnilateral(&Random) * MaxSpeed; + + r32 SphereTime = Time + SphereSpeed; + r32 HeightOffset = 150 - (SphereSeedA * MaxHeightOffset); + r32 RotationOffset = SphereTime + SphereSeedB * TauR32; + r32 SphereRotationDir = NextRandomBilateral(&Random) < 0 ? -1 : 1; + v3 SpherePosOffset = v3{ + SinR32(RotationOffset * SphereRotationDir) * (SphereRotationRadius * 2), + HeightOffset, + CosR32(RotationOffset * SphereRotationDir) * (SphereRotationRadius * 2) + }; + SphereCenter[i] = Assembly.Center + SpherePosOffset; + } + + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + v3 P = Leds->Positions[LedIndex].xyz; + + r32 Dist = 10000000; + for (u32 i = 0; i < SphereCount; i++) + { + r32 SphereSDF = Abs(SDF_Sphere(P, SphereCenter[i], SphereRadius)); + SphereSDF = SphereSDF / SphereRadius; + Dist = Min(Dist, SphereSDF); + } + + v4 C = BGColor; + if (Dist <= 1) + { + r32 Brightness = Clamp01(SphereRadius - Dist); + C = V4Lerp(Brightness, BGColor, FGColor); + } + + Leds->Colors[LedIndex] = V4ToRGBPixel(C); + } +} + +internal void +Pattern_Rotary(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; + Pattern_RotaryOptions(Leds, Range, Assembly, Time, Transient, UserData, .25f, BlackV4, WhiteV4); +} + +internal void +Pattern_AllOnMask(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + pixel White = V4ToRGBPixel(WhiteV4); + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + v3 P = Leds->Positions[LedIndex].xyz; + Leds->Colors[LedIndex] = White; + } +} + +internal void +Pattern_BulbMask(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; + + r32 Top = 141; + r32 BulbRange = 50; + + pixel White = V4ToRGBPixel(WhiteV4); + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + v3 P = Leds->Positions[LedIndex].xyz; + + r32 BulbSDF = 1 - Clamp01(((Top - P.y) - BulbRange) / BulbRange); + r32 N = Noise3D((P / 17) + v3{Time, -Time, 0}); + N = Clamp01(N) * 2; + N = Smoothstep(N); + N *= N; + N = Smoothstep(N); + N *= 1.0f - PowR32(1.0f - BulbSDF, 4); + BulbSDF += N; + BulbSDF = Clamp01(BulbSDF); + v4 C = WhiteV4 * BulbSDF; + Leds->Colors[LedIndex] = V4ToRGBPixel(C); + } +} + +internal v4 +GenPatchyColor(v3 P, r32 Time, v4 C0, v4 C1, v4 C2) +{ + r32 LedRange = 300.0f; + r32 ScaleFactor = 1.0f / LedRange; + v3 Pp = P + v3{150, 100, 0}; + + r32 ScaleA = 1; + r32 NoiseA = Noise3D(((Pp / 38) + v3{0, 0, Time}) * ScaleA); + NoiseA = PowR32(NoiseA, 3); + NoiseA = Smoothstep(NoiseA); + + r32 ScaleBP = 2; + r32 ScaleB = 15; + r32 NoiseBP = Noise3D(((Pp / 13) + v3{ 0, Time * -0.33f, 0}) * ScaleBP); + NoiseBP = PowR32(NoiseBP, 3); + r32 NoiseB = Noise3D(((Pp / 75) + v3{Time * 0.5f, 0, 0}) * ScaleB); + NoiseB = PowR32(NoiseB, 3); + NoiseB = Smoothstep(NoiseB) * NoiseBP; + + r32 ScaleC = 1.5; + r32 NoiseCP = Noise3D(((Pp / 132) + v3{Time * -0.33f, 0, 0}) * 0.5f); + r32 NoiseC = Noise3D(((Pp / 164) + v3{Time * 0.25f, 0, 0}) * ScaleC); + NoiseC = PowR32(NoiseC, 3); + NoiseC = Smoothstep(NoiseC) * NoiseCP; + + v4 C = (C0 * NoiseA) + (C1 * NoiseB) + (C2 * NoiseC); + C /= (NoiseA + NoiseB + NoiseC); + return C; +} + +internal r32 +GenVerticalStrips(v3 P, r32 Time) +{ + v2 Right = v2{1, 0}; + v2 Pa = V2Normalize(v2{P.x, P.z}); + r32 Angle = .5f + (.5f * V2Dot(Pa, Right)); + + r32 HOffset = 70.0f; + r32 O = 50.0f; + r32 C = 10.0f; + + r32 X = Angle; + r32 Y = P.y; + r32 I = FloorR32(Y / C) * C; + I += (X * HOffset) + (Time * 25); + + r32 V = FractR32(I / O); + V = 2.0f * (0.5f - Abs(V - 0.5f)); + Assert(V >= 0 && V <= 1); + + return V; +} + +internal v4 +GenVerticalLeaves(v3 P, r32 Time, v4 C0, v4 C1, v4 C2) +{ + r32 A = GenVerticalStrips(P, Time * .25f); + r32 B = GenVerticalStrips(P * .3f, Time); + r32 C = GenVerticalStrips(P * .25f, Time * 2); + + v4 R = (C0 * A) + (C1 * B) + (C2 * C); + R /= A + B + C; + return R; +} + +internal void +AddIn_WavesPattern(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData, r32 Granularity, v4 C0, v4 C1, v4 C2) +{ + DEBUG_TRACK_FUNCTION; + + v4 C2P = C2 * 255; + + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + v3 P = Leds->Positions[LedIndex].xyz; + + v4 C = v4{ + (r32)Leds->Colors[LedIndex].R, + (r32)Leds->Colors[LedIndex].G, + (r32)Leds->Colors[LedIndex].B, + 1 + }; + + r32 Offset = -250; + r32 Width = 30; + r32 Bands = 0; + for (u32 i = 1; i <= 1; i++) + { + P.x = FloorR32(P.x); + P.z = FloorR32(P.z); + + v3 P0 = v3{P.x + (23.124f * i), 0, P.z - (-12.34f * i) + Time}; + r32 S = Fbm3D(P0 * .005f, Time) * 250; + S += ModR32((Time * 100) - (150 * i), 400); + + r32 Y = (P.y - Offset); + r32 V = (Width - Abs(Y - S)) / Width; + V = Clamp01(V); + + Bands += V; + } + + C = V4Lerp(Bands, C * .5f, C2P); + + Leds->Colors[LedIndex] = pixel{(u8)C.r, (u8)C.g, (u8)C.b}; + } +} + +internal r32 +GenDotBands(v3 P, r32 Time) +{ + r32 RowHeight = 25; + r32 DotRadius = 20; + + r32 Y = P.y + 150; + s32 Row = (s32)FloorR32(Y / RowHeight); + r32 RowH = Abs(FractR32(Y / RowHeight)); + r32 DotDistY = Max(0, .5f - RowH) * 2; + + r32 Angle = (V2Dot(V2Normalize(v2{P.x, P.z}), v2{1,0}) * .5f) + .5f; + r32 DotDistX = Abs(ModR32(Angle, .2f)); + + r32 DotDist = SqrtR32(PowR32(DotDistX, 2) + PowR32(RowH, 2)); + r32 B = (DotRadius - DotDist) / DotRadius; + B = Clamp01(DotDist); + + return DotDistY; + +} + +internal void +Pattern_VoicePattern(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + phrase_hue Hue = BlumenLumen_GetCurrentHue(BLState, Assembly); + v4 C0 = RGBFromPhraseHue(Hue.Hue0); + v4 C1 = RGBFromPhraseHue(Hue.Hue1); + v4 C2 = RGBFromPhraseHue(Hue.Hue2); + + Time = Time * BLState->PatternSpeed * Hue.Speed;; + + switch (Hue.Pattern) + { + case HuePattern_Wavy: + { + Pattern_WavyOptions(Leds, Range, Assembly, Time, Transient, UserData, Hue.Granularity, C0, C1, C0); + }break; + + default: + { + Pattern_PatchyOptions(Leds, Range, Assembly, Time, Transient, UserData, Hue.Granularity, C0, C1, C2); + }break; + } + + +} + +internal void +Pattern_VoiceAddIns(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + phrase_hue Hue = BlumenLumen_GetCurrentHue(BLState, Assembly); + v4 C0 = RGBFromPhraseHue(Hue.Hue0); + v4 C1 = RGBFromPhraseHue(Hue.Hue1); + v4 C2 = RGBFromPhraseHue(Hue.Hue2); + + Time = Time * BLState->PatternSpeed * Hue.Speed;; + + switch (Hue.AddIn) + { + case AddIn_Rotary: + { + Pattern_RotaryOptions(Leds, Range, Assembly, Time, Transient, UserData, Hue.Granularity, BlackV4, C2); + }break; + + case AddIn_Waves: + { + AddIn_WavesPattern(Leds, Range, Assembly, Time, Transient, UserData, Hue.Granularity, C0, C1, C2); + }break; + + case AddIn_None: + default: + { + }break; + } +} + +internal void +Pattern_StemSolid(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + + pixel WhiteMask = V4ToRGBPixel(WhiteV4); + + led_strip_list Stem = BLState->StemStrips[Assembly.AssemblyIndex]; + for (u32 s = 0; s < Stem.Count; s++) + { + u32 StripIndex = Stem.StripIndices[s]; + v2_strip Strip = Assembly.Strips[StripIndex]; + for (u32 i = 0; i < Strip.LedCount; i++) + { + u32 LedIndex = Strip.LedLUT[i]; + Leds->Colors[LedIndex] = WhiteMask; + } + } +} + +internal void +Pattern_PrimaryHue(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; + + phrase_hue Hue = BlumenLumen_GetCurrentHue(BLState, Assembly); + v4 C0 = RGBFromPhraseHue(Hue.Hue0); + v4 C1 = RGBFromPhraseHue(Hue.Hue1); + v4 C2 = RGBFromPhraseHue(Hue.Hue2); + + pixel HueOut = V4ToRGBPixel(C0); + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + Leds->Colors[LedIndex] = HueOut; + } +} + +internal void +Pattern_GrowFadeMask(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; + + r32 Period = 10.0f; // seconds + r32 ElapsedPct = FractR32(Time / Period); + + r32 ElapsedPctGrow = PowR32(ElapsedPct * 2, 2); + r32 ElapsedPctFade = Clamp01((ElapsedPct * 2) - 1); + + r32 Radius = 300 * ElapsedPctGrow; + + v3 Origin = Assembly.Center - v3{0, 150, 0}; + + r32 Brightness = Smoothstep(1.0f - ElapsedPctFade); + + pixel COutside = V4ToRGBPixel(BlackV4); + pixel CInside = V4ToRGBPixel(WhiteV4 * Brightness); + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + v3 P = Leds->Positions[LedIndex].xyz; + r32 Dist = V3Mag(P - Origin); + if (Dist < Radius) + { + Leds->Colors[LedIndex] = CInside; + } + else + { + Leds->Colors[LedIndex] = COutside; + } + } +} + +internal void +Pattern_RainbowLoadingBar(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + DEBUG_TRACK_FUNCTION; + + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; + Time = Time * BLState->PatternSpeed; + + // constants + r32 Period = 5.0f; // seconds + r32 CSpeed = 16.0f; + r32 HIncrement = CSpeed * Period; + r32 HOffset = CSpeed * Period; + r32 MaxSphereRadius = 300; + + // sphere + r32 ElapsedPct = FractR32(Time / Period); + r32 ElapsedPctGrow = PowR32(ElapsedPct, 2); + r32 Radius = MaxSphereRadius * ElapsedPctGrow; + v3 Origin = Assembly.Center - v3{0, 150, 0}; + + // colors + r32 T = Time * CSpeed; + r32 TimeStep0 = T; + r32 TimeStep1 = T + HOffset; + r32 Hue0 = FloorR32(TimeStep0 / HIncrement) * HIncrement; + r32 Hue1 = FloorR32(TimeStep1 / HIncrement) * HIncrement; + v4 H0 = v4{ModR32(Hue0, 360), 1, 1, 1}; + v4 H1 = v4{ModR32(Hue1, 360), 1, 1, 1}; + pixel C0 = V4ToRGBPixel(HSVToRGB(H0)); + pixel C1 = V4ToRGBPixel(HSVToRGB(H1)); + + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + v3 P = Leds->Positions[LedIndex].xyz; + r32 Dist = V3Mag(P - Origin); + if (Dist < Radius) + { + Leds->Colors[LedIndex] = C1; + } + else + { + Leds->Colors[LedIndex] = C0; + } + } +} + +internal void +Pattern_Blue(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData) +{ + pixel Blue = pixel{0, 0, 255}; + for (u32 LedIndex = Range.First; LedIndex < Range.OnePastLast; LedIndex++) + { + Leds->Colors[LedIndex] = Blue; + } +} + #define BLUMEN_PATTERNS_H #endif // BLUMEN_PATTERNS_H \ No newline at end of file diff --git a/src/app/platform_win32/win32_foldhaus.cpp b/src/app/platform_win32/win32_foldhaus.cpp index df968c8..d281552 100644 --- a/src/app/platform_win32/win32_foldhaus.cpp +++ b/src/app/platform_win32/win32_foldhaus.cpp @@ -332,8 +332,7 @@ DebugPrint (char* Format, ...) gs_string StringBuffer = MakeString(Buffer, 256); va_list Args; va_start(Args, Format); - PrintF(&StringBuffer, Format, Args); - OutputDebugStringA(Buffer); + Log_PrintFVarArgs(GlobalLogBuffer, LogEntry_Message, Format, Args); va_end(Args); } @@ -356,22 +355,6 @@ SetApplicationLinks (context* Context, win32_dll_refresh DLL, gs_work_queue* Wor } } -// TODO(Peter): :Redundant remove -internal u8* -DEBUGAlloc(s32 ElementSize, s32 ElementCount) -{ - return (u8*)Win32Alloc(ElementSize * ElementCount, 0); -} - -// TODO(Peter): :Redundant remove -internal u8* -Win32Realloc(u8* Buf, s32 OldSize, s32 NewSize) -{ - u8* NewMemory = (u8*)Win32Alloc(NewSize, 0); - CopyMemoryTo(Buf, NewMemory, OldSize); - return NewMemory; -} - internal void Win32_SendAddressedDataBuffer(gs_thread_context Context, addressed_data_buffer* BufferAt) { @@ -396,7 +379,7 @@ Win32_SendAddressedDataBuffer(gs_thread_context Context, addressed_data_buffer* { if (BufferAt->ComPort.Length > 0) { - HANDLE SerialPort = Win32SerialArray_GetOrOpen(BufferAt->ComPort, 2000000, 8, NOPARITY, 1); + HANDLE SerialPort = Win32SerialArray_GetOrOpen(BufferAt->ComPort, 2000000, 8, NOPARITY, 1, Context.Transient); if (SerialPort != INVALID_HANDLE_VALUE) { if (Win32SerialPort_Write(SerialPort, BufferAt->Data)) @@ -413,7 +396,8 @@ Win32_SendAddressedDataBuffer(gs_thread_context Context, addressed_data_buffer* else { #if 0 - OutputDebugStringA("Skipping data buffer because its COM Port isn't set"); + Log_Message(GlobalLogBuffer, + "Skipping data buffer because its COM Port isn't set"); #endif } }break; @@ -430,18 +414,19 @@ Win32_SendAddressedDataBuffer_Job(gs_thread_context Context, gs_data Arg) } internal bool -ReloadAndLinkDLL(win32_dll_refresh* DLL, context* Context, gs_work_queue* WorkQueue, bool ShouldError) +ReloadAndLinkDLL(win32_dll_refresh* DLL, context* Context, gs_work_queue* WorkQueue, bool ShouldError, bool AppReady) { bool Success = false; if (HotLoadDLL(DLL)) { SetApplicationLinks(Context, *DLL, WorkQueue); - Context->ReloadStaticData(*Context, GlobalDebugServices); + Context->ReloadStaticData(*Context, GlobalDebugServices, GlobalLogBuffer, AppReady); Success = true; + Log_Message(GlobalLogBuffer, "Reloaded DLL\n"); } else if(ShouldError) { - OutputDebugStringA("Unable to load application DLL at startup.\nAborting\n"); + Log_Error(GlobalLogBuffer, "Unable to load application DLL at startup.\nAborting\n"); } return Success; } @@ -505,9 +490,9 @@ SetWorkingDirectory(HINSTANCE HInstance, gs_thread_context ThreadContext) if (WorkingDirectory.Length > 0) { - OutputDebugStringA("Setting Working Directory\n"); - OutputDebugStringA(WorkingDirectory.Str); - + Log_Message(GlobalLogBuffer, + "Setting Working Directory \n%S \n", + WorkingDirectory.ConstString); Result = SetCurrentDirectory(WorkingDirectory.Str); if (!Result) { @@ -517,7 +502,75 @@ SetWorkingDirectory(HINSTANCE HInstance, gs_thread_context ThreadContext) } else { - OutputDebugStringA("Error, no data folder found\n"); + Log_Error(GlobalLogBuffer, "Error, no data folder found\n"); + } + + return Result; +} + +#include "../../gs_libs/gs_path.h" + +internal void +Win32_SendOutputData(gs_thread_context ThreadContext, addressed_data_buffer_list OutputData) +{ + bool Multithread = true; + if (Multithread) + { + for (addressed_data_buffer* At = OutputData.Root; + At != 0; + At = At->Next) + { + gs_data ProcArg = {}; + ProcArg.Memory = (u8*)At; + ProcArg.Size = sizeof(addressed_data_buffer); + Win32PushWorkOnQueue(&Win32WorkQueue.WorkQueue, Win32_SendAddressedDataBuffer_Job, ProcArg, ConstString("Send UART Data")); + } + } + else + { + for (addressed_data_buffer* At = OutputData.Root; + At != 0; + At = At->Next) + { + gs_data ProcArg = {}; + ProcArg.Memory = (u8*)At; + ProcArg.Size = sizeof(addressed_data_buffer); + Win32_SendAddressedDataBuffer_Job(ThreadContext, ProcArg); + } + } + +} + +// Time +internal system_time +Win32GetSystemTime() +{ + system_time Result = {}; + + SYSTEMTIME WinLocalTime; + GetLocalTime(&WinLocalTime); + + SYSTEMTIME WinSysTime; + FILETIME WinSysFileTime; + GetSystemTime(&WinSysTime); + if (SystemTimeToFileTime((const SYSTEMTIME*)&WinSysTime, &WinSysFileTime)) + { + ULARGE_INTEGER SysTime = {}; + SysTime.LowPart = WinSysFileTime.dwLowDateTime; + SysTime.HighPart = WinSysFileTime.dwHighDateTime; + + Result.NanosSinceEpoch = SysTime.QuadPart; + Result.Year = WinLocalTime.wYear; + Result.Month = WinLocalTime.wMonth; + Result.Day = WinLocalTime.wDay; + Result.Hour = WinLocalTime.wHour; + Result.Minute = WinLocalTime.wMinute; + Result.Second = WinLocalTime.wSecond; + } + else + { + u32 Error = GetLastError(); + InvalidCodePath; } return Result; @@ -533,37 +586,61 @@ WinMain ( { gs_thread_context ThreadContext = Win32CreateThreadContext(); + gs_memory_arena PlatformPermanent = MemoryArenaCreate(MB(4), + Bytes(8), ThreadContext.Allocator, + 0, + 0, + "Platform Memory"); + + GlobalLogBuffer = AllocStruct(ThreadContext.Allocator, log_buffer, "Global Log Buffer"); + *GlobalLogBuffer = Log_Init(&PlatformPermanent, 32); + if (!SetWorkingDirectory(HInstance, ThreadContext)) return 1; - MainWindow = Win32CreateWindow (HInstance, "Foldhaus", 1440, 768, HandleWindowEvents); - Win32UpdateWindowDimension(&MainWindow); - - win32_opengl_window_info OpenGLWindowInfo = {}; - OpenGLWindowInfo.ColorBits = 32; - OpenGLWindowInfo.AlphaBits = 8; - OpenGLWindowInfo.DepthBits = 0; - CreateOpenGLWindowContext(OpenGLWindowInfo, &MainWindow); - context Context = {}; Context.ThreadContext = ThreadContext; - Context.MemorySize = MB(64); - Context.MemoryBase = (u8*)Win32Alloc(Context.MemorySize, 0); + Context.SystemTime_Current = Win32GetSystemTime(); - gs_memory_arena PlatformPermanent = CreateMemoryArena(Context.ThreadContext.Allocator); + gs_const_string Args = ConstString((char*)CmdLineArgs); + if (StringsEqual(Args, ConstString("-headless"))) + { + Log_Message(GlobalLogBuffer, "Running Headless\n"); + Context.Headless = true; + } + + if (!Context.Headless) + { + MainWindow = Win32CreateWindow (HInstance, "Foldhaus", 1440, 768, HandleWindowEvents); + Win32UpdateWindowDimension(&MainWindow); + + win32_opengl_window_info OpenGLWindowInfo = {}; + OpenGLWindowInfo.ColorBits = 32; + OpenGLWindowInfo.AlphaBits = 8; + OpenGLWindowInfo.DepthBits = 0; + CreateOpenGLWindowContext(OpenGLWindowInfo, &MainWindow); + } s64 PerformanceCountFrequency = GetPerformanceFrequency(); s64 LastFrameEnd = GetWallClock(); - r32 TargetSecondsPerFrame = 1 / 60.0f; + r32 TargetSecondsPerFrame = 1 / 30.0f; r32 LastFrameSecondsElapsed = 0.0f; GlobalDebugServices = PushStruct(&PlatformPermanent, debug_services); - InitDebugServices(GlobalDebugServices, - PerformanceCountFrequency, - DEBUGAlloc, - Win32Realloc, - GetWallClock, - Win32GetThreadId, - PLATFORM_THREAD_COUNT + 1); +#if DEBUG + InitDebugServices_DebugMode(GlobalDebugServices, + PerformanceCountFrequency, + GetWallClock, + Win32GetThreadId, + Context.ThreadContext, + PLATFORM_THREAD_COUNT + 1); +#else + InitDebugServices_OffMode(GlobalDebugServices, + PerformanceCountFrequency, + GetWallClock, + Win32GetThreadId, + Context.ThreadContext, + PLATFORM_THREAD_COUNT + 1); +#endif input_queue InputQueue = InputQueue_Create(&PlatformPermanent, 32); @@ -583,19 +660,25 @@ WinMain ( *Context.SocketManager = CreatePlatformSocketManager(Win32ConnectSocket, Win32CloseSocket, Win32SocketQueryStatus, Win32SocketPeek, Win32SocketReceive, Win32SocketSend); win32_dll_refresh DLLRefresh = InitializeDLLHotReloading(DLLName, WorkingDLLName, DLLLockFileName); - if (!ReloadAndLinkDLL(&DLLRefresh, &Context, &Win32WorkQueue.WorkQueue, true)) { return -1; } + if (!ReloadAndLinkDLL(&DLLRefresh, &Context, &Win32WorkQueue.WorkQueue, true, false)) { return -1; } Mouse_Init(); Win32SocketSystem_Init(&PlatformPermanent); - Win32SerialArray_Create(ThreadContext); + Win32SerialArray_Create(&PlatformPermanent); - render_command_buffer RenderBuffer = AllocateRenderCommandBuffer(MB(12), &PlatformPermanent, Win32Realloc); + render_command_buffer RenderBuffer = {}; + if (!Context.Headless) + { + RenderBuffer = AllocateRenderCommandBuffer(MB(12), &PlatformPermanent, ThreadContext); + } addressed_data_buffer_list OutputData = AddressedDataBufferList_Create(ThreadContext); - Context.InitializeApplication(Context); + Context.InitializeApplication(&Context); + + system_time StartTime = Win32GetSystemTime(); Running = true; Context.WindowIsVisible = true; @@ -605,64 +688,72 @@ WinMain ( { EndDebugFrame(GlobalDebugServices); } + DEBUG_TRACK_SCOPE(MainLoop); + { + Context.SystemTime_Last = Context.SystemTime_Current; + Context.SystemTime_Current = Win32GetSystemTime(); + +#define PRINT_SYSTEM_TIME 0 +#if PRINT_SYSTEM_TIME + gs_string T = PushStringF(Context.ThreadContext.Transient, + 256, + "%d %d %d - %lld\n", + Context.SystemTime_Current.Hour, + Context.SystemTime_Current.Minute, + Context.SystemTime_Current.Second, + Context.SystemTime_Current.NanosSinceEpoch); + + u64 NanosElapsed = Context.SystemTime_Current.NanosSinceEpoch - StartTime.NanosSinceEpoch; + r64 SecondsElapsed = (r64)NanosElapsed * NanosToSeconds; + + Log_Message(GlobalLogBuffer, + "%lld %f Seconds \n", + NanosElapsed, + SecondsElapsed); +#endif + } + ResetInputQueue(&InputQueue); - ReloadAndLinkDLL(&DLLRefresh, &Context, &Win32WorkQueue.WorkQueue, false); + ReloadAndLinkDLL(&DLLRefresh, &Context, &Win32WorkQueue.WorkQueue, false, true); AddressedDataBufferList_Clear(&OutputData); - Mouse_Update(MainWindow, &Context); - - MSG Message; - while (PeekMessageA(&Message, MainWindow.Handle, 0, 0, PM_REMOVE)) + if (!Context.Headless) { - DEBUG_TRACK_SCOPE(PeekWindowsMessages); - HandleWindowMessage(Message, &MainWindow, &InputQueue, &Context.Mouse); + Mouse_Update(MainWindow, &Context); + MSG Message; + while (PeekMessageA(&Message, MainWindow.Handle, 0, 0, PM_REMOVE)) + { + DEBUG_TRACK_SCOPE(PeekWindowsMessages); + HandleWindowMessage(Message, &MainWindow, &InputQueue, &Context.Mouse); + } + + Context.WindowBounds = rect2{v2{0, 0}, v2{(r32)MainWindow.Width, (r32)MainWindow.Height}}; + RenderBuffer.ViewWidth = MainWindow.Width; + RenderBuffer.ViewHeight = MainWindow.Height; } - Context.WindowBounds = rect2{v2{0, 0}, v2{(r32)MainWindow.Width, (r32)MainWindow.Height}}; - RenderBuffer.ViewWidth = MainWindow.Width; - RenderBuffer.ViewHeight = MainWindow.Height; Context.DeltaTime = LastFrameSecondsElapsed; + Context.TotalTime += (r64)Context.DeltaTime; Context.UpdateAndRender(&Context, InputQueue, &RenderBuffer, &OutputData); - bool Multithread = false; - if (Multithread) + Win32_SendOutputData(ThreadContext, OutputData); + + if (!Context.Headless) { - for (addressed_data_buffer* At = OutputData.Root; - At != 0; - At = At->Next) - { - gs_data ProcArg = {}; - ProcArg.Memory = (u8*)At; - ProcArg.Size = sizeof(addressed_data_buffer); - Win32PushWorkOnQueue(&Win32WorkQueue.WorkQueue, Win32_SendAddressedDataBuffer_Job, ProcArg, ConstString("Send UART Data")); - } + RenderCommandBuffer(RenderBuffer); + ClearRenderBuffer(&RenderBuffer); + + Mouse_Advance(&Context); + + HDC DeviceContext = GetDC(MainWindow.Handle); + SwapBuffers(DeviceContext); + ReleaseDC(MainWindow.Handle, DeviceContext); } - else - { - for (addressed_data_buffer* At = OutputData.Root; - At != 0; - At = At->Next) - { - gs_data ProcArg = {}; - ProcArg.Memory = (u8*)At; - ProcArg.Size = sizeof(addressed_data_buffer); - Win32_SendAddressedDataBuffer_Job(ThreadContext, ProcArg); - } - } - - RenderCommandBuffer(RenderBuffer); - ClearRenderBuffer(&RenderBuffer); - - Mouse_Advance(&Context); - - HDC DeviceContext = GetDC(MainWindow.Handle); - SwapBuffers(DeviceContext); - ReleaseDC(MainWindow.Handle, DeviceContext); Win32DoQueueWorkUntilDone(&Win32WorkQueue.WorkQueue, Context.ThreadContext); @@ -681,11 +772,11 @@ WinMain ( LastFrameEnd = GetWallClock(); } - Context.CleanupApplication(Context); + Context.CleanupApplication(Context, &OutputData); + Win32_SendOutputData(ThreadContext, OutputData); + Win32DoQueueWorkUntilDone(&Win32WorkQueue.WorkQueue, Context.ThreadContext); Win32WorkQueue_Cleanup(); - //Win32_TestCode_SocketReading_Cleanup(); - Win32SocketSystem_Cleanup(); return 0; diff --git a/src/app/platform_win32/win32_foldhaus_dll.h b/src/app/platform_win32/win32_foldhaus_dll.h index 26071e6..396f15e 100644 --- a/src/app/platform_win32/win32_foldhaus_dll.h +++ b/src/app/platform_win32/win32_foldhaus_dll.h @@ -11,92 +11,92 @@ // DLL struct win32_dll_refresh { - FILETIME LastWriteTime; - HMODULE DLL; - - bool IsValid; - - char SourceDLLPath[MAX_PATH]; - char WorkingDLLPath[MAX_PATH]; - char LockFilePath[MAX_PATH]; + FILETIME LastWriteTime; + HMODULE DLL; + + bool IsValid; + + char SourceDLLPath[MAX_PATH]; + char WorkingDLLPath[MAX_PATH]; + char LockFilePath[MAX_PATH]; }; internal int Win32DLLgs_stringLength(char* gs_string) { - char* At = gs_string; - while (*At) { At++; }; - return At - gs_string; + char* At = gs_string; + while (*At) { At++; }; + return At - gs_string; } internal int Win32DLLConcatgs_strings(int ALength, char* A, int BLength, char* B, int DestLength, char* Dest) { - char* Dst = Dest; - char* AAt = A; - int ALengthToCopy = ALength < DestLength ? ALength : DestLength; - for (s32 a = 0; a < ALength; a++) - { - *Dst++ = *AAt++; - } - char* BAt = B; - int DestLengthRemaining = DestLength - (Dst - Dest); - int BLengthToCopy = BLength < DestLengthRemaining ? BLength : DestLength; - for (s32 b = 0; b < BLengthToCopy; b++) - { - *Dst++ = *BAt++; - } - int DestLengthOut = Dst - Dest; - int NullTermIndex = DestLengthOut < DestLength ? DestLengthOut : DestLength; - Dest[NullTermIndex] = 0; - return DestLengthOut; + char* Dst = Dest; + char* AAt = A; + int ALengthToCopy = ALength < DestLength ? ALength : DestLength; + for (s32 a = 0; a < ALength; a++) + { + *Dst++ = *AAt++; + } + char* BAt = B; + int DestLengthRemaining = DestLength - (Dst - Dest); + int BLengthToCopy = BLength < DestLengthRemaining ? BLength : DestLength; + for (s32 b = 0; b < BLengthToCopy; b++) + { + *Dst++ = *BAt++; + } + int DestLengthOut = Dst - Dest; + int NullTermIndex = DestLengthOut < DestLength ? DestLengthOut : DestLength; + Dest[NullTermIndex] = 0; + return DestLengthOut; } internal void GetApplicationPath(system_path* Result) { - Assert(Result->Path); - Result->PathLength = GetModuleFileNameA(0, Result->Path, Result->PathLength); - - u32 CharactersScanned = 0; - u32 IndexOfLastSlash = 0; - char *Scan = Result->Path; - while(*Scan) + Assert(Result->Path); + Result->PathLength = GetModuleFileNameA(0, Result->Path, Result->PathLength); + + u32 CharactersScanned = 0; + u32 IndexOfLastSlash = 0; + char *Scan = Result->Path; + while(*Scan) + { + if (*Scan == '\\') { - if (*Scan == '\\') - { - Result->IndexOfLastSlash = CharactersScanned + 1; - } - Scan++; - CharactersScanned++; + Result->IndexOfLastSlash = CharactersScanned + 1; } + Scan++; + CharactersScanned++; + } } internal b32 LoadApplicationDLL(char* DLLName, win32_dll_refresh* DLLResult) { - b32 Success = false; - Assert(DLLResult->DLL == 0); - - DLLResult->DLL = LoadLibraryA(DLLName); - if (DLLResult->DLL) - { - Success = true; - DLLResult->IsValid = true; - } - - return Success; + b32 Success = false; + Assert(DLLResult->DLL == 0); + + DLLResult->DLL = LoadLibraryA(DLLName); + if (DLLResult->DLL) + { + Success = true; + DLLResult->IsValid = true; + } + + return Success; } internal void UnloadApplicationDLL(win32_dll_refresh* DLL) { - if (DLL->DLL) - { - FreeLibrary(DLL->DLL); - } - DLL->DLL = 0; - DLL->IsValid = false; + if (DLL->DLL) + { + FreeLibrary(DLL->DLL); + } + DLL->DLL = 0; + DLL->IsValid = false; } internal win32_dll_refresh @@ -104,57 +104,57 @@ InitializeDLLHotReloading(char* SourceDLLName, char* WorkingDLLFileName, char* LockFileName) { - win32_dll_refresh Result = {}; - Result.IsValid = false; - - system_path ExePath = {}; - ExePath.PathLength = MAX_PATH; - ExePath.Path = (char*)VirtualAlloc(NULL, ExePath.PathLength, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); - GetApplicationPath(&ExePath); - - Win32DLLConcatgs_strings(ExePath.IndexOfLastSlash, ExePath.Path, - Win32DLLgs_stringLength(SourceDLLName), SourceDLLName, - MAX_PATH, Result.SourceDLLPath); - Win32DLLConcatgs_strings(ExePath.IndexOfLastSlash, ExePath.Path, - Win32DLLgs_stringLength(WorkingDLLFileName), WorkingDLLFileName, - MAX_PATH, Result.WorkingDLLPath); - Win32DLLConcatgs_strings(ExePath.IndexOfLastSlash, ExePath.Path, - Win32DLLgs_stringLength(LockFileName), LockFileName, - MAX_PATH, Result.LockFilePath); - - Win32Free((u8*)ExePath.Path, ExePath.PathLength); - return Result; - + win32_dll_refresh Result = {}; + Result.IsValid = false; + + system_path ExePath = {}; + ExePath.PathLength = MAX_PATH; + ExePath.Path = (char*)VirtualAlloc(NULL, ExePath.PathLength, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); + GetApplicationPath(&ExePath); + + Win32DLLConcatgs_strings(ExePath.IndexOfLastSlash, ExePath.Path, + Win32DLLgs_stringLength(SourceDLLName), SourceDLLName, + MAX_PATH, Result.SourceDLLPath); + Win32DLLConcatgs_strings(ExePath.IndexOfLastSlash, ExePath.Path, + Win32DLLgs_stringLength(WorkingDLLFileName), WorkingDLLFileName, + MAX_PATH, Result.WorkingDLLPath); + Win32DLLConcatgs_strings(ExePath.IndexOfLastSlash, ExePath.Path, + Win32DLLgs_stringLength(LockFileName), LockFileName, + MAX_PATH, Result.LockFilePath); + + Win32Free((u8*)ExePath.Path, ExePath.PathLength, 0); + return Result; + } internal b32 HotLoadDLL(win32_dll_refresh* DLL) { - b32 DidReload = false; - - FILETIME UpdatedLastWriteTime = {}; - WIN32_FIND_DATA FindData = {}; - HANDLE FileHandle = FindFirstFileA(DLL->SourceDLLPath, &FindData); - if (FileHandle != INVALID_HANDLE_VALUE) + b32 DidReload = false; + + FILETIME UpdatedLastWriteTime = {}; + WIN32_FIND_DATA FindData = {}; + HANDLE FileHandle = FindFirstFileA(DLL->SourceDLLPath, &FindData); + if (FileHandle != INVALID_HANDLE_VALUE) + { + UpdatedLastWriteTime = FindData.ftLastWriteTime; + FindClose(FileHandle); + } + + if (CompareFileTime(&UpdatedLastWriteTime, &DLL->LastWriteTime)) + { + WIN32_FILE_ATTRIBUTE_DATA Ignored; + if (!GetFileAttributesEx(DLL->LockFilePath, GetFileExInfoStandard, &Ignored)) { - UpdatedLastWriteTime = FindData.ftLastWriteTime; - FindClose(FileHandle); + UnloadApplicationDLL(DLL); + CopyFileA(DLL->SourceDLLPath, DLL->WorkingDLLPath, FALSE); + LoadApplicationDLL(DLL->WorkingDLLPath, DLL); + DLL->LastWriteTime = UpdatedLastWriteTime; + DidReload = true; } - - if (CompareFileTime(&UpdatedLastWriteTime, &DLL->LastWriteTime)) - { - WIN32_FILE_ATTRIBUTE_DATA Ignored; - if (!GetFileAttributesEx(DLL->LockFilePath, GetFileExInfoStandard, &Ignored)) - { - UnloadApplicationDLL(DLL); - CopyFileA(DLL->SourceDLLPath, DLL->WorkingDLLPath, FALSE); - LoadApplicationDLL(DLL->WorkingDLLPath, DLL); - DLL->LastWriteTime = UpdatedLastWriteTime; - DidReload = true; - } - } - - return DidReload; + } + + return DidReload; } diff --git a/src/app/platform_win32/win32_foldhaus_fileio.h b/src/app/platform_win32/win32_foldhaus_fileio.h index 95163ea..906d947 100644 --- a/src/app/platform_win32/win32_foldhaus_fileio.h +++ b/src/app/platform_win32/win32_foldhaus_fileio.h @@ -11,258 +11,272 @@ internal u64 Win32HighLowToU64(u32 LowPart, u32 HighPart) { - ULARGE_INTEGER Time = {}; - Time.LowPart = LowPart; - Time.HighPart = HighPart; - u64 Result = Time.QuadPart; - return Result; + ULARGE_INTEGER Time = {}; + Time.LowPart = LowPart; + Time.HighPart = HighPart; + u64 Result = Time.QuadPart; + return Result; } internal u64 Win32FileTimeToU64(FILETIME FileTime) { - u64 Result = Win32HighLowToU64(FileTime.dwLowDateTime, FileTime.dwHighDateTime); - return Result; + u64 Result = Win32HighLowToU64(FileTime.dwLowDateTime, FileTime.dwHighDateTime); + return Result; } GET_FILE_INFO(Win32GetFileInfo) { - Assert(IsNullTerminated(Path)); - gs_file_info Result = {}; - HANDLE FileHandle = CreateFileA(Path.Str, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (FileHandle != INVALID_HANDLE_VALUE) + Assert(IsNullTerminated(Path)); + gs_file_info Result = {}; + HANDLE FileHandle = CreateFileA(Path.Str, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (FileHandle != INVALID_HANDLE_VALUE) + { + Result.Path = Path; + Result.FileSize = (u64)GetFileSize(FileHandle, NULL) + 1; + FILETIME CreationTime, LastWriteTime; + if (GetFileTime(FileHandle, &CreationTime, (LPFILETIME)0, &LastWriteTime)) { - Result.Path = Path; - Result.FileSize = (u64)GetFileSize(FileHandle, NULL) + 1; - FILETIME CreationTime, LastWriteTime; - if (GetFileTime(FileHandle, &CreationTime, (LPFILETIME)0, &LastWriteTime)) - { - Result.CreationTime = Win32FileTimeToU64(CreationTime); - Result.LastWriteTime = Win32FileTimeToU64(LastWriteTime); - } - else - { - PrintLastError(); - } - CloseHandle(FileHandle); + Result.CreationTime = Win32FileTimeToU64(CreationTime); + Result.LastWriteTime = Win32FileTimeToU64(LastWriteTime); } else { - DWORD FileAttr = GetFileAttributes(Path.Str); - if (FileAttr != INVALID_FILE_ATTRIBUTES && - (FileAttr & FILE_ATTRIBUTE_DIRECTORY)) - { - Result.Path = Path; - Result.IsDirectory = true; - } - else - { - // Path is not a file or directory - } + PrintLastError(); } - return Result; + CloseHandle(FileHandle); + } + else + { + DWORD FileAttr = GetFileAttributes(Path.Str); + if (FileAttr != INVALID_FILE_ATTRIBUTES && + (FileAttr & FILE_ATTRIBUTE_DIRECTORY)) + { + Result.Path = Path; + Result.IsDirectory = true; + } + else + { + // Path is not a file or directory + } + } + return Result; } READ_ENTIRE_FILE(Win32ReadEntireFile) { - Assert(DataIsNonEmpty(Memory)); - Assert(IsNullTerminated(Path)); - - gs_file Result = {0}; - u32 Error = 0; - Result.FileInfo.Path = Path; - - HANDLE FileHandle = CreateFileA(Path.Str, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (FileHandle != INVALID_HANDLE_VALUE) + Assert(DataIsNonEmpty(Memory)); + Assert(IsNullTerminated(Path)); + + gs_file Result = {0}; + u32 Error = 0; + Result.FileInfo.Path = Path; + + HANDLE FileHandle = CreateFileA(Path.Str, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (FileHandle != INVALID_HANDLE_VALUE) + { + DWORD BytesRead = 0; + if (ReadFile(FileHandle, (LPVOID)Memory.Memory, Memory.Size - 1, (LPDWORD)(&BytesRead), NULL)) { - DWORD BytesRead = 0; - if (ReadFile(FileHandle, (LPVOID)Memory.Memory, Memory.Size - 1, (LPDWORD)(&BytesRead), NULL)) - { - Memory.Memory[Memory.Size - 1] = 0; - Result.Data = Memory; - - gs_string AbsolutePath = PushString(FileHandler.Transient, 512); - AbsolutePath.Length = GetFullPathNameA(Path.Str, AbsolutePath.Size, AbsolutePath.Str, NULL); - if (AbsolutePath.Length == 0) - { - Error = GetLastError(); - InvalidCodePath; - } - Result.FileInfo.AbsolutePath = AbsolutePath.ConstString; - } - else - { - // NOTE(Peter): If we get to this error case, it means that the file exists, - // and was successfully opened, but we can't read from it. I'm choosing to - // treat this as a legitimate error at this point. - gs_string Message = Win32DumpErrorAndPrepareMessageBoxString(FileHandler.Transient, "Attempting to read file: %S", Path); - if (MessageBox(NULL, Message.Str, "Error", MB_OK) == IDOK) - { - PostQuitMessage(-1); - } - } - CloseHandle(FileHandle); + Memory.Memory[Memory.Size - 1] = 0; + Result.Data = Memory; + + gs_string AbsolutePath = PushString(FileHandler.Transient, 512); + AbsolutePath.Length = GetFullPathNameA(Path.Str, AbsolutePath.Size, AbsolutePath.Str, NULL); + if (AbsolutePath.Length == 0) + { + Error = GetLastError(); + InvalidCodePath; + } + Result.FileInfo.AbsolutePath = AbsolutePath.ConstString; } else { - + // NOTE(Peter): If we get to this error case, it means that the file exists, + // and was successfully opened, but we can't read from it. I'm choosing to + // treat this as a legitimate error at this point. + gs_string Message = Win32DumpErrorAndPrepareMessageBoxString(FileHandler.Transient, "Attempting to read file: %S", Path); + if (MessageBox(NULL, Message.Str, "Error", MB_OK) == IDOK) + { + PostQuitMessage(-1); + } } + CloseHandle(FileHandle); + } + else + { - return Result; + } + + return Result; } WRITE_ENTIRE_FILE(Win32WriteEntireFile) { - Assert(DataIsNonEmpty(Data)); - Assert(IsNullTerminated(Path)); - - bool Success = false; - HANDLE FileHandle = CreateFileA(Path.Str, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (FileHandle != INVALID_HANDLE_VALUE) + Assert(DataIsNonEmpty(Data)); + Assert(IsNullTerminated(Path)); + + bool Success = false; + HANDLE FileHandle = CreateFileA(Path.Str, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (FileHandle != INVALID_HANDLE_VALUE) + { + DWORD BytesWritten = 0; + if (WriteFile(FileHandle, Data.Memory, Data.Size, &BytesWritten, NULL)) { - DWORD BytesWritten = 0; - if (WriteFile(FileHandle, Data.Memory, Data.Size, &BytesWritten, NULL)) - { - Success = (BytesWritten == Data.Size); - } - else - { - gs_string Message = Win32DumpErrorAndPrepareMessageBoxString(FileHandler.Transient, "Attempting to write to file: %S", Path); - MessageBox(NULL, Message.Str, "Error", MB_OK); - } - CloseHandle(FileHandle); + Success = (BytesWritten == Data.Size); } else { - + gs_string Message = Win32DumpErrorAndPrepareMessageBoxString(FileHandler.Transient, "Attempting to write to file: %S", Path); + MessageBox(NULL, Message.Str, "Error", MB_OK); } + CloseHandle(FileHandle); + } + else + { - return Success; + } + + return Success; } internal FILETIME GetFileLastWriteTime(char* Path) { - FILETIME Result = {}; - - WIN32_FIND_DATA FindData = {}; - HANDLE FileHandle = FindFirstFileA(Path, &FindData); - - if (FileHandle != INVALID_HANDLE_VALUE) - { - Result = FindData.ftLastWriteTime; - FindClose(FileHandle); - } - else - { - // TODO(Peter): :ErrorLogging - } - - return Result; + FILETIME Result = {}; + + WIN32_FIND_DATA FindData = {}; + HANDLE FileHandle = FindFirstFileA(Path, &FindData); + + if (FileHandle != INVALID_HANDLE_VALUE) + { + Result = FindData.ftLastWriteTime; + FindClose(FileHandle); + } + else + { + // TODO(Peter): :ErrorLogging + } + + return Result; } struct temp_file_list_entry { - gs_file_info Info; - temp_file_list_entry* Next; + gs_file_info Info; + temp_file_list_entry* Next; }; struct temp_file_list { - temp_file_list_entry* First; - temp_file_list_entry* Last; + temp_file_list_entry* First; + temp_file_list_entry* Last; }; internal void Win32SetFileInfoFromFindFileData(gs_file_info* Info, WIN32_FIND_DATA FindFileData, gs_const_string SearchPath, gs_memory_arena* Storage) { - u32 FileNameLength = CharArrayLength(FindFileData.cFileName); - - // NOTE(Peter): String Storage - // Storing the string in the final storage means we don't have to copy the string later, and all - // strings will be continguous in memory at the calling site, though they will be before the array - gs_string FileName = PushString(Storage, SearchPath.Length + FileNameLength + 1); - PrintF(&FileName, "%S%.*s", SearchPath, FileName.Size, FindFileData.cFileName); - NullTerminate(&FileName); - - Info->FileSize = Win32HighLowToU64(FindFileData.nFileSizeLow, FindFileData.nFileSizeHigh); - Info->CreationTime = Win32FileTimeToU64(FindFileData.ftCreationTime); - Info->LastWriteTime = Win32FileTimeToU64(FindFileData.ftLastWriteTime); - Info->Path = FileName.ConstString; - Info->IsDirectory = HasFlag(FindFileData.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY); + u32 FileNameLength = CharArrayLength(FindFileData.cFileName); + + Info->FileSize = Win32HighLowToU64(FindFileData.nFileSizeLow, FindFileData.nFileSizeHigh); + Info->CreationTime = Win32FileTimeToU64(FindFileData.ftCreationTime); + Info->LastWriteTime = Win32FileTimeToU64(FindFileData.ftLastWriteTime); + Info->IsDirectory = HasFlag(FindFileData.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY); + + // NOTE(Peter): String Storage + // Storing the string in the final storage means we don't have to copy the string later, and all + // strings will be continguous in memory at the calling site, though they will be before the array + gs_string FileName = PushString(Storage, SearchPath.Length + FileNameLength + 2); + PrintF(&FileName, "%S%.*s", SearchPath, FileName.Size, FindFileData.cFileName); + if (Info->IsDirectory) + { + AppendPrintF(&FileName, "\\"); + } + NullTerminate(&FileName); + + Info->Path = FileName.ConstString; } internal u32 Win32EnumerateDirectoryIntoTempList(gs_file_handler FileHandler, temp_file_list* TempList, gs_const_string Path, gs_memory_arena* Storage, b32 Flags) { - u32 FilesCount = 0; - - s64 IndexOfLastSlash = FindLastFromSet(Path, "\\/"); - Assert(IndexOfLastSlash >= 0); - gs_const_string SearchPath = Substring(Path, 0, IndexOfLastSlash + 1); - - WIN32_FIND_DATA FindFileData; - HANDLE SearchHandle = FindFirstFile(Path.Str, &FindFileData); - if (SearchHandle != INVALID_HANDLE_VALUE) + u32 FilesCount = 0; + Assert(Path.Str[Path.Length - 1] != '\\' && + Path.Str[Path.Length - 1] != '/'); + gs_const_string SearchPath = Path; + + gs_const_string SearchPathDir = SearchPath; + s64 LastSlash = FindLastFromSet(SearchPath, "\\/"); + if (LastSlash >= 0) + { + SearchPathDir = Substring(SearchPath, 0, LastSlash + 1); + } + + WIN32_FIND_DATA FindFileData; + HANDLE SearchHandle = FindFirstFile(Path.Str, &FindFileData); + if (SearchHandle != INVALID_HANDLE_VALUE) + { + do { - do + b32 AddFile = true; + + if (HasFlag(FindFileData.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY)) + { + gs_const_string SubDirName = ConstString(FindFileData.cFileName); + bool IsNav = (StringsEqual(SubDirName, ConstString(".")) || + StringsEqual(SubDirName, ConstString(".."))); + + if (HasFlag(Flags, EnumerateDirectory_Recurse)) { - b32 AddFile = true; - - if (HasFlag(FindFileData.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY)) - { - if (HasFlag(Flags, EnumerateDirectory_Recurse)) - { - gs_const_string SubDirName = ConstString(FindFileData.cFileName); - if (!StringsEqual(SubDirName, ConstString(".")) && - !StringsEqual(SubDirName, ConstString(".."))) - { - gs_string SubDirectoryPath = PushString(FileHandler.Transient, SearchPath.Length + SubDirName.Length + 3); - PrintF(&SubDirectoryPath, "%S%S/*\0", SearchPath, SubDirName); - FilesCount += Win32EnumerateDirectoryIntoTempList(FileHandler, TempList, SubDirectoryPath.ConstString, Storage, Flags); - } - } - - AddFile = HasFlag(Flags, EnumerateDirectory_IncludeDirectories); - } - - if (AddFile) - { - temp_file_list_entry* File = PushStruct(FileHandler.Transient, temp_file_list_entry); - *File = {0}; - Win32SetFileInfoFromFindFileData(&File->Info, FindFileData, SearchPath, Storage); - SLLPushOrInit(TempList->First, TempList->Last, File); - FilesCount += 1; - } - }while(FindNextFile(SearchHandle, &FindFileData)); - } - else - { - PrintLastError(); - } - - return FilesCount; + if (!IsNav) + { + gs_string SubDirectoryPath = PushString(FileHandler.Transient, SearchPath.Length + SubDirName.Length + 3); + PrintF(&SubDirectoryPath, "%S%S/*\0", SearchPath, SubDirName); + FilesCount += Win32EnumerateDirectoryIntoTempList(FileHandler, TempList, SubDirectoryPath.ConstString, + Storage, Flags); + } + } + + AddFile = HasFlag(Flags, EnumerateDirectory_IncludeDirectories); + } + + if (AddFile) + { + temp_file_list_entry* File = PushStruct(FileHandler.Transient, temp_file_list_entry); + *File = {0}; + Win32SetFileInfoFromFindFileData(&File->Info, FindFileData, SearchPathDir, Storage); + SLLPushOrInit(TempList->First, TempList->Last, File); + FilesCount += 1; + } + }while(FindNextFile(SearchHandle, &FindFileData)); + } + else + { + PrintLastError(); + } + + return FilesCount; } ENUMERATE_DIRECTORY(Win32EnumerateDirectory) { - Assert(IsNullTerminated(Path)); - gs_file_info_array Result = {}; - - temp_file_list TempList = {}; - Result.MaxCount = Win32EnumerateDirectoryIntoTempList(FileHandler, &TempList, Path, Storage, Flags); - - Result.Values = PushArray(Storage, gs_file_info, Result.MaxCount); - for (temp_file_list_entry* FileAt = TempList.First; - FileAt != 0; - FileAt = FileAt->Next) - { - // NOTE(Peter): We don't copy the file name here because its already in Storage. - // See String Storage note above ^^ - Result.Values[Result.Count++] = FileAt->Info; - } - - return Result; + Assert(IsNullTerminated(Path)); + gs_file_info_array Result = {}; + + temp_file_list TempList = {}; + Result.MaxCount = Win32EnumerateDirectoryIntoTempList(FileHandler, &TempList, Path, Storage, Flags); + + Result.Values = PushArray(Storage, gs_file_info, Result.MaxCount); + for (temp_file_list_entry* FileAt = TempList.First; + FileAt != 0; + FileAt = FileAt->Next) + { + // NOTE(Peter): We don't copy the file name here because its already in Storage. + // See String Storage note above ^^ + Result.Values[Result.Count++] = FileAt->Info; + } + + return Result; } #define WIN32_FOLDHAUS_FILEIO_H diff --git a/src/app/platform_win32/win32_foldhaus_memory.h b/src/app/platform_win32/win32_foldhaus_memory.h index 100dd1a..6dbce1c 100644 --- a/src/app/platform_win32/win32_foldhaus_memory.h +++ b/src/app/platform_win32/win32_foldhaus_memory.h @@ -1,36 +1,26 @@ -// -// File: win32_foldhaus_memory.h -// Author: Peter Slattery -// Creation Date: 2020-02-04 -// -// -// NOTE: Relies on having imported foldhaus_platform.h prior to this file -// -#ifndef WIN32_FOLDHAUS_MEMORY_H +/* date = May 10th 2021 11:48 pm */ -ALLOCATOR_ALLOC(Win32Alloc) +#ifndef GS_MEMORY_WIN32_H +#define GS_MEMORY_WIN32_H + +PLATFORM_ALLOC(Win32Alloc) { - u8* Result = (u8*)VirtualAlloc(NULL, Size, - MEM_COMMIT | MEM_RESERVE, - PAGE_EXECUTE_READWRITE); - if (ResultSize != 0) - { - *ResultSize = Size; - } - return Result; + u8* Result = (u8*)VirtualAlloc(NULL, Size, + MEM_COMMIT | MEM_RESERVE, + PAGE_EXECUTE_READWRITE); + if (ResultSize) *ResultSize = Size; + return Result; } -ALLOCATOR_FREE(Win32Free) +PLATFORM_FREE(Win32Free) { - b32 Result = VirtualFree(Ptr, 0, MEM_RELEASE); - if (!Result) - { - s32 Error = GetLastError(); - // TODO(Peter): I'm waiting to see an error actually occur here - // to know what it could possibly be. - InvalidCodePath; - } + VirtualFree(Base, 0, MEM_RELEASE); } -#define WIN32_FOLDHAUS_MEMORY_H -#endif // WIN32_FOLDHAUS_MEMORY_H \ No newline at end of file +internal gs_allocator +CreatePlatformAllocator() +{ + return AllocatorCreate(Win32Alloc, Win32Free, 0); +} + +#endif //GS_MEMORY_WIN32_H diff --git a/src/app/platform_win32/win32_foldhaus_serial.h b/src/app/platform_win32/win32_foldhaus_serial.h index 71b4c99..4b309c8 100644 --- a/src/app/platform_win32/win32_foldhaus_serial.h +++ b/src/app/platform_win32/win32_foldhaus_serial.h @@ -13,277 +13,367 @@ global s32* Win32SerialPortFilled; DCB Win32SerialPort_GetState(HANDLE ComPortHandle) { - DEBUG_TRACK_FUNCTION; - DCB ControlSettings = {0}; - ZeroStruct(&ControlSettings); - ControlSettings.DCBlength = sizeof(ControlSettings); - - bool Success = GetCommState(ComPortHandle, &ControlSettings); - Assert(Success); - - return ControlSettings; + DEBUG_TRACK_FUNCTION; + DCB ControlSettings = {0}; + ZeroStruct(&ControlSettings); + ControlSettings.DCBlength = sizeof(ControlSettings); + + bool Success = GetCommState(ComPortHandle, &ControlSettings); + Assert(Success); + + return ControlSettings; } void Win32SerialPort_SetState(HANDLE ComPortHandle, u32 BaudRate, u8 ByteSize, u8 Parity, u8 StopBits) { - DEBUG_TRACK_FUNCTION; - DCB ControlSettings = Win32SerialPort_GetState(ComPortHandle); + DEBUG_TRACK_FUNCTION; + DCB ControlSettings = Win32SerialPort_GetState(ComPortHandle); + + // TODO(pjs): Validate BaudRate - There's only certain rates that are valid right? + ControlSettings.BaudRate = BaudRate; + + if (Parity == NOPARITY) + { + ControlSettings.Parity = Parity; + ControlSettings.fParity = 0; + } + if (Parity == EVENPARITY || Parity == ODDPARITY) + { + ControlSettings.Parity = Parity; + ControlSettings.fParity = 1; + } + + ControlSettings.StopBits = StopBits; + ControlSettings.ByteSize = ByteSize; + + ControlSettings.fBinary = true; + + ControlSettings.fOutxCtsFlow = false; + ControlSettings.fOutxDsrFlow = false; + ControlSettings.fDtrControl = DTR_CONTROL_DISABLE; + ControlSettings.fDsrSensitivity = 0; + ControlSettings.fRtsControl = RTS_CONTROL_DISABLE; + ControlSettings.fOutX = false; + ControlSettings.fInX = false; + + ControlSettings.fErrorChar = 0; + ControlSettings.fNull = false; + ControlSettings.fAbortOnError = false; + ControlSettings.wReserved = false; + ControlSettings.XonLim = 2; + ControlSettings.XoffLim = 4; + ControlSettings.XonChar = 0x13; + ControlSettings.XoffChar = 0x19; + ControlSettings.EvtChar = 0; + + bool Success = SetCommState(ComPortHandle, &ControlSettings); +} + +gs_const_string_array +Win32SerialPorts_List(gs_memory_arena* Arena, gs_memory_arena* Transient) +{ + gs_const_string_array Result = {}; + + DWORD SizeNeeded0 = 0; + DWORD CountReturned0 = 0; + EnumPorts(NULL, 1, 0, 0, &SizeNeeded0, &CountReturned0); + Assert(GetLastError() == ERROR_INSUFFICIENT_BUFFER); + + DWORD SizeNeeded1 = 0; + DWORD CountReturned1 = 0; + PORT_INFO_1* PortsArray = (PORT_INFO_1*)PushSize(Transient, SizeNeeded0).Memory; + if (EnumPorts(NULL, + 1, + (u8*)PortsArray, + SizeNeeded0, + &SizeNeeded1, + &CountReturned1)) + { + Result.CountMax = (u64)CountReturned1; + Result.Strings = PushArray(Arena, gs_const_string, Result.CountMax); - // TODO(pjs): Validate BaudRate - There's only certain rates that are valid right? - ControlSettings.BaudRate = BaudRate; - - if (Parity == NOPARITY) + for (; Result.Count < Result.CountMax; Result.Count++) { - ControlSettings.Parity = Parity; - ControlSettings.fParity = 0; + u64 Index = Result.Count; + u64 StrLen = CStringLength(PortsArray[Index].pName); + gs_string Str = PushString(Arena, StrLen); + PrintF(&Str, "%.*s", StrLen, PortsArray[Index].pName); + Result.Strings[Result.Count] = Str.ConstString; } - if (Parity == EVENPARITY || Parity == ODDPARITY) + } + + return Result; +} + +bool +Win32SerialPort_Exists(char* PortName, gs_memory_arena* Transient) +{ + bool Result = false; + if (PortName != 0) + { + gs_const_string PortIdent = ConstString(PortName); + u32 IdentBegin = FindLast(PortIdent, '\\') + 1; + PortIdent = Substring(PortIdent, IdentBegin, PortIdent.Length); + + gs_const_string_array PortsAvailable = Win32SerialPorts_List(Transient, Transient); + + for (u64 i = 0; i < PortsAvailable.Count; i++) { - ControlSettings.Parity = Parity; - ControlSettings.fParity = 1; + gs_const_string AvailablePortName = PortsAvailable.Strings[i]; + if (StringsEqualUpToLength(AvailablePortName, PortIdent, PortIdent.Length)) + { + Result = true; + break; + } } - - ControlSettings.StopBits = StopBits; - ControlSettings.ByteSize = ByteSize; - - ControlSettings.fBinary = true; - - ControlSettings.fOutxCtsFlow = false; - ControlSettings.fOutxDsrFlow = false; - ControlSettings.fDtrControl = DTR_CONTROL_DISABLE; - ControlSettings.fDsrSensitivity = 0; - ControlSettings.fRtsControl = RTS_CONTROL_DISABLE; - ControlSettings.fOutX = false; - ControlSettings.fInX = false; - - ControlSettings.fErrorChar = 0; - ControlSettings.fNull = false; - ControlSettings.fAbortOnError = false; - ControlSettings.wReserved = false; - ControlSettings.XonLim = 2; - ControlSettings.XoffLim = 4; - ControlSettings.XonChar = 0x13; - ControlSettings.XoffChar = 0x19; - ControlSettings.EvtChar = 0; - - bool Success = SetCommState(ComPortHandle, &ControlSettings); + } + return Result; } HANDLE -Win32SerialPort_Open(char* PortName) +Win32SerialPort_Open(char* PortName, gs_memory_arena* Transient) { - DEBUG_TRACK_FUNCTION; - HANDLE ComPortHandle = CreateFile(PortName, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, // Default Security Attr - OPEN_EXISTING, - 0, // Not overlapped I/O - NULL); + DEBUG_TRACK_FUNCTION; + HANDLE ComPortHandle = INVALID_HANDLE_VALUE;; + + if (Win32SerialPort_Exists(PortName, Transient)) + { + + ComPortHandle = CreateFile(PortName, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, // Default Security Attr + OPEN_EXISTING, + 0, // Not overlapped I/O + NULL); + + bool HasError = false; if (ComPortHandle != INVALID_HANDLE_VALUE) { - COMMTIMEOUTS Timeouts = { 0 }; - Timeouts.ReadIntervalTimeout = 0; // in milliseconds - Timeouts.ReadTotalTimeoutConstant = 0; // in milliseconds - Timeouts.ReadTotalTimeoutMultiplier = 0; // in milliseconds - Timeouts.WriteTotalTimeoutConstant = 0; // in milliseconds - Timeouts.WriteTotalTimeoutMultiplier = 0; // in milliseconds - - if (SetCommTimeouts(ComPortHandle, &Timeouts)) - { - - } - else - { - s32 Error = GetLastError(); - // TODO(pjs): Error logging - } + COMMTIMEOUTS Timeouts = { 0 }; + Timeouts.ReadIntervalTimeout = 0; // in milliseconds + Timeouts.ReadTotalTimeoutConstant = 0; // in milliseconds + Timeouts.ReadTotalTimeoutMultiplier = 0; // in milliseconds + Timeouts.WriteTotalTimeoutConstant = 0; // in milliseconds + Timeouts.WriteTotalTimeoutMultiplier = 0; // in milliseconds + + HasError = !SetCommTimeouts(ComPortHandle, &Timeouts); } else { - // Error - s32 Error = GetLastError(); - // TODO(pjs): Error logging + HasError = true; } - return ComPortHandle; + if (HasError) + { + // Error + s32 Error = GetLastError(); + switch (Error) + { + case ERROR_INVALID_FUNCTION: + case ERROR_NO_SUCH_DEVICE: + case ERROR_FILE_NOT_FOUND: + { + // NOTE(PS): The outer scope should handle these cases + ComPortHandle = INVALID_HANDLE_VALUE; + }break; + + InvalidDefaultCase; + } + } + } + + return ComPortHandle; } void Win32SerialPort_Close(HANDLE PortHandle) { - CloseHandle(PortHandle); + CloseHandle(PortHandle); } bool Win32SerialPort_Write(HANDLE PortHandle, gs_data Buffer) { - DEBUG_TRACK_FUNCTION; - Assert(PortHandle != INVALID_HANDLE_VALUE); - bool Success = false; - - DWORD BytesWritten = 0; - if (WriteFile(PortHandle, Buffer.Memory, Buffer.Size, &BytesWritten, NULL)) + DEBUG_TRACK_FUNCTION; + Assert(PortHandle != INVALID_HANDLE_VALUE); + bool Success = false; + + DWORD BytesWritten = 0; + if (WriteFile(PortHandle, Buffer.Memory, Buffer.Size, &BytesWritten, NULL)) + { + Success = (BytesWritten == Buffer.Size); + if (!Success) { - Success = (BytesWritten == Buffer.Size); - if (!Success) - { - OutputDebugString("Error: Entire buffer not written.\n"); - } + Log_Error(GlobalLogBuffer, "Error: Entire buffer not written.\n"); } - else + } + else + { + Log_Error(GlobalLogBuffer, "Error: Unable to write to port\n"); + s32 Error = GetLastError(); + switch (Error) { - OutputDebugStringA("Error: Unable to write to port\n"); - s32 Error = GetLastError(); - switch (Error) - { - case ERROR_OPERATION_ABORTED: - case ERROR_GEN_FAILURE: - { - // NOTE(pjs): Probably means that the serial port became invalid - // ie. the usb stick was removed - }break; - - case ERROR_INVALID_HANDLE: - InvalidDefaultCase; - } + case ERROR_OPERATION_ABORTED: + case ERROR_GEN_FAILURE: + { + // NOTE(pjs): Probably means that the serial port became invalid + // ie. the usb stick was removed + }break; + + case ERROR_ACCESS_DENIED: + { + // ?? + }break; + + case ERROR_NO_SUCH_DEVICE: + { + }break; + + case ERROR_INVALID_HANDLE: + InvalidDefaultCase; } - - return Success; + } + + return Success; } bool Win32SerialPort_SetRead(HANDLE PortHandle) { - bool Status = SetCommMask(PortHandle, EV_RXCHAR); - return Status; + bool Status = SetCommMask(PortHandle, EV_RXCHAR); + return Status; } u32 Win32SerialPort_ReadMessageWhenReady(HANDLE PortHandle, gs_data Data) { - u32 ReadSize = 0; - - DWORD EventMask = 0; - bool Status = WaitCommEvent(PortHandle, &EventMask, NULL); - if (Status) + u32 ReadSize = 0; + + DWORD EventMask = 0; + bool Status = WaitCommEvent(PortHandle, &EventMask, NULL); + if (Status) + { + DWORD NoBytesRead = 0; + do { - DWORD NoBytesRead = 0; - do - { - u8 Byte = 0; - Status = ReadFile(PortHandle, &Byte, sizeof(char), &NoBytesRead, NULL); - Data.Memory[ReadSize] = Byte; - ReadSize++; - } - while (NoBytesRead > 0 && ReadSize < Data.Size); + u8 Byte = 0; + Status = ReadFile(PortHandle, &Byte, sizeof(char), &NoBytesRead, NULL); + Data.Memory[ReadSize] = Byte; + ReadSize++; } - //Read data and store in a buffer - - return ReadSize; + while (NoBytesRead > 0 && ReadSize < Data.Size); + } + //Read data and store in a buffer + + return ReadSize; } ///////////////////////// // Win32SerialArray void -Win32SerialArray_Create(gs_thread_context Context) +Win32SerialArray_Create(gs_memory_arena* A) { - DEBUG_TRACK_FUNCTION; - - Win32SerialHandlesCountMax = 32; - - Win32SerialHandles = AllocatorAllocArray(Context.Allocator, HANDLE, Win32SerialHandlesCountMax); - Win32SerialPortNames = AllocatorAllocArray(Context.Allocator, gs_string, Win32SerialHandlesCountMax); - Win32SerialPortFilled = AllocatorAllocArray(Context.Allocator, s32, Win32SerialHandlesCountMax); - - for (u32 i = 0; i < Win32SerialHandlesCountMax; i++) - { - Win32SerialPortNames[i] = AllocatorAllocString(Context.Allocator, 256); - Win32SerialPortFilled[i] = 0; - } + DEBUG_TRACK_FUNCTION; + + Win32SerialHandlesCountMax = 32; + + Win32SerialHandles = PushArray(A, HANDLE, Win32SerialHandlesCountMax); + Win32SerialPortNames = PushArray(A, gs_string, Win32SerialHandlesCountMax); + Win32SerialPortFilled = PushArray(A, s32, Win32SerialHandlesCountMax); + + u64 PortNameSize = 256; + u64 PortNameBufferSize = PortNameSize * Win32SerialHandlesCountMax; + char* PortNameBuffer = PushArray(A, char, PortNameBufferSize); + for (u32 i = 0; i < Win32SerialHandlesCountMax; i++) + { + char* NameBase = PortNameBuffer + (PortNameSize * i); + Win32SerialPortNames[i] = MakeString(NameBase, 0, PortNameSize); + Win32SerialPortFilled[i] = 0; + } } void Win32SerialArray_Push(HANDLE SerialHandle, gs_const_string PortName) { - DEBUG_TRACK_FUNCTION; - - bool Found = false; - for (u32 i = 0; i < Win32SerialHandlesCountMax; i++) + DEBUG_TRACK_FUNCTION; + + bool Found = false; + for (u32 i = 0; i < Win32SerialHandlesCountMax; i++) + { + bool WasFilled = InterlockedCompareExchange((LONG volatile*)Win32SerialPortFilled + i, 1, 0); + if (!WasFilled) { - bool WasFilled = InterlockedCompareExchange((LONG volatile*)Win32SerialPortFilled + i, 1, 0); - if (!WasFilled) - { - Win32SerialHandles[i] = SerialHandle; - PrintF(&Win32SerialPortNames[i], "%S", PortName); - Found = true; - break; - } + Win32SerialHandles[i] = SerialHandle; + PrintF(&Win32SerialPortNames[i], "%S", PortName); + Found = true; + break; } - Assert(Found); + } + Assert(Found); } void Win32SerialArray_Pop(u32 Index) { - bool WasFilled = InterlockedCompareExchange((LONG volatile*)Win32SerialPortFilled + Index, 0, 1); - Assert(WasFilled); - Win32SerialPortFilled[Index] = false; - Win32SerialHandles[Index] = INVALID_HANDLE_VALUE; + bool WasFilled = InterlockedCompareExchange((LONG volatile*)Win32SerialPortFilled + Index, 0, 1); + Assert(WasFilled); + Win32SerialPortFilled[Index] = false; + Win32SerialHandles[Index] = INVALID_HANDLE_VALUE; } HANDLE Win32SerialArray_Get(gs_const_string PortName) { - DEBUG_TRACK_FUNCTION; - - HANDLE PortHandle = INVALID_HANDLE_VALUE; - for (u32 i = 0; i < Win32SerialHandlesCountMax; i++) + DEBUG_TRACK_FUNCTION; + + HANDLE PortHandle = INVALID_HANDLE_VALUE; + for (u32 i = 0; i < Win32SerialHandlesCountMax; i++) + { + if (Win32SerialPortFilled[i] && + StringsEqual(Win32SerialPortNames[i].ConstString, PortName)) { - if (Win32SerialPortFilled[i] && - StringsEqual(Win32SerialPortNames[i].ConstString, PortName)) - { - PortHandle = Win32SerialHandles[i]; - break; - } + PortHandle = Win32SerialHandles[i]; + break; } - return PortHandle; + } + return PortHandle; } HANDLE -Win32SerialArray_GetOrOpen(gs_const_string PortName, u32 BaudRate, u8 ByteSize, u8 Parity, u8 StopBits) +Win32SerialArray_GetOrOpen(gs_const_string PortName, u32 BaudRate, u8 ByteSize, u8 Parity, u8 StopBits, gs_memory_arena* Transient) { - DEBUG_TRACK_FUNCTION; - - HANDLE PortHandle = Win32SerialArray_Get(PortName); - if (PortHandle == INVALID_HANDLE_VALUE) + DEBUG_TRACK_FUNCTION; + + HANDLE PortHandle = Win32SerialArray_Get(PortName); + if (PortHandle == INVALID_HANDLE_VALUE) + { + Assert(IsNullTerminated(PortName)); + PortHandle = Win32SerialPort_Open(PortName.Str, Transient); + if (PortHandle != INVALID_HANDLE_VALUE) { - Assert(IsNullTerminated(PortName)); - PortHandle = Win32SerialPort_Open(PortName.Str); - if (PortHandle != INVALID_HANDLE_VALUE) - { - Win32SerialPort_SetState(PortHandle, BaudRate, ByteSize, Parity, StopBits); - Win32SerialArray_Push(PortHandle, PortName); - } + Win32SerialPort_SetState(PortHandle, BaudRate, ByteSize, Parity, StopBits); + Win32SerialArray_Push(PortHandle, PortName); } - return PortHandle; + } + return PortHandle; } void Win32SerialArray_Close(gs_const_string PortName) { - for (u32 i = 0; i < Win32SerialHandlesCountMax; i++) + for (u32 i = 0; i < Win32SerialHandlesCountMax; i++) + { + if (Win32SerialPortFilled[i] && StringsEqual(Win32SerialPortNames[i].ConstString, PortName)) { - if (Win32SerialPortFilled[i] && StringsEqual(Win32SerialPortNames[i].ConstString, PortName)) - { - Win32SerialPort_Close(Win32SerialHandles[i]); - Win32SerialArray_Pop(i); - break; - } + Win32SerialPort_Close(Win32SerialHandles[i]); + Win32SerialArray_Pop(i); + break; } + } } #define WIN32_SERIAL_H diff --git a/src/app/platform_win32/win32_foldhaus_socket.h b/src/app/platform_win32/win32_foldhaus_socket.h index b42c8c9..1f05067 100644 --- a/src/app/platform_win32/win32_foldhaus_socket.h +++ b/src/app/platform_win32/win32_foldhaus_socket.h @@ -7,14 +7,14 @@ struct win32_socket { - SOCKET Socket; + SOCKET Socket; }; struct win32_socket_array { - win32_socket* Values; - s32 CountMax; - s32 Count; + win32_socket* Values; + s32 CountMax; + s32 Count; }; global WSADATA WSAData; @@ -27,28 +27,28 @@ global win32_socket_array Win32Sockets; internal win32_socket_array Win32SocketArray_Create(u32 CountMax, gs_memory_arena* Storage) { - win32_socket_array Result = {}; - Result.CountMax = CountMax; - Result.Values = PushArray(Storage, win32_socket, CountMax); - return Result; + win32_socket_array Result = {}; + Result.CountMax = CountMax; + Result.Values = PushArray(Storage, win32_socket, CountMax); + return Result; } internal s32 Win32SocketArray_Take(win32_socket_array* Array) { - Assert(Array->Count < Array->CountMax); - s32 Result = Array->Count++; - win32_socket* Socket = Array->Values + Result; - *Socket = {0}; - return Result; + Assert(Array->Count < Array->CountMax); + s32 Result = Array->Count++; + win32_socket* Socket = Array->Values + Result; + *Socket = {0}; + return Result; } internal win32_socket* Win32SocketArray_Get(win32_socket_array Array, s32 Index) { - Assert(Index < Array.Count); - win32_socket* Result = Array.Values + Index; - return Result; + Assert(Index < Array.Count); + win32_socket* Result = Array.Values + Index; + return Result; } ////////////////////// @@ -58,409 +58,448 @@ Win32SocketArray_Get(win32_socket_array Array, s32 Index) internal win32_socket Win32Socket_Create(s32 AddressFamily, s32 Type, s32 Protocol) { - win32_socket Result = {0}; - Result.Socket = socket(AddressFamily, Type, Protocol); - if (Result.Socket == INVALID_SOCKET) - { - s32 Error = WSAGetLastError(); - InvalidCodePath; - } - return Result; + win32_socket Result = {0}; + Result.Socket = socket(AddressFamily, Type, Protocol); + if (Result.Socket == INVALID_SOCKET) + { + s32 Error = WSAGetLastError(); + InvalidCodePath; + } + return Result; } internal void Win32Socket_Bind(win32_socket* Socket, s32 AddressFamily, char* Address, s32 Port) { - sockaddr_in Service = {0}; - Service.sin_family = AddressFamily; - Service.sin_addr.s_addr = inet_addr(Address); - Service.sin_port = htons(Port); - - s32 Result = bind(Socket->Socket, (SOCKADDR*)&Service, sizeof(Service)); - if (Result == SOCKET_ERROR) - { - s32 Error = WSAGetLastError(); - InvalidCodePath; - } + sockaddr_in Service = {0}; + Service.sin_family = AddressFamily; + Service.sin_addr.s_addr = inet_addr(Address); + Service.sin_port = htons(Port); + + s32 Result = bind(Socket->Socket, (SOCKADDR*)&Service, sizeof(Service)); + if (Result == SOCKET_ERROR) + { + s32 Error = WSAGetLastError(); + InvalidCodePath; + } } internal win32_socket Win32Socket_ConnectToAddress(char* Address, char* DefaultPort) { - win32_socket Result = {}; - - addrinfo Hints = {0}; - Hints.ai_family = AF_UNSPEC; - Hints.ai_socktype = SOCK_STREAM; - Hints.ai_protocol = IPPROTO_TCP; - - addrinfo* PotentialConnections; - s32 Error = getaddrinfo(Address, DefaultPort, &Hints, &PotentialConnections); - if (Error == 0) - { - for (addrinfo* InfoAt = PotentialConnections; InfoAt != NULL; InfoAt = InfoAt->ai_next) - { - win32_socket Socket = Win32Socket_Create(InfoAt->ai_family, InfoAt->ai_socktype, InfoAt->ai_protocol); - if (Socket.Socket == INVALID_SOCKET) - { - Error = WSAGetLastError(); - InvalidCodePath; - } - - Error = connect(Socket.Socket, InfoAt->ai_addr, (int)InfoAt->ai_addrlen); - if (Error == SOCKET_ERROR) - { - closesocket(Socket.Socket); - continue; - } - else - { - Result = Socket; - break; - } - } - } - else + win32_socket Result = {}; + + addrinfo Hints = {0}; + Hints.ai_family = AF_UNSPEC; + Hints.ai_socktype = SOCK_STREAM; + Hints.ai_protocol = IPPROTO_TCP; + + addrinfo* PotentialConnections; + s32 Error = getaddrinfo(Address, DefaultPort, &Hints, &PotentialConnections); + if (Error == 0) + { + for (addrinfo* InfoAt = PotentialConnections; InfoAt != NULL; InfoAt = InfoAt->ai_next) { + win32_socket Socket = Win32Socket_Create(InfoAt->ai_family, InfoAt->ai_socktype, InfoAt->ai_protocol); + if (Socket.Socket == INVALID_SOCKET) + { Error = WSAGetLastError(); InvalidCodePath; + } + + Error = connect(Socket.Socket, InfoAt->ai_addr, (int)InfoAt->ai_addrlen); + if (Error == SOCKET_ERROR) + { + closesocket(Socket.Socket); + continue; + } + else + { + Result = Socket; + break; + } } - - freeaddrinfo(PotentialConnections); - - return Result; + } + else + { + Error = WSAGetLastError(); + InvalidCodePath; + } + + freeaddrinfo(PotentialConnections); + + return Result; } internal bool -Win32ConnectSocket(platform_socket* Socket) +Win32ConnectSocket(platform_socket_manager* Manager, platform_socket* Socket) { - bool Result = false; - - addrinfo Hints = {0}; - Hints.ai_family = AF_UNSPEC; - Hints.ai_socktype = SOCK_STREAM; - Hints.ai_protocol = IPPROTO_TCP; - - addrinfo* PotentialConnections; - s32 Error = getaddrinfo(Socket->Addr, Socket->Port, &Hints, &PotentialConnections); - if (Error == 0) - { - for (addrinfo* InfoAt = PotentialConnections; InfoAt != NULL; InfoAt = InfoAt->ai_next) - { - SOCKET SocketHandle = socket(InfoAt->ai_family, InfoAt->ai_socktype, InfoAt->ai_protocol); - if (SocketHandle == INVALID_SOCKET) - { - Error = WSAGetLastError(); - InvalidCodePath; - } - - // If iMode == 0, blocking is enabled - // if iMode != 0, non-blocking mode is enabled - u_long iMode = 1; - Error = ioctlsocket(SocketHandle, FIONBIO, &iMode); - if (Error != NO_ERROR) - { - InvalidCodePath; - } - - Error = connect(SocketHandle, InfoAt->ai_addr, (int)InfoAt->ai_addrlen); - if (Error == SOCKET_ERROR) - { - u32 Status = WSAGetLastError(); - if (Status == WSAEWOULDBLOCK) - { -#if 0 - TIMEVAL Timeout = { 0, 500 }; - fd_set SocketSet = {}; - FD_ZERO(&SocketSet); - FD_SET(SocketHandle, &SocketSet); - Assert(FD_ISSET(SocketHandle, &SocketSet)); - Status = select(0, &SocketSet, 0, 0, (const TIMEVAL*)&Timeout); - if (Status == SOCKET_ERROR) - { - - } - else if (Status == 0) - { - } - else - { - - } -#endif - } - else - { - closesocket(SocketHandle); - continue; - } - } - - Socket->PlatformHandle = (u8*)Win32Alloc(sizeof(SOCKET), 0); - *(SOCKET*)Socket->PlatformHandle = SocketHandle; - Result = true; - break; - } - } - else + bool Result = false; + + addrinfo Hints = {0}; + Hints.ai_family = AF_UNSPEC; + Hints.ai_socktype = SOCK_STREAM; + Hints.ai_protocol = IPPROTO_TCP; + + addrinfo* PotentialConnections; + s32 Error = getaddrinfo(Socket->Addr, Socket->Port, &Hints, &PotentialConnections); + if (Error == 0) + { + for (addrinfo* InfoAt = PotentialConnections; InfoAt != NULL; InfoAt = InfoAt->ai_next) { + SOCKET SocketHandle = socket(InfoAt->ai_family, InfoAt->ai_socktype, InfoAt->ai_protocol); + if (SocketHandle == INVALID_SOCKET) + { Error = WSAGetLastError(); InvalidCodePath; - } - - if (!Result) - { - Assert(Socket->PlatformHandle == 0); - } - - freeaddrinfo(PotentialConnections); - return Result; -} - -internal bool -Win32CloseSocket(platform_socket* Socket) -{ - SOCKET* Win32Sock = (SOCKET*)Socket->PlatformHandle; - closesocket(*Win32Sock); - Win32Free((u8*)Socket->PlatformHandle, sizeof(SOCKET)); - *Socket = {}; - return true; -} - -internal bool -Win32SocketQueryStatus(platform_socket* Socket) -{ - SOCKET* Win32Sock = (SOCKET*)Socket->PlatformHandle; - bool Result = (*Win32Sock != INVALID_SOCKET); - return Result; -} - -internal u32 -Win32SocketPeek(platform_socket* Socket) -{ - u32 Result = 0; - s32 Flags = MSG_PEEK; - SOCKET* Win32Sock = (SOCKET*)Socket->PlatformHandle; - char Temp[4]; - u32 TempSize = 4; - - s32 BytesQueued = recv(*Win32Sock, Temp, TempSize, Flags); - if (BytesQueued != SOCKET_ERROR) - { - Result = (u32)BytesQueued; - } - else - { - // TODO(pjs): Error handling - s32 Error = WSAGetLastError(); - switch (Error) - { - case WSAEWOULDBLOCK: - case WSAENOTCONN: - { - }break; - - InvalidDefaultCase; - } - } - return Result; -} - -internal gs_data -Win32SocketReceive(platform_socket* Socket, gs_memory_arena* Storage) -{ - // TODO(pjs): Test this first code path when you have data running - it should - // get the actual size of the data packet being sent -#if 0 - gs_data Result = {}; - s32 BytesQueued = Win32Socket_PeekGetTotalSize(Socket); - if (BytesQueued > 0) - { - Result = PushSizeToData(Storage, BytesQueued); - s32 Flags = 0; - s32 BytesReceived = recv(Socket->Socket, (char*)Result.Memory, Result.Size, Flags); - Assert(BytesReceived == BytesQueued); - } - return Result; -#else - gs_data Result = PushSizeToData(Storage, 1024); - s32 Flags = 0; - SOCKET* Win32Sock = (SOCKET*)Socket->PlatformHandle; - s32 BytesReceived = recv(*Win32Sock, (char*)Result.Memory, Result.Size, Flags); - if (BytesReceived == SOCKET_ERROR) - { - // TODO(pjs): Error logging - s32 Error = WSAGetLastError(); + } + + // If iMode == 0, blocking is enabled + // if iMode != 0, non-blocking mode is enabled + u_long iMode = 0; + Error = ioctlsocket(SocketHandle, FIONBIO, &iMode); + if (Error != NO_ERROR) + { InvalidCodePath; - } - Result.Size = BytesReceived; - return Result; + } + + Error = connect(SocketHandle, InfoAt->ai_addr, (int)InfoAt->ai_addrlen); + if (Error == SOCKET_ERROR) + { + u32 Status = WSAGetLastError(); + if (Status == WSAEWOULDBLOCK) + { + // Non-blocking sockets +#if 0 + TIMEVAL Timeout = { 0, 500 }; + fd_set SocketSet = {}; + FD_ZERO(&SocketSet); + FD_SET(SocketHandle, &SocketSet); + Assert(FD_ISSET(SocketHandle, &SocketSet)); + Status = select(0, &SocketSet, 0, 0, (const TIMEVAL*)&Timeout); + if (Status == SOCKET_ERROR) + { + + } + else if (Status == 0) + { + } + else + { + + } #endif -} - -internal s32 -Win32SocketSend(platform_socket* Socket, u32 Address, u32 Port, gs_data Data, s32 Flags) -{ - SOCKET* Win32Sock = (SOCKET*)Socket->PlatformHandle; - - sockaddr_in SockAddress = {}; - SockAddress.sin_family = AF_INET; - SockAddress.sin_port = HostToNetU16(Port); - SockAddress.sin_addr.s_addr = HostToNetU32(Address); - - s32 LengthSent = sendto(*Win32Sock, (char*)Data.Memory, Data.Size, Flags, (sockaddr*)&SockAddress, sizeof(sockaddr_in)); - - if (LengthSent == SOCKET_ERROR) - { - s32 Error = WSAGetLastError(); - if (Error == 10051) - { - } - if (Error == 10053) - { - // TODO(pjs): WSAECONNABORTED - InvalidCodePath; } else { - // TODO(Peter): :ErrorLogging - InvalidCodePath; + closesocket(SocketHandle); + continue; } + } + + Socket->PlatformHandle = (u8*)Win32Alloc(sizeof(SOCKET), 0, 0); + *(SOCKET*)Socket->PlatformHandle = SocketHandle; + Result = true; + break; } - - return LengthSent; + } + else + { + Error = WSAGetLastError(); + InvalidCodePath; + } + + if (!Result) + { + Assert(Socket->PlatformHandle == 0); + } + + freeaddrinfo(PotentialConnections); + return Result; +} + +internal bool +Win32CloseSocket(platform_socket_manager* Manager, platform_socket* Socket) +{ + SOCKET* Win32Sock = (SOCKET*)Socket->PlatformHandle; + closesocket(*Win32Sock); + Win32Free((u8*)Socket->PlatformHandle, sizeof(SOCKET), 0); + *Socket = {}; + return true; +} + +internal bool +Win32SocketQueryStatus(platform_socket_manager* Manager, platform_socket* Socket) +{ + SOCKET* Win32Sock = (SOCKET*)Socket->PlatformHandle; + bool Result = (*Win32Sock != INVALID_SOCKET); + return Result; +} + +internal u32 +Win32SocketPeek(platform_socket_manager* Manager, platform_socket* Socket) +{ + u32 Result = 0; + s32 Flags = MSG_PEEK; + SOCKET* Win32Sock = (SOCKET*)Socket->PlatformHandle; + char Temp[4]; + u32 TempSize = 4; + + //Log_Message(GlobalLogBuffer, "Pre Peek..."); + //s32 BytesQueued = recv(*Win32Sock, Temp, TempSize, Flags); + u_long BytesQueued = 0; + ioctlsocket(*Win32Sock, FIONREAD, &BytesQueued); + //Log_Message(GlobalLogBuffer, "Post Peek\n"); + + if (BytesQueued != SOCKET_ERROR) + { + Result = (u32)BytesQueued; + } + else + { + s32 Error = WSAGetLastError(); + switch (Error) + { + case WSAEWOULDBLOCK: + { + // NOTE(PS): This case covers non-blocking sockets + // if we peek and there's nothing there, it returns + // this error code. MSDN says its a non-fatal error + // and the operation should be retried later + Result = 0; + } break; + + case WSAENOTCONN: + case WSAECONNRESET: + case WSAECONNABORTED: + { + CloseSocket(Manager, Socket); + }break; + + InvalidDefaultCase; + } + } + return (s32)Result; +} + +internal gs_data +Win32SocketReceive(platform_socket_manager* Manager, platform_socket* Socket, gs_memory_arena* Storage) +{ + // TODO(pjs): Test this first code path when you have data running - it should + // get the actual size of the data packet being sent +#if 0 + gs_data Result = {}; + s32 BytesQueued = Win32Socket_PeekGetTotalSize(Socket); + if (BytesQueued > 0) + { + Result = PushSizeToData(Storage, BytesQueued); + s32 Flags = 0; + s32 BytesReceived = recv(Socket->Socket, (char*)Result.Memory, Result.Size, Flags); + Assert(BytesReceived == BytesQueued); + } + return Result; +#else + gs_data Result = PushSize(Storage, 1024); + s32 Flags = 0; + SOCKET* Win32Sock = (SOCKET*)Socket->PlatformHandle; + s32 BytesReceived = recv(*Win32Sock, (char*)Result.Memory, Result.Size, Flags); + if (BytesReceived == SOCKET_ERROR) + { + // TODO(pjs): Error logging + s32 Error = WSAGetLastError(); + InvalidCodePath; + } + Result.Size = BytesReceived; + return Result; +#endif +} + + +internal s32 +Win32SocketSend(platform_socket_manager* Manager, platform_socket* Socket, u32 Address, u32 Port, gs_data Data, s32 Flags) +{ + SOCKET* Win32Sock = (SOCKET*)Socket->PlatformHandle; + + sockaddr_in SockAddress = {}; + SockAddress.sin_family = AF_INET; + SockAddress.sin_port = HostToNetU16(Port); + SockAddress.sin_addr.s_addr = HostToNetU32(Address); + + s32 LengthSent = sendto(*Win32Sock, (char*)Data.Memory, Data.Size, Flags, (sockaddr*)&SockAddress, sizeof(sockaddr_in)); + + //Log_Message(GlobalLogBuffer, "Attempting To Send Network Data: "); + if (LengthSent == SOCKET_ERROR) + { + s32 Error = WSAGetLastError(); + switch (Error) + { + case WSAEWOULDBLOCK: + { + // NOTE(PS): This covers non-blocking sockets + // In this case the message should be tried again + LengthSent = 0; + //Log_Message(GlobalLogBuffer, "Not sent, buffered\n"); + }break; + + case WSAECONNABORTED: + case WSAENETUNREACH: + case WSAECONNRESET: + case WSAENOTCONN: + { + if (CloseSocket(Manager, Socket)) + { + Log_Error(GlobalLogBuffer, "Error: %d\n", Error); + Error = 0; + } + }break; + + InvalidDefaultCase; + } + } + else + { + Log_Message(GlobalLogBuffer, "Sent\n"); + } + + return LengthSent; } internal s32 Win32Socket_SetOption(win32_socket* Socket, s32 Level, s32 Option, const char* OptionValue, s32 OptionLength) { - int Error = setsockopt(Socket->Socket, Level, Option, OptionValue, OptionLength); - if (Error == SOCKET_ERROR) - { - Error = WSAGetLastError(); - // TODO(Peter): :ErrorLogging - } - - return Error; + int Error = setsockopt(Socket->Socket, Level, Option, OptionValue, OptionLength); + if (Error == SOCKET_ERROR) + { + Error = WSAGetLastError(); + // TODO(Peter): :ErrorLogging + } + + return Error; } internal s32 Win32Socket_SetOption(platform_socket_handle SocketHandle, s32 Level, s32 Option, const char* OptionValue, s32 OptionLength) { - win32_socket* Socket = Win32SocketArray_Get(Win32Sockets, (s32)SocketHandle); - return Win32Socket_SetOption(Socket, Level, Option, OptionValue, OptionLength); + win32_socket* Socket = Win32SocketArray_Get(Win32Sockets, (s32)SocketHandle); + return Win32Socket_SetOption(Socket, Level, Option, OptionValue, OptionLength); } internal s32 Win32Socket_SendTo(platform_socket_handle SocketHandle, u32 Address, u32 Port, const char* Buffer, s32 BufferLength, s32 Flags) { - win32_socket* Socket = Win32SocketArray_Get(Win32Sockets, (s32)SocketHandle); - - sockaddr_in SockAddress = {}; - SockAddress.sin_family = AF_INET; - SockAddress.sin_port = HostToNetU16(Port); - SockAddress.sin_addr.s_addr = HostToNetU32(Address); - - s32 LengthSent = sendto(Socket->Socket, Buffer, BufferLength, Flags, (sockaddr*)&SockAddress, sizeof(sockaddr_in)); - - if (LengthSent == SOCKET_ERROR) + win32_socket* Socket = Win32SocketArray_Get(Win32Sockets, (s32)SocketHandle); + + sockaddr_in SockAddress = {}; + SockAddress.sin_family = AF_INET; + SockAddress.sin_port = HostToNetU16(Port); + SockAddress.sin_addr.s_addr = HostToNetU32(Address); + + s32 LengthSent = sendto(Socket->Socket, Buffer, BufferLength, Flags, (sockaddr*)&SockAddress, sizeof(sockaddr_in)); + + if (LengthSent == SOCKET_ERROR) + { + s32 Error = WSAGetLastError(); + switch (Error) { - s32 Error = WSAGetLastError(); - if (Error == 10051) - { - } - else - { - // TODO(Peter): :ErrorLogging - InvalidCodePath; - } + case WSAENETUNREACH: + { + Log_Message(GlobalLogBuffer, + "Non Critical Error: WSAENETUNREACH \n"); + } break; + + default: + { + Log_Error(GlobalLogBuffer, "Error: %d \n", Error); + InvalidCodePath; + } break; } - - return LengthSent; + } + + return LengthSent; } internal void Win32Socket_SetListening(win32_socket* Socket) { - if (listen(Socket->Socket, SOMAXCONN) == SOCKET_ERROR) - { - // TODO(pjs): Error logging - s32 Error = WSAGetLastError(); - InvalidCodePath; - } + if (listen(Socket->Socket, SOMAXCONN) == SOCKET_ERROR) + { + // TODO(pjs): Error logging + s32 Error = WSAGetLastError(); + InvalidCodePath; + } } internal s32 Win32Socket_PeekGetTotalSize(win32_socket* Socket) { - s32 Flags = MSG_PEEK; - char Temp[4]; - s32 BytesQueued = recv(Socket->Socket, Temp, 4, Flags); - if (BytesQueued == SOCKET_ERROR) - { - // TODO(pjs): Error logging - s32 Error = WSAGetLastError(); - BytesQueued = 0; - } - return BytesQueued; + s32 Flags = MSG_PEEK; + char Temp[4]; + s32 BytesQueued = recv(Socket->Socket, Temp, 4, Flags); + if (BytesQueued == SOCKET_ERROR) + { + // TODO(pjs): Error logging + s32 Error = WSAGetLastError(); + BytesQueued = 0; + } + return BytesQueued; } internal gs_data Win32Socket_Receive(win32_socket* Socket, gs_memory_arena* Storage) { #if 0 - gs_data Result = {}; - s32 BytesQueued = Win32Socket_PeekGetTotalSize(Socket); - if (BytesQueued > 0) - { - Result = PushSizeToData(Storage, BytesQueued); - s32 Flags = 0; - s32 BytesReceived = recv(Socket->Socket, (char*)Result.Memory, Result.Size, Flags); - Assert(BytesReceived == BytesQueued); - } - return Result; -#else - gs_data Result = PushSizeToData(Storage, 1024); + gs_data Result = {}; + s32 BytesQueued = Win32Socket_PeekGetTotalSize(Socket); + if (BytesQueued > 0) + { + Result = PushSizeToData(Storage, BytesQueued); s32 Flags = 0; s32 BytesReceived = recv(Socket->Socket, (char*)Result.Memory, Result.Size, Flags); - if (BytesReceived == SOCKET_ERROR) + Assert(BytesReceived == BytesQueued); + } + return Result; +#else + gs_data Result = PushSize(Storage, 1024); + s32 Flags = 0; + s32 BytesReceived = recv(Socket->Socket, (char*)Result.Memory, Result.Size, Flags); + if (BytesReceived == SOCKET_ERROR) + { + // TODO(pjs): Error logging + s32 Error = WSAGetLastError(); + switch (Error) { - // TODO(pjs): Error logging - s32 Error = WSAGetLastError(); - switch (Error) - { - case WSAECONNABORTED: - case WSANOTINITIALISED: - break; - - case WSAENOTCONN: - { - - }break; - InvalidDefaultCase; - } + case WSAECONNABORTED: + case WSANOTINITIALISED: + break; + + case WSAENOTCONN: + { + + }break; + InvalidDefaultCase; } - Result.Size = BytesReceived; - return Result; + } + Result.Size = BytesReceived; + return Result; #endif } internal void Win32Socket_Close(win32_socket* Socket) { - closesocket(Socket->Socket); - Socket->Socket = INVALID_SOCKET; + closesocket(Socket->Socket); + Socket->Socket = INVALID_SOCKET; } internal void Win32Socket_CloseArray(win32_socket_array Array) { - for (s32 i = 0; i < Array.Count; i++) - { - win32_socket* Socket = Array.Values + i; - Win32Socket_Close(Socket); - } + for (s32 i = 0; i < Array.Count; i++) + { + win32_socket* Socket = Array.Values + i; + Win32Socket_Close(Socket); + } } ////////////////////// @@ -470,30 +509,30 @@ Win32Socket_CloseArray(win32_socket_array Array) internal void Win32SocketSystem_Init(gs_memory_arena* Arena) { - WSAStartup(MAKEWORD(2, 2), &WSAData); - Win32Sockets = Win32SocketArray_Create(16, Arena); + WSAStartup(MAKEWORD(2, 2), &WSAData); + Win32Sockets = Win32SocketArray_Create(16, Arena); } internal void Win32SocketSystem_Cleanup() { - Win32Socket_CloseArray(Win32Sockets); - - s32 CleanupResult = 0; - do { - CleanupResult = WSACleanup(); - }while(CleanupResult == SOCKET_ERROR); + Win32Socket_CloseArray(Win32Sockets); + + s32 CleanupResult = 0; + do { + CleanupResult = WSACleanup(); + }while(CleanupResult == SOCKET_ERROR); } PLATFORM_GET_SOCKET_HANDLE(Win32GetSocketHandle) { - s32 Result = Win32SocketArray_Take(&Win32Sockets); - s32 Error = 0; - win32_socket* Socket = Win32SocketArray_Get(Win32Sockets, Result); - *Socket = Win32Socket_Create(AF_INET, SOCK_DGRAM, 0); - Error = Win32Socket_SetOption(Socket, IPPROTO_IP, IP_MULTICAST_TTL, - (const char*)(&Multicast_TimeToLive), sizeof(Multicast_TimeToLive)); - return (platform_socket_handle)Result; + s32 Result = Win32SocketArray_Take(&Win32Sockets); + s32 Error = 0; + win32_socket* Socket = Win32SocketArray_Get(Win32Sockets, Result); + *Socket = Win32Socket_Create(AF_INET, SOCK_DGRAM, 0); + Error = Win32Socket_SetOption(Socket, IPPROTO_IP, IP_MULTICAST_TTL, + (const char*)(&Multicast_TimeToLive), sizeof(Multicast_TimeToLive)); + return (platform_socket_handle)Result; } #define WIN32_FOLDHAUS_SOCKET_H diff --git a/src/app/platform_win32/win32_foldhaus_timing.h b/src/app/platform_win32/win32_foldhaus_timing.h index 6d04a31..dee60bf 100644 --- a/src/app/platform_win32/win32_foldhaus_timing.h +++ b/src/app/platform_win32/win32_foldhaus_timing.h @@ -11,33 +11,33 @@ internal s64 GetPerformanceFrequency () { - LARGE_INTEGER Frequency; - if (!QueryPerformanceFrequency(&Frequency)) - { - s32 Error = GetLastError(); - // TODO(Peter): I'm waiting to see an error actually occur here - // to know what it could possibly be. - InvalidCodePath; - } - return (s64)Frequency.QuadPart; + LARGE_INTEGER Frequency; + if (!QueryPerformanceFrequency(&Frequency)) + { + s32 Error = GetLastError(); + // TODO(Peter): I'm waiting to see an error actually occur here + // to know what it could possibly be. + InvalidCodePath; + } + return (s64)Frequency.QuadPart; } internal s64 GetWallClock () { #if 0 - s64 Result = __rdtsc(); - return Result; + s64 Result = __rdtsc(); + return Result; #else - LARGE_INTEGER Time; - if (!QueryPerformanceCounter(&Time)) - { - s32 Error = GetLastError(); - // TODO(Peter): I'm waiting to see an error actually occur here - // to know what it could possibly be. - InvalidCodePath; - } - return (s64)Time.QuadPart; + LARGE_INTEGER Time; + if (!QueryPerformanceCounter(&Time)) + { + s32 Error = GetLastError(); + // TODO(Peter): I'm waiting to see an error actually occur here + // to know what it could possibly be. + InvalidCodePath; + } + return (s64)Time.QuadPart; #endif } diff --git a/src/app/platform_win32/win32_foldhaus_utils.h b/src/app/platform_win32/win32_foldhaus_utils.h index 5392c9f..c1a4579 100644 --- a/src/app/platform_win32/win32_foldhaus_utils.h +++ b/src/app/platform_win32/win32_foldhaus_utils.h @@ -43,8 +43,7 @@ Error Code: %d\n DEBUG_PRINT(Win32DebugPrint) { - Assert(IsNullTerminated(Message)); - OutputDebugStringA(Message.Str); + Log_Message(GlobalLogBuffer, "%S", Message); } #define PrintLastError() PrintLastError_(__FILE__, __LINE__) @@ -54,8 +53,7 @@ PrintLastError_(char* File, u32 Line) char DebugStringData[256]; gs_string DebugString = MakeString(DebugStringData, 0, 256); u32 Error = GetLastError(); - PrintF(&DebugString, "%s Line %d: Win32 Error %d\n\0", File, Line, Error); - OutputDebugStringA(DebugString.Str); + Log_Error(GlobalLogBuffer, "%s Line %d: Win32 Error %d\n\0", File, Line, Error); } diff --git a/src/app/platform_win32/win32_foldhaus_work_queue.h b/src/app/platform_win32/win32_foldhaus_work_queue.h index b3a2a36..7c56418 100644 --- a/src/app/platform_win32/win32_foldhaus_work_queue.h +++ b/src/app/platform_win32/win32_foldhaus_work_queue.h @@ -7,22 +7,22 @@ struct worker_thread_entry { - b32 IsValid; - u32 Index; + b32 IsValid; + u32 Index; }; struct worker_thread_info { - gs_thread_context ThreadContext; - HANDLE Handle; - gs_work_queue* Queue; + gs_thread_context ThreadContext; + HANDLE Handle; + gs_work_queue* Queue; }; struct win32_work_queue { - u32 ThreadCount; - worker_thread_info* Threads; - gs_work_queue WorkQueue; + u32 ThreadCount; + worker_thread_info* Threads; + gs_work_queue WorkQueue; }; worker_thread_info* WorkerThreads; @@ -31,221 +31,219 @@ win32_work_queue Win32WorkQueue; internal s32 Win32GetThreadId() { - s32 Result = GetCurrentThreadId(); - return Result; + s32 Result = GetCurrentThreadId(); + return Result; } internal gs_thread_context Win32CreateThreadContext(gs_memory_arena* Transient = 0) { - gs_thread_context Result = {0}; - Result.ThreadInfo.ThreadID = Win32GetThreadId(); - Result.Allocator = CreateAllocator(Win32Alloc, Win32Free); - if (Transient != 0) - { - Result.Transient = Transient; - } - else - { - Result.Transient = (gs_memory_arena*)AllocatorAlloc(Result.Allocator, sizeof(gs_memory_arena)).Memory; - *Result.Transient = CreateMemoryArena(Result.Allocator); - } - Result.FileHandler = CreateFileHandler(Win32GetFileInfo, - Win32ReadEntireFile, - Win32WriteEntireFile, - Win32EnumerateDirectory, - Result.Transient); - - Result.DebugOutput.Print = Win32DebugPrint; - - return Result; + gs_thread_context Result = {0}; + Result.ThreadInfo.ThreadID = Win32GetThreadId(); + Result.Allocator = CreatePlatformAllocator(); + if (Transient != 0) + { + Result.Transient = Transient; + } + else + { + Result.Transient = AllocStruct(Result.Allocator, gs_memory_arena, "Work Queue"); + *Result.Transient = MemoryArenaCreate(MB(4), Bytes(8), Result.Allocator, 0, 0, "Tctx Transient"); + } + Result.FileHandler = CreateFileHandler(Win32GetFileInfo, + Win32ReadEntireFile, + Win32WriteEntireFile, + Win32EnumerateDirectory, + Result.Transient); + + Result.DebugOutput.Print = Win32DebugPrint; + + return Result; } PUSH_WORK_ON_QUEUE(Win32PushWorkOnQueue) { -#ifdef DEBUG - // NOTE(Peter): Just prints out the names of all the pending jobs if we end up - // overflowing the buffer - if (Queue->JobsCount >= Queue->JobsMax) +#if DEBUG + // NOTE(Peter): Just prints out the names of all the pending jobs if we end up + // overflowing the buffer + if (Queue->JobsCount >= Queue->JobsMax) + { + gs_string DebugString = MakeString((char*)malloc(256), 256); + for (u32 i = 0; i < Queue->JobsCount; i++) { - gs_string DebugString = MakeString((char*)malloc(256), 256); - for (u32 i = 0; i < Queue->JobsCount; i++) - { - PrintF(&DebugString, "%d %s\n", i, Queue->Jobs[i].JobName); - NullTerminate(&DebugString); - OutputDebugStringA(DebugString.Str); - } + Log_Message(GlobalLogBuffer, "%d %s \n", i, Queue->Jobs[i].JobName); } + } #endif - Assert(Queue->JobsCount < Queue->JobsMax); - - gs_threaded_job* Job = Queue->Jobs + Queue->JobsCount; - Job->WorkProc = WorkProc; - Job->Data = Data; -#ifdef DEBUG - Job->JobName = JobName; + Assert(Queue->JobsCount < Queue->JobsMax); + + gs_threaded_job* Job = Queue->Jobs + Queue->JobsCount; + Job->WorkProc = WorkProc; + Job->Data = Data; +#if DEBUG + Job->JobName = JobName; #endif - - // Complete Past Writes before Future Writes - _WriteBarrier(); - _mm_sfence(); - - ++Queue->JobsCount; - ReleaseSemaphore(Queue->SemaphoreHandle, 1, 0); + + // Complete Past Writes before Future Writes + _WriteBarrier(); + _mm_sfence(); + + ++Queue->JobsCount; + ReleaseSemaphore(Queue->SemaphoreHandle, 1, 0); } internal worker_thread_entry CompleteAndTakeNextJob(gs_work_queue* Queue, worker_thread_entry Completed, gs_thread_context Context) { - if (Completed.IsValid) + if (Completed.IsValid) + { + InterlockedIncrement((LONG volatile*)&Queue->JobsCompleted); + } + + worker_thread_entry Result = {}; + Result.IsValid = false; + + u32 OriginalNextJobIndex = Queue->NextJobIndex; + while (OriginalNextJobIndex < Queue->JobsCount) + { + u32 Index = InterlockedCompareExchange((LONG volatile*)&Queue->NextJobIndex, + OriginalNextJobIndex + 1, + OriginalNextJobIndex); + if (Index == OriginalNextJobIndex) { - InterlockedIncrement((LONG volatile*)&Queue->JobsCompleted); + Result.Index = Index; + Result.IsValid = true; + break; } - - worker_thread_entry Result = {}; - Result.IsValid = false; - - u32 OriginalNextJobIndex = Queue->NextJobIndex; - while (OriginalNextJobIndex < Queue->JobsCount) - { - u32 Index = InterlockedCompareExchange((LONG volatile*)&Queue->NextJobIndex, - OriginalNextJobIndex + 1, - OriginalNextJobIndex); - if (Index == OriginalNextJobIndex) - { - Result.Index = Index; - Result.IsValid = true; - break; - } - OriginalNextJobIndex = Queue->NextJobIndex; - } - - return Result; + OriginalNextJobIndex = Queue->NextJobIndex; + } + + return Result; } COMPLETE_QUEUE_WORK(Win32DoQueueWorkUntilDone) { - worker_thread_entry Entry = {}; - Entry.IsValid = false; - while (Queue->JobsCompleted < Queue->JobsCount) + worker_thread_entry Entry = {}; + Entry.IsValid = false; + while (Queue->JobsCompleted < Queue->JobsCount) + { + Entry = CompleteAndTakeNextJob(Queue, Entry, Context); + if (Entry.IsValid) { - Entry = CompleteAndTakeNextJob(Queue, Entry, Context); - if (Entry.IsValid) - { - Queue->Jobs[Entry.Index].WorkProc(Context, Queue->Jobs[Entry.Index].Data); - } + Queue->Jobs[Entry.Index].WorkProc(Context, Queue->Jobs[Entry.Index].Data); } + } } DWORD WINAPI WorkerThreadProc (LPVOID InputThreadInfo) { - worker_thread_info* ThreadInfo = (worker_thread_info*)InputThreadInfo; - ThreadInfo->ThreadContext = Win32CreateThreadContext(); - - worker_thread_entry Entry = {}; - Entry.IsValid = false; - while (true) + worker_thread_info* ThreadInfo = (worker_thread_info*)InputThreadInfo; + ThreadInfo->ThreadContext = Win32CreateThreadContext(); + + worker_thread_entry Entry = {}; + Entry.IsValid = false; + while (true) + { + MemoryArenaClear(ThreadInfo->ThreadContext.Transient); + Entry = CompleteAndTakeNextJob(ThreadInfo->Queue, Entry, ThreadInfo->ThreadContext); + if (Entry.IsValid) { - ClearArena(ThreadInfo->ThreadContext.Transient); - Entry = CompleteAndTakeNextJob(ThreadInfo->Queue, Entry, ThreadInfo->ThreadContext); - if (Entry.IsValid) - { - ThreadInfo->Queue->Jobs[Entry.Index].WorkProc(ThreadInfo->ThreadContext, - ThreadInfo->Queue->Jobs[Entry.Index].Data); - } - else - { - WaitForSingleObjectEx(ThreadInfo->Queue->SemaphoreHandle, INFINITE, 0); - } + ThreadInfo->Queue->Jobs[Entry.Index].WorkProc(ThreadInfo->ThreadContext, + ThreadInfo->Queue->Jobs[Entry.Index].Data); } - - return 0; + else + { + WaitForSingleObjectEx(ThreadInfo->Queue->SemaphoreHandle, INFINITE, 0); + } + } + + return 0; } DWORD WINAPI Win32ThreadProcWrapper(LPVOID ThreadInfo) { - platform_thread* Thread = (platform_thread*)ThreadInfo; - gs_thread_context Ctx = Win32CreateThreadContext(); - Thread->Proc(&Ctx, Thread->UserData); - - // TODO(pjs): Destroy Thread Context - // TODO(pjs): How do we notify the thread manager this thread belongs to that it is free? - // Probaby put a pointer to the thread manager in the platform_thread struct - // so we can update the tracking structure? - - return 0; + platform_thread* Thread = (platform_thread*)ThreadInfo; + gs_thread_context Ctx = Win32CreateThreadContext(); + Thread->Proc(&Ctx, Thread->UserData); + + // TODO(pjs): Destroy Thread Context + // TODO(pjs): How do we notify the thread manager this thread belongs to that it is free? + // Probaby put a pointer to the thread manager in the platform_thread struct + // so we can update the tracking structure? + + return 0; } CREATE_THREAD(Win32CreateThread) { - Thread->Proc = Proc; - Thread->UserData = UserData; - - // TODO(pjs): ugh, allocation out in the middle of nowhere - HANDLE* ThreadHandle = (HANDLE*)Win32Alloc(sizeof(HANDLE), 0); - *ThreadHandle = CreateThread(0, 0, Win32ThreadProcWrapper, (void*)Thread, 0, 0); - // TODO(pjs): Error checking on the created thread - - Thread->PlatformHandle = (u8*)ThreadHandle; - - return true; + Thread->Proc = Proc; + Thread->UserData = UserData; + + // TODO(pjs): ugh, allocation out in the middle of nowhere + HANDLE* ThreadHandle = AllocStruct(Ctx.Allocator, HANDLE, "Create Thread"); + *ThreadHandle = CreateThread(0, 0, Win32ThreadProcWrapper, (void*)Thread, 0, 0); + // TODO(pjs): Error checking on the created thread + + Thread->PlatformHandle = (u8*)ThreadHandle; + + return true; } KILL_THREAD(Win32KillThread) { - HANDLE* ThreadHandle = (HANDLE*)Thread->PlatformHandle; - TerminateThread(ThreadHandle, 0); - - // TODO(pjs): see allocation out in the middle of nowhere in Win32CreateThread - Win32Free((void*)Thread->PlatformHandle, sizeof(HANDLE)); - - // TODO(pjs): Error checking - return true; + HANDLE* ThreadHandle = (HANDLE*)Thread->PlatformHandle; + TerminateThread(ThreadHandle, 0); + + // TODO(pjs): see allocation out in the middle of nowhere in Win32CreateThread + Win32Free((void*)Thread->PlatformHandle, sizeof(HANDLE), 0); + + // TODO(pjs): Error checking + return true; } internal void Win32WorkQueue_Init(gs_memory_arena* Arena, u32 ThreadCount) { - if (ThreadCount > 0) - { - Win32WorkQueue.ThreadCount = ThreadCount; - Win32WorkQueue.Threads = PushArray(Arena, worker_thread_info, ThreadCount); - } - - gs_work_queue WQ = {}; - WQ.SemaphoreHandle = CreateSemaphoreEx(0, 0, ThreadCount, 0, 0, SEMAPHORE_ALL_ACCESS);; - WQ.JobsMax = 512; - WQ.Jobs = PushArray(Arena, gs_threaded_job, WQ.JobsMax); - WQ.NextJobIndex = 0; - WQ.PushWorkOnQueue = Win32PushWorkOnQueue; - WQ.CompleteQueueWork = Win32DoQueueWorkUntilDone; - - Win32WorkQueue.WorkQueue = WQ; - - // ID = 0 is reserved for this thread - for (u32 i = 0; i < ThreadCount; i++) - { - worker_thread_info* T = Win32WorkQueue.Threads + i; - T->Queue = &Win32WorkQueue.WorkQueue; - T->Handle = CreateThread(0, 0, &WorkerThreadProc, (void*)T, 0, 0); - } + if (ThreadCount > 0) + { + Win32WorkQueue.ThreadCount = ThreadCount; + Win32WorkQueue.Threads = PushArray(Arena, worker_thread_info, ThreadCount); + } + + gs_work_queue WQ = {}; + WQ.SemaphoreHandle = CreateSemaphoreEx(0, 0, ThreadCount, 0, 0, SEMAPHORE_ALL_ACCESS);; + WQ.JobsMax = 512; + WQ.Jobs = PushArray(Arena, gs_threaded_job, WQ.JobsMax); + WQ.NextJobIndex = 0; + WQ.PushWorkOnQueue = Win32PushWorkOnQueue; + WQ.CompleteQueueWork = Win32DoQueueWorkUntilDone; + + Win32WorkQueue.WorkQueue = WQ; + + // ID = 0 is reserved for this thread + for (u32 i = 0; i < ThreadCount; i++) + { + worker_thread_info* T = Win32WorkQueue.Threads + i; + T->Queue = &Win32WorkQueue.WorkQueue; + T->Handle = CreateThread(0, 0, &WorkerThreadProc, (void*)T, 0, 0); + } } internal void Win32WorkQueue_Cleanup() { - u32 Error = 0; - for (u32 Thread = 0; Thread < Win32WorkQueue.ThreadCount; Thread++) + u32 Error = 0; + for (u32 Thread = 0; Thread < Win32WorkQueue.ThreadCount; Thread++) + { + u32 Success = TerminateThread(Win32WorkQueue.Threads[Thread].Handle, 0); + if (!Success) { - u32 Success = TerminateThread(Win32WorkQueue.Threads[Thread].Handle, 0); - if (!Success) - { - Error = GetLastError(); - InvalidCodePath; - } + Error = GetLastError(); + InvalidCodePath; } + } } #define WIN32_FOLDHAUS_WORK_QUEUE_H diff --git a/src/app/ss_blumen_lumen/blumen_lumen.cpp b/src/app/ss_blumen_lumen/blumen_lumen.cpp new file mode 100644 index 0000000..08ac0e0 --- /dev/null +++ b/src/app/ss_blumen_lumen/blumen_lumen.cpp @@ -0,0 +1,1155 @@ +// +// File: blumen_lumen.cpp +// Author: Peter Slattery +// Creation Date: 2021-01-23 +// +#ifndef BLUMEN_LUMEN_CPP + +internal animation_handle_array +LoadAllAnimationsInDir(gs_const_string Path, blumen_lumen_state* BLState, app_state* State, context Context) +{ + animation_handle_array Result = {}; + + gs_thread_context Ctx = Context.ThreadContext; + gs_file_info_array FilesInDir = EnumerateDirectory(Ctx.FileHandler, State->Transient, Path, 0); + + Result.Count = FilesInDir.Count; + Result.Handles = PushArray(&State->Permanent, animation_handle, Result.Count); + + for (u32 i = 0; i < FilesInDir.Count; i++) + { + gs_file_info File = FilesInDir.Values[i]; + Result.Handles[i] = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, + State->Patterns, + Context, + File.Path); + } + + return Result; +} + +internal s32 +GetCCIndex (assembly Assembly, blumen_lumen_state* BLState) +{ + s32 Result = 0; + + u64 AssemblyNameHash = HashDJB2ToU32(StringExpand(Assembly.Name)); + for (u32 i = 0; i < BLState->AssemblyNameToClearCoreMapCount; i++) + { + if (AssemblyNameHash == BLState->AssemblyNameToClearCore_Names[i]) + { + Result = (s32)i; + break; + } + } + + return Result; +} + +internal void +DEBUG_AppendText(gs_string Str, gs_thread_context Ctx) +{ + gs_const_string DebugPath = ConstString("data/debug_motor_changes.txt"); + gs_file DebugFile = ReadEntireFile(Ctx.FileHandler, + DebugPath); + gs_string NewString = PushString(Ctx.Transient, DebugFile.Size + Str.Size + 16); + if (DebugFile.Size > 0) + { + PrintF(&NewString, "%.*s\nENTRY:\n", DebugFile.Size, (char*)DebugFile.Memory); + } + AppendPrintF(&NewString, "%S\n", Str.ConstString); + NullTerminate(&NewString); + + if (!WriteEntireFile(Ctx.FileHandler, DebugPath, StringToData(NewString))) + { + InvalidCodePath; + } +} + +internal void +DEBUG_SentMotorCommand(motor_packet Packet, gs_thread_context Ctx) +{ + Log_Message(GlobalLogBuffer, + "Motor Command Sent\nRequested Positions: %d %d %d\n", + Packet.FlowerPositions[0], + Packet.FlowerPositions[1], + Packet.FlowerPositions[2]); +} + +internal void +DEBUG_ReceivedMotorPositions(blumen_lumen_state* BLState, + motor_status_packet NewPos, + gs_thread_context Ctx) +{ + motor_packet LastPos = BLState->LastKnownMotorState; + bool PosChanged = (LastPos.FlowerPositions[0] != NewPos.Pos.FlowerPositions[0] || + LastPos.FlowerPositions[1] != NewPos.Pos.FlowerPositions[1] || + LastPos.FlowerPositions[2] != NewPos.Pos.FlowerPositions[2]); + + if (PosChanged) + { + Log_Message(GlobalLogBuffer, + "Motor Status Received\nCurrent Positions: %d %d %d\n", + NewPos.Pos.FlowerPositions[0], + NewPos.Pos.FlowerPositions[1], + NewPos.Pos.FlowerPositions[2]); + } +} + +internal void +DEBUG_ReceivedTemperature(temp_packet Temp, gs_thread_context Ctx) +{ + Log_Message(GlobalLogBuffer, + "\nTemperature: %d\n", + Temp.Temperature); +} + +internal void +BlumenLumen_MicListenJob(gs_thread_context* Ctx, u8* UserData) +{ + mic_listen_job_data* Data = (mic_listen_job_data*)UserData; + + gs_data Msg = {}; + + u8 WeathermanIPAddr[4] = {}; + WeathermanIPAddr[0] = 127; + WeathermanIPAddr[1] = 0; + WeathermanIPAddr[2] = 0; + WeathermanIPAddr[3] = 1; + + u32 WeathermanIPV4 = (u32)UpackB4(WeathermanIPAddr); + u32 WeathermanPort = 20185; + + platform_socket_handle_ ListenSocket = {0}; + + while (*Data->Running) + { + if (!SocketQueryStatus(Data->SocketManager, ListenSocket)) + { + Data->IsConnected = false; + if (SocketHandleIsValid(ListenSocket)) + { + Log_Message(GlobalLogBuffer, "Disconnected from Python Server\n"); + CloseSocket(Data->SocketManager, ListenSocket); + } + ListenSocket = CreateSocket(Data->SocketManager, "127.0.0.1", "20185"); + if (ListenSocket.Index != 0) + { + Log_Message(GlobalLogBuffer, "Connected to Python Server\n"); + Data->IsConnected = true; + } + } + + if (SocketQueryStatus(Data->SocketManager, ListenSocket)) + { + if (SocketPeek(Data->SocketManager, ListenSocket)) + { + Msg = SocketRecieve(Data->SocketManager, ListenSocket, Ctx->Transient); + if (Msg.Size > 0) + { + MessageQueue_Write(Data->IncomingMsgQueue, Msg); + } + } + + while (MessageQueue_CanRead(*Data->OutgoingMsgQueue)) + { + Msg = MessageQueue_Peek(Data->OutgoingMsgQueue); + + u32 Address = WeathermanIPV4; + u32 Port = WeathermanPort; + s32 Flags = 0; + s32 LengthSent = SocketSend(Data->SocketManager, ListenSocket, Address, Port, Msg, Flags); + if (LengthSent != 0) + { + // if we actually sent the message, THEN we pull it off the + // message queue + MessageQueue_Read(Data->OutgoingMsgQueue); + } else { + break; + } + } + } + } + + CloseSocket(Data->SocketManager, ListenSocket); +} + +internal void +BlumenLumen_SetPatternMode(bl_pattern_mode Mode, r32 FadeDuration, animation_system* System, blumen_lumen_state* BLState) +{ + BLState->PatternMode = Mode; + animation_handle_array Playlist = BLState->ModeAnimations[Mode]; + System->RepeatMode = AnimationRepeat_Loop; + System->PlaylistFadeTime = FadeDuration; + AnimationSystem_FadeToPlaylist(System, Playlist); +} + +internal void +BlumenLumen_LoadPatterns(app_state* State) +{ + animation_pattern_array* Patterns = &State->Patterns; + if (Patterns->CountMax == 0) + { + *Patterns = Patterns_Create(&State->Permanent, 32); + } + + Patterns->Count = 0; + Patterns_PushPattern(Patterns, Pattern_None, PATTERN_SINGLETHREADED); + Patterns_PushPattern(Patterns, Pattern_HueShift, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_Rainbow, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_BasicFlowers, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_Wavy, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_Patchy, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_Leafy, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_LeafyPatchy, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_WavyPatchy, PATTERN_SINGLETHREADED); + Patterns_PushPattern(Patterns, Pattern_VerticalLines, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_Rotary, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_AllOnMask, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_BulbMask, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_VoicePattern, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_VoiceAddIns, PATTERN_MULTITHREADED); + + Patterns_PushPattern(Patterns, Pattern_StemSolid, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_PrimaryHue, PATTERN_MULTITHREADED); + + Patterns_PushPattern(Patterns, Pattern_GrowFadeMask, PATTERN_MULTITHREADED); + Patterns_PushPattern(Patterns, Pattern_RainbowLoadingBar, PATTERN_MULTITHREADED); + + Patterns_PushPattern(Patterns, Pattern_Blue, PATTERN_MULTITHREADED); +} + +internal void +AppendPrintDate(gs_string* WriteStr, system_time Time) +{ + AppendPrintF(WriteStr, "%d-%d-%d : %d:%d:%d\n\n", + Time.Year, Time.Month, Time.Day, + Time.Hour, Time.Minute, Time.Second); +} + +internal void +BlumenLumen_AppendBootupLog(app_state* State, blumen_lumen_state* BLState, context Context) +{ + gs_thread_context Ctx = Context.ThreadContext; + gs_const_string BootupLogPath = ConstString("lumenarium_boot_log.log"); + + gs_file BootLog = ReadEntireFile(Ctx.FileHandler, BootupLogPath); + gs_string WriteStr = {}; + + // we don't want the log file getting huge + // if it gets above some threshold, instead of appending, + // copy what there is to an _old file, and start this one over + // + // The thinking is that without the copy operation, when we reached + // our threshold, we'd overwrite the whole log. If something went + // wrong at that point, we'd have nothing to go on. This way, there is + // always some historical data present on the system + // + if (BootLog.Size < MB(4)) + { + WriteStr = PushString(State->Transient, BootLog.Size + 1024); + } + else + { + if (!WriteEntireFile(Ctx.FileHandler, ConstString("lumenarium_boot_log_old.log"), + BootLog.Data)) + { + InvalidCodePath; + } + WriteStr = PushString(State->Transient, 1024); + } + + + // Copy old entries in + if (BootLog.Size > 0) + { + PrintF(&WriteStr, "%.*s", BootLog.Size, BootLog.Memory); + } + + // New Entry + AppendPrintF(&WriteStr, "Lumenarium Restarted\n"); + AppendPrintF(&WriteStr, "* Time: "); + AppendPrintDate(&WriteStr, Context.SystemTime_Current); + + gs_data Data = StringToData(WriteStr); + WriteEntireFile(Ctx.FileHandler, BootupLogPath, Data); +} + +internal void +BlumenLumen_UpdateLog(app_state* State, blumen_lumen_state* BLState, context Context) +{ + if (!BLState->ShouldUpdateLog) return; + + gs_string FileStr = PushString(State->Transient, 1024); + AppendPrintF(&FileStr, "Lumenarium Status\n"); + + AppendPrintF(&FileStr, "Last Updated At:"); + AppendPrintDate(&FileStr, Context.SystemTime_Current); + AppendPrintF(&FileStr, "\n\n"); + + animation* CurrAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem); + AppendPrintF(&FileStr, "Curr Animation: %S\n", CurrAnim->Name); + + bool IsPlaying = State->AnimationSystem.TimelineShouldAdvance; + AppendPrintF(&FileStr, "\tIs Playing: %s\n", + IsPlaying ? "True" : "False"); + + char* Connected = BLState->MicListenJobData.IsConnected ? "Connected" : "Disconnected"; + AppendPrintF(&FileStr, "Connected to Python: %s\n", Connected); + + u8 MP0 = BLState->LastKnownMotorState.FlowerPositions[0]; + u8 MP1 = BLState->LastKnownMotorState.FlowerPositions[1]; + u8 MP2 = BLState->LastKnownMotorState.FlowerPositions[2]; + AppendPrintF(&FileStr, "Last Known Motor State: %d %d %d\n", MP0, MP1, MP2); + + time_range MotorRange = {}; + if (SystemTimeIsInTimeRangeList(Context.SystemTime_Current, + MotorOpenTimes, + MotorOpenTimesCount, + &MotorRange)) + { + AppendPrintF(&FileStr, "\tIn Motor-Open Time Range: ( %d:%d - %d:%d)\n", + MotorRange.StartHour, MotorRange.StartMinute, + MotorRange.EndHour, MotorRange.EndMinute); + } + else + { + AppendPrintF(&FileStr, "\tIn Motor-Open Time Range: None\n"); + } + + char* PatternMode = 0; + switch (BLState->PatternMode) + { + case BlumenPattern_Standard: { PatternMode = "Standard"; } break; + case BlumenPattern_VoiceCommand: { PatternMode = "Voice Command"; } break; + case BlumenPattern_NoControl: { PatternMode = "No Control: Someone's doing the Awaken sequence!"; } break; + } + AppendPrintF(&FileStr, "Pattern Mode: %s\n", PatternMode); + + phrase_hue LastHuePhrase = BLState->LastHuePhrase; + AppendPrintF(&FileStr, "Last Mic Phrase: %S\n", LastHuePhrase.Phrase); + + AppendPrintF(&FileStr, "Pattern Speed: %f\n", BLState->PatternSpeed); + + AppendPrintF(&FileStr, "Pattern Brightness: %f\n", BLState->BrightnessPercent); + + time_range RangeIn = {}; + if (SystemTimeIsInTimeRangeList(Context.SystemTime_Current, + LedOnTimes, + LedOnTimesCount, + &RangeIn)) + { + AppendPrintF(&FileStr, "\tIn Leds-On Time Range: ( %d:%d - %d:%d)\n", + RangeIn.StartHour, RangeIn.StartMinute, + RangeIn.EndHour, RangeIn.EndMinute); + } + else + { + AppendPrintF(&FileStr, "\tIn Leds-On Time Range: None\n"); + } + + AppendPrintF(&FileStr, "\tTemp Dimming: %s\n", + Blumen_TempShouldDimLeds(BLState) ? "On" : "Off"); + + AppendPrintF(&FileStr, "Last Temp Received: %d\n", BLState->LastTemperatureReceived); + + gs_data LogMem = StringToData(FileStr); + if (!WriteEntireFile(Context.ThreadContext.FileHandler, ConstString("lumenarium_status.log"), LogMem)) + { + InvalidCodePath; + } +} + +internal gs_data +BlumenLumen_CustomInit(app_state* State, context Context) +{ + // This is memory for any custom data that we want to use + // as a part of a particular sculpture. + // By returning it from here, it will be sent as an argument to + // the sculpture's CustomUpdate function; + gs_data Result = {}; + + Result = PushSize(&State->Permanent, sizeof(blumen_lumen_state)); + + blumen_lumen_state* BLState = (blumen_lumen_state*)Result.Memory; + BLState->Running = true; + BLState->BrightnessPercent = 1; + MessageQueue_Init(&BLState->IncomingMsgQueue, &State->Permanent); + MessageQueue_Init(&BLState->OutgoingMsgQueue, &State->Permanent); + + BLState->MicListenJobData.Running = &BLState->Running; + BLState->MicListenJobData.SocketManager = Context.SocketManager; + BLState->MicListenJobData.IncomingMsgQueue = &BLState->IncomingMsgQueue; + BLState->MicListenJobData.OutgoingMsgQueue = &BLState->OutgoingMsgQueue; + + BLState->PatternSpeed = GlobalAnimSpeed; + +#if 1 + BLState->MicListenThread = CreateThread(Context.ThreadManager, BlumenLumen_MicListenJob, (u8*)&BLState->MicListenJobData, Context.ThreadContext); +#endif + + assembly* Flower0 = LoadAssembly(Flower0AssemblyPath, State, Context); + assembly* Flower1 = LoadAssembly(Flower1AssemblyPath, State, Context); + assembly* Flower2 = LoadAssembly(Flower2AssemblyPath, State, Context); + + for (u32 i = 0; i < BL_FLOWER_COUNT; i++) + { + assembly Assembly = State->Assemblies.Values[i]; + BLState->StemStrips[Assembly.AssemblyIndex] = AssemblyStripsGetWithTagValue(Assembly, ConstString("section"), ConstString("stem"), &State->Permanent); + } + + BLState->AssemblyNameToClearCoreMapCount = 3; + BLState->AssemblyNameToClearCore_Names = PushArray(&State->Permanent, + u64, + BLState->AssemblyNameToClearCoreMapCount); + BLState->AssemblyNameToClearCore_Names[0] = HashDJB2ToU32(StringExpand(Flower2->Name)); + BLState->AssemblyNameToClearCore_Names[1] = HashDJB2ToU32(StringExpand(Flower1->Name)); + BLState->AssemblyNameToClearCore_Names[2] = HashDJB2ToU32(StringExpand(Flower0->Name)); + + gs_file_handler FileHandler = Context.ThreadContext.FileHandler; + gs_file ColorPhraseCSVFile = ReadEntireFile(FileHandler, PhraseMapCSVPath); + if (ColorPhraseCSVFile.Memory != 0) + { + gs_const_string ColorPhraseMapStr = DataToString(ColorPhraseCSVFile.Data); + gscsv_sheet ColorPhraseSheet = CSV_Parse(ColorPhraseMapStr, + { PhraseMapCSVSeparator }, + State->Transient); + + BLState->PhraseHueMap = PhraseHueMap_GenFromCSV(ColorPhraseSheet, + &State->Permanent); + } + +#if 0 + animation_handle DemoPatternsAnim = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, + State->Patterns, + Context, + ConstString("data/demo_patterns.foldanim")); + State->AnimationSystem.ActiveFadeGroup.From = DemoPatternsAnim; +#else + + BLState->ModeAnimations[BlumenPattern_Standard] = LoadAllAnimationsInDir(AmbientPatternFolder, BLState, State, Context); + BLState->ModeAnimations[BlumenPattern_VoiceCommand] = LoadAllAnimationsInDir(VoicePatternFolder, BLState, State, Context); + AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, State->Patterns, Context, ConstString("data/blumen_animations/anim_demo.foldanim")); + + BlumenLumen_SetPatternMode(BlumenPattern_Standard, GlobalAnimTransitionSpeed, &State->AnimationSystem, BLState); + + BLState->AwakenHandle = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, + State->Patterns, + Context, + ConstString("data/blumen_animations/awaken.foldanim")); + BLState->OffAnimHandle = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, + State->Patterns, + Context, + ConstString("data/blumen_animations/off_anim.foldanim")); + +#endif + State->AnimationSystem.TimelineShouldAdvance = true; + + BLState->StandardPatternHues.Granularity = 1; + BLState->StandardPatternHues.Speed = 1; + BLState->StandardPatternHues.AddIn = AddIn_Rotary; + BLState->StandardPatternHues.Pattern = HuePattern_Wavy; + + BLState->DebugHue.Hue0.HSV = v4{0, 1, 1, 1}; + BLState->DebugHue.Hue1.HSV = v4{0, 1, 1, 1}; + BLState->DebugHue.Hue2.HSV = v4{0, 1, 1, 1}; + + BlumenLumen_AppendBootupLog(State, BLState, Context); + return Result; +} + +internal void +BlumenLumen_UpdateMotorState(blumen_lumen_state* BLState, motor_status_packet Motor, context Context) +{ + DEBUG_ReceivedMotorPositions(BLState, Motor, Context.ThreadContext); + + motor_packet LastPos = BLState->LastKnownMotorState; + motor_packet CurrPos = Motor.Pos; + for (u32 i = 0; i < BL_FLOWER_COUNT; i++) + { + if (LastPos.FlowerPositions[i] != CurrPos.FlowerPositions[i]) + { + BLState->LastTimeMotorStateChanged[i] = Context.SystemTime_Current.NanosSinceEpoch; + } + } + + BLState->LastKnownMotorState = Motor.Pos; + BLState->ShouldUpdateLog = true; +} + +internal void +BlumenLumen_ApplyNextHotHue(blumen_lumen_state* BLState, context Context, gs_string* DebugStr, app_state* State) +{ + // if we are in standard color mode, shift all flowers to the new color + // otherwise, only shift the next flower in the sequence to the new color + phrase_hue NewHue = BLState->NextHotHue; + Log_Message(GlobalLogBuffer, "Switching To: %S\n", NewHue.Phrase); + + + if (BLState->PatternMode == BlumenPattern_Standard || + NewHue.OverrideAll) + { + BlumenLumen_SetNextHue(BLState, 0, NewHue); + BlumenLumen_SetNextHue(BLState, 1, NewHue); + BlumenLumen_SetNextHue(BLState, 2, NewHue); + } + else + { + u32 AssemblyIdx = BLState->LastAssemblyColorSet; + BlumenLumen_SetNextHue(BLState, AssemblyIdx, NewHue); + BLState->LastAssemblyColorSet = (BLState->LastAssemblyColorSet + 1) % 3; + } + + BlumenLumen_SetPatternMode(BlumenPattern_VoiceCommand, GlobalAnimTransitionSpeed, &State->AnimationSystem, BLState); + BLState->TimeLastSetToVoiceMode = Context.SystemTime_Current; + BLState->LastHuePhrase = NewHue; + BLState->ShouldUpdateLog = true; + BLState->InPhraseReceptionMode = false; +} + +internal void +BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context) +{ + DEBUG_TRACK_FUNCTION; + + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData.Memory; + BLState->ShouldUpdateLog = false; + + gs_string DebugStr = PushString(State->Transient, 256); + + while (MessageQueue_CanRead(BLState->IncomingMsgQueue)) + { + gs_data PacketData = MessageQueue_Read(&BLState->IncomingMsgQueue); + if (PacketData.Memory == 0) continue; + + blumen_packet Packet = *(blumen_packet*)PacketData.Memory; + switch (Packet.Type) { + case PacketType_PatternCommand: + { + microphone_packet Mic = Packet.MicPacket; + u64 NameHash = HashDJB2ToU32(Mic.AnimationFileName); + u32 NameLen = CStringLength(Mic.AnimationFileName); + + phrase_hue NewHue = PhraseHueMap_Find(BLState->PhraseHueMap, NameHash); + if (NewHue.Phrase.Length > 0) + { + bool IsLonger = (BLState->NextHotHue.Phrase.Length < NewHue.Phrase.Length); + bool IsntInPhraseReceptionMode = !BLState->InPhraseReceptionMode; + if (IsLonger || IsntInPhraseReceptionMode) + { + Log_Message(GlobalLogBuffer, "Queueing: %S\n", NewHue.Phrase); + + BLState->NextHotHue = NewHue; + if (SecondsElapsed(BLState->TimePhraseReceptionBegan, + Context->SystemTime_Current) > PhrasePriorityMessageGroupingTime) + { + BLState->TimePhraseReceptionBegan = Context->SystemTime_Current; + BLState->InPhraseReceptionMode = true; + } + BLState->TimeLastPhraseReceived = Context->SystemTime_Current; + } + } + }break; + + case PacketType_MotorState: + { + motor_status_packet Motor = Packet.MotorStatusPacket; + + // NOTE(pjs): Python sends multi-byte integers in little endian + // order. Have to unpack + u8* T = (u8*)&Motor.Temperature; + Motor.Temperature = (T[0] << 8 | + T[1] << 0); + + BlumenLumen_UpdateMotorState(BLState, Motor, *Context); + }break; + + case PacketType_Temperature: + { + temp_packet Temp = Packet.TempPacket; + BLState->LastTemperatureReceived = Temp.Temperature; + DEBUG_ReceivedTemperature(Temp, Context->ThreadContext); + BLState->ShouldUpdateLog = true; + }break; + + InvalidDefaultCase; + } + } + + + + if (BLState->InPhraseReceptionMode) + { + r32 SecondsSincePhraseBegan = SecondsElapsed(BLState->TimePhraseReceptionBegan, Context->SystemTime_Current); + if (SecondsSincePhraseBegan > PhrasePriorityMessageGroupingTime) + { + BlumenLumen_ApplyNextHotHue(BLState, *Context, &DebugStr, State); + } + } + + BlumenLumen_AdvanceHueFade(BLState, *Context); + + // Update next frames Hues + if (!BLState->DebugOverrideHue) + { + r32 AnimTime = AnimationSystem_GetCurrentTime(State->AnimationSystem); + AnimTime = (r32)Context->TotalTime; + r32 BaseTime = AnimTime * BLState->PatternSpeed; + + r32 ColorSpeed = 1; //.001; + r32 ColorOscSpeed = .05 * ColorSpeed; + r32 ColorRelOscSpeed = 1 * ColorSpeed;; + r32 ColorOscillation = (SinR32(BaseTime * ColorOscSpeed) + 1) / 2; + r32 ColorRelationship = 30 + (((1 + SinR32(BaseTime * ColorRelOscSpeed)) / 2) * 300); + + r32 H0 = ModR32(ColorOscillation * 360, 360); + r32 H1 = ModR32(BaseTime + ColorRelationship, 360); + // TODO(PS): use our new HSV lerp + r32 H2 = LerpR32(.3f, H0, H1); + + BLState->StandardPatternHues.Hue0.HSV = v4{ H0, 1, 1, 1 }; + BLState->StandardPatternHues.Hue1.HSV = v4{ H1, 1, 1, 1 }; + BLState->StandardPatternHues.Hue2.HSV = v4{ H2, 1, 1, 1 }; + + // Transition back to standard mode after some time + if (BLState->PatternMode == BlumenPattern_VoiceCommand) + { + u64 LastChangeClock = BLState->TimeLastSetToVoiceMode.NanosSinceEpoch; + u64 NowClocks = Context->SystemTime_Current.NanosSinceEpoch; + s64 NanosSinceChange = NowClocks - LastChangeClock; + r64 SecondsSinceChange = (r64)NanosSinceChange * NanosToSeconds; + + if (SecondsSinceChange > VoiceCommandSustainDuration) + { + BlumenLumen_SetPatternMode(BlumenPattern_Standard, GlobalAnimTransitionSpeed, &State->AnimationSystem, BLState); + BLState->ShouldUpdateLog = true; + } + } + + } + else + { + BLState->StandardPatternHues = BLState->DebugHue; + AnimationSystem_FadeToPlaylist(&State->AnimationSystem, BLState->ModeAnimations[BlumenPattern_VoiceCommand]); + + } + + // Open / Close the Motor + if (MessageQueue_CanWrite(BLState->OutgoingMsgQueue) && + !BLState->IgnoreTimeOfDay_MotorState) + { + bool SendMotorCommand = false; + + u64 NanosSinceLastSend = Context->SystemTime_Current.NanosSinceEpoch - BLState->LastSendTime.NanosSinceEpoch; + r32 SecondsSinceLastSend = (r64)NanosSinceLastSend * NanosToSeconds; + bool ShouldSendCurrentState = SecondsSinceLastSend >= MotorResendStatePeriod; + + bl_motor_state_value NewMotorState = MotorState_Closed; + bool SendOpen = false; + for (u32 i = 0; i < MotorOpenTimesCount; i++) + { + time_range Range = MotorOpenTimes[i]; + bool CurrTimeInRange = SystemTimeIsInTimeRange(Context->SystemTime_Current, Range); + if (CurrTimeInRange) { + NewMotorState = MotorState_Open; + } + } + + if (NewMotorState != BLState->LastSendState) + { + ShouldSendCurrentState = true; + } + + if (ShouldSendCurrentState) + { + BLState->LastSendTime = Context->SystemTime_Current; + BLState->LastSendState = NewMotorState; + + blumen_packet Packet = {}; + Packet.Type = PacketType_MotorState; + Packet.MotorPacket.FlowerPositions[0] = NewMotorState; + Packet.MotorPacket.FlowerPositions[1] = NewMotorState; + Packet.MotorPacket.FlowerPositions[2] = NewMotorState; + gs_data Msg = StructToData(&Packet, blumen_packet); + MessageQueue_Write(&BLState->OutgoingMsgQueue, Msg); + + DEBUG_SentMotorCommand(Packet.MotorPacket, Context->ThreadContext); + } + } + + // When a motor state changes to being open, wait to turn Upper Leds on + // in order to hide the fact that they are turning off + motor_packet CurrMotorPos = BLState->LastKnownMotorState; + u64 NowNanos = Context->SystemTime_Current.NanosSinceEpoch; + for (u32 i = 0; i < BL_FLOWER_COUNT; i++) + { + // have to map from "assembly load order" to + // the order that the clear core is referencing the + // motors by + assembly Assembly = State->Assemblies.Values[i]; + u64 AssemblyCCIndex = GetCCIndex(Assembly, BLState); + u8 MotorPos = CurrMotorPos.FlowerPositions[AssemblyCCIndex]; + + if ((MotorPos == MotorState_Open || MotorPos == MotorState_MostlyOpen) && + !BLState->ShouldDimUpperLeds[i]) + { + u64 ChangedNanos = BLState->LastTimeMotorStateChanged[i]; + u64 NanosSinceChanged = NowNanos - ChangedNanos; + r64 SecondsSinceChanged = (r64)NanosSinceChanged * NanosToSeconds; + if (SecondsSinceChanged > TurnUpperLedsOffAfterMotorCloseCommandDelay) + { + BLState->ShouldDimUpperLeds[i] = true; + } + else + { + BLState->ShouldDimUpperLeds[i] = false; + } + } + else if (MotorPos == MotorState_Closed || + MotorPos == MotorState_HalfOpen) + { + BLState->ShouldDimUpperLeds[i] = false; + + bool SendMotorCommand = false; + + u64 NanosSinceLastSend = Context->SystemTime_Current.NanosSinceEpoch - BLState->LastSendTime.NanosSinceEpoch; + r32 SecondsSinceLastSend = (r64)NanosSinceLastSend * NanosToSeconds; + bool ShouldSendCurrentState = SecondsSinceLastSend >= MotorResendStatePeriod; + + bl_motor_state_value NewMotorState = MotorState_Closed; + bool SendOpen = false; + for (u32 j = 0; j < MotorOpenTimesCount; j++) + { + time_range Range = MotorOpenTimes[j]; + bool CurrTimeInRange = SystemTimeIsInTimeRange(Context->SystemTime_Current, Range); + if (CurrTimeInRange) { + NewMotorState = MotorState_Open; + } + } + + + if (NewMotorState != BLState->LastSendState) + { + ShouldSendCurrentState = true; + } + + if (ShouldSendCurrentState) + { + BLState->LastSendTime = Context->SystemTime_Current; + BLState->LastSendState = NewMotorState; + + blumen_packet Packet = {}; + Packet.Type = PacketType_MotorState; + Packet.MotorPacket.FlowerPositions[0] = NewMotorState; + Packet.MotorPacket.FlowerPositions[1] = NewMotorState; + Packet.MotorPacket.FlowerPositions[2] = NewMotorState; + gs_data Msg = StructToData(&Packet, blumen_packet); + MessageQueue_Write(&BLState->OutgoingMsgQueue, Msg); + + DEBUG_SentMotorCommand(Packet.MotorPacket, Context->ThreadContext); + } + } + } + + // NOTE(PS): If the flowers are mostly open or full open + // we mask off the top leds to prevent them from overheating + // while telescoped inside the flower + for (u32 a = 0; a < BL_FLOWER_COUNT; a++) + { + assembly Assembly = State->Assemblies.Values[a]; + if (!BLState->ShouldDimUpperLeds[a]) continue; + + led_buffer Buffer = State->LedSystem.Buffers[Assembly.LedBufferIndex]; + led_strip_list TopStrips = AssemblyStripsGetWithTagValue(Assembly, ConstString("section"), ConstString("inner_bloom"), State->Transient); + for (u32 s = 0; s < TopStrips.Count; s++) + { + u32 SIndex = TopStrips.StripIndices[s]; + v2_strip Strip = Assembly.Strips[SIndex]; + for (u32 l = 0; l < Strip.LedCount; l++) + { + u32 LIndex = Strip.LedLUT[l]; + Buffer.Colors[LIndex] = {0}; + } + } + } + + if (!BLState->IgnoreTimeOfDay_LedDimming) + { + bool TimelineShouldAdvance = false; + r32 OverrideBrightness = 0.0f; + + time_range RangeIn = {}; + if (SystemTimeIsInTimeRangeList(Context->SystemTime_Current, + LedOnTimes, + LedOnTimesCount, + &RangeIn) || + DEBUGIgnoreLedOnTimeRange) + { + + if (Blumen_TempShouldDimLeds(BLState)) + { + OverrideBrightness = HighTemperatureBrightnessPercent; + } + else + { + OverrideBrightness = FullBrightnessPercent; + } + TimelineShouldAdvance = true; + } + + State->AnimationSystem.TimelineShouldAdvance = TimelineShouldAdvance; + BLState->BrightnessPercent = OverrideBrightness; + } + + // Dim the leds based on temp data + b8 ShouldDim = (State->AnimationSystem.UpdatesThisFrame > 0); + if (BLState->BrightnessPercent == 0) ShouldDim = true; + if (BLState->DEBUG_IgnoreWeatherDimmingLeds) ShouldDim = false; + if (ShouldDim) + { + led_buffer B0 = State->LedSystem.Buffers[0]; + pixel P0 = B0.Colors[0]; + + for (u32 i = 0; i < State->LedSystem.BuffersCount; i++) + { + led_buffer Buffer = State->LedSystem.Buffers[i]; + for (u32 j = 0; j < Buffer.LedCount; j++) + { + pixel* Color = Buffer.Colors + j; + Color->R = Color->R * BLState->BrightnessPercent; + Color->G = Color->G * BLState->BrightnessPercent; + Color->B = Color->B * BLState->BrightnessPercent; + } + } + + led_buffer B1 = State->LedSystem.Buffers[0]; + pixel P1 = B1.Colors[0]; + } + + // Send Status Packet + { + system_time LastSendTime = BLState->LastStatusUpdateTime; + r64 NanosSinceLastSend = ((r64)Context->SystemTime_Current.NanosSinceEpoch - (r64)LastSendTime.NanosSinceEpoch); + r64 SecondsSinceLastSend = NanosSinceLastSend * NanosToSeconds; + if (SecondsSinceLastSend >= STATUS_PACKET_FREQ_SECONDS) + { + BLState->LastStatusUpdateTime = Context->SystemTime_Current; + Log_Message(GlobalLogBuffer, "Attempting to Send Lumenarium Status\n"); + + blumen_packet Packet = {}; + Packet.Type = PacketType_LumenariumStatus; + Packet.StatusPacket.NextMotorEventType = 0; + Packet.StatusPacket.NextEventTime = 0; + + animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem); + if (ActiveAnim) + { + CopyMemoryTo(ActiveAnim->Name.Str, Packet.StatusPacket.AnimFileName, + Min(ActiveAnim->Name.Length, 32)); + Packet.StatusPacket.AnimFileName[ActiveAnim->Name.Length] = 0; + } + + gs_data Msg = StructToData(&Packet, blumen_packet); + MessageQueue_Write(&BLState->OutgoingMsgQueue, Msg); + + // there's no new information here, but by updating the log here, + // we're updating it at some infrequent but regular period that isnt + // every single frame + BLState->ShouldUpdateLog = true; + } + } + + BlumenLumen_UpdateLog(State, BLState, *Context); +} + +US_CUSTOM_DEBUG_UI(BlumenLumen_DebugUI) +{ + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData.Memory; + ui_interface* I = &State->Interface; + + ui_BeginRow(I, BlumenDebug_Count); + for (u32 i = 0; i < BlumenDebug_Count; i++) + { + if (ui_Button(I, MakeString(BlDebugUiModeStrings[i]))) + { + BLState->DebugMode = (bl_debug_ui_mode)i; + } + } + ui_EndRow(I); + + switch (BLState->DebugMode) + { + case BlumenDebug_Motors: + { + motor_packet PendingPacket = BLState->DEBUG_PendingMotorPacket; + + BLState->IgnoreTimeOfDay_MotorState = ui_ToggleText(I, MakeString("Motors Ignore Time Limit"), BLState->IgnoreTimeOfDay_MotorState); + + for (u32 MotorIndex = 0; MotorIndex < BL_FLOWER_COUNT; MotorIndex++) + { + gs_string Label = PushStringF(State->Transient, 32, "Motor %d", MotorIndex); + ui_BeginRow(I, 5); + { + ui_Label(I, Label); + + bool IsClosed = PendingPacket.FlowerPositions[MotorIndex] == MotorState_Closed; + if (ui_ToggleText(I, MakeString("Closed (1)"), IsClosed)) + { + PendingPacket.FlowerPositions[MotorIndex] = MotorState_Closed; + } + bool IsHOpen = PendingPacket.FlowerPositions[MotorIndex] == MotorState_HalfOpen; + if (ui_ToggleText(I, MakeString("Half Open (3)"), IsHOpen)) + { + PendingPacket.FlowerPositions[MotorIndex] = MotorState_HalfOpen; + } + bool IsMOpen = PendingPacket.FlowerPositions[MotorIndex] == MotorState_MostlyOpen; + if (ui_ToggleText(I, MakeString("Mostly Open (4)"), IsMOpen)) + { + PendingPacket.FlowerPositions[MotorIndex] = MotorState_MostlyOpen; + } + bool IsOpen = PendingPacket.FlowerPositions[MotorIndex] == MotorState_Open; + if (ui_ToggleText(I, MakeString("Open (2)"), IsOpen)) + { + PendingPacket.FlowerPositions[MotorIndex] = MotorState_Open; + } + } + ui_EndRow(I); + } + BLState->DEBUG_PendingMotorPacket = PendingPacket; + + if (ui_Button(I, MakeString("Send Motor Packet"))) + { + blumen_packet Packet = {}; + Packet.Type = PacketType_MotorState; + Packet.MotorPacket = BLState->DEBUG_PendingMotorPacket; + gs_data Msg = StructToData(&Packet, blumen_packet); + MessageQueue_Write(&BLState->OutgoingMsgQueue, Msg); + DEBUG_SentMotorCommand(Packet.MotorPacket, Context.ThreadContext); + + } + + motor_packet MotorPos = BLState->LastKnownMotorState; + ui_Label(I, MakeString("Current Motor Positions")); + { + for (u32 i = 0; i < BL_FLOWER_COUNT; i++) + { + ui_BeginRow(I, 2); + gs_string MotorStr = PushStringF(State->Transient, 32, + "Motor %d", + i); + ui_Label(I, MotorStr); + + gs_string StateStr = {}; + switch (MotorPos.FlowerPositions[i]) + { + case MotorState_Closed: { + StateStr = MakeString("Closed"); + } break; + case MotorState_HalfOpen: { + StateStr = MakeString("Half Open"); + } break; + case MotorState_MostlyOpen: { + StateStr = MakeString("Mostly Open"); + } break; + case MotorState_Open: { + StateStr = MakeString("Open"); + } break; + + default: + { + StateStr = MakeString("Invalid Value"); + } break; + } + + ui_Label(I, StateStr); + ui_EndRow(I); + } + } + + ui_Label(I, MakeString("Set Internal Motor State:")); + if (ui_Button(I, MakeString("Closed"))) + { + motor_status_packet Motor = {}; + Motor.Pos.FlowerPositions[0] = MotorState_Closed; + Motor.Pos.FlowerPositions[1] = MotorState_Closed; + Motor.Pos.FlowerPositions[2] = MotorState_Closed; + Motor.Temperature = 16; + + BlumenLumen_UpdateMotorState(BLState, Motor, Context); + } + if (ui_Button(I, MakeString("Open"))) + { + motor_status_packet Motor = {}; + Motor.Pos.FlowerPositions[0] = MotorState_Open; + Motor.Pos.FlowerPositions[1] = MotorState_Open; + Motor.Pos.FlowerPositions[2] = MotorState_Open; + Motor.Temperature = 16; + + BlumenLumen_UpdateMotorState(BLState, Motor, Context); + } + } break; + + case BlumenDebug_Leds: + { + BLState->DEBUG_IgnoreWeatherDimmingLeds = ui_LabeledToggle(I, MakeString("Ignore Weather Dimming Leds"), BLState->DEBUG_IgnoreWeatherDimmingLeds); + + BLState->IgnoreTimeOfDay_LedDimming = ui_ToggleText(I, MakeString("Leds Ignore Time Limit"), BLState->IgnoreTimeOfDay_LedDimming); + + if (ui_BeginLabeledDropdown(I, MakeString("Phrase"), MakeString(BLState->PendingPhrase.Phrase))) + { + u32 ListCount = BLState->PhraseHueMap.Count; + ui_BeginList(I, MakeString("Phrase List"), 5, ListCount); + for (u32 i = 0; i < ListCount; i++) + { + gs_string Str = MakeString(BLState->PhraseHueMap.Phrases[i]); + if (ui_Button(I, Str)) + { + BLState->PendingPhrase = PhraseHueMap_Get(BLState->PhraseHueMap, i); + BLState->DebugHue = BLState->PendingPhrase; + } + } + ui_EndList(I); + } + ui_EndLabeledDropdown(I); + if (ui_Button(I, MakeString("Say Phrase"))) + { + gs_string DebugStr = PushString(State->Transient, 256); + BLState->NextHotHue = BLState->PendingPhrase; + BlumenLumen_ApplyNextHotHue(BLState, Context, &DebugStr, State); + } + + ui_Label(I, MakeString("Phrase Constructor")); + BLState->DebugOverrideHue = ui_ToggleText(I, MakeString("Override Hue"), BLState->DebugOverrideHue); + if (BLState->DebugOverrideHue) + { + phrase_hue PHue = BLState->DebugHue; + PHue.Hue0.HSV.x = (r64)ui_LabeledRangeSlider(I, MakeString("Hue0"), (r32)PHue.Hue0.HSV.x, 0, 360); + PHue.Hue1.HSV.x = (r64)ui_LabeledRangeSlider(I, MakeString("Hue1"), (r32)PHue.Hue1.HSV.x, 0, 360); + PHue.Hue2.HSV.x = (r64)ui_LabeledRangeSlider(I, MakeString("Hue2"), (r32)PHue.Hue2.HSV.x, 0, 360); + PHue.Granularity = (u32)ui_LabeledRangeSlider(I, MakeString("Granularity"), (r32)PHue.Granularity, 0, 5); + PHue.Speed = ui_LabeledRangeSlider(I, MakeString("Speed"), PHue.Speed, 0, 4); + + gs_string PatternOptions[HuePattern_Count] = {}; + PatternOptions[HuePattern_Patchy] = MakeString("patchy"); + PatternOptions[HuePattern_Wavy] = MakeString("wavy"); + + gs_string CPattern = PatternOptions[PHue.Pattern]; + if (ui_BeginLabeledDropdown(I, MakeString("Pattern"), CPattern)) + { + for (u32 i = 0; i < HuePattern_Count; i++) + { + if (ui_Button(I, PatternOptions[i])) + { + PHue.Pattern = i; + } + } + } + ui_EndLabeledDropdown(I); + + + gs_string AddInOptions[AddIn_Count] = {}; + AddInOptions[AddIn_None] = MakeString("NA"); + AddInOptions[AddIn_Waves] = MakeString("waves"); + AddInOptions[AddIn_Rotary] = MakeString("rotary"); + + gs_string CAddIn = AddInOptions[PHue.AddIn]; + if (ui_BeginLabeledDropdown(I, MakeString("Add In"), CAddIn)) + { + for (u32 i = 0; i < AddIn_Count; i++) + { + if (ui_Button(I, AddInOptions[i])) + { + PHue.AddIn = i; + } + } + } + ui_EndLabeledDropdown(I); + BLState->DebugHue = PHue; + } + + + InterfaceAssert(I->PerFrameMemory); + }break; + + case BlumenDebug_Awaken: + { + ui_Label(I, MakeString("Step 1:")); + ui_Label(I, MakeString("Leds off, flowers closed")); + if (ui_Button(I, MakeString("Prepare"))) + { + // motors closed + blumen_packet M = {}; + M.Type = PacketType_MotorState; + M.MotorPacket.FlowerPositions[0] = MotorState_Closed; + M.MotorPacket.FlowerPositions[1] = MotorState_Closed; + M.MotorPacket.FlowerPositions[2] = MotorState_Closed; + gs_data D = StructToData(&M, blumen_packet); + MessageQueue_Write(&BLState->OutgoingMsgQueue, D); + + // animation + State->AnimationSystem.RepeatMode = AnimationRepeat_Single; + AnimationFadeGroup_FadeTo(&State->AnimationSystem.ActiveFadeGroup, + BLState->OffAnimHandle, + VoiceCommandFadeDuration); + + BLState->PatternMode = BlumenPattern_NoControl; + BLState->IgnoreTimeOfDay_LedDimming = true; + BLState->IgnoreTimeOfDay_MotorState = true; + } + + ui_Label(I, MakeString("Step 2:")); + if (ui_Button(I, MakeString("Begin Light Show"))) + { + AnimationFadeGroup_FadeTo(&State->AnimationSystem.ActiveFadeGroup, + BLState->AwakenHandle, + VoiceCommandFadeDuration); + } + + ui_Label(I, MakeString("Step 3:")); + if (ui_Button(I, MakeString("Open Flowers"))) + { + // motors closed + blumen_packet M = {}; + M.Type = PacketType_MotorState; + M.MotorPacket.FlowerPositions[0] = MotorState_Open; + M.MotorPacket.FlowerPositions[1] = MotorState_Open; + M.MotorPacket.FlowerPositions[2] = MotorState_Open; + gs_data D = StructToData(&M, blumen_packet); + MessageQueue_Write(&BLState->OutgoingMsgQueue, D); + } + + ui_Label(I, MakeString("Step 4:")); + ui_Label(I, MakeString("Resets Lumenarium")); + if (ui_Button(I, MakeString("Complete"))) + { + BLState->IgnoreTimeOfDay_LedDimming = false; + BLState->IgnoreTimeOfDay_MotorState = false; + BlumenLumen_SetPatternMode(BlumenPattern_Standard, GlobalAnimTransitionSpeed, &State->AnimationSystem, + BLState); + } + }break; + + InvalidDefaultCase; + } +} + +US_CUSTOM_CLEANUP(BlumenLumen_CustomCleanup) +{ + blumen_lumen_state* BLState = (blumen_lumen_state*)UserData.Memory; + BLState->Running = false; +} + +internal user_space_desc +BlumenLumen_UserSpaceCreate() +{ + user_space_desc Result = {}; + Result.LoadPatterns = BlumenLumen_LoadPatterns; + Result.CustomInit = BlumenLumen_CustomInit; + Result.CustomUpdate = BlumenLumen_CustomUpdate; + Result.CustomDebugUI = BlumenLumen_DebugUI; + Result.CustomCleanup = BlumenLumen_CustomCleanup; + return Result; +} + +#define BLUMEN_LUMEN_CPP +#endif // BLUMEN_LUMEN_CPP diff --git a/src/app/ss_blumen_lumen/blumen_lumen.h b/src/app/ss_blumen_lumen/blumen_lumen.h new file mode 100644 index 0000000..fb04238 --- /dev/null +++ b/src/app/ss_blumen_lumen/blumen_lumen.h @@ -0,0 +1,393 @@ +// +// File: blumen_lumen.h +// Author: Peter Slattery +// Creation Date: 2021-01-15 +// +#ifndef BLUMEN_LUMEN_H + +#include "message_queue.h" + +enum bl_debug_ui_mode +{ + BlumenDebug_Motors, + BlumenDebug_Leds, + BlumenDebug_Awaken, + + BlumenDebug_Count, +}; + +char* BlDebugUiModeStrings[] = { + "Motors", + "Leds", + "Awaken", +}; + +enum bl_pattern_mode +{ + BlumenPattern_Standard, + BlumenPattern_VoiceCommand, + BlumenPattern_NoControl, + + BlumenPattern_Count, +}; + +enum bl_python_packet_type +{ + PacketType_Invalid = 0, + PacketType_PatternCommand = 1, + PacketType_MotorState = 2, + PacketType_Temperature = 3, + PacketType_LumenariumStatus = 4, +}; + +enum bl_motor_state_value +{ + MotorState_Invalid = 0, + + MotorState_Closed = 1, + MotorState_Open = 2, + MotorState_HalfOpen = 3, + MotorState_MostlyOpen = 4, +}; + +#pragma pack(push, 1) +typedef struct motor_packet +{ + u8 FlowerPositions[3]; +} motor_packet; + +typedef struct motor_status_packet +{ + motor_packet Pos; + u8 MotorStatus[3]; + u16 Temperature; + +} motor_status_packet; + +typedef struct microphone_packet +{ + b8 ChangeAnimation; + char AnimationFileName[32]; + b8 SetLayer; + char LayerName[32]; + r32 LayerOpacity; + b8 SetLayerParamColor; + char LayerParamColor[7]; + r32 OverrideDuration; +} microphone_packet; + +typedef struct temp_packet +{ + s8 Temperature; +} temp_packet; + +enum motor_event_type +{ + MotorEvent_Close = 0, + MotorEvent_Open = 1, +}; + +typedef struct status_packet +{ + u8 NextMotorEventType; + // u16 Padding; + u32 NextEventTime; + + char AnimFileName[32]; +} status_packet; + +typedef struct blumen_packet +{ + u8 Type; + union + { + motor_packet MotorPacket; + motor_status_packet MotorStatusPacket; + microphone_packet MicPacket; + temp_packet TempPacket; + status_packet StatusPacket; + }; +} blumen_packet; + +#pragma pack(pop) + +// TODO(pjs): Refactor this -> blumen_network_job_state +struct mic_listen_job_data +{ + bool* Running; + + platform_socket_manager* SocketManager; + blumen_network_msg_queue* IncomingMsgQueue; + + blumen_network_msg_queue* OutgoingMsgQueue; + + // Status + bool IsConnected; +}; + +typedef struct time_range +{ + s32 StartHour; + s32 StartMinute; + + s32 EndHour; + s32 EndMinute; +} time_range; + +internal bool +SystemTimeIsBeforeTime(system_time SysTime, s32 Hour, s32 Minute) +{ + bool Result = false; + if (SysTime.Hour == Hour) { + Result = SysTime.Minute < Minute; + } else { + Result = SysTime.Hour < Hour; + } + return Result; +} + +internal bool +SystemTimeIsAfterTime(system_time SysTime, s32 Hour, s32 Minute) +{ + bool Result = false; + if (SysTime.Hour == Hour) { + Result = SysTime.Minute >= Minute; + } else { + Result = SysTime.Hour > Hour; + } + return Result; +} + +internal bool +SystemTimeIsInTimeRange(system_time SysTime, time_range Range) +{ + bool Result = false; + + bool IsAfterStartTime = SystemTimeIsAfterTime(SysTime, Range.StartHour, Range.StartMinute); + bool IsBeforeEndTime = SystemTimeIsBeforeTime(SysTime, Range.EndHour, Range.EndMinute); + Result = IsAfterStartTime && IsBeforeEndTime; + + return Result; +} + +internal bool +SystemTimeIsInTimeRangeList(system_time SysTime, time_range* Ranges, u32 RangesCount, time_range* RangeOut = 0) +{ + bool Result = false; + for (u32 i = 0; i < RangesCount; i++) + { + time_range Range = Ranges[i]; + bool CurrTimeInRange = SystemTimeIsInTimeRange(SysTime, Range); + if (CurrTimeInRange) + { + Result = true; + if (RangeOut != 0) { + *RangeOut = Range; + } + break; + } + } + return Result; +} + +#include "blumen_lumen_settings.h" + +struct blumen_lumen_state +{ + bool Running; + + blumen_network_msg_queue IncomingMsgQueue; + blumen_network_msg_queue OutgoingMsgQueue; + + temp_job_req JobReq; + + led_strip_list StemStrips[BL_FLOWER_COUNT]; + + platform_thread_handle MicListenThread; + mic_listen_job_data MicListenJobData; + + motor_packet LastKnownMotorState; + u64 LastTimeMotorStateChanged[BL_FLOWER_COUNT]; + b8 ShouldDimUpperLeds[BL_FLOWER_COUNT]; + + // NOTE(pjs): Based on temperature data from weatherman + // dim the leds. + r32 BrightnessPercent; + s8 LastTemperatureReceived; + system_time LastStatusUpdateTime; + + system_time LastSendTime; + bl_motor_state_value LastSendState; + + phrase_hue StandardPatternHues; + r32 AssemblyColorsTransitionTimeLeft[BL_FLOWER_COUNT]; + phrase_hue NextAssemblyColors[BL_FLOWER_COUNT]; + phrase_hue AssemblyColors[BL_FLOWER_COUNT]; + u32 LastAssemblyColorSet; + + // The indices of this array are the index the clear core uses to + // represent a motor. + // The values of the array are the names Lumenarium uses to + // represent assemblies. + // + u32 AssemblyNameToClearCoreMapCount; + u64* AssemblyNameToClearCore_Names; + + bl_pattern_mode PatternMode; + animation_handle_array ModeAnimations[BlumenPattern_Count]; + animation_handle OffAnimHandle; + animation_handle AwakenHandle; + + phrase_hue_map PhraseHueMap; + + bool InPhraseReceptionMode; + phrase_hue NextHotHue; + system_time TimePhraseReceptionBegan; + system_time TimeLastPhraseReceived; + + system_time TimeLastSetToVoiceMode; + phrase_hue LastHuePhrase; + + r32 PatternSpeed; + + // Debug + bl_debug_ui_mode DebugMode; + + motor_packet DEBUG_PendingMotorPacket; + bool DEBUG_IgnoreWeatherDimmingLeds; + + bool ShouldUpdateLog; + bool IgnoreTimeOfDay_LedDimming; + bool IgnoreTimeOfDay_MotorState; + + phrase_hue PendingPhrase; + + bool DebugOverrideHue; + phrase_hue DebugHue; +}; + +internal bool +Blumen_TempShouldDimLeds(blumen_lumen_state* BLState) +{ + bool Result = BLState->LastTemperatureReceived > MinHighTemperature; + return Result; +} + +#include "message_queue.cpp" + +internal void +BlumenLumen_SetNextHue(blumen_lumen_state* BLState, u32 AssemblyIndex, phrase_hue Hue) +{ +#if 1 + BLState->NextAssemblyColors[AssemblyIndex] = Hue; + BLState->AssemblyColorsTransitionTimeLeft[AssemblyIndex] = PhraseHueFadeInDuration; +#else + BLState->AssemblyColors[AssemblyIndex] = Hue; +#endif +} + +internal void +BlumenLumen_AdvanceHueFade(blumen_lumen_state* BLState, context Context) +{ + for (u32 i = 0; i < BL_FLOWER_COUNT; i++) + { + r32 T = BLState->AssemblyColorsTransitionTimeLeft[i]; + if (T > 0) + { + T -= Context.DeltaTime; + if (T <= 0) + { + BLState->AssemblyColors[i] = BLState->NextAssemblyColors[i]; + } + BLState->AssemblyColorsTransitionTimeLeft[i] = T; + } + } +} + +internal phrase_hue +BlumenLumen_GetCurrentHue(blumen_lumen_state* BLState, assembly Assembly) +{ + phrase_hue Result = {}; + + switch (BLState->PatternMode) + { + case BlumenPattern_NoControl: + case BlumenPattern_Standard: + { + Result = BLState->StandardPatternHues; + }break; + + case BlumenPattern_VoiceCommand: + { + u32 i = Assembly.AssemblyIndex % 3; + r32 T = BLState->AssemblyColorsTransitionTimeLeft[i]; + if (T > 0) + { + T = Clamp(T / PhraseHueFadeInDuration, 0, 1); + Result = LerpPhraseHue(T, BLState->NextAssemblyColors[i], BLState->AssemblyColors[i]); + } else { + Result = BLState->AssemblyColors[i]; + } + }break; + } + + return Result; +} + + + + + + + + + + + + + + + + +// If you change anything, exit lumenarium if its running +// then in this application hit f1 to compile then +// go to remedybg (the debugger) and hit f5 + + +// don't touch this +u8 LastPosition = 1; + +u8 ClosedValue = 1; +u8 OpenValue = 2; + + +r64 MotorTimeElapsed = 0; +r64 OpenClosePeriod = 15.0f; + + + + + + + + + + + + + + + + + + + + + + + + + + +#define BLUMEN_LUMEN_H +#endif // BLUMEN_LUMEN_H \ No newline at end of file diff --git a/src/app/ss_blumen_lumen/blumen_lumen_settings.h b/src/app/ss_blumen_lumen/blumen_lumen_settings.h new file mode 100644 index 0000000..59d4767 --- /dev/null +++ b/src/app/ss_blumen_lumen/blumen_lumen_settings.h @@ -0,0 +1,135 @@ +/* date = March 27th 2021 2:50 pm */ + +#ifndef BLUMEN_LUMEN_SETTINGS_H +#define BLUMEN_LUMEN_SETTINGS_H + +// Hey you never know, might need to change this some day lololol +// The number of flowers in the sculpture. Used to size all sorts of +// arrays. Maybe don't touch this unless you really know what you're doing? +#define BL_FLOWER_COUNT 3 + +// The path to the three flower assembly files +// PS is 90% sure you don't need to touch these ever +gs_const_string Flower0AssemblyPath = ConstString("data/ss_blumen_one.fold"); +gs_const_string Flower1AssemblyPath = ConstString("data/ss_blumen_two.fold"); +gs_const_string Flower2AssemblyPath = ConstString("data/ss_blumen_three.fold"); + +// The path to the phrase map CSV. Can be an absolute path, or relative +// to the app_run_tree folder +gs_const_string PhraseMapCSVPath = ConstString("C:/projects/flowers-sound/flower_codes.tsv"); +char PhraseMapCSVSeparator = '\t'; + +// Search Strings for which folders to find ambient animation files and +// voice animation files in. +// these search patterns should always end in *.foldanim so they only +// return valid animation files +gs_const_string AmbientPatternFolder = ConstString("data/blumen_animations/ambient_patterns/*.foldanim"); +gs_const_string VoicePatternFolder = ConstString("data/blumen_animations/audio_responses/*.foldanim"); + +// The times of day when the motors should be open. +// +// @TimeFormat: documentation follows +// these are in the format { Start_Hour, Start_Minute, End_Hour, End_Minute } +// Hours are in the range 0-23 inclusive +// Minutes are in the range 0-59 inclusive +// +// NOTE: There is no need to modify the MotorOpenTimesCount variable - +// it is a compile time constant that gets calculated automatically +global time_range MotorOpenTimes[] = { + { 8, 00, 12, 00 }, // 8:00am to 12:00pm + { 12, 30, 18, 00 }, // 12:30pm to 06:00pm + { 18, 30, 22, 00 }, // 6:30pm to 10:00pm +}; +global u32 MotorOpenTimesCount = CArrayLength(MotorOpenTimes); // do not edit + +// Lumenarium repeatedly resends the current motor state to the python +// server. This variable determines how much time elapses between each +// message. +global r32 MotorResendStatePeriod = 90.0f; // seconds + +// The times of day when the leds should be on +// Search for @TimeFormat to find documentation +global time_range LedOnTimes[] = { + { 17, 00, 23, 59 }, + { 00, 00, 06, 30 }, +}; +global u32 LedOnTimesCount = CArrayLength(LedOnTimes); // do not edit +global b8 DEBUGIgnoreLedOnTimeRange = false; + +// How long it takes to fade from the default pattern to the +// voice activated pattern +r32 VoiceCommandFadeDuration = 0.5f; // in seconds + +// How long the voice activated pattern will remain active +// without additional voice commands, before fading back to +// default behaviour. +// ie. +// if this is set to 30 seconds, upon receiving a voice command +// lumenarium will fade to the requested pattern/color palette +// and then wait 30 seconds before fading back to the original +// pattern. If, in that 30 second window, another voice command +// is issued, lumenarium will reset the 30 second counter. +r64 VoiceCommandSustainDuration = 120.0; // in seconds + +// When we send a Motor Close command, we don't want the upper leds to +// immediately turn off. Instead, we want to wait until the flower is +// at least some of the way closed. This variable dictates how long +// we wait for. +// For example: +// 1. We send a 'motor close' command to the clear core +// 2. the clear core sends back a 'motor closed' state packet +// 3. We begin a timer +// 4. When the timer reaches the value set in this variable, +// we turn the upper leds off. +// +// NOTE: This is not a symmetric operation. When we send a 'motor open' +// command, we want to immediately turn the upper leds on so they appear +// to have been on the whole time. +r64 TurnUpperLedsOffAfterMotorCloseCommandDelay = 120.0; // in seconds + + +// NOTE: Temperature & Time of Day Based Led Brightness Settings + +// The temperature above which we dim the leds to +// HighTemperatureBrightnessPercent (below) +// +// NOTE: this is an 8bit signed integer so its range is +// -128 to 127, not that we should need either of those extremes for +// this, but just a note that you can't just put anything in here. +s8 MinHighTemperature = 26; + +// The percent brightness we set leds to during high temperatures. +// A value in the range 0:1 inclusive +// This is multiplied by each pixels R, G, & B channels before being +// sent. So if it is set to .1f, then the maximum brightness value sent +// to any channel of any pixel will be 25 (255 * .1 = 25). +r32 HighTemperatureBrightnessPercent = 0.25f; + +// The percent brightness we set leds to when no other conditions apply +// A value in the range 0:1 inclusive. +// Probably wants to be something high like 1 but we might want to +// lower it for heat reasons? +r32 FullBrightnessPercent = 0.50f; + +// A global modifier so Joerg can just slow all the patterns right down +// XD +// This is a percent - so 1 is full speed, 0.1f is 1/10 full speed and +// 2 is 2x as fast. +r32 GlobalAnimSpeed = 1.0f; + +// How long it takes to fade from one animation to the next. +// This is used both for transitioning between animation files +// as well as transitioning from Standard pattern mode to voice +// activated mode +r32 GlobalAnimTransitionSpeed = 0.0f; + +// how long it takes to fade from the old voice hue to the new one +r32 PhraseHueFadeInDuration = 0.01f; // seconds + +r64 PhrasePriorityMessageGroupingTime = 0.1f; + +// How often should Lumenarium send its status to the python server? +// +#define STATUS_PACKET_FREQ_SECONDS 10 // in seconds + +#endif //BLUMEN_LUMEN_SETTINGS_H diff --git a/src/app/ss_blumen_lumen/gfx_math.h b/src/app/ss_blumen_lumen/gfx_math.h new file mode 100644 index 0000000..34b667d --- /dev/null +++ b/src/app/ss_blumen_lumen/gfx_math.h @@ -0,0 +1,461 @@ +/* date = March 31st 2021 2:19 am */ + +#ifndef GFX_MATH_H +#define GFX_MATH_H + +internal r32 +Smoothstep(r32 T) +{ + r32 Result = (T * T * (3 - (2 * T))); + return Result; +} +internal r32 +Smoothstep(r32 T, r32 A, r32 B) +{ + return LerpR32(Smoothstep(T), A, B); +} +internal v3 +Smoothstep(v3 P) +{ + v3 R = {}; + R.x = Smoothstep(P.x); + R.y = Smoothstep(P.y); + R.z = Smoothstep(P.z); + return R; +} + +internal v3 +AbsV3(v3 P) +{ + v3 Result = {}; + Result.x = Abs(P.x); + Result.y = Abs(P.y); + Result.z = Abs(P.z); + return Result; +} + +internal v2 +FloorV2(v2 P) +{ + v2 Result = {}; + Result.x = FloorR32(P.x); + Result.y = FloorR32(P.y); + return Result; +} +internal v3 +FloorV3(v3 P) +{ + v3 Result = {}; + Result.x = FloorR32(P.x); + Result.y = FloorR32(P.y); + Result.z = FloorR32(P.z); + return Result; +} + +internal v2 +FractV2(v2 P) +{ + v2 Result = {}; + Result.x = FractR32(P.x); + Result.y = FractR32(P.y); + return Result; +} +internal v3 +FractV3(v3 P) +{ + v3 Result = {}; + Result.x = FractR32(P.x); + Result.y = FractR32(P.y); + Result.z = FractR32(P.z); + return Result; +} + +internal v2 +SinV2(v2 P) +{ + v2 Result = {}; + Result.x = SinR32(P.x); + Result.y = SinR32(P.y); + return Result; +} +internal v3 +SinV3(v3 P) +{ + v3 Result = {}; + Result.x = SinR32(P.x); + Result.y = SinR32(P.y); + Result.y = SinR32(P.z); + return Result; +} + +internal r32 +Hash1(v2 P) +{ + v2 Result = FractV2( P * 0.3183099f ) * 50.f; + return FractR32(P.x * P.y * (P.x + P.y)); +} + +internal r32 +Hash1(r32 N) +{ + return FractR32(N * 17.0f * FractR32(N * 0.3183099f)); +} + +internal v2 +Hash2(r32 N) +{ + v2 P = V2MultiplyPairwise(SinV2(v2{N,N+1.0f}), v2{43758.5453123f,22578.1459123f}); + return FractV2(P); +} + +internal v2 +Hash2(v2 P) +{ + v2 K = v2{ 0.3183099f, 0.3678794f }; + v2 Kp = v2{K.y, K.x}; + v2 R = V2MultiplyPairwise(P, K) + Kp; + return FractV2( K * 16.0f * FractR32( P.x * P.y * (P.x + P.y))); +} + +internal v3 +Hash3(v2 P) +{ + v3 Q = v3{}; + Q.x = V2Dot(P, v2{127.1f, 311.7f}); + Q.y = V2Dot(P, v2{267.5f, 183.3f}); + Q.z = V2Dot(P, v2{419.2f, 371.9f}); + return FractV3(SinV3(Q) * 43758.5453f); +} + +internal r32 +HashV3ToR32(v3 P) +{ + v3 Pp = FractV3(P * 0.3183099f + v3{0.1f, 0.1f, 0.1f}); + Pp *= 17.0f; + r32 Result = FractR32(Pp.x * Pp.y * Pp.z * (Pp.x + Pp.y + Pp.z)); + return Result; +} + +internal r32 +Random(v2 N) +{ + v2 V = v2{12.9898f, 4.1414f}; + return FractR32(SinR32(V2Dot(N, V)) * 43758.5453); +} + +internal r32 +Noise2D(v2 P) +{ + v2 IP = FloorV2(P); + v2 U = FractV2(P); + U = V2MultiplyPairwise(U, U); + U = V2MultiplyPairwise(U, ((U * 2.0f) + v2{-3, -3})); + + r32 A = LerpR32(U.x, Random(IP), Random(IP + v2{1.0f, 0})); + r32 B = LerpR32(U.x, Random(IP + v2{0, 1}), Random(IP + v2{1, 1})); + r32 Res = LerpR32(U.y, A, B); + + return Res * Res; +} + +internal r32 +Noise3D(v3 P) +{ + P = AbsV3(P); + v3 PFloor = FloorV3(P); + v3 PFract = FractV3(P); + v3 F = Smoothstep(PFract); + + r32 Result = LerpR32(F.z, + LerpR32(F.y, + LerpR32(F.x, + HashV3ToR32(PFloor + v3{0, 0, 0}), + HashV3ToR32(PFloor + v3{1, 0, 0})), + LerpR32(F.x, + HashV3ToR32(PFloor + v3{0, 1, 0}), + HashV3ToR32(PFloor + v3{1, 1, 0}))), + LerpR32(F.y, + LerpR32(F.x, + HashV3ToR32(PFloor + v3{0, 0, 1}), + HashV3ToR32(PFloor + v3{1, 0, 1})), + LerpR32(F.x, + HashV3ToR32(PFloor + v3{0, 1, 1}), + HashV3ToR32(PFloor + v3{1, 1, 1})))); + + Assert(Result >= 0 && Result <= 1); + return Result; +} + +internal r32 +Noise3D_(v3 Pp) +{ + v3 P = FloorV3(Pp); + v3 W = FractV3(Pp); + + //v3 U = W * W * W * (W * (W * 6.0f - 15.0f) + 10.0f); + v3 U = V3MultiplyPairwise(W, W * 6.0f - v3{15, 15, 15}); + U = U + v3{10, 10, 10}; + U = V3MultiplyPairwise(U, W); + U = V3MultiplyPairwise(U, W); + U = V3MultiplyPairwise(U, W); + + r32 N = P.x + 317.0f * P.y + 157.0f * P.z; + + r32 A = Hash1(N + 0.0f); + r32 B = Hash1(N + 1.0f); + r32 C = Hash1(N + 317.0f); + r32 D = Hash1(N + 317.0f); + r32 E = Hash1(N + 157.0f); + r32 F = Hash1(N + 158.0f); + r32 G = Hash1(N + 474.0f); + r32 H = Hash1(N + 475.0f); + + r32 K0 = A; + r32 K1 = B - A; + r32 K2 = C - A; + r32 K3 = E - A; + r32 K4 = A - B - C + D; + r32 K5 = A - C - E + G; + r32 K6 = A - B - E + F; + r32 K7 = A + B + C - D + E - F - G + H; + + return -1.0f + 2.0f * (K0 + + K1 * U.x + + K2 * U.y + + K3 * U.z + + K4 * U.x * U.y + + K5 * U.y + U.z + + K6 * U.z * U.x + + K7 * U.x * U.y * U.z); +} + +internal r32 +Fbm2D(v2 P) +{ + r32 R = 0; + r32 Amp = 1.0; + r32 Freq = 1.0; + for (u32 i = 0; i < 3; i++) + { + R += Amp * Noise2D(P * Freq); + Amp *= 0.5f; + Freq *= 1.0f / 0.5f; + } + return R; +} + +global m44 M3 = m44{ + 0.00f, 0.80f, 0.60f, 0, + -0.80f, 0.36f, -0.48f, 0, + -0.60f, -0.48f, 0.64f, 0, + 0, 0, 0, 1 +}; + +internal r32 +Fbm3D(v3 P) +{ + v3 X = P; + r32 F = 2.0f; + r32 S = 0.5f; + r32 A = 0.0f; + r32 B = 0.5f; + for (u32 i = 0; i < 4; i++) + { + r32 N = Noise3D(X); + A += B * N; + B *= S; + v4 Xp = M3 * ToV4Point(X); + X = Xp.xyz * F; + } + + return A; +} + +internal r32 +Fbm3D(v3 P, r32 T) +{ + v3 Tt = v3{T, T, T}; + r32 SinT = SinR32(T); + v3 Tv = v3{SinT, SinT, SinT}; + v3 Pp = P; + r32 F = 0.0; + + F += 0.500000f * Noise3D(Pp + Tt); Pp = Pp * 2.02; + //F += 0.031250f * Noise3D(Pp); Pp = Pp * 2.01; + F += 0.300000f * Noise3D(Pp - Tt); Pp = Pp * 2.03; + F += 0.125000f * Noise3D(Pp); Pp = Pp * 2.01; + F += 0.062500f * Noise3D(Pp + Tt); Pp = Pp * 2.04; + //F += 0.015625f * Noise3D(Pp + Tv); + r32 D = 0.9875f; + + F = F / D; + return F; +} + +internal r32 +Voronoise(v2 P, r32 U, r32 V) +{ + r32 K = 1.0f + 63.0f + PowR32(1.0f - V, 6.0f); + + v2 I = FloorV2(P); + v2 F = FractV2(P); + + v2 A = v2{0, 0}; + for (s32 y = -2; y <= 2; y++) + { + for (s32 x = -2; x <= 2; x++) + { + v2 G = v2{(r32)x, (r32)y}; + v3 O = V3MultiplyPairwise(Hash3(I + G), v3{U, U, 1.0f}); + v2 D = G - F + O.xy; + r32 W = PowR32(1.0f - Smoothstep(V2Mag(D), 0.0f, 1.414f), K); + A += v2{O.z * W, W}; + } + } + + return A.x / A.y; +} + + +v4 RGBToHSV(v4 In) +{ + v4 Result = {}; + + r32 Min = Min(In.r, Min(In.g, In.b)); + r32 Max = Max(In.r, Max(In.g, In.b)); + + r32 V = Max; + r32 Delta = Max - Min; + r32 S = 0; + r32 H = 0; + if( Max != 0 ) + { + S = Delta / Max; + + if( In.r == Max ) + { + H = ( In.g - In.b ) / Delta; // between yellow & magenta + } + else if( In.g == Max ) + { + H = 2 + ( In.b - In.r ) / Delta; // between cyan & yellow + } + else + { + H = 4 + ( In.r - In.g ) / Delta; // between magenta & cyan + } + H *= 60; // degrees + if( H < 0 ) + H += 360; + Result = v4{H, S, V, 1}; + } + else + { + // r = g = b = 0 + // s = 0, v is undefined + S = 0; + H = -1; + Result = v4{H, S, 1, 1}; + } + + return Result; +} + +v4 HSVToRGB (v4 In) +{ + float Hue = In.x; + /* +while (Hue > 360.0f) { Hue -= 360.0f; } + while (Hue < 0.0f) { Hue += 360.0f; } + */ + Hue = ModR32(Hue, 360.0f); + if (Hue < 0) { Hue += 360.0f; } + if (Hue == MinR32) { Hue = 0; } + if (Hue == MaxR32) { Hue = 360; } + Assert(Hue >= 0 && Hue < 360); + + float Sat = In.y; + float Value = In.z; + + float hh, p, q, t, ff; + long i; + v4 Result = {}; + Result.a = In.a; + + if(Sat <= 0.0f) { // < is bogus, just shuts up warnings + Result.r = Value; + Result.g = Value; + Result.b = Value; + return Result; + } + hh = Hue; + if(hh >= 360.0f) hh = 0.0f; + hh /= 60.0f; + i = (long)hh; + ff = hh - i; + p = Value * (1.0f - Sat); + q = Value * (1.0f - (Sat * ff)); + t = Value * (1.0f - (Sat * (1.0f - ff))); + + switch(i) { + case 0: + {Result.r = Value; + Result.g = t; + Result.b = p; + }break; + + case 1: + { + Result.r = q; + Result.g = Value; + Result.b = p; + }break; + + case 2: + { + Result.r = p; + Result.g = Value; + Result.b = t; + }break; + + case 3: + { + Result.r = p; + Result.g = q; + Result.b = Value; + }break; + + case 4: + { + Result.r = t; + Result.g = p; + Result.b = Value; + }break; + + case 5: + default: + { + Result.r = Value; + Result.g = p; + Result.b = q; + }break; + } + + return Result; +} + +internal pixel +V4ToRGBPixel(v4 C) +{ + C.x = Clamp01(C.x); + C.y = Clamp01(C.y); + C.z = Clamp01(C.z); + + pixel Result = {}; + Result.R = (u8)(C.x * 255); + Result.G = (u8)(C.y * 255); + Result.B = (u8)(C.z * 255); + return Result; +} + +#endif //GFX_MATH_H diff --git a/src/app/ss_blumen_lumen/message_queue.cpp b/src/app/ss_blumen_lumen/message_queue.cpp new file mode 100644 index 0000000..4d4211d --- /dev/null +++ b/src/app/ss_blumen_lumen/message_queue.cpp @@ -0,0 +1,83 @@ + +internal void +MessageQueue_Init(blumen_network_msg_queue* Queue, gs_memory_arena* Arena) +{ + gs_data MessageQueueData = PushSize(Arena, DEFAULT_QUEUE_ENTRY_SIZE * BLUMEN_MESSAGE_QUEUE_COUNT); + gs_memory_cursor C = MemoryCursorCreateFromData(MessageQueueData); + + for (u32 i = 0; i < BLUMEN_MESSAGE_QUEUE_COUNT; i++) + { + Queue->Buffers[i] = MemoryCursorPushSize(&C, DEFAULT_QUEUE_ENTRY_SIZE); + } +} + +internal bool +MessageQueue_CanWrite(blumen_network_msg_queue Queue) +{ + bool Result = ((Queue.WriteHead >= Queue.ReadHead) || + (Queue.WriteHead < Queue.ReadHead)); + return Result; +} + +internal bool +MessageQueue_Write(blumen_network_msg_queue* Queue, gs_data Msg) +{ + Assert(Msg.Size <= DEFAULT_QUEUE_ENTRY_SIZE); + + u32 Index = Queue->WriteHead; + Assert(Index >= 0 && + Index < BLUMEN_MESSAGE_QUEUE_COUNT); + + gs_data* Dest = Queue->Buffers + Index; + CopyMemoryTo(Msg.Memory, Dest->Memory, Msg.Size); + Dest->Size = Msg.Size; + + // NOTE(pjs): We increment write head at the end of writing so that + // a reader thread doesn't pull the message off before we've finished + // filling it out + Queue->WriteHead = (Queue->WriteHead + 1) % BLUMEN_MESSAGE_QUEUE_COUNT; + return true; +} + +internal bool +MessageQueue_CanRead(blumen_network_msg_queue Queue) +{ + bool Result = (Queue.ReadHead != Queue.WriteHead); + return Result; +} + +internal gs_data +MessageQueue_Peek(blumen_network_msg_queue* Queue) +{ + gs_data Result = {}; + u32 ReadIndex = Queue->ReadHead; + if (ReadIndex >= BLUMEN_MESSAGE_QUEUE_COUNT) + { + ReadIndex = 0; + } + Result = Queue->Buffers[ReadIndex]; + return Result; +} + +internal gs_data +MessageQueue_Read(blumen_network_msg_queue* Queue) +{ + gs_data Result = {}; + u32 ReadIndex = Queue->ReadHead++; + if (ReadIndex >= BLUMEN_MESSAGE_QUEUE_COUNT) + { + Queue->ReadHead = 0; + ReadIndex = 0; + } + Result = Queue->Buffers[ReadIndex]; + return Result; +} + +internal void +MessageQueue_Clear(blumen_network_msg_queue* Queue) +{ + while (MessageQueue_CanRead(*Queue)) + { + MessageQueue_Read(Queue); + } +} diff --git a/src/app/ss_blumen_lumen/message_queue.h b/src/app/ss_blumen_lumen/message_queue.h new file mode 100644 index 0000000..a450b54 --- /dev/null +++ b/src/app/ss_blumen_lumen/message_queue.h @@ -0,0 +1,17 @@ +/* date = March 27th 2021 3:07 pm */ + +#ifndef MESSAGE_QUEUE_H +#define MESSAGE_QUEUE_H + +#define BLUMEN_MESSAGE_QUEUE_COUNT 32 +typedef struct blumen_network_msg_queue +{ + gs_data Buffers[BLUMEN_MESSAGE_QUEUE_COUNT]; + u32 WriteHead; + u32 ReadHead; +} blumen_network_msg_queue; + +// KB(1) is just bigger than any packet we send. Good for now +#define DEFAULT_QUEUE_ENTRY_SIZE KB(1) + +#endif //MESSAGE_QUEUE_H diff --git a/src/app/ss_blumen_lumen/phrase_hue_map.h b/src/app/ss_blumen_lumen/phrase_hue_map.h new file mode 100644 index 0000000..3b2af84 --- /dev/null +++ b/src/app/ss_blumen_lumen/phrase_hue_map.h @@ -0,0 +1,283 @@ +/* date = March 27th 2021 1:55 pm */ + +#ifndef PHRASE_HUE_MAP_H +#define PHRASE_HUE_MAP_H + +enum p_hue_flag +{ + Hue_Value = 0, + Hue_White = 1, + Hue_Black = 2, +}; + +enum p_hue_pattern +{ + HuePattern_Patchy, + HuePattern_Wavy, + + HuePattern_Count, +}; + +enum p_hue_add_in +{ + AddIn_None, + AddIn_Waves, + AddIn_Rotary, + + AddIn_Count, +}; + +typedef struct p_hue +{ + v4 HSV; +} p_hue; + +typedef struct phrase_hue_map +{ + u64 CountMax; + u64 Count; + gs_const_string* Phrases; + u64* PhraseHashes; + p_hue* Hue0; + p_hue* Hue1; + p_hue* Hue2; + u32* Gran; // granularity + r32* Speed; + u8* Pattern; + u8* AddIn; + bool* OverrideAll; +} phrase_hue_map; + +typedef struct phrase_hue +{ + gs_const_string Phrase; + u64 PhraseHash; + p_hue Hue0; + p_hue Hue1; + p_hue Hue2; + u32 Granularity; + r32 Speed; + u8 Pattern; + u8 AddIn; + bool OverrideAll; +} phrase_hue; + +internal p_hue +LerpPHue(r32 T, p_hue A, p_hue B) +{ + p_hue Result = {}; + + if (Abs(A.HSV.x - B.HSV.x) < 180.0f) + { + Result.HSV.x = LerpR64(T, A.HSV.x, B.HSV.x); + } + else if (B.HSV.x > A.HSV.x) + { + Result.HSV.x = LerpR64(T, A.HSV.x, B.HSV.x - 360.0f); + } + else + { + Result.HSV.x = LerpR64(T, A.HSV.x - 360.0f, B.HSV.x); + } + if (Result.HSV.x < 360) Result.HSV.x += 360; + if (Result.HSV.x > 360) Result.HSV.x -= 360; + Result.HSV.x = Clamp(0, Result.HSV.x, 360); + Result.HSV.y = LerpR32(T, A.HSV.y, B.HSV.y); + Result.HSV.z = LerpR32(T, A.HSV.z, B.HSV.z); + Result.HSV.w = LerpR32(T, A.HSV.w, B.HSV.w); + + return Result; +} + +internal phrase_hue +LerpPhraseHue(r32 T, phrase_hue A, phrase_hue B) +{ + phrase_hue Result = {}; + Result.Hue0 = LerpPHue(T, A.Hue0, B.Hue0); + Result.Hue1 = LerpPHue(T, A.Hue1, B.Hue1); + Result.Hue2 = LerpPHue(T, A.Hue2, B.Hue2); + Result.Granularity = (u32)LerpR32(T, (r32)A.Granularity, (r32)B.Granularity); + Result.Speed = LerpR32(T, A.Speed, B.Speed); + + if (T < .5f) { + Result.Phrase = A.Phrase; + Result.PhraseHash = A.PhraseHash; + Result.Pattern = A.Pattern; + Result.AddIn = A.AddIn; + } + else { + Result.Phrase = B.Phrase; + Result.PhraseHash = B.PhraseHash; + Result.Pattern = B.Pattern; + Result.AddIn = B.AddIn; + } + + return Result; +} + +internal p_hue +CreateHueFromString(gs_const_string Str) +{ + p_hue Result = {}; + if (Str.Str[0] == 'b') { + Result.HSV = v4{0, 0, 0, 1 }; + } else if (Str.Str[0] == 'w') { + Result.HSV = v4{0, 0, 1, 1 };; + } else { + parse_float_result Parsed = ValidateAndParseFloat(Str); + if (!Parsed.Success) + { + Log_Error(GlobalLogBuffer, "Failed to Parse CSV Float\n"); + Parsed.Value = 0.0; + } + Result.HSV = v4{ (r32)Parsed.Value, 1, 1, 1 }; + + } + return Result; +} + +internal v4 +RGBFromPhraseHue (p_hue H) +{ + v4 Result = H.HSV; + Result = HSVToRGB(Result); + return Result; +} + +internal phrase_hue_map +PhraseHueMap_GenFromCSV(gscsv_sheet Sheet, gs_memory_arena* Arena) +{ + phrase_hue_map Result = {}; + if (Sheet.RowCount == 0) return Result; + + Result.CountMax = Sheet.RowCount - 1; // we don't include the header row + Result.Phrases = PushArray(Arena, gs_const_string, Result.CountMax); + Result.PhraseHashes = PushArray(Arena, u64, Result.CountMax); + Result.Hue0 = PushArray(Arena, p_hue, Result.CountMax); + Result.Hue1 = PushArray(Arena, p_hue, Result.CountMax); + Result.Hue2 = PushArray(Arena, p_hue, Result.CountMax); + Result.Gran = PushArray(Arena, u32, Result.CountMax); + Result.Pattern = PushArray(Arena, u8, Result.CountMax); + Result.Speed = PushArray(Arena, r32, Result.CountMax); + Result.AddIn = PushArray(Arena, u8, Result.CountMax); + Result.OverrideAll = PushArray(Arena, bool, Result.CountMax); + + // this lets us tightly pack phrase_hues even if there is a + // row in the csv that is empty or invalid + s32 DestOffset = 0; + for (u32 Row = 1; Row < Sheet.RowCount; Row++) + { + s32 Index = (Row - 1) - DestOffset; + Assert(Index >= 0 && Index < Result.CountMax); + + gs_const_string Phrase = CSVSheet_GetCell(Sheet, + 0, Row); + gs_const_string Hue0Str = CSVSheet_GetCell(Sheet, 1, Row); + gs_const_string Hue1Str = CSVSheet_GetCell(Sheet, 2, Row); + gs_const_string Hue2Str = CSVSheet_GetCell(Sheet, 3, Row); + gs_const_string Homonyms = CSVSheet_GetCell(Sheet, 4, Row); + gs_const_string Granularity = CSVSheet_GetCell(Sheet, 5, Row); + gs_const_string Speed = CSVSheet_GetCell(Sheet, 6, Row); + gs_const_string Pattern = CSVSheet_GetCell(Sheet, 7, Row); + gs_const_string AddIn = CSVSheet_GetCell(Sheet, 8, Row); + gs_const_string OverrideAll = CSVSheet_GetCell(Sheet, 9, Row); + + // essential parameters + if (Phrase.Length == 0 || + Hue0Str.Length == 0 || + Hue1Str.Length == 0 || + Hue2Str.Length == 0) + { + DestOffset++; + continue; + } + + Result.Phrases[Index] = PushStringF(Arena, Phrase.Length, "%S", Phrase).ConstString; + for (u64 i = 0; i < Result.Phrases[Index].Length; i++) + { + char C = Result.Phrases[Index].Str[i]; + if (IsAlpha(C)) + { + Result.Phrases[Index].Str[i] = ToLower(C); + } + } + + u64 PhraseHash = HashDJB2ToU32(StringExpand(Result.Phrases[Index])); + + Result.PhraseHashes[Index] = PhraseHash; + Result.Hue0[Index] = CreateHueFromString(Hue0Str); + Result.Hue1[Index] = CreateHueFromString(Hue1Str); + Result.Hue2[Index] = CreateHueFromString(Hue2Str); + + parse_float_result ParsedSpeed = ValidateAndParseFloat(Speed); + if (!ParsedSpeed.Success) + { + ParsedSpeed.Value = 1.0; + } + Result.Speed[Index] = ParsedSpeed.Value; + + if (StringsEqual(Pattern, ConstString("wavy"))) + { + Result.Pattern[Index] = HuePattern_Wavy; + } else { + Result.Pattern[Index] = HuePattern_Patchy; + } + + if (StringsEqual(AddIn, ConstString("waves"))) + { + Result.AddIn[Index] = AddIn_Waves; + } else if (StringsEqual(AddIn, ConstString("rotary"))) { + Result.AddIn[Index] = AddIn_Rotary; + } else { + Result.AddIn[Index] = AddIn_None; + } + + parse_uint_result ParsedGranularity = ValidateAndParseUInt(Granularity); + if (!ParsedGranularity.Success) + { + ParsedGranularity.Value = 1; + } + Result.Gran[Index] = ParsedGranularity.Value; + + Result.OverrideAll[Index] = StringsEqualUpToLength(OverrideAll, ConstString("yes"), 3); + } + + Result.Count = Result.CountMax + DestOffset; + + return Result; +} + +internal phrase_hue +PhraseHueMap_Get(phrase_hue_map Map, u32 Index) +{ + Assert(Index < Map.Count); + phrase_hue Result = {}; + Result.Phrase = Map.Phrases[Index]; + Result.PhraseHash = Map.PhraseHashes[Index]; + Result.Hue0 = Map.Hue0[Index]; + Result.Hue1 = Map.Hue1[Index]; + Result.Hue2 = Map.Hue2[Index]; + Result.Granularity = Map.Gran[Index]; + Result.Speed = Map.Speed[Index]; + Result.AddIn = Map.AddIn[Index]; + Result.Pattern = Map.Pattern[Index]; + Result.OverrideAll = Map.OverrideAll[Index]; + return Result; +} + +internal phrase_hue +PhraseHueMap_Find(phrase_hue_map Map, u64 PhraseHash) +{ + phrase_hue Result = {}; + for (u32 i = 0; i < Map.Count; i++) + { + if (Map.PhraseHashes[i] == PhraseHash) + { + Result = PhraseHueMap_Get(Map, i); + break; + } + } + return Result; +} + +#endif //PHRASE_HUE_MAP_H diff --git a/src/app/ss_blumen_lumen/sdf.h b/src/app/ss_blumen_lumen/sdf.h new file mode 100644 index 0000000..58e40e9 --- /dev/null +++ b/src/app/ss_blumen_lumen/sdf.h @@ -0,0 +1,20 @@ +/* date = March 29th 2021 10:41 pm */ + +#ifndef SDF_H +#define SDF_H + +internal r32 +SDF_Sphere(v3 Point, v3 Center, r32 Radius) +{ + r32 Result = V3Mag(Point - Center) - Radius; + return Result; +} + +internal r32 +SDF_SphereNormalized(v3 Point, v3 Center, r32 Radius) +{ + r32 Result = SDF_Sphere(Point, Center, Radius) / Radius; + return Result; +} + +#endif //SDF_H diff --git a/src/app/sse_mathfun.h b/src/app/sse_mathfun.h deleted file mode 100644 index 16b22e9..0000000 --- a/src/app/sse_mathfun.h +++ /dev/null @@ -1,711 +0,0 @@ -/* SIMD (SSE1+MMX or SSE2) implementation of sin, cos, exp and log - - Inspired by Intel Approximate Math library, and based on the - corresponding algorithms of the cephes math library - - The default is to use the SSE1 version. If you define USE_SSE2 the - the SSE2 intrinsics will be used in place of the MMX intrinsics. Do - not expect any significant performance improvement with SSE2. -*/ - -/* Copyright (C) 2007 Julien Pommier - - 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. - - (this is the zlib license) -*/ - -#include - -/* yes I know, the top of this file is quite ugly */ - -#ifdef _MSC_VER /* visual c++ */ -# define ALIGN16_BEG __declspec(align(16)) -# define ALIGN16_END -#else /* gcc or icc */ -# define ALIGN16_BEG -# define ALIGN16_END __attribute__((aligned(16))) -#endif - -/* __m128 is ugly to write */ -typedef __m128 v4sf; // vector of 4 float (sse1) - -#ifdef USE_SSE2 -# include -typedef __m128i v4si; // vector of 4 int (sse2) -#else -typedef __m64 v2si; // vector of 2 int (mmx) -#endif - -/* declare some SSE constants -- why can't I figure a better way to do that? */ -#define _PS_CONST(Name, Val) \ -static const ALIGN16_BEG float _ps_##Name[4] ALIGN16_END = { Val, Val, Val, Val } -#define _PI32_CONST(Name, Val) \ -static const ALIGN16_BEG int _pi32_##Name[4] ALIGN16_END = { Val, Val, Val, Val } -#define _PS_CONST_TYPE(Name, Type, Val) \ -static const ALIGN16_BEG Type _ps_##Name[4] ALIGN16_END = { Val, Val, Val, Val } - -_PS_CONST(1 , 1.0f); -_PS_CONST(0p5, 0.5f); -/* the smallest non denormalized float number */ -_PS_CONST_TYPE(min_norm_pos, int, 0x00800000); -_PS_CONST_TYPE(mant_mask, int, 0x7f800000); -_PS_CONST_TYPE(inv_mant_mask, int, ~0x7f800000); - -_PS_CONST_TYPE(sign_mask, int, (int)0x80000000); -_PS_CONST_TYPE(inv_sign_mask, int, ~0x80000000); - -_PI32_CONST(1, 1); -_PI32_CONST(inv1, ~1); -_PI32_CONST(2, 2); -_PI32_CONST(4, 4); -_PI32_CONST(0x7f, 0x7f); - -_PS_CONST(cephes_SQRTHF, 0.707106781186547524); -_PS_CONST(cephes_log_p0, 7.0376836292E-2); -_PS_CONST(cephes_log_p1, - 1.1514610310E-1); -_PS_CONST(cephes_log_p2, 1.1676998740E-1); -_PS_CONST(cephes_log_p3, - 1.2420140846E-1); -_PS_CONST(cephes_log_p4, + 1.4249322787E-1); -_PS_CONST(cephes_log_p5, - 1.6668057665E-1); -_PS_CONST(cephes_log_p6, + 2.0000714765E-1); -_PS_CONST(cephes_log_p7, - 2.4999993993E-1); -_PS_CONST(cephes_log_p8, + 3.3333331174E-1); -_PS_CONST(cephes_log_q1, -2.12194440e-4); -_PS_CONST(cephes_log_q2, 0.693359375); - -#ifndef USE_SSE2 -typedef union xmm_mm_union { - __m128 xmm; - __m64 mm[2]; -} xmm_mm_union; - -#define COPY_XMM_TO_MM(xmm_, mm0_, mm1_) { \ - xmm_mm_union u; u.xmm = xmm_; \ - mm0_ = u.mm[0]; \ - mm1_ = u.mm[1]; \ -} - -#define COPY_MM_TO_XMM(mm0_, mm1_, xmm_) { \ - xmm_mm_union u; u.mm[0]=mm0_; u.mm[1]=mm1_; xmm_ = u.xmm; \ -} - -#endif // USE_SSE2 - -/* natural logarithm computed for 4 simultaneous float - return NaN for x <= 0 -*/ -v4sf log_ps(v4sf x) { -#ifdef USE_SSE2 - v4si emm0; -#else - v2si mm0, mm1; -#endif - v4sf one = *(v4sf*)_ps_1; - - v4sf invalid_mask = _mm_cmple_ps(x, _mm_setzero_ps()); - - x = _mm_max_ps(x, *(v4sf*)_ps_min_norm_pos); /* cut off denormalized stuff */ - -#ifndef USE_SSE2 - /* part 1: x = frexpf(x, &e); */ - COPY_XMM_TO_MM(x, mm0, mm1); - mm0 = _mm_srli_pi32(mm0, 23); - mm1 = _mm_srli_pi32(mm1, 23); -#else - emm0 = _mm_srli_epi32(_mm_castps_si128(x), 23); -#endif - /* keep only the fractional part */ - x = _mm_and_ps(x, *(v4sf*)_ps_inv_mant_mask); - x = _mm_or_ps(x, *(v4sf*)_ps_0p5); - -#ifndef USE_SSE2 - /* now e=mm0:mm1 contain the really base-2 exponent */ - mm0 = _mm_sub_pi32(mm0, *(v2si*)_pi32_0x7f); - mm1 = _mm_sub_pi32(mm1, *(v2si*)_pi32_0x7f); - v4sf e = _mm_cvtpi32x2_ps(mm0, mm1); - _mm_empty(); /* bye bye mmx */ -#else - emm0 = _mm_sub_epi32(emm0, *(v4si*)_pi32_0x7f); - v4sf e = _mm_cvtepi32_ps(emm0); -#endif - - e = _mm_add_ps(e, one); - - /* part2: - if( x < SQRTHF ) { - e -= 1; - x = x + x - 1.0; - } else { x = x - 1.0; } - */ - v4sf mask = _mm_cmplt_ps(x, *(v4sf*)_ps_cephes_SQRTHF); - v4sf tmp = _mm_and_ps(x, mask); - x = _mm_sub_ps(x, one); - e = _mm_sub_ps(e, _mm_and_ps(one, mask)); - x = _mm_add_ps(x, tmp); - - - v4sf z = _mm_mul_ps(x,x); - - v4sf y = *(v4sf*)_ps_cephes_log_p0; - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p1); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p2); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p3); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p4); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p5); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p6); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p7); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_log_p8); - y = _mm_mul_ps(y, x); - - y = _mm_mul_ps(y, z); - - - tmp = _mm_mul_ps(e, *(v4sf*)_ps_cephes_log_q1); - y = _mm_add_ps(y, tmp); - - - tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5); - y = _mm_sub_ps(y, tmp); - - tmp = _mm_mul_ps(e, *(v4sf*)_ps_cephes_log_q2); - x = _mm_add_ps(x, y); - x = _mm_add_ps(x, tmp); - x = _mm_or_ps(x, invalid_mask); // negative arg will be NAN - return x; -} - -_PS_CONST(exp_hi, 88.3762626647949f); -_PS_CONST(exp_lo, -88.3762626647949f); - -_PS_CONST(cephes_LOG2EF, 1.44269504088896341); -_PS_CONST(cephes_exp_C1, 0.693359375); -_PS_CONST(cephes_exp_C2, -2.12194440e-4); - -_PS_CONST(cephes_exp_p0, 1.9875691500E-4); -_PS_CONST(cephes_exp_p1, 1.3981999507E-3); -_PS_CONST(cephes_exp_p2, 8.3334519073E-3); -_PS_CONST(cephes_exp_p3, 4.1665795894E-2); -_PS_CONST(cephes_exp_p4, 1.6666665459E-1); -_PS_CONST(cephes_exp_p5, 5.0000001201E-1); - -v4sf exp_ps(v4sf x) { - v4sf tmp = _mm_setzero_ps(), fx; -#ifdef USE_SSE2 - v4si emm0; -#else - v2si mm0, mm1; -#endif - v4sf one = *(v4sf*)_ps_1; - - x = _mm_min_ps(x, *(v4sf*)_ps_exp_hi); - x = _mm_max_ps(x, *(v4sf*)_ps_exp_lo); - - /* express exp(x) as exp(g + n*log(2)) */ - fx = _mm_mul_ps(x, *(v4sf*)_ps_cephes_LOG2EF); - fx = _mm_add_ps(fx, *(v4sf*)_ps_0p5); - - /* how to perform a floorf with SSE: just below */ -#ifndef USE_SSE2 - /* step 1 : cast to int */ - tmp = _mm_movehl_ps(tmp, fx); - mm0 = _mm_cvttps_pi32(fx); - mm1 = _mm_cvttps_pi32(tmp); - /* step 2 : cast back to float */ - tmp = _mm_cvtpi32x2_ps(mm0, mm1); -#else - emm0 = _mm_cvttps_epi32(fx); - tmp = _mm_cvtepi32_ps(emm0); -#endif - /* if greater, substract 1 */ - v4sf mask = _mm_cmpgt_ps(tmp, fx); - mask = _mm_and_ps(mask, one); - fx = _mm_sub_ps(tmp, mask); - - tmp = _mm_mul_ps(fx, *(v4sf*)_ps_cephes_exp_C1); - v4sf z = _mm_mul_ps(fx, *(v4sf*)_ps_cephes_exp_C2); - x = _mm_sub_ps(x, tmp); - x = _mm_sub_ps(x, z); - - z = _mm_mul_ps(x,x); - - v4sf y = *(v4sf*)_ps_cephes_exp_p0; - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p1); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p2); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p3); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p4); - y = _mm_mul_ps(y, x); - y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p5); - y = _mm_mul_ps(y, z); - y = _mm_add_ps(y, x); - y = _mm_add_ps(y, one); - - /* build 2^n */ -#ifndef USE_SSE2 - z = _mm_movehl_ps(z, fx); - mm0 = _mm_cvttps_pi32(fx); - mm1 = _mm_cvttps_pi32(z); - mm0 = _mm_add_pi32(mm0, *(v2si*)_pi32_0x7f); - mm1 = _mm_add_pi32(mm1, *(v2si*)_pi32_0x7f); - mm0 = _mm_slli_pi32(mm0, 23); - mm1 = _mm_slli_pi32(mm1, 23); - - v4sf pow2n; - COPY_MM_TO_XMM(mm0, mm1, pow2n); - _mm_empty(); -#else - emm0 = _mm_cvttps_epi32(fx); - emm0 = _mm_add_epi32(emm0, *(v4si*)_pi32_0x7f); - emm0 = _mm_slli_epi32(emm0, 23); - v4sf pow2n = _mm_castsi128_ps(emm0); -#endif - y = _mm_mul_ps(y, pow2n); - return y; -} - -_PS_CONST(minus_cephes_DP1, -0.78515625); -_PS_CONST(minus_cephes_DP2, -2.4187564849853515625e-4); -_PS_CONST(minus_cephes_DP3, -3.77489497744594108e-8); -_PS_CONST(sincof_p0, -1.9515295891E-4); -_PS_CONST(sincof_p1, 8.3321608736E-3); -_PS_CONST(sincof_p2, -1.6666654611E-1); -_PS_CONST(coscof_p0, 2.443315711809948E-005); -_PS_CONST(coscof_p1, -1.388731625493765E-003); -_PS_CONST(coscof_p2, 4.166664568298827E-002); -_PS_CONST(cephes_FOPI, 1.27323954473516); // 4 / M_PI - - -/* evaluation of 4 sines at onces, using only SSE1+MMX intrinsics so - it runs also on old athlons XPs and the pentium III of your grand - mother. - - The code is the exact rewriting of the cephes sinf function. - Precision is excellent as long as x < 8192 (I did not bother to - take into account the special handling they have for greater values - -- it does not return garbage for arguments over 8192, though, but - the extra precision is missing). - - Note that it is such that sinf((float)M_PI) = 8.74e-8, which is the - surprising but correct result. - - Performance is also surprisingly good, 1.33 times faster than the - macos vsinf SSE2 function, and 1.5 times faster than the - __vrs4_sinf of amd's ACML (which is only available in 64 bits). Not - too bad for an SSE1 function (with no special tuning) ! - However the latter libraries probably have a much better handling of NaN, - Inf, denormalized and other special arguments.. - - On my core 1 duo, the execution of this function takes approximately 95 cycles. - - From what I have observed on the experiments with Intel AMath lib, switching to an - SSE2 version would improve the perf by only 10%. - - Since it is based on SSE intrinsics, it has to be compiled at -O2 to - deliver full speed. -*/ -v4sf sin_ps(v4sf x) { // any x - v4sf xmm1, xmm2 = _mm_setzero_ps(), xmm3, sign_bit, y; - -#ifdef USE_SSE2 - v4si emm0, emm2; -#else - v2si mm0, mm1, mm2, mm3; -#endif - sign_bit = x; - /* take the absolute value */ - x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask); - /* extract the sign bit (upper one) */ - sign_bit = _mm_and_ps(sign_bit, *(v4sf*)_ps_sign_mask); - - /* scale by 4/Pi */ - y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI); - -#ifdef USE_SSE2 - /* store the integer part of y in mm0 */ - emm2 = _mm_cvttps_epi32(y); - /* j=(j+1) & (~1) (see the cephes sources) */ - emm2 = _mm_add_epi32(emm2, *(v4si*)_pi32_1); - emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_inv1); - y = _mm_cvtepi32_ps(emm2); - - /* get the swap sign flag */ - emm0 = _mm_and_si128(emm2, *(v4si*)_pi32_4); - emm0 = _mm_slli_epi32(emm0, 29); - /* get the polynom selection mask - there is one polynom for 0 <= x <= Pi/4 - and another one for Pi/4> precision OK for the tan_ps <<- - -checking tan on [-0.49*Pi, 0.49*Pi] -max deviation from tanf(x): 3.8147e-06 at -0.490000009841*Pi, max deviation from cephes_tan(x): -9.53674e-07 - ->> precision OK for the tan_ps <<- - -checking cot on [0.2*Pi, 0.7*Pi] -max deviation from cotf(x): 1.19209e-07 at 0.204303119606*Pi, max deviation from cephes_cot(x): -1.19209e-07 - ->> precision OK for the cot_ps <<- - -checking cot on [0.01*Pi, 0.99*Pi] -max deviation from cotf(x): 3.8147e-06 at 0.987876517942*Pi, max deviation from cephes_cot(x): -9.53674e-07 - ->> precision OK for the cot_ps <<- - -With atan_ps and atan2_ps you get pretty good precision, atan_ps max deviation is < 2e-7 and -atan2_ps max deviation is < 2.5e-7 -*/ - -/* Copyright (C) 2016 Tolga Mizrak - - 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. - - (this is the zlib license) -*/ - -#pragma once - -#ifndef _SSE_MATHFUN_EXTENSION_H_INCLUDED_ -#define _SSE_MATHFUN_EXTENSION_H_INCLUDED_ - -#ifndef USE_SSE2 -#error sse1 & mmx version not implemented -#endif - -#ifdef _MSC_VER -#pragma warning( push ) -/* warning C4838: conversion from 'double' to 'const float' requires a narrowing conversion */ -#pragma warning( disable : 4838 ) -/* warning C4305: 'initializing': truncation from 'double' to 'const float' */ -#pragma warning( disable : 4305 ) -#endif - -#include "sse_mathfun.h" - -_PS_CONST( 0, 0 ); -_PS_CONST( 2, 2 ); -_PI32_CONST( neg1, 1 ); - -_PS_CONST( tancof_p0, 9.38540185543E-3 ); -_PS_CONST( tancof_p1, 3.11992232697E-3 ); -_PS_CONST( tancof_p2, 2.44301354525E-2 ); -_PS_CONST( tancof_p3, 5.34112807005E-2 ); -_PS_CONST( tancof_p4, 1.33387994085E-1 ); -_PS_CONST( tancof_p5, 3.33331568548E-1 ); - -_PS_CONST( tancot_eps, 1.0e-4 ); - -v4sf tancot_ps( v4sf x, int cotFlag ) -{ - v4sf xmm1, xmm2 = _mm_setzero_ps(), xmm3, sign_bit, y; - -#ifdef USE_SSE2 - v4si emm2; -#else -#endif - sign_bit = x; - /* take the absolute value */ - x = _mm_and_ps( x, *(v4sf*)_ps_inv_sign_mask ); - /* extract the sign bit (upper one) */ - sign_bit = _mm_and_ps( sign_bit, *(v4sf*)_ps_sign_mask ); - - /* scale by 4/Pi */ - y = _mm_mul_ps( x, *(v4sf*)_ps_cephes_FOPI ); - -#ifdef USE_SSE2 - /* store the integer part of y in mm0 */ - emm2 = _mm_cvttps_epi32( y ); - /* j=(j+1) & (~1) (see the cephes sources) */ - emm2 = _mm_add_epi32( emm2, *(v4si*)_pi32_1 ); - emm2 = _mm_and_si128( emm2, *(v4si*)_pi32_inv1 ); - y = _mm_cvtepi32_ps( emm2 ); - - emm2 = _mm_and_si128( emm2, *(v4si*)_pi32_2 ); - emm2 = _mm_cmpeq_epi32( emm2, _mm_setzero_si128() ); - - v4sf poly_mask = _mm_castsi128_ps( emm2 ); -#else -#endif - /* The magic pass: "Extended precision modular arithmetic" - x = ((x - y * DP1) - y * DP2) - y * DP3; */ - xmm1 = *(v4sf*)_ps_minus_cephes_DP1; - xmm2 = *(v4sf*)_ps_minus_cephes_DP2; - xmm3 = *(v4sf*)_ps_minus_cephes_DP3; - xmm1 = _mm_mul_ps( y, xmm1 ); - xmm2 = _mm_mul_ps( y, xmm2 ); - xmm3 = _mm_mul_ps( y, xmm3 ); - v4sf z = _mm_add_ps( x, xmm1 ); - z = _mm_add_ps( z, xmm2 ); - z = _mm_add_ps( z, xmm3 ); - - v4sf zz = _mm_mul_ps( z, z ); - - y = *(v4sf*)_ps_tancof_p0; - y = _mm_mul_ps( y, zz ); - y = _mm_add_ps( y, *(v4sf*)_ps_tancof_p1 ); - y = _mm_mul_ps( y, zz ); - y = _mm_add_ps( y, *(v4sf*)_ps_tancof_p2 ); - y = _mm_mul_ps( y, zz ); - y = _mm_add_ps( y, *(v4sf*)_ps_tancof_p3 ); - y = _mm_mul_ps( y, zz ); - y = _mm_add_ps( y, *(v4sf*)_ps_tancof_p4 ); - y = _mm_mul_ps( y, zz ); - y = _mm_add_ps( y, *(v4sf*)_ps_tancof_p5 ); - y = _mm_mul_ps( y, zz ); - y = _mm_mul_ps( y, z ); - y = _mm_add_ps( y, z ); - - v4sf y2; - if( cotFlag ) { - y2 = _mm_xor_ps( y, *(v4sf*)_ps_sign_mask ); - /* y = _mm_rcp_ps( y ); */ - /* using _mm_rcp_ps here loses on way too much precision, better to do a div */ - y = _mm_div_ps( *(v4sf*)_ps_1, y ); - } else { - /* y2 = _mm_rcp_ps( y ); */ - /* using _mm_rcp_ps here loses on way too much precision, better to do a div */ - y2 = _mm_div_ps( *(v4sf*)_ps_1, y ); - y2 = _mm_xor_ps( y2, *(v4sf*)_ps_sign_mask ); - } - - /* select the correct result from the two polynoms */ - xmm3 = poly_mask; - y = _mm_and_ps( xmm3, y ); - y2 = _mm_andnot_ps( xmm3, y2 ); - y = _mm_or_ps( y, y2 ); - - /* update the sign */ - y = _mm_xor_ps( y, sign_bit ); - - return y; -} - -v4sf tan_ps( v4sf x ) { return tancot_ps( x, 0 ); } - -v4sf cot_ps( v4sf x ) { return tancot_ps( x, 1 ); } - -_PS_CONST( atanrange_hi, 2.414213562373095 ); -_PS_CONST( atanrange_lo, 0.4142135623730950 ); -const float PIF = 3.141592653589793238; -const float PIO2F = 1.5707963267948966192; -_PS_CONST( cephes_PIF, 3.141592653589793238 ); -_PS_CONST( cephes_PIO2F, 1.5707963267948966192 ); -_PS_CONST( cephes_PIO4F, 0.7853981633974483096 ); - -_PS_CONST( atancof_p0, 8.05374449538e-2 ); -_PS_CONST( atancof_p1, 1.38776856032E-1 ); -_PS_CONST( atancof_p2, 1.99777106478E-1 ); -_PS_CONST( atancof_p3, 3.33329491539E-1 ); - -v4sf atan_ps( v4sf x ) -{ - v4sf sign_bit, y; - - sign_bit = x; - /* take the absolute value */ - x = _mm_and_ps( x, *(v4sf*)_ps_inv_sign_mask ); - /* extract the sign bit (upper one) */ - sign_bit = _mm_and_ps( sign_bit, *(v4sf*)_ps_sign_mask ); - - /* range reduction, init x and y depending on range */ -#ifdef USE_SSE2 - /* x > 2.414213562373095 */ - v4sf cmp0 = _mm_cmpgt_ps( x, *(v4sf*)_ps_atanrange_hi ); - /* x > 0.4142135623730950 */ - v4sf cmp1 = _mm_cmpgt_ps( x, *(v4sf*)_ps_atanrange_lo ); - - /* x > 0.4142135623730950 && !( x > 2.414213562373095 ) */ - v4sf cmp2 = _mm_andnot_ps( cmp0, cmp1 ); - - /* -( 1.0/x ) */ - v4sf y0 = _mm_and_ps( cmp0, *(v4sf*)_ps_cephes_PIO2F ); - v4sf x0 = _mm_div_ps( *(v4sf*)_ps_1, x ); - x0 = _mm_xor_ps( x0, *(v4sf*)_ps_sign_mask ); - - v4sf y1 = _mm_and_ps( cmp2, *(v4sf*)_ps_cephes_PIO4F ); - /* (x-1.0)/(x+1.0) */ - v4sf x1_o = _mm_sub_ps( x, *(v4sf*)_ps_1 ); - v4sf x1_u = _mm_add_ps( x, *(v4sf*)_ps_1 ); - v4sf x1 = _mm_div_ps( x1_o, x1_u ); - - v4sf x2 = _mm_and_ps( cmp2, x1 ); - x0 = _mm_and_ps( cmp0, x0 ); - x2 = _mm_or_ps( x2, x0 ); - cmp1 = _mm_or_ps( cmp0, cmp2 ); - x2 = _mm_and_ps( cmp1, x2 ); - x = _mm_andnot_ps( cmp1, x ); - x = _mm_or_ps( x2, x ); - - y = _mm_or_ps( y0, y1 ); -#else -#error sse1 & mmx version not implemented -#endif - - v4sf zz = _mm_mul_ps( x, x ); - v4sf acc = *(v4sf*)_ps_atancof_p0; - acc = _mm_mul_ps( acc, zz ); - acc = _mm_sub_ps( acc, *(v4sf*)_ps_atancof_p1 ); - acc = _mm_mul_ps( acc, zz ); - acc = _mm_add_ps( acc, *(v4sf*)_ps_atancof_p2 ); - acc = _mm_mul_ps( acc, zz ); - acc = _mm_sub_ps( acc, *(v4sf*)_ps_atancof_p3 ); - acc = _mm_mul_ps( acc, zz ); - acc = _mm_mul_ps( acc, x ); - acc = _mm_add_ps( acc, x ); - y = _mm_add_ps( y, acc ); - - /* update the sign */ - y = _mm_xor_ps( y, sign_bit ); - - return y; -} - -v4sf atan2_ps( v4sf y, v4sf x ) -{ - v4sf x_eq_0 = _mm_cmpeq_ps( x, *(v4sf*)_ps_0 ); - v4sf x_gt_0 = _mm_cmpgt_ps( x, *(v4sf*)_ps_0 ); - v4sf x_le_0 = _mm_cmple_ps( x, *(v4sf*)_ps_0 ); - v4sf y_eq_0 = _mm_cmpeq_ps( y, *(v4sf*)_ps_0 ); - v4sf x_lt_0 = _mm_cmplt_ps( x, *(v4sf*)_ps_0 ); - v4sf y_lt_0 = _mm_cmplt_ps( y, *(v4sf*)_ps_0 ); - - v4sf zero_mask = _mm_and_ps( x_eq_0, y_eq_0 ); - v4sf zero_mask_other_case = _mm_and_ps( y_eq_0, x_gt_0 ); - zero_mask = _mm_or_ps( zero_mask, zero_mask_other_case ); - - v4sf pio2_mask = _mm_andnot_ps( y_eq_0, x_eq_0 ); - v4sf pio2_mask_sign = _mm_and_ps( y_lt_0, *(v4sf*)_ps_sign_mask ); - v4sf pio2_result = *(v4sf*)_ps_cephes_PIO2F; - pio2_result = _mm_xor_ps( pio2_result, pio2_mask_sign ); - pio2_result = _mm_and_ps( pio2_mask, pio2_result ); - - v4sf pi_mask = _mm_and_ps( y_eq_0, x_le_0 ); - v4sf pi = *(v4sf*)_ps_cephes_PIF; - v4sf pi_result = _mm_and_ps( pi_mask, pi ); - - v4sf swap_sign_mask_offset = _mm_and_ps( x_lt_0, y_lt_0 ); - swap_sign_mask_offset = _mm_and_ps( swap_sign_mask_offset, *(v4sf*)_ps_sign_mask ); - - v4sf offset0 = _mm_setzero_ps(); - v4sf offset1 = *(v4sf*)_ps_cephes_PIF; - offset1 = _mm_xor_ps( offset1, swap_sign_mask_offset ); - - v4sf offset = _mm_andnot_ps( x_lt_0, offset0 ); - offset = _mm_and_ps( x_lt_0, offset1 ); - - v4sf arg = _mm_div_ps( y, x ); - v4sf atan_result = atan_ps( arg ); - atan_result = _mm_add_ps( atan_result, offset ); - - /* select between zero_result, pio2_result and atan_result */ - - v4sf result = _mm_andnot_ps( zero_mask, pio2_result ); - atan_result = _mm_andnot_ps( pio2_mask, atan_result ); - atan_result = _mm_andnot_ps( pio2_mask, atan_result); - result = _mm_or_ps( result, atan_result ); - result = _mm_or_ps( result, pi_result ); - - return result; -} - -/* for convenience of calling simd sqrt */ -float sqrt_ps( float x ) -{ - v4sf sse_value = _mm_set_ps1( x ); - sse_value = _mm_sqrt_ps( sse_value ); - return _mm_cvtss_f32( sse_value ); -} -float rsqrt_ps( float x ) -{ - v4sf sse_value = _mm_set_ps1( x ); - sse_value = _mm_rsqrt_ps( sse_value ); - return _mm_cvtss_f32( sse_value ); -} - -/* atan2 implementation using atan, used as a reference to implement atan2_ps */ -float atan2_ref( float y, float x ) -{ - if( x == 0.0f ) { - if( y == 0.0f ) { - return 0.0f; - } - float result = _ps_cephes_PIO2F[0]; - if( y < 0.0f ) { - result = -result; - } - return result; - } - - if( y == 0.0f ) { - if( x > 0.0f ) { - return 0.0f; - } - return PIF; - } - - float offset = 0; - if( x < 0.0f ) { - offset = PIF; - if( y < 0.0f ) { - offset = -offset; - } - } - - v4sf val = _mm_set_ps1( y / x ); - val = atan_ps( val ); - return offset + _mm_cvtss_f32( val ); -} - -#ifdef _MSC_VER -#pragma warning( pop ) -#endif - -#endif diff --git a/src/gs_libs/gs_csv.h b/src/gs_libs/gs_csv.h new file mode 100644 index 0000000..6969d4c --- /dev/null +++ b/src/gs_libs/gs_csv.h @@ -0,0 +1,214 @@ +/* date = March 24th 2021 5:53 pm */ + +#ifndef GS_CSV_H +#define GS_CSV_H + +struct gscsv_cell +{ + gs_const_string Value; +}; + +struct gscsv_row +{ + u64* CellIndices; +}; + +struct gscsv_sheet +{ + char SeparatorChar; + gscsv_cell* Cells; + gscsv_row* Rows; + u64 RowCount; + u64 ColumnCount; +}; + +struct gscsv_sheet_desc +{ + char SeparatorChar; +}; + +struct gscsv_parser +{ + gs_const_string Str; + u64 At; + u64 Line; +}; + +internal void +CSVParser_Reset(gscsv_parser* Parser) +{ + Parser->At = 0; +} + +internal char +CSVParser_CharAt(gscsv_parser Parser) +{ + char Result = Parser.Str.Str[Parser.At]; + return Result; +} + +internal bool +CSVParser_CanAdvance(gscsv_parser Parser) { + bool Result = Parser.At < Parser.Str.Length; + return Result; +} + +internal void +CSVParser_Advance(gscsv_parser* Parser) +{ + if (CSVParser_CanAdvance(*Parser)) { + if (IsNewline(CSVParser_CharAt(*Parser))) + { + Parser->Line += 1; + } + Parser->At += 1; + } +} + +internal void +CSVParser_AdvancePastChar(gscsv_parser* Parser, char Char) +{ + while (CSVParser_CanAdvance(*Parser) && CSVParser_CharAt(*Parser) != Char) + { + CSVParser_Advance(Parser); + } + + if (CSVParser_CanAdvance(*Parser)) + { + Assert(CSVParser_CharAt(*Parser) == Char); + CSVParser_Advance(Parser); + } +} + +internal u64 +CSVParser_AdvancePastSeparatorOrNewline(gscsv_parser* Parser, char SeparatorChar) +{ + u64 PointBeforeSeparator = 0; + + while (CSVParser_CanAdvance(*Parser) && + !(CSVParser_CharAt(*Parser) == SeparatorChar || + IsNewline(CSVParser_CharAt(*Parser)))) + { + CSVParser_Advance(Parser); + } + + PointBeforeSeparator = Parser->At; + + if (CSVParser_CanAdvance(*Parser)) + { + while(IsNewline(CSVParser_CharAt(*Parser))) { + CSVParser_Advance(Parser); + } + if (CSVParser_CharAt(*Parser) == SeparatorChar) + { + CSVParser_Advance(Parser); + } + } + + return PointBeforeSeparator; +} + +internal gscsv_cell +CSVCell_Init(gs_const_string File, u64 CellStart, u64 CellEnd) +{ + gscsv_cell Result = {}; + Result.Value = Substring(File, CellStart, CellEnd); + return Result; +} + +internal void +CSVRow_PushCell(gscsv_row* Row, u64 CellIndex, u64 ColumnIndex) +{ + Row->CellIndices[ColumnIndex] = CellIndex; +} + +internal gscsv_sheet +CSV_Parse(gs_const_string File, gscsv_sheet_desc Desc, gs_memory_arena* Arena) +{ + gscsv_sheet Result = {}; + + gscsv_parser Parser = {}; + Parser.Str = File; + Parser.At = 0; + Parser.Line = 0; + + // Count Tabs in first line + u64 Columns = 0; + while (CSVParser_CanAdvance(Parser) && !IsNewline(CSVParser_CharAt(Parser))) + { + char At = CSVParser_CharAt(Parser); + if (At == Desc.SeparatorChar) { + Columns += 1; + } + CSVParser_Advance(&Parser); + } + // NOTE(PS): Add one on the end because the last column won't end in a SeparatorChar, + // it ends in a newline + Columns += 1; + CSVParser_Reset(&Parser); + + // Count New Lines + u64 Rows = 0; + while (CSVParser_CanAdvance(Parser)) + { + char At = CSVParser_CharAt(Parser); + if (IsNewline(At)) + { + Rows++; + while (CSVParser_CanAdvance(Parser) && IsNewline(CSVParser_CharAt(Parser))) + { + CSVParser_Advance(&Parser); + } + } else { + CSVParser_Advance(&Parser); + } + } + // NOTE(PS): Adding a row becuase the last row will just end in the EOF + Rows += 1; + CSVParser_Reset(&Parser); + + // Allocate Result + Result.SeparatorChar = Desc.SeparatorChar; + Result.RowCount = Rows; + Result.ColumnCount = Columns; + Result.Cells = PushArray(Arena, gscsv_cell, Result.RowCount * Result.ColumnCount); + Result.Rows = PushArray(Arena, gscsv_row, Result.RowCount); + + // for rows, parse row + // for cells parse cells + for (u64 r = 0; r < Result.RowCount; r++) + { + u64 RowIndex = r; + gscsv_row* Row = Result.Rows + RowIndex; + Row->CellIndices = PushArray(Arena, u64, Result.ColumnCount); + + for (u64 c = 0; c < Result.ColumnCount; c++) + { + u64 CellIndex = (r * Result.ColumnCount) + c; + u64 CellStart = Parser.At; + u64 CellEnd = CSVParser_AdvancePastSeparatorOrNewline(&Parser, Desc.SeparatorChar); + + Result.Cells[CellIndex] = CSVCell_Init(Parser.Str, CellStart, CellEnd); + CSVRow_PushCell(Row, CellIndex, c); + } + } + + return Result; +} + +internal gs_const_string +CSVSheet_GetCell(gscsv_sheet Sheet, u64 Column, u64 Row) +{ + gs_const_string Result = {}; + + if (Row < Sheet.RowCount && Column < Sheet.ColumnCount) + { + u64 CellIndex = (Row * Sheet.ColumnCount) + Column; + Result = Sheet.Cells[CellIndex].Value; + } + + return Result; +} + + +#endif //GS_CSV_H diff --git a/src/gs_libs/gs_input.h b/src/gs_libs/gs_input.h index 4a696b3..f0c1c79 100644 --- a/src/gs_libs/gs_input.h +++ b/src/gs_libs/gs_input.h @@ -6,86 +6,86 @@ #ifndef GS_INPUT_H enum key_code { - KeyCode_Invalid, - - KeyCode_Esc, - - KeyCode_Space, - KeyCode_Tab, - KeyCode_CapsLock, - KeyCode_LeftShift, KeyCode_RightShift, - KeyCode_LeftCtrl, KeyCode_RightCtrl, - KeyCode_Fn, - KeyCode_Alt, - KeyCode_PageUp, KeyCode_PageDown, - KeyCode_Backspace, KeyCode_Delete, - KeyCode_Enter, - - // Function Keys - KeyCode_F0, KeyCode_F1, KeyCode_F2, KeyCode_F3, KeyCode_F4, KeyCode_F5, KeyCode_F6, KeyCode_F7, - KeyCode_F8, KeyCode_F9, KeyCode_F10, KeyCode_F11, KeyCode_F12, - - // Letters - KeyCode_a, KeyCode_b, KeyCode_c, KeyCode_d, KeyCode_e, KeyCode_f, KeyCode_g, KeyCode_h, - KeyCode_i, KeyCode_j, KeyCode_k, KeyCode_l, KeyCode_m, KeyCode_n, KeyCode_o, KeyCode_p, - KeyCode_q, KeyCode_r, KeyCode_s, KeyCode_t, KeyCode_u, KeyCode_v, KeyCode_w, KeyCode_x, - KeyCode_y, KeyCode_z, - - KeyCode_A, KeyCode_B, KeyCode_C, KeyCode_D, KeyCode_E, KeyCode_F, KeyCode_G, KeyCode_H, - KeyCode_I, KeyCode_J, KeyCode_K, KeyCode_L, KeyCode_M, KeyCode_N, KeyCode_O, KeyCode_P, - KeyCode_Q, KeyCode_R, KeyCode_S, KeyCode_T, KeyCode_U, KeyCode_V, KeyCode_W, KeyCode_X, - KeyCode_Y, KeyCode_Z, - - // Numbers - KeyCode_0, KeyCode_1, KeyCode_2, KeyCode_3, KeyCode_4, KeyCode_5, KeyCode_6, KeyCode_7, - KeyCode_8, KeyCode_9, - - KeyCode_Num0, KeyCode_Num1, KeyCode_Num2, KeyCode_Num3, KeyCode_Num4, KeyCode_Num5, - KeyCode_Num6, KeyCode_Num7, KeyCode_Num8, KeyCode_Num9, - - // Symbols - KeyCode_Bang, KeyCode_At, KeyCode_Pound, KeyCode_Dollar, KeyCode_Percent, KeyCode_Carrot, - KeyCode_Ampersand, KeyCode_Star, KeyCode_LeftParen, KeyCode_RightParen, KeyCode_Minus, KeyCode_Plus, - KeyCode_Equals, KeyCode_Underscore, KeyCode_LeftBrace, KeyCode_RightBrace, KeyCode_LeftBracket, - KeyCode_RightBracket, KeyCode_Colon, KeyCode_SemiColon, KeyCode_SingleQuote, KeyCode_DoubleQuote, - KeyCode_ForwardSlash, KeyCode_Backslash, KeyCode_Pipe, KeyCode_Comma, KeyCode_Period, - KeyCode_QuestionMark, KeyCode_LessThan, KeyCode_GreaterThan, KeyCode_Tilde, KeyCode_BackQuote, - - // Arrows - KeyCode_UpArrow, - KeyCode_DownArrow, - KeyCode_LeftArrow, - KeyCode_RightArrow, - - // Mouse - // NOTE(Peter): Including this here so we can utilize the same KeyDown, KeyUp etc. functions - KeyCode_MouseLeftButton, - KeyCode_MouseMiddleButton, - KeyCode_MouseRightButton, - - KeyCode_Count, + KeyCode_Invalid, + + KeyCode_Esc, + + KeyCode_Space, + KeyCode_Tab, + KeyCode_CapsLock, + KeyCode_LeftShift, KeyCode_RightShift, + KeyCode_LeftCtrl, KeyCode_RightCtrl, + KeyCode_Fn, + KeyCode_Alt, + KeyCode_PageUp, KeyCode_PageDown, + KeyCode_Backspace, KeyCode_Delete, + KeyCode_Enter, + + // Function Keys + KeyCode_F0, KeyCode_F1, KeyCode_F2, KeyCode_F3, KeyCode_F4, KeyCode_F5, KeyCode_F6, KeyCode_F7, + KeyCode_F8, KeyCode_F9, KeyCode_F10, KeyCode_F11, KeyCode_F12, + + // Letters + KeyCode_a, KeyCode_b, KeyCode_c, KeyCode_d, KeyCode_e, KeyCode_f, KeyCode_g, KeyCode_h, + KeyCode_i, KeyCode_j, KeyCode_k, KeyCode_l, KeyCode_m, KeyCode_n, KeyCode_o, KeyCode_p, + KeyCode_q, KeyCode_r, KeyCode_s, KeyCode_t, KeyCode_u, KeyCode_v, KeyCode_w, KeyCode_x, + KeyCode_y, KeyCode_z, + + KeyCode_A, KeyCode_B, KeyCode_C, KeyCode_D, KeyCode_E, KeyCode_F, KeyCode_G, KeyCode_H, + KeyCode_I, KeyCode_J, KeyCode_K, KeyCode_L, KeyCode_M, KeyCode_N, KeyCode_O, KeyCode_P, + KeyCode_Q, KeyCode_R, KeyCode_S, KeyCode_T, KeyCode_U, KeyCode_V, KeyCode_W, KeyCode_X, + KeyCode_Y, KeyCode_Z, + + // Numbers + KeyCode_0, KeyCode_1, KeyCode_2, KeyCode_3, KeyCode_4, KeyCode_5, KeyCode_6, KeyCode_7, + KeyCode_8, KeyCode_9, + + KeyCode_Num0, KeyCode_Num1, KeyCode_Num2, KeyCode_Num3, KeyCode_Num4, KeyCode_Num5, + KeyCode_Num6, KeyCode_Num7, KeyCode_Num8, KeyCode_Num9, + + // Symbols + KeyCode_Bang, KeyCode_At, KeyCode_Pound, KeyCode_Dollar, KeyCode_Percent, KeyCode_Carrot, + KeyCode_Ampersand, KeyCode_Star, KeyCode_LeftParen, KeyCode_RightParen, KeyCode_Minus, KeyCode_Plus, + KeyCode_Equals, KeyCode_Underscore, KeyCode_LeftBrace, KeyCode_RightBrace, KeyCode_LeftBracket, + KeyCode_RightBracket, KeyCode_Colon, KeyCode_SemiColon, KeyCode_SingleQuote, KeyCode_DoubleQuote, + KeyCode_ForwardSlash, KeyCode_Backslash, KeyCode_Pipe, KeyCode_Comma, KeyCode_Period, + KeyCode_QuestionMark, KeyCode_LessThan, KeyCode_GreaterThan, KeyCode_Tilde, KeyCode_BackQuote, + + // Arrows + KeyCode_UpArrow, + KeyCode_DownArrow, + KeyCode_LeftArrow, + KeyCode_RightArrow, + + // Mouse + // NOTE(Peter): Including this here so we can utilize the same KeyDown, KeyUp etc. functions + KeyCode_MouseLeftButton, + KeyCode_MouseMiddleButton, + KeyCode_MouseRightButton, + + KeyCode_Count, }; internal char CharacterFromKeyCode (key_code Code) { - char Result = 0; + char Result = 0; + + switch (Code) + { + case KeyCode_Space: { Result = ' '; }break; + case KeyCode_Tab: { Result = '\t'; }break; - switch (Code) - { - case KeyCode_Space: { Result = ' '; }break; - case KeyCode_Tab: { Result = '\t'; }break; - - // Letters - case KeyCode_a: { Result = 'a'; }break; - case KeyCode_b: { Result = 'b'; }break; - case KeyCode_c: { Result = 'c'; }break; - case KeyCode_d: { Result = 'd'; }break; - case KeyCode_e: { Result = 'e'; }break; + // Letters + case KeyCode_a: { Result = 'a'; }break; + case KeyCode_b: { Result = 'b'; }break; + case KeyCode_c: { Result = 'c'; }break; + case KeyCode_d: { Result = 'd'; }break; + case KeyCode_e: { Result = 'e'; }break; case KeyCode_f: { Result = 'f'; }break; case KeyCode_g: { Result = 'g'; }break; case KeyCode_h: { Result = 'h'; }break; - case KeyCode_i: { Result = 'i'; }break; + case KeyCode_i: { Result = 'i'; }break; case KeyCode_j: { Result = 'j'; }break; case KeyCode_k: { Result = 'k'; }break; case KeyCode_l: { Result = 'l'; }break; @@ -93,7 +93,7 @@ CharacterFromKeyCode (key_code Code) case KeyCode_n: { Result = 'n'; }break; case KeyCode_o: { Result = 'o'; }break; case KeyCode_p: { Result = 'p'; }break; - case KeyCode_q: { Result = 'q'; }break; + case KeyCode_q: { Result = 'q'; }break; case KeyCode_r: { Result = 'r'; }break; case KeyCode_s: { Result = 's'; }break; case KeyCode_t: { Result = 't'; }break; @@ -101,10 +101,10 @@ CharacterFromKeyCode (key_code Code) case KeyCode_v: { Result = 'v'; }break; case KeyCode_w: { Result = 'w'; }break; case KeyCode_x: { Result = 'x'; }break; - case KeyCode_y: { Result = 'y'; }break; + case KeyCode_y: { Result = 'y'; }break; case KeyCode_z: { Result = 'z'; }break; - - case KeyCode_A: { Result = 'A'; }break; + + case KeyCode_A: { Result = 'A'; }break; case KeyCode_B: { Result = 'B'; }break; case KeyCode_C: { Result = 'C'; }break; case KeyCode_D: { Result = 'D'; }break; @@ -112,7 +112,7 @@ CharacterFromKeyCode (key_code Code) case KeyCode_F: { Result = 'F'; }break; case KeyCode_G: { Result = 'G'; }break; case KeyCode_H: { Result = 'H'; }break; - case KeyCode_I: { Result = 'I'; }break; + case KeyCode_I: { Result = 'I'; }break; case KeyCode_J: { Result = 'J'; }break; case KeyCode_K: { Result = 'K'; }break; case KeyCode_L: { Result = 'L'; }break; @@ -120,7 +120,7 @@ CharacterFromKeyCode (key_code Code) case KeyCode_N: { Result = 'N'; }break; case KeyCode_O: { Result = 'O'; }break; case KeyCode_P: { Result = 'P'; }break; - case KeyCode_Q: { Result = 'Q'; }break; + case KeyCode_Q: { Result = 'Q'; }break; case KeyCode_R: { Result = 'R'; }break; case KeyCode_S: { Result = 'S'; }break; case KeyCode_T: { Result = 'T'; }break; @@ -128,11 +128,11 @@ CharacterFromKeyCode (key_code Code) case KeyCode_V: { Result = 'V'; }break; case KeyCode_W: { Result = 'W'; }break; case KeyCode_X: { Result = 'X'; }break; - case KeyCode_Y: { Result = 'Y'; }break; + case KeyCode_Y: { Result = 'Y'; }break; case KeyCode_Z: { Result = 'Z'; }break; - - // Numbers - case KeyCode_0: { Result = '0'; }break; + + // Numbers + case KeyCode_0: { Result = '0'; }break; case KeyCode_1: { Result = '1'; }break; case KeyCode_2: { Result = '2'; }break; case KeyCode_3: { Result = '3'; }break; @@ -140,88 +140,88 @@ CharacterFromKeyCode (key_code Code) case KeyCode_5: { Result = '5'; }break; case KeyCode_6: { Result = '6'; }break; case KeyCode_7: { Result = '7'; }break; - case KeyCode_8: { Result = '8'; }break; + case KeyCode_8: { Result = '8'; }break; case KeyCode_9: { Result = '9'; }break; - - case KeyCode_Num0: { Result = '0'; }break; + + case KeyCode_Num0: { Result = '0'; }break; case KeyCode_Num1: { Result = '1'; }break; case KeyCode_Num2: { Result = '2'; }break; case KeyCode_Num3: { Result = '3'; }break; case KeyCode_Num4: { Result = '4'; }break; case KeyCode_Num5: { Result = '5'; }break; - case KeyCode_Num6: { Result = '6'; }break; + case KeyCode_Num6: { Result = '6'; }break; case KeyCode_Num7: { Result = '7'; }break; case KeyCode_Num8: { Result = '8'; }break; case KeyCode_Num9: { Result = '9'; }break; - - // Symbols - case KeyCode_Bang: { Result = '!'; }break; + + // Symbols + case KeyCode_Bang: { Result = '!'; }break; case KeyCode_At: { Result = '@'; }break; case KeyCode_Pound: { Result = '#'; }break; case KeyCode_Dollar: { Result = '$'; }break; case KeyCode_Percent: { Result = '%'; }break; case KeyCode_Carrot: { Result = '^'; }break; - case KeyCode_Ampersand: { Result = '&'; }break; + case KeyCode_Ampersand: { Result = '&'; }break; case KeyCode_Star: { Result = '*'; }break; case KeyCode_LeftParen: { Result = '('; }break; case KeyCode_RightParen: { Result = ')'; }break; case KeyCode_Minus: { Result = '-'; }break; case KeyCode_Plus: { Result = '+'; }break; - case KeyCode_Equals: { Result = '='; }break; + case KeyCode_Equals: { Result = '='; }break; case KeyCode_Underscore: { Result = '_'; }break; case KeyCode_LeftBrace: { Result = '['; }break; case KeyCode_RightBrace: { Result = ']'; }break; case KeyCode_LeftBracket: { Result = '{'; }break; - case KeyCode_RightBracket: { Result = '}'; }break; + case KeyCode_RightBracket: { Result = '}'; }break; case KeyCode_Colon: { Result = ':'; }break; case KeyCode_SemiColon: { Result = ';'; }break; case KeyCode_SingleQuote: { Result = '\''; }break; case KeyCode_DoubleQuote: { Result = '"'; }break; - case KeyCode_ForwardSlash: { Result = '/'; }break; + case KeyCode_ForwardSlash: { Result = '/'; }break; case KeyCode_Backslash: { Result = '\\'; }break; case KeyCode_Pipe: { Result = '|'; }break; case KeyCode_Comma: { Result = ','; }break; case KeyCode_Period: { Result = '.'; }break; - case KeyCode_QuestionMark: { Result = '?'; }break; + case KeyCode_QuestionMark: { Result = '?'; }break; case KeyCode_LessThan: { Result = '<'; }break; case KeyCode_GreaterThan: { Result = '>'; }break; case KeyCode_Tilde: { Result = '~'; }break; case KeyCode_BackQuote: { Result = '`'; }break; - } - - Assert(Result != 0); - return Result; + } + + Assert(Result != 0); + return Result; } enum modifier_flags { - Modifier_Shift = 1 << 0, - Modifier_Ctrl = 1 << 1, - Modifier_Alt = 1 << 2, - Modifier_Sys = 1 << 3, // NOTE(Peter): this is the windows key + Modifier_Shift = 1 << 0, + Modifier_Ctrl = 1 << 1, + Modifier_Alt = 1 << 2, + Modifier_Sys = 1 << 3, // NOTE(Peter): this is the windows key }; #define INPUT_FRAME_STRING_LENGTH 32 struct input_frame { - b32 KeysDown[(int)KeyCode_Count]; - s32 StringInputUsed; - char StringInput[INPUT_FRAME_STRING_LENGTH]; - s32 MouseX, MouseY, MouseScroll; + b32 KeysDown[(int)KeyCode_Count]; + s32 StringInputUsed; + char StringInput[INPUT_FRAME_STRING_LENGTH]; + s32 MouseX, MouseY, MouseScroll; }; struct input { - input_frame Frames[2]; - input_frame* New; - input_frame* Old; - s32 MouseDownX, MouseDownY; + input_frame Frames[2]; + input_frame* New; + input_frame* Old; + s32 MouseDownX, MouseDownY; }; enum key_state_flags { - KeyState_WasDown = 1 << 0, - KeyState_IsDown = 1 << 1, + KeyState_WasDown = 1 << 0, + KeyState_IsDown = 1 << 1, }; #define KeyWasDown(event) ((event & KeyState_WasDown) > 0) @@ -234,75 +234,75 @@ enum key_state_flags struct input_entry { - key_code Key; - b32 State; - b32 Modifiers; + key_code Key; + b32 State; + b32 Modifiers; }; struct input_queue { - s32 QueueSize; - s32 QueueUsed; - input_entry* Entries; + s32 QueueSize; + s32 QueueUsed; + input_entry* Entries; }; enum cursor_type { - CursorType_Arrow, - CursorType_Pointer, - CursorType_Loading, - CursorType_HArrows, - CursorType_VArrows, - CursorType_DTopLeftArrows, - CursorType_DTopRightArrows, - CursorType_Count, + CursorType_Arrow, + CursorType_Pointer, + CursorType_Loading, + CursorType_HArrows, + CursorType_VArrows, + CursorType_DTopLeftArrows, + CursorType_DTopRightArrows, + CursorType_Count, }; struct mouse_state { - s32 Scroll; - - v2 Pos; - v2 OldPos; - v2 DeltaPos; - v2 DownPos; - - b32 LeftButtonState; - b32 MiddleButtonState; - b32 RightButtonState; - - - - cursor_type CursorType; + s32 Scroll; + + v2 Pos; + v2 OldPos; + v2 DeltaPos; + v2 DownPos; + + b32 LeftButtonState; + b32 MiddleButtonState; + b32 RightButtonState; + + + + cursor_type CursorType; }; internal input_queue InputQueue_Create (u8* Memory, s32 MemorySize) { - input_queue Result = {}; - s32 EntriesCount = MemorySize / sizeof(input_entry); - Result.QueueSize = EntriesCount; - Result.QueueUsed = 0; - Result.Entries = (input_entry*)Memory; - return Result; + input_queue Result = {}; + s32 EntriesCount = MemorySize / sizeof(input_entry); + Result.QueueSize = EntriesCount; + Result.QueueUsed = 0; + Result.Entries = (input_entry*)Memory; + return Result; } internal input_queue InputQueue_Create(gs_memory_arena* Arena, u32 CountMax) { - input_queue Result = {0}; - if (CountMax > 0) - { - s32 Size = sizeof(input_entry) * 32; - u8* Memory = PushSize(Arena, Size); - Result = InputQueue_Create(Memory, Size); - } - return Result; + input_queue Result = {0}; + if (CountMax > 0) + { + s32 Size = sizeof(input_entry) * 32; + u8* Memory = PushSize(Arena, Size).Memory; + Result = InputQueue_Create(Memory, Size); + } + return Result; } internal void ResetInputQueue (input_queue* Queue) { - Queue->QueueUsed = 0; + Queue->QueueUsed = 0; } internal void InitializeInput (input* Input); @@ -311,360 +311,360 @@ internal void SwapInputBuffers (input* Input); internal void InitializeInput (input* Input) { - *(Input) = {}; - Input->New = &Input->Frames[0]; - Input->Old = &Input->Frames[1]; + *(Input) = {}; + Input->New = &Input->Frames[0]; + Input->Old = &Input->Frames[1]; } internal void SwapInputBuffers (input* Input) { - input_frame* NowOld = Input->New; - Input->New = Input->Old; - Input->Old = NowOld; - - for (s32 Key = 0; Key < KeyCode_Count; Key++) { Input->New->KeysDown[Key] = Input->Old->KeysDown[Key]; } - Input->New->StringInputUsed = 0; + input_frame* NowOld = Input->New; + Input->New = Input->Old; + Input->Old = NowOld; + + for (s32 Key = 0; Key < KeyCode_Count; Key++) { Input->New->KeysDown[Key] = Input->Old->KeysDown[Key]; } + Input->New->StringInputUsed = 0; } internal b32 KeyDown (input Input, key_code Key) { - return Input.New->KeysDown[Key]; + return Input.New->KeysDown[Key]; } internal b32 KeyTransitionedDown (input Input, key_code Key) { - return Input.New->KeysDown[Key] && !Input.Old->KeysDown[Key]; + return Input.New->KeysDown[Key] && !Input.Old->KeysDown[Key]; } internal b32 KeyTransitionedUp (input Input, key_code Key) { - return !Input.New->KeysDown[Key] && Input.Old->KeysDown[Key]; + return !Input.New->KeysDown[Key] && Input.Old->KeysDown[Key]; } internal void AddInputEventEntry (input_queue* Queue, key_code Key, b32 WasDown, b32 IsDown, b32 ShiftDown, b32 AltDown, b32 CtrlDown, b32 SysDown) { - Assert(Queue->QueueUsed < Queue->QueueSize); - - input_entry* Entry = Queue->Entries + Queue->QueueUsed++; - Entry->Key = Key; - - Entry->State = (key_state_flags)0; - if (WasDown) { Entry->State |= KeyState_WasDown; } - if (IsDown) { Entry->State |= KeyState_IsDown; } - - Entry->Modifiers = 0; - if (ShiftDown) { Entry->Modifiers |= Modifier_Shift; } - if (CtrlDown) { Entry->Modifiers |= Modifier_Ctrl; } - if (AltDown) { Entry->Modifiers |= Modifier_Alt; } - if (SysDown) { Entry->Modifiers |= Modifier_Sys; } + Assert(Queue->QueueUsed < Queue->QueueSize); + + input_entry* Entry = Queue->Entries + Queue->QueueUsed++; + Entry->Key = Key; + + Entry->State = (key_state_flags)0; + if (WasDown) { Entry->State |= KeyState_WasDown; } + if (IsDown) { Entry->State |= KeyState_IsDown; } + + Entry->Modifiers = 0; + if (ShiftDown) { Entry->Modifiers |= Modifier_Shift; } + if (CtrlDown) { Entry->Modifiers |= Modifier_Ctrl; } + if (AltDown) { Entry->Modifiers |= Modifier_Alt; } + if (SysDown) { Entry->Modifiers |= Modifier_Sys; } } internal b32 KeyTransitionedDown (input_entry Entry) { - return (!KeyWasDown(Entry.State) && KeyIsDown(Entry.State)); + return (!KeyWasDown(Entry.State) && KeyIsDown(Entry.State)); } internal b32 KeyTransitionedUp (input_entry Entry) { - return (KeyWasDown(Entry.State) && !KeyIsDown(Entry.State)); + return (KeyWasDown(Entry.State) && !KeyIsDown(Entry.State)); } internal b32 KeyHeldDown (input_entry Entry) { - return (KeyWasDown(Entry.State) && KeyIsDown(Entry.State)); + return (KeyWasDown(Entry.State) && KeyIsDown(Entry.State)); } internal b32 MouseButtonTransitionedDown (b32 MouseButtonState) { - return (!KeyWasDown(MouseButtonState) && KeyIsDown(MouseButtonState)); + return (!KeyWasDown(MouseButtonState) && KeyIsDown(MouseButtonState)); } internal b32 MouseButtonTransitionedUp (b32 MouseButtonState) { - return (KeyWasDown(MouseButtonState) && !KeyIsDown(MouseButtonState)); + return (KeyWasDown(MouseButtonState) && !KeyIsDown(MouseButtonState)); } internal b32 MouseButtonHeldDown (b32 MouseButtonState) { - b32 WasDown = KeyWasDown(MouseButtonState); - b32 IsDown = KeyIsDown(MouseButtonState); - return (WasDown && IsDown); + b32 WasDown = KeyWasDown(MouseButtonState); + b32 IsDown = KeyIsDown(MouseButtonState); + return (WasDown && IsDown); } inline b32 GetMouseButtonStateAdvanced (b32 ButtonState) { - b32 Result = ButtonState; - if (ButtonState & KeyState_WasDown && - !((ButtonState & KeyState_IsDown) > 0)) - { - Result= 0; - } - else if (ButtonState & KeyState_IsDown) - { - Result |= KeyState_WasDown; - } - return Result; + b32 Result = ButtonState; + if (ButtonState & KeyState_WasDown && + !((ButtonState & KeyState_IsDown) > 0)) + { + Result= 0; + } + else if (ButtonState & KeyState_IsDown) + { + Result |= KeyState_WasDown; + } + return Result; } internal char KeyCodeToChar(key_code Code) { - char Result = 0; + char Result = 0; + + switch (Code) + { + case KeyCode_Space: { Result = ' '; } break; + case KeyCode_Tab: { Result = '\t'; } break; + case KeyCode_Enter: { Result = '\n'; } break; + case KeyCode_Backspace: { Result = '\b'; } break; - switch (Code) - { - case KeyCode_Space: { Result = ' '; } break; - case KeyCode_Tab: { Result = '\t'; } break; - case KeyCode_Enter: { Result = '\n'; } break; - case KeyCode_Backspace: { Result = '\b'; } break; - - case KeyCode_a: { Result = 'a'; } break; - case KeyCode_b: { Result = 'b'; } break; - case KeyCode_c: { Result = 'c'; } break; - case KeyCode_d: { Result = 'd'; } break; - case KeyCode_e: { Result = 'e'; } break; - case KeyCode_f: { Result = 'f'; } break; - case KeyCode_g: { Result = 'g'; } break; - case KeyCode_h: { Result = 'h'; } break; - case KeyCode_i: { Result = 'i'; } break; - case KeyCode_j: { Result = 'j'; } break; - case KeyCode_k: { Result = 'k'; } break; - case KeyCode_l: { Result = 'l'; } break; - case KeyCode_m: { Result = 'm'; } break; - case KeyCode_n: { Result = 'n'; } break; - case KeyCode_o: { Result = 'o'; } break; - case KeyCode_p: { Result = 'p'; } break; - case KeyCode_q: { Result = 'q'; } break; - case KeyCode_r: { Result = 'r'; } break; - case KeyCode_s: { Result = 's'; } break; - case KeyCode_t: { Result = 't'; } break; - case KeyCode_u: { Result = 'u'; } break; - case KeyCode_v: { Result = 'v'; } break; - case KeyCode_w: { Result = 'w'; } break; - case KeyCode_x: { Result = 'x'; } break; - case KeyCode_y: { Result = 'y'; } break; - case KeyCode_z: { Result = 'z'; } break; - case KeyCode_A: { Result = 'A'; } break; - case KeyCode_B: { Result = 'B'; } break; - case KeyCode_C: { Result = 'C'; } break; - case KeyCode_D: { Result = 'D'; } break; - case KeyCode_E: { Result = 'E'; } break; - case KeyCode_F: { Result = 'F'; } break; - case KeyCode_G: { Result = 'G'; } break; - case KeyCode_H: { Result = 'H'; } break; - case KeyCode_I: { Result = 'I'; } break; - case KeyCode_J: { Result = 'J'; } break; - case KeyCode_K: { Result = 'K'; } break; - case KeyCode_L: { Result = 'L'; } break; - case KeyCode_M: { Result = 'M'; } break; - case KeyCode_N: { Result = 'N'; } break; - case KeyCode_O: { Result = 'O'; } break; - case KeyCode_P: { Result = 'P'; } break; - case KeyCode_Q: { Result = 'Q'; } break; - case KeyCode_R: { Result = 'R'; } break; - case KeyCode_S: { Result = 'S'; } break; - case KeyCode_T: { Result = 'T'; } break; - case KeyCode_U: { Result = 'U'; } break; - case KeyCode_V: { Result = 'V'; } break; - case KeyCode_W: { Result = 'W'; } break; - case KeyCode_X: { Result = 'X'; } break; - case KeyCode_Y: { Result = 'Y'; } break; - case KeyCode_Z: { Result = 'Z'; } break; - - case KeyCode_Num0: - case KeyCode_0: { Result = '0'; } break; - case KeyCode_Num1: - case KeyCode_1: { Result = '1'; } break; - case KeyCode_Num2: - case KeyCode_2: { Result = '2'; } break; - case KeyCode_Num3: - case KeyCode_3: { Result = '3'; } break; - case KeyCode_Num4: - case KeyCode_4: { Result = '4'; } break; - case KeyCode_Num5: - case KeyCode_5: { Result = '5'; } break; - case KeyCode_Num6: - case KeyCode_6: { Result = '6'; } break; - case KeyCode_Num7: - case KeyCode_7: { Result = '7'; } break; - case KeyCode_Num8: - case KeyCode_8: { Result = '8'; } break; - case KeyCode_Num9: - case KeyCode_9: { Result = '9'; } break; - - case KeyCode_Bang: { Result = '!'; } break; - case KeyCode_At: { Result = '@'; } break; - case KeyCode_Pound: { Result = '#'; } break; - case KeyCode_Dollar: { Result = '$'; } break; - case KeyCode_Percent: { Result = '%'; } break; - case KeyCode_Carrot: { Result = '^'; } break; - case KeyCode_Ampersand: { Result = '&'; } break; - case KeyCode_Star: { Result = '*'; } break; - case KeyCode_LeftParen: { Result = '('; } break; - case KeyCode_RightParen: { Result = ')'; } break; - case KeyCode_Minus: { Result = '-'; } break; - case KeyCode_Plus: { Result = '+'; } break; - case KeyCode_Equals: { Result = '='; } break; - case KeyCode_Underscore: { Result = '_'; } break; - case KeyCode_LeftBrace: { Result = '{'; } break; - case KeyCode_RightBrace: { Result = '}'; } break; - case KeyCode_LeftBracket: { Result = '['; } break; - case KeyCode_RightBracket: { Result = ']'; } break; - case KeyCode_Colon: { Result = ':'; } break; - case KeyCode_SemiColon: { Result = ';'; } break; - case KeyCode_SingleQuote: { Result = '\''; } break; - case KeyCode_DoubleQuote: { Result = '"'; } break; - case KeyCode_ForwardSlash: { Result = '/'; } break; - case KeyCode_Backslash: { Result = '\\'; } break; - case KeyCode_Pipe: { Result = '|'; } break; - case KeyCode_Comma: { Result = ','; } break; - case KeyCode_Period: { Result = '.'; } break; - case KeyCode_QuestionMark: { Result = '?'; } break; - case KeyCode_LessThan: { Result = '<'; } break; - case KeyCode_GreaterThan: { Result = '>'; } break; - case KeyCode_Tilde: { Result = '~'; } break; - case KeyCode_BackQuote: { Result = '`'; } break; - - default: { Result = 0; } break; - } + case KeyCode_a: { Result = 'a'; } break; + case KeyCode_b: { Result = 'b'; } break; + case KeyCode_c: { Result = 'c'; } break; + case KeyCode_d: { Result = 'd'; } break; + case KeyCode_e: { Result = 'e'; } break; + case KeyCode_f: { Result = 'f'; } break; + case KeyCode_g: { Result = 'g'; } break; + case KeyCode_h: { Result = 'h'; } break; + case KeyCode_i: { Result = 'i'; } break; + case KeyCode_j: { Result = 'j'; } break; + case KeyCode_k: { Result = 'k'; } break; + case KeyCode_l: { Result = 'l'; } break; + case KeyCode_m: { Result = 'm'; } break; + case KeyCode_n: { Result = 'n'; } break; + case KeyCode_o: { Result = 'o'; } break; + case KeyCode_p: { Result = 'p'; } break; + case KeyCode_q: { Result = 'q'; } break; + case KeyCode_r: { Result = 'r'; } break; + case KeyCode_s: { Result = 's'; } break; + case KeyCode_t: { Result = 't'; } break; + case KeyCode_u: { Result = 'u'; } break; + case KeyCode_v: { Result = 'v'; } break; + case KeyCode_w: { Result = 'w'; } break; + case KeyCode_x: { Result = 'x'; } break; + case KeyCode_y: { Result = 'y'; } break; + case KeyCode_z: { Result = 'z'; } break; + case KeyCode_A: { Result = 'A'; } break; + case KeyCode_B: { Result = 'B'; } break; + case KeyCode_C: { Result = 'C'; } break; + case KeyCode_D: { Result = 'D'; } break; + case KeyCode_E: { Result = 'E'; } break; + case KeyCode_F: { Result = 'F'; } break; + case KeyCode_G: { Result = 'G'; } break; + case KeyCode_H: { Result = 'H'; } break; + case KeyCode_I: { Result = 'I'; } break; + case KeyCode_J: { Result = 'J'; } break; + case KeyCode_K: { Result = 'K'; } break; + case KeyCode_L: { Result = 'L'; } break; + case KeyCode_M: { Result = 'M'; } break; + case KeyCode_N: { Result = 'N'; } break; + case KeyCode_O: { Result = 'O'; } break; + case KeyCode_P: { Result = 'P'; } break; + case KeyCode_Q: { Result = 'Q'; } break; + case KeyCode_R: { Result = 'R'; } break; + case KeyCode_S: { Result = 'S'; } break; + case KeyCode_T: { Result = 'T'; } break; + case KeyCode_U: { Result = 'U'; } break; + case KeyCode_V: { Result = 'V'; } break; + case KeyCode_W: { Result = 'W'; } break; + case KeyCode_X: { Result = 'X'; } break; + case KeyCode_Y: { Result = 'Y'; } break; + case KeyCode_Z: { Result = 'Z'; } break; - return Result; + case KeyCode_Num0: + case KeyCode_0: { Result = '0'; } break; + case KeyCode_Num1: + case KeyCode_1: { Result = '1'; } break; + case KeyCode_Num2: + case KeyCode_2: { Result = '2'; } break; + case KeyCode_Num3: + case KeyCode_3: { Result = '3'; } break; + case KeyCode_Num4: + case KeyCode_4: { Result = '4'; } break; + case KeyCode_Num5: + case KeyCode_5: { Result = '5'; } break; + case KeyCode_Num6: + case KeyCode_6: { Result = '6'; } break; + case KeyCode_Num7: + case KeyCode_7: { Result = '7'; } break; + case KeyCode_Num8: + case KeyCode_8: { Result = '8'; } break; + case KeyCode_Num9: + case KeyCode_9: { Result = '9'; } break; + + case KeyCode_Bang: { Result = '!'; } break; + case KeyCode_At: { Result = '@'; } break; + case KeyCode_Pound: { Result = '#'; } break; + case KeyCode_Dollar: { Result = '$'; } break; + case KeyCode_Percent: { Result = '%'; } break; + case KeyCode_Carrot: { Result = '^'; } break; + case KeyCode_Ampersand: { Result = '&'; } break; + case KeyCode_Star: { Result = '*'; } break; + case KeyCode_LeftParen: { Result = '('; } break; + case KeyCode_RightParen: { Result = ')'; } break; + case KeyCode_Minus: { Result = '-'; } break; + case KeyCode_Plus: { Result = '+'; } break; + case KeyCode_Equals: { Result = '='; } break; + case KeyCode_Underscore: { Result = '_'; } break; + case KeyCode_LeftBrace: { Result = '{'; } break; + case KeyCode_RightBrace: { Result = '}'; } break; + case KeyCode_LeftBracket: { Result = '['; } break; + case KeyCode_RightBracket: { Result = ']'; } break; + case KeyCode_Colon: { Result = ':'; } break; + case KeyCode_SemiColon: { Result = ';'; } break; + case KeyCode_SingleQuote: { Result = '\''; } break; + case KeyCode_DoubleQuote: { Result = '"'; } break; + case KeyCode_ForwardSlash: { Result = '/'; } break; + case KeyCode_Backslash: { Result = '\\'; } break; + case KeyCode_Pipe: { Result = '|'; } break; + case KeyCode_Comma: { Result = ','; } break; + case KeyCode_Period: { Result = '.'; } break; + case KeyCode_QuestionMark: { Result = '?'; } break; + case KeyCode_LessThan: { Result = '<'; } break; + case KeyCode_GreaterThan: { Result = '>'; } break; + case KeyCode_Tilde: { Result = '~'; } break; + case KeyCode_BackQuote: { Result = '`'; } break; + + default: { Result = 0; } break; + } + + return Result; } internal bool KeyCodeHasChar(key_code Code) { - bool Result = KeyCodeToChar(Code) != 0; - return Result; + bool Result = KeyCodeToChar(Code) != 0; + return Result; } internal key_code CharToKeyCode(char C) { - key_code Result = KeyCode_Invalid; + key_code Result = KeyCode_Invalid; + + switch (C) + { + case ' ': { Result = KeyCode_Space; } break; + case '\t': { Result = KeyCode_Tab; } break; + case '\n': { Result = KeyCode_Enter; } break; + case '\b': { Result = KeyCode_Backspace; } break; - switch (C) - { - case ' ': { Result = KeyCode_Space; } break; - case '\t': { Result = KeyCode_Tab; } break; - case '\n': { Result = KeyCode_Enter; } break; - case '\b': { Result = KeyCode_Backspace; } break; - - case 'a': { Result = KeyCode_a; } break; - case 'b': { Result = KeyCode_b; } break; - case 'c': { Result = KeyCode_c; } break; - case 'd': { Result = KeyCode_d; } break; - case 'e': { Result = KeyCode_e; } break; - case 'f': { Result = KeyCode_f; } break; - case 'g': { Result = KeyCode_g; } break; - case 'h': { Result = KeyCode_h; } break; - case 'i': { Result = KeyCode_i; } break; - case 'j': { Result = KeyCode_j; } break; - case 'k': { Result = KeyCode_k; } break; - case 'l': { Result = KeyCode_l; } break; - case 'm': { Result = KeyCode_m; } break; - case 'n': { Result = KeyCode_n; } break; - case 'o': { Result = KeyCode_o; } break; - case 'p': { Result = KeyCode_p; } break; - case 'q': { Result = KeyCode_q; } break; - case 'r': { Result = KeyCode_r; } break; - case 's': { Result = KeyCode_s; } break; - case 't': { Result = KeyCode_t; } break; - case 'u': { Result = KeyCode_u; } break; - case 'v': { Result = KeyCode_v; } break; - case 'w': { Result = KeyCode_w; } break; - case 'x': { Result = KeyCode_x; } break; - case 'y': { Result = KeyCode_y; } break; - case 'z': { Result = KeyCode_z; } break; - case 'A': { Result = KeyCode_A; } break; - case 'B': { Result = KeyCode_B; } break; - case 'C': { Result = KeyCode_C; } break; - case 'D': { Result = KeyCode_D; } break; - case 'E': { Result = KeyCode_E; } break; - case 'F': { Result = KeyCode_F; } break; - case 'G': { Result = KeyCode_G; } break; - case 'H': { Result = KeyCode_H; } break; - case 'I': { Result = KeyCode_I; } break; - case 'J': { Result = KeyCode_J; } break; - case 'K': { Result = KeyCode_K; } break; - case 'L': { Result = KeyCode_L; } break; - case 'M': { Result = KeyCode_M; } break; - case 'N': { Result = KeyCode_N; } break; - case 'O': { Result = KeyCode_O; } break; - case 'P': { Result = KeyCode_P; } break; - case 'Q': { Result = KeyCode_Q; } break; - case 'R': { Result = KeyCode_R; } break; - case 'S': { Result = KeyCode_S; } break; - case 'T': { Result = KeyCode_T; } break; - case 'U': { Result = KeyCode_U; } break; - case 'V': { Result = KeyCode_V; } break; - case 'W': { Result = KeyCode_W; } break; - case 'X': { Result = KeyCode_X; } break; - case 'Y': { Result = KeyCode_Y; } break; - case 'Z': { Result = KeyCode_Z; } break; - - case '0': { Result = KeyCode_0; } break; - case '1': { Result = KeyCode_1; } break; - case '2': { Result = KeyCode_2; } break; - case '3': { Result = KeyCode_3; } break; - case '4': { Result = KeyCode_4; } break; - case '5': { Result = KeyCode_5; } break; - case '6': { Result = KeyCode_6; } break; - case '7': { Result = KeyCode_7; } break; - case '8': { Result = KeyCode_8; } break; - case '9': { Result = KeyCode_9; } break; - - case '!': { Result = KeyCode_Bang; } break; - case '@': { Result = KeyCode_At; } break; - case '#': { Result = KeyCode_Pound; } break; - case '$': { Result = KeyCode_Dollar; } break; - case '%': { Result = KeyCode_Percent; } break; - case '^': { Result = KeyCode_Carrot; } break; - case '&': { Result = KeyCode_Ampersand; } break; - case '*': { Result = KeyCode_Star; } break; - case '(': { Result = KeyCode_LeftParen; } break; - case ')': { Result = KeyCode_RightParen; } break; - case '-': { Result = KeyCode_Minus; } break; - case '+': { Result = KeyCode_Plus; } break; - case '=': { Result = KeyCode_Equals; } break; - case '_': { Result = KeyCode_Underscore; } break; - case '{': { Result = KeyCode_LeftBrace; } break; - case '}': { Result = KeyCode_RightBrace; } break; - case '[': { Result = KeyCode_LeftBracket; } break; - case ']': { Result = KeyCode_RightBracket; } break; - case ':': { Result = KeyCode_Colon; } break; - case ';': { Result = KeyCode_SemiColon; } break; - case '\'': { Result = KeyCode_SingleQuote; } break; - case '"': { Result = KeyCode_DoubleQuote; } break; - case '/': { Result = KeyCode_ForwardSlash; } break; - case '\\': { Result = KeyCode_Backslash; } break; - case '|': { Result = KeyCode_Pipe; } break; - case ',': { Result = KeyCode_Comma; } break; - case '.': { Result = KeyCode_Period; } break; - case '?': { Result = KeyCode_QuestionMark; } break; - case '<': { Result = KeyCode_LessThan; } break; - case '>': { Result = KeyCode_GreaterThan; } break; - case '~': { Result = KeyCode_Tilde; } break; - case '`': { Result = KeyCode_BackQuote; } break; - - default: { Result = KeyCode_Invalid; } break; - } + case 'a': { Result = KeyCode_a; } break; + case 'b': { Result = KeyCode_b; } break; + case 'c': { Result = KeyCode_c; } break; + case 'd': { Result = KeyCode_d; } break; + case 'e': { Result = KeyCode_e; } break; + case 'f': { Result = KeyCode_f; } break; + case 'g': { Result = KeyCode_g; } break; + case 'h': { Result = KeyCode_h; } break; + case 'i': { Result = KeyCode_i; } break; + case 'j': { Result = KeyCode_j; } break; + case 'k': { Result = KeyCode_k; } break; + case 'l': { Result = KeyCode_l; } break; + case 'm': { Result = KeyCode_m; } break; + case 'n': { Result = KeyCode_n; } break; + case 'o': { Result = KeyCode_o; } break; + case 'p': { Result = KeyCode_p; } break; + case 'q': { Result = KeyCode_q; } break; + case 'r': { Result = KeyCode_r; } break; + case 's': { Result = KeyCode_s; } break; + case 't': { Result = KeyCode_t; } break; + case 'u': { Result = KeyCode_u; } break; + case 'v': { Result = KeyCode_v; } break; + case 'w': { Result = KeyCode_w; } break; + case 'x': { Result = KeyCode_x; } break; + case 'y': { Result = KeyCode_y; } break; + case 'z': { Result = KeyCode_z; } break; + case 'A': { Result = KeyCode_A; } break; + case 'B': { Result = KeyCode_B; } break; + case 'C': { Result = KeyCode_C; } break; + case 'D': { Result = KeyCode_D; } break; + case 'E': { Result = KeyCode_E; } break; + case 'F': { Result = KeyCode_F; } break; + case 'G': { Result = KeyCode_G; } break; + case 'H': { Result = KeyCode_H; } break; + case 'I': { Result = KeyCode_I; } break; + case 'J': { Result = KeyCode_J; } break; + case 'K': { Result = KeyCode_K; } break; + case 'L': { Result = KeyCode_L; } break; + case 'M': { Result = KeyCode_M; } break; + case 'N': { Result = KeyCode_N; } break; + case 'O': { Result = KeyCode_O; } break; + case 'P': { Result = KeyCode_P; } break; + case 'Q': { Result = KeyCode_Q; } break; + case 'R': { Result = KeyCode_R; } break; + case 'S': { Result = KeyCode_S; } break; + case 'T': { Result = KeyCode_T; } break; + case 'U': { Result = KeyCode_U; } break; + case 'V': { Result = KeyCode_V; } break; + case 'W': { Result = KeyCode_W; } break; + case 'X': { Result = KeyCode_X; } break; + case 'Y': { Result = KeyCode_Y; } break; + case 'Z': { Result = KeyCode_Z; } break; - return Result; + case '0': { Result = KeyCode_0; } break; + case '1': { Result = KeyCode_1; } break; + case '2': { Result = KeyCode_2; } break; + case '3': { Result = KeyCode_3; } break; + case '4': { Result = KeyCode_4; } break; + case '5': { Result = KeyCode_5; } break; + case '6': { Result = KeyCode_6; } break; + case '7': { Result = KeyCode_7; } break; + case '8': { Result = KeyCode_8; } break; + case '9': { Result = KeyCode_9; } break; + + case '!': { Result = KeyCode_Bang; } break; + case '@': { Result = KeyCode_At; } break; + case '#': { Result = KeyCode_Pound; } break; + case '$': { Result = KeyCode_Dollar; } break; + case '%': { Result = KeyCode_Percent; } break; + case '^': { Result = KeyCode_Carrot; } break; + case '&': { Result = KeyCode_Ampersand; } break; + case '*': { Result = KeyCode_Star; } break; + case '(': { Result = KeyCode_LeftParen; } break; + case ')': { Result = KeyCode_RightParen; } break; + case '-': { Result = KeyCode_Minus; } break; + case '+': { Result = KeyCode_Plus; } break; + case '=': { Result = KeyCode_Equals; } break; + case '_': { Result = KeyCode_Underscore; } break; + case '{': { Result = KeyCode_LeftBrace; } break; + case '}': { Result = KeyCode_RightBrace; } break; + case '[': { Result = KeyCode_LeftBracket; } break; + case ']': { Result = KeyCode_RightBracket; } break; + case ':': { Result = KeyCode_Colon; } break; + case ';': { Result = KeyCode_SemiColon; } break; + case '\'': { Result = KeyCode_SingleQuote; } break; + case '"': { Result = KeyCode_DoubleQuote; } break; + case '/': { Result = KeyCode_ForwardSlash; } break; + case '\\': { Result = KeyCode_Backslash; } break; + case '|': { Result = KeyCode_Pipe; } break; + case ',': { Result = KeyCode_Comma; } break; + case '.': { Result = KeyCode_Period; } break; + case '?': { Result = KeyCode_QuestionMark; } break; + case '<': { Result = KeyCode_LessThan; } break; + case '>': { Result = KeyCode_GreaterThan; } break; + case '~': { Result = KeyCode_Tilde; } break; + case '`': { Result = KeyCode_BackQuote; } break; + + default: { Result = KeyCode_Invalid; } break; + } + + return Result; } #define GS_INPUT_H diff --git a/src/gs_libs/gs_language.h b/src/gs_libs/gs_language.h index b95b246..3e31391 100644 --- a/src/gs_libs/gs_language.h +++ b/src/gs_libs/gs_language.h @@ -85,7 +85,7 @@ typedef double r64; #endif -#ifdef DEBUG +#if DEBUG static void DebugPrint(char* Format, ...); @@ -95,8 +95,8 @@ static void DebugPrint(char* Format, ...); if((expression)) \ { \ }else{ \ - volatile int* p = 0; \ - *p = 5; \ +volatile int* p = 0; \ +*p = 5; \ } #endif @@ -319,9 +319,9 @@ GSIntDivideRoundUpDef(s64); #define GSRemapDef(type) \ static type GSRemap(type Value, type OldMin, type OldMax, type NewMin, type NewMax) { \ - type Result = (Value - OldMin) / (OldMax - OldMin); \ - Result = (Result * (NewMax - NewMin)) + NewMin; \ - return Result; \ +type Result = (Value - OldMin) / (OldMax - OldMin); \ +Result = (Result * (NewMax - NewMin)) + NewMin; \ +return Result; \ } GSRemapDef(u8); GSRemapDef(u16); diff --git a/src/gs_libs/gs_memory.h b/src/gs_libs/gs_memory.h new file mode 100644 index 0000000..d72ac56 --- /dev/null +++ b/src/gs_libs/gs_memory.h @@ -0,0 +1,528 @@ +/* date = May 10th 2021 10:19 pm */ + +#ifndef GS_MEMORY_H +#define GS_MEMORY_H + +#if !defined(Assert) +# define Assert(c) +#endif + +#if !defined(InvalidCodePath) +# define InvalidCodePath +#endif + +#if !defined(GS_MEMORY_PROFILE_FUNC) +# define GS_MEMORY_PROFILE_FUNC +#endif + +#define MemoryClearArray(b,t,s) MemoryClear((u8*)(b), sizeof(t) * (s)) +internal void +MemoryClear(u8* Base, u64 Size) +{ + for (u64 i = 0; i < Size; i++) Base[i] = 0; +} + +#ifndef DEBUG_LOC + +typedef struct gs_debug_loc +{ + char* File; + char* Function; + u32 Line; +} gs_debug_loc; + +# define DEBUG_LOC gs_debug_loc{ (char*)__FILE__, (char*)__FUNCTION__, __LINE__ } + +#endif +// +// Debug Info +// + +typedef struct gs_debug_memory_allocation +{ + gs_debug_loc Loc; + u64 ArenaHash; + u64 Size; + + struct gs_debug_memory_allocation* Next; +} gs_debug_memory_allocation; + +typedef struct gs_debug_arena_info +{ + char* ArenaName; + u64 AllocationsCount; + u64 TotalSize; +} gs_debug_arena_info; + +typedef struct gs_debug_allocations_list +{ + gs_debug_memory_allocation* Root; + gs_debug_memory_allocation* Head; + u64 AllocationsSizeTotal; + u64 AllocationsCount; + + u64 ArenaHashesCount; + u64* ArenaHashes; + gs_debug_arena_info* ArenaInfos; +} gs_debug_allocations_list; + +// +// Allocator +// + +#define PLATFORM_ALLOC(name) void* name(u64 Size, u64* ResultSize, u8* UserData) +typedef PLATFORM_ALLOC(platform_alloc); + +#define PLATFORM_FREE(name) void name(void* Base, u64 Size, u8* UserData) +typedef PLATFORM_FREE(platform_free); + +typedef struct gs_allocator +{ + platform_alloc* PAlloc; + platform_free* PFree; + u8* UserData; + + gs_debug_allocations_list* DEBUGAllocList; +} gs_allocator; + +PLATFORM_ALLOC(AllocNoOp) +{ + GS_MEMORY_PROFILE_FUNC; + if (ResultSize) *ResultSize = 0; + return 0; +} + +PLATFORM_FREE(FreeNoOp) +{ + GS_MEMORY_PROFILE_FUNC; + return; +} + +internal u64 +GSMemoryHash(char* Str, u64 Len) +{ + u64 Hash = 5381; + for (u32 i = 0; i < Len; i++) + { + Hash = ((Hash << 5) + Hash) + Str[i]; + } + return Hash; +} + +#define Alloc(a,s,an) Alloc_((a),(s),DEBUG_LOC, (char*)(an)).Memory +#define AllocStruct(a,t,an) (t*)Alloc_((a),sizeof(t),DEBUG_LOC, (char*)(an)).Memory +#define AllocArray(a,t,c,an) (t*)Alloc_((a),sizeof(t)*(c),DEBUG_LOC, (char*)(an)).Memory +#define AllocData(a,s,an) Alloc_((a),(s),DEBUG_LOC, (char*)(an)) + +internal gs_data +Alloc_(gs_allocator A, u64 Size, gs_debug_loc Loc, char* ArenaName) +{ + GS_MEMORY_PROFILE_FUNC; + + gs_data Result = {}; + Result.Memory = (u8*)A.PAlloc(Size, &Result.Size, A.UserData); + + // Debug + { + u64 ArenaHash = GSMemoryHash(ArenaName, CStringLength(ArenaName)); + + gs_debug_memory_allocation* Allocation = (gs_debug_memory_allocation*)A.PAlloc(sizeof(gs_debug_memory_allocation*), 0, A.UserData); + Allocation->Loc = Loc; + Allocation->Size = Size; + Allocation->ArenaHash = ArenaHash; + SLLPushOrInit(A.DEBUGAllocList->Root, A.DEBUGAllocList->Head, Allocation); + + A.DEBUGAllocList->AllocationsSizeTotal += Size; + A.DEBUGAllocList->AllocationsCount += 1; + + u64 ArenaStartIndex = ArenaHash % A.DEBUGAllocList->ArenaHashesCount; + u64 ArenaIndex = ArenaStartIndex; + while (A.DEBUGAllocList->ArenaHashes[ArenaIndex] != 0 && + A.DEBUGAllocList->ArenaHashes[ArenaIndex] != ArenaHash) + { + ArenaIndex = (ArenaIndex + 1) % A.DEBUGAllocList->ArenaHashesCount; + + // NOTE(PS): this means you've created enough arena's to fill up every + // slot in the arena hash table. Go increase the size of of DEBUG_ALLOCATOR_ARENA_MAX + Assert(ArenaIndex != ArenaStartIndex); + } + + if (A.DEBUGAllocList->ArenaHashes[ArenaIndex] == 0) + { + A.DEBUGAllocList->ArenaHashes[ArenaIndex] = ArenaHash; + + gs_debug_arena_info AI = {}; + AI.ArenaName = ArenaName; + A.DEBUGAllocList->ArenaInfos[ArenaIndex] = AI; + } + + A.DEBUGAllocList->ArenaInfos[ArenaIndex].AllocationsCount += 1; + A.DEBUGAllocList->ArenaInfos[ArenaIndex].TotalSize += Size; + } + + + + return Result; +} + +#define AllocString(a,s,l) AllocString_((a), (s), DEBUG_LOC, (l)) +internal gs_string +AllocString_(gs_allocator A, u64 Size, gs_debug_loc Loc, char* LocString) +{ + gs_string Result = {}; + Result.Str = (char*)Alloc_(A, sizeof(char)*Size, Loc, LocString).Memory; + Result.Length = 0; + Result.Size = Size; + return Result; +} + +#define Free(a,b,s) Free_((a),(b),(s),DEBUG_LOC) +#define FreeStruct(a,b,t) Free_((a),(u8*)(b),sizeof(t),DEBUG_LOC) +#define FreeArray(a,b,t,c) Free_((a),(u8*)(b),sizeof(t)*(c),DEBUG_LOC) +internal void +Free_(gs_allocator A, u8* Base, u64 Size, gs_debug_loc Loc) +{ + GS_MEMORY_PROFILE_FUNC; + + A.PFree(Base, Size, A.UserData); +} + +// NOTE(PS): cast function and struct pointers to proper data types +// for convenience +#define AllocatorCreate(a,f,u) AllocatorCreate_((platform_alloc*)(a),(platform_free*)(f),(u8*)(u)) +internal gs_allocator +AllocatorCreate_(platform_alloc* PAlloc, platform_free* PFree, u8* UserData) +{ + gs_allocator Result = {}; + Result.PAlloc = PAlloc; + Result.PFree = PFree; + Result.UserData = UserData; + + if (!PAlloc) Result.PAlloc = AllocNoOp; + if (!PFree) Result.PFree = FreeNoOp; + + // @DEBUG +#define DEBUG_ALLOCATOR_ARENA_MAX 256 + Result.DEBUGAllocList = (gs_debug_allocations_list*)PAlloc(sizeof(gs_debug_allocations_list*), 0, UserData); + + Result.DEBUGAllocList->ArenaHashesCount = DEBUG_ALLOCATOR_ARENA_MAX; + Result.DEBUGAllocList->ArenaHashes = (u64*)PAlloc(sizeof(u64*) * DEBUG_ALLOCATOR_ARENA_MAX, 0, UserData); + Result.DEBUGAllocList->ArenaInfos = (gs_debug_arena_info*)PAlloc(sizeof(gs_debug_arena_info) * DEBUG_ALLOCATOR_ARENA_MAX, 0, UserData); + return Result; +} + +// +// Memory Cursor +// + +typedef struct gs_memory_cursor +{ + gs_data Data; + u64 Position; +} gs_memory_cursor; + +internal gs_memory_cursor +MemoryCursorCreate(u8* Base, u64 Size) +{ + GS_MEMORY_PROFILE_FUNC; + + gs_memory_cursor Result = {}; + Result.Data.Memory = Base; + Result.Data.Size = Size; + Result.Position = 0; + + return Result; +} +internal gs_memory_cursor +MemoryCursorCreateFromData(gs_data Data) +{ + GS_MEMORY_PROFILE_FUNC; + return MemoryCursorCreate(Data.Memory, Data.Size); +} + +internal u64 +MemoryCursorRoomLeft(gs_memory_cursor Cursor) +{ + GS_MEMORY_PROFILE_FUNC; + + u64 Result = 0; + if (Cursor.Data.Size >= Cursor.Position) + { + Result = Cursor.Data.Size - Cursor.Position; + } + return Result; +} + +internal bool +MemoryCursorHasRoom(gs_memory_cursor Cursor) +{ + GS_MEMORY_PROFILE_FUNC; + + u64 RoomLeft = MemoryCursorRoomLeft(Cursor); + bool Result = RoomLeft > 0; + return Result; +} + +internal bool +MemoryCursorCanPush(gs_memory_cursor Cursor, u64 Size) +{ + GS_MEMORY_PROFILE_FUNC; + + u64 RoomLeft = MemoryCursorRoomLeft(Cursor); + bool Result = RoomLeft >= Size; + return Result; +} + +#define MemoryCursorPushSize(c,s) MemoryCursorPushSize_((c),(s)) +#define MemoryCursorPushStruct(c,s) (s*)MemoryCursorPushSize_((c),sizeof(s)).Memory +#define MemoryCursorPushArray(c,s,l) (s*)MemoryCursorPushSize_((c),sizeof(s)*(l)).Memory +internal gs_data +MemoryCursorPushSize_(gs_memory_cursor* C, u64 Size) +{ + GS_MEMORY_PROFILE_FUNC; + + gs_data Result = {0}; + if (MemoryCursorCanPush(*C, Size)) + { + Result.Memory = C->Data.Memory + C->Position; + Result.Size = Size, + C->Position += Size; + } + return Result; +} + +internal gs_data +MemoryCursorAlign(gs_memory_cursor* C, u64 Alignment) +{ + GS_MEMORY_PROFILE_FUNC; + + u64 Position = RoundUpTo64(C->Position, Alignment); + if (Position > C->Data.Size) + { + Position = C->Data.Size; + } + u64 AlignmentDist = Position - C->Position; + gs_data Result = MemoryCursorPushSize_(C, AlignmentDist); + return Result; +} + +#define MemoryCursorWriteValue(c,t,v) *PushStructOnCursor((c),(t)) = (v) +internal void +MemoryCursorWriteBuffer(gs_memory_cursor* C, gs_data Buffer) +{ + GS_MEMORY_PROFILE_FUNC; + + gs_data Dest = MemoryCursorPushSize(C, Buffer.Size); + if (Dest.Size == Buffer.Size) + { + CopyMemoryTo(Buffer.Memory, Dest.Memory, Buffer.Size); + } +} + +internal void +MemoryCursorPopSize(gs_memory_cursor* C, u64 Size) +{ + GS_MEMORY_PROFILE_FUNC; + + u64 SizeToPop = Size; + if (SizeToPop > C->Position) + { + SizeToPop = C->Position; + } + + C->Position -= SizeToPop; +} + +internal void +MemoryCursorReset(gs_memory_cursor* C) +{ + GS_MEMORY_PROFILE_FUNC; + + C->Position = 0; +} + +// +// Memory Arena +// + +typedef struct gs_memory_cursor_sll +{ + gs_memory_cursor Cursor; + struct gs_memory_cursor_sll* Next; +} gs_memory_cursor_sll; + +typedef struct gs_memory_arena +{ + u64 ChunkSize; + u64 Alignment; + char* ArenaName; + + gs_memory_cursor_sll* CursorsRoot; + gs_memory_cursor_sll* CursorsHead; + + struct gs_memory_arena* Parent; + gs_allocator Allocator; + u8* UserData; + // TODO: some sort of GrowArena function +} gs_memory_arena; + +internal gs_memory_arena +MemoryArenaCreate(u64 ChunkSize, u64 Alignment, gs_allocator Allocator, gs_memory_arena* Parent, u8* UserData, char* Name) +{ + GS_MEMORY_PROFILE_FUNC; + + gs_memory_arena Result = {}; + Result.ChunkSize = ChunkSize; + Result.Alignment = Alignment; + Result.Allocator = Allocator; + Result.Parent = Parent; + Result.UserData = UserData; + Result.ArenaName = Name; + + return Result; +} + +internal gs_data PushSize_(gs_memory_arena* Arena, u64 Size, gs_debug_loc Loc); + +internal gs_memory_cursor* +MemoryArenaPushCursor(gs_memory_arena* Arena, u64 MinSize, gs_debug_loc Loc) +{ + GS_MEMORY_PROFILE_FUNC; + + gs_memory_cursor* Result = 0; + + u64 CursorSize = MinSize; + if (CursorSize < Arena->ChunkSize) + { + CursorSize = Arena->ChunkSize; + } + u64 AllocSize = CursorSize + sizeof(gs_memory_cursor_sll); + + gs_data CursorMemory = {0}; + if (Arena->Parent) + { + CursorMemory = PushSize_(Arena->Parent, AllocSize, Loc); + } else if (Arena->UserData) { + // TODO(PS): implement custom MemoryArenaAllocCursor functionality + InvalidCodePath; + } else { + Assert(Arena->Allocator.PAlloc); + CursorMemory = Alloc_(Arena->Allocator, AllocSize, Loc, Arena->ArenaName); + } + + gs_memory_cursor_sll* CursorEntry = (gs_memory_cursor_sll*)CursorMemory.Memory; + if (!Arena->CursorsRoot) + { + Arena->CursorsRoot = CursorEntry; + } + if (Arena->CursorsHead) + { + Arena->CursorsHead->Next = CursorEntry; + } + Arena->CursorsHead = CursorEntry; + + u8* CursorBase = (u8*)(CursorEntry + 1); + CursorEntry->Cursor = MemoryCursorCreate(CursorBase, CursorSize); + Result = &CursorEntry->Cursor; + + return Result; +} + +#define PushSize(a,s) PushSize_((a), (s), DEBUG_LOC) +#define PushStruct(a,t) (t*)PushSize_((a), sizeof(t), DEBUG_LOC).Memory +#define PushArray(a,t,c) (t*)PushSize_((a), sizeof(t) * (c), DEBUG_LOC).Memory +#define PushString(a,c) gs_string{ PushArray((a),char,(c)), 0, (c) } + +internal gs_data +PushSize_(gs_memory_arena* Arena, u64 Size, gs_debug_loc Loc) +{ + GS_MEMORY_PROFILE_FUNC; + + gs_data Result = {0}; + if (Size > 0) + { + gs_memory_cursor* Cursor = 0; + for (gs_memory_cursor_sll* C = Arena->CursorsRoot; + C != 0; + C = C->Next) + { + if (MemoryCursorCanPush(C->Cursor, Size)) + { + Cursor = &C->Cursor; + break; + } + } + + // NOTE(PS): We didn't find a cursor with enough room + // for the allocation being requested + if (!Cursor) + { + Cursor = MemoryArenaPushCursor(Arena, Size, Loc); + } + Assert(Cursor); + Assert(MemoryCursorCanPush(*Cursor, Size)); + + Result = MemoryCursorPushSize(Cursor, Size); + + gs_data Alignment = MemoryCursorAlign(Cursor, Arena->Alignment); + Result.Size += Alignment.Size; + } + return Result; +} + +internal void +MemoryArenaClear(gs_memory_arena* Arena) +{ + GS_MEMORY_PROFILE_FUNC; + + for (gs_memory_cursor_sll* C = Arena->CursorsRoot; + C != 0; + C = C->Next) + { + MemoryCursorReset(&C->Cursor); + } +} + +internal void +MemoryArenaFree(gs_memory_arena* Arena) +{ + GS_MEMORY_PROFILE_FUNC; + + // NOTE(PS): If this isn't a base arena, we can't + // really free it. + // TODO(PS): Once we have the User Specified codepaths + // in, we can probably provide a way for the user to + // let us free a custom allocator + Assert(Arena->Allocator.PFree); + + gs_allocator A = Arena->Allocator; + gs_memory_cursor_sll* At = Arena->CursorsRoot; + while (At) + { + gs_memory_cursor_sll* NextAt = At->Next; + + u64 Size = At->Cursor.Data.Size + sizeof(gs_memory_cursor_sll); + Free(A, (u8*)At, Size); + + At = NextAt; + } + + Arena->CursorsRoot = 0; + Arena->CursorsHead = 0; +} + +#ifdef GS_PLATFORM_IMPLEMENTATION + +internal gs_allocator CreatePlatformAllocator(); + +# if PLATFORM_WINDOWS +# include "./gs_memory_win32.h" +# elif PLATFORM_OSX +# include "./gs_memory_osx.h" +# elif PLATFORM_LINUX +# include "./gs_memory_linux.h" +# endif + +#endif + +#endif //GS_MEMORY_H diff --git a/src/gs_libs/gs_memory_arena.h b/src/gs_libs/gs_memory_arena.h index 4fbeb3b..e4bad68 100644 --- a/src/gs_libs/gs_memory_arena.h +++ b/src/gs_libs/gs_memory_arena.h @@ -153,13 +153,13 @@ typedef unsigned int gs_mem_u32; typedef unsigned long long int gs_mem_u64; -#ifdef DEBUG +#if DEBUG #if !defined(GSMem_Assert) #define GSMem_Assert(expression) \ if((expression)) { \ }else{ \ - volatile int* p = 0; \ - *p = 5; \ +volatile int* p = 0; \ +*p = 5; \ } #endif diff --git a/src/gs_libs/gs_path.h b/src/gs_libs/gs_path.h new file mode 100644 index 0000000..ebcbb7b --- /dev/null +++ b/src/gs_libs/gs_path.h @@ -0,0 +1,106 @@ +// +// File: gs_path.h +// Author: Peter Slattery +// Creation Date: 2021-03-06 +// +#ifndef GS_PATH_H + +internal gs_const_string +ClearString() +{ + gs_const_string R = {}; + R.Str = 0; + R.Length = 0; + return R; +} + +internal void +SanitizePath (gs_const_string Path, gs_string* Dest, gs_memory_arena* Scratch) +{ + Dest->Length = 0; + + // Put all slashes in the same format + s32 SlashCount = 0; + for (u64 i = 0; i < Path.Length; i++) + { + char At = Path.Str[i]; + if (At == '\\' || At == '/') { + SlashCount += 1; + } + } + + // we add one to slash count in case the last element is a file or + // doesn't end in a slash (even if it should) + u32 PathEleCountMax = SlashCount + 1; + u32 PathEleCount = 0; + gs_const_string* PathEle = PushArray(Scratch, gs_const_string, PathEleCountMax); + + u64 OnePastLastEleEnd = 0; + for (s64 i = 0; i < (s64)Path.Length; i++) + { + char At = Path.Str[i]; + if (At == '\\' || At == '/') + { + gs_const_string* NewEle = PathEle + PathEleCount++; + *NewEle = Substring(Path, OnePastLastEleEnd, i + 1); + OnePastLastEleEnd = i + 1; + } + } + + if (OnePastLastEleEnd != Path.Length) + { + gs_const_string* NewEle = PathEle + PathEleCount++; + *NewEle = Substring(Path, OnePastLastEleEnd, Path.Length); + OnePastLastEleEnd = Path.Length; + } + + // Remove redundant elements + for (u32 i = 0; i < PathEleCount; i++) + { + gs_const_string* At = PathEle + i; + bool ShouldRemove = false; + if (i != 0) + { + if (StringsEqual(*At, ConstString(".\\")) || + StringsEqual(*At, ConstString("./"))) + { + *At = ClearString(); + } + else if (StringsEqual(*At, ConstString("..\\")) || + StringsEqual(*At, ConstString("../"))) + { + PathEle[i - 1] = ClearString(); + if (i != 1) { + PathEle[i] = ClearString(); + } + } + } + } + + for (u32 i = 0; i < PathEleCount; i++) + { + if (PathEle[i].Str) { + AppendPrintF(Dest, "%S", PathEle[i]); + } + } + + // Put all slashes in the same format + for (u64 i = 0; i < Dest->Length; i++) + { + if (Dest->Str[i] == '/') { + Dest->Str[i] = '\\'; + } + } +} + +internal gs_const_string +SanitizePath (gs_const_string Path, gs_memory_arena* Scratch) +{ + gs_string Result = PushString(Scratch, Path.Length); + SanitizePath(Path, &Result, Scratch); + return Result.ConstString; +} + + +#define GS_PATH_H +#endif // GS_PATH_H \ No newline at end of file diff --git a/src/gs_libs/gs_radix_sort.h b/src/gs_libs/gs_radix_sort.h index 8e62a27..cf4464d 100644 --- a/src/gs_libs/gs_radix_sort.h +++ b/src/gs_libs/gs_radix_sort.h @@ -1,12 +1,11 @@ /* gs_radix_sort.h - An implementation of radix sort for fixed size unsigned 32bit integer buffers -TODO */ #ifndef GS_RADIX_SORT_H -#ifdef DEBUG +#if DEBUG #if !defined(GSRad_Assert) #define GSRad_Assert(expression) \ if(!(expression)) { \ diff --git a/src/gs_libs/gs_tests.h b/src/gs_libs/gs_tests.h new file mode 100644 index 0000000..7a38fb5 --- /dev/null +++ b/src/gs_libs/gs_tests.h @@ -0,0 +1,72 @@ +// +// File: gs_tests.h +// Author: Peter Slattery +// Creation Date: 2021-03-06 +// +#ifndef GS_TESTS_H + +int CStringLen(char* Str) +{ + char* At = Str; + while (*At != 0) { At++; } + int Result = At - Str; + return Result; +} + +struct test_ctx +{ + int TestsCount; + int TestsPassedCount; +}; + +static test_ctx TestCtx = {0}; + +static void +BeginTest(char* Name) +{ + int Length = CStringLen(Name); + int Spaces = 25 - Length; + if(Spaces < 0) + { + Spaces = 0; + } + printf("\"%s\" %.*s [", Name, Spaces, "------------------------------"); + TestCtx.TestsCount = 0; + TestCtx.TestsPassedCount = 0; +} + +static void +TestResult(bool Result) +{ + TestCtx.TestsCount += 1; + if (Result) { + TestCtx.TestsPassedCount += 1; + } + printf(Result ? "." : "X"); +} + +static void +EndTest(void) +{ + int Spaces = 10 - TestCtx.TestsCount; + if(Spaces < 0) { Spaces = 0; } + printf("]%.*s ", Spaces, " "); + printf("[%i/%i] %i passed, %i tests, ", + TestCtx.TestsPassedCount, TestCtx.TestsCount, + TestCtx.TestsPassedCount, TestCtx.TestsCount); + if(TestCtx.TestsCount == TestCtx.TestsPassedCount) + { + printf("SUCCESS ( )"); + } + else + { + printf("FAILED (X)"); + } + printf("\n"); +} + +#define Test(name) for(int _i_ = (BeginTest(name), 0); !_i_; _i_ += 1, EndTest()) + + +#define GS_TESTS_H +#endif // GS_TESTS_H \ No newline at end of file diff --git a/src/gs_libs/gs_types.cpp b/src/gs_libs/gs_types.cpp index 197c270..bdf12c4 100644 --- a/src/gs_libs/gs_types.cpp +++ b/src/gs_libs/gs_types.cpp @@ -9,18 +9,18 @@ internal gs_data StructToData_(u8* Memory, u64 Size) { - gs_data Result = {0}; - Result.Memory = Memory; - Result.Size = Size; - return Result; + gs_data Result = {0}; + Result.Memory = Memory; + Result.Size = Size; + return Result; } internal u32 U32DivideRoundUp (u32 A, u32 B) { - r32 Result = (r32)A / (r32)B; - Result += .99999f; - return (u32)Result; + r32 Result = (r32)A / (r32)B; + Result += .99999f; + return (u32)Result; } inline bool XOR(bool A, bool B) { return (A == !B); } @@ -31,495 +31,495 @@ inline bool XOR(b64 A, b64 B) { return (A == !B); } internal u32 RoundUpToMultiple(u32 Value, u32 MultipleOf) { - u32 Result = Value; - if (MultipleOf != 0) - { - u32 Remainder = Value % MultipleOf; - Result = Value + (MultipleOf - Remainder); - } - return Result; + u32 Result = Value; + if (MultipleOf != 0) + { + u32 Remainder = Value % MultipleOf; + Result = Value + (MultipleOf - Remainder); + } + return Result; } internal u32 RoundUpToPow2U32(u32 Value) { - u32 Result = Value - 1; - Result |= Result >> 1; - Result |= Result >> 2; - Result |= Result >> 4; - Result |= Result >> 8; - Result |= Result >> 16; - Result++; - return Result; + u32 Result = Value - 1; + Result |= Result >> 1; + Result |= Result >> 2; + Result |= Result >> 4; + Result |= Result >> 8; + Result |= Result >> 16; + Result++; + return Result; } internal u32 RoundUpToPow2U64(u64 Value) { - u64 Result = Value - 1; - Result |= Result >> 1; - Result |= Result >> 2; - Result |= Result >> 4; - Result |= Result >> 8; - Result |= Result >> 16; - Result |= Result >> 32; - Result++; - return Result; + u64 Result = Value - 1; + Result |= Result >> 1; + Result |= Result >> 2; + Result |= Result >> 4; + Result |= Result >> 8; + Result |= Result >> 16; + Result |= Result >> 32; + Result++; + return Result; } internal u64 RoundUpTo64(u64 Value, u64 Alignment) { - Value += Alignment - 1; - Value -= Value % Alignment; - return Value; + Value += Alignment - 1; + Value -= Value % Alignment; + return Value; } internal u8 PowU8(u8 X, u32 Power) { - u8 Result = X; - for (u32 i = 1; i < Power; i++) { Result *= X; } - return Result; + u8 Result = X; + for (u32 i = 1; i < Power; i++) { Result *= X; } + return Result; } internal u16 PowU16(u16 X, u32 Power) { - u16 Result = X; - for (u32 i = 1; i < Power; i++) { Result *= X; } - return Result; + u16 Result = X; + for (u32 i = 1; i < Power; i++) { Result *= X; } + return Result; } internal u32 PowU32(u32 X, u32 Power) { - u32 Result = X; - for (u32 i = 1; i < Power; i++) { Result *= X; } - return Result; + u32 Result = X; + for (u32 i = 1; i < Power; i++) { Result *= X; } + return Result; } internal u64 PowU64(u64 X, u32 Power) { - u64 Result = X; - for (u32 i = 1; i < Power; i++) { Result *= X; } - return Result; + u64 Result = X; + for (u32 i = 1; i < Power; i++) { Result *= X; } + return Result; } internal s8 PowS8(s8 X, u32 Power) { - s8 Result = X; - for (u32 i = 1; i < Power; i++) { Result *= X; } - return Result; + s8 Result = X; + for (u32 i = 1; i < Power; i++) { Result *= X; } + return Result; } internal s16 PowS16(s16 X, u32 Power) { - s16 Result = X; - for (u32 i = 1; i < Power; i++) { Result *= X; } - return Result; + s16 Result = X; + for (u32 i = 1; i < Power; i++) { Result *= X; } + return Result; } internal s32 PowS32(s32 X, u32 Power) { - s32 Result = X; - for (u32 i = 1; i < Power; i++) { Result *= X; } - return Result; + s32 Result = X; + for (u32 i = 1; i < Power; i++) { Result *= X; } + return Result; } internal s64 PowS64(s64 X, u32 Power) { - s64 Result = X; - for (u32 i = 1; i < Power; i++) { Result *= X; } - return Result; + s64 Result = X; + for (u32 i = 1; i < Power; i++) { Result *= X; } + return Result; } internal r32 PowR32(r32 X, u32 Power) { - r32 Result = X; - for (u32 i = 1; i < Power; i++) { Result *= X; } - return Result; + r32 Result = X; + for (u32 i = 1; i < Power; i++) { Result *= X; } + return Result; } internal r64 PowR64(r64 X, u32 Power) { - r64 Result = X; - for (u32 i = 1; i < Power; i++) { Result *= X; } - return Result; + r64 Result = X; + for (u32 i = 1; i < Power; i++) { Result *= X; } + return Result; } internal u8 LerpU8(r32 T, u8 A, u8 B) { - return (u8)((A * (1.0f - T)) + (B * T)); + return (u8)((A * (1.0f - T)) + (B * T)); } internal u16 LerpU16(r32 T, u16 A, u16 B) { - return (u16)((A * (1.0f - T)) + (B * T)); + return (u16)((A * (1.0f - T)) + (B * T)); } internal u32 LerpU32(r32 T, u32 A, u32 B) { - return (u32)((A * (1.0f - T)) + (B * T)); + return (u32)((A * (1.0f - T)) + (B * T)); } internal u64 LerpU64(r32 T, u64 A, u64 B) { - return (u64)((A * (1.0f - T)) + (B * T)); + return (u64)((A * (1.0f - T)) + (B * T)); } internal s8 LerpS8(r32 T, s8 A, s8 B) { - return (s8)((A * (1.0f - T)) + (B * T)); + return (s8)((A * (1.0f - T)) + (B * T)); } internal s16 LerpS16(r32 T, s16 A, s16 B) { - return (s16)((A * (1.0f - T)) + (B * T)); + return (s16)((A * (1.0f - T)) + (B * T)); } internal s32 LerpS32(r32 T, s32 A, s32 B) { - return (s32)((A * (1.0f - T)) + (B * T)); + return (s32)((A * (1.0f - T)) + (B * T)); } internal s64 LerpS64(r32 T, s64 A, s64 B) { - return (s64)((A * (1.0f - T)) + (B * T)); + return (s64)((A * (1.0f - T)) + (B * T)); } internal r32 LerpR32(r32 T, r32 A, r32 B) { - return (r32)((A * (1.0f - T)) + (B * T)); + return (r32)((A * (1.0f - T)) + (B * T)); } internal r64 LerpR64(r32 T, r64 A, r64 B) { - return (r64)((A * (1.0f - T)) + (B * T)); + return (r64)((A * (1.0f - T)) + (B * T)); } internal u8 UnlerpU8(u8 Value, u8 Min, u8 Max) { - return (u8)((r64)(Value - Min) / (r64)(Max - Min)); + return (u8)((r64)(Value - Min) / (r64)(Max - Min)); } internal u16 UnlerpU16(u16 Value, u16 Min, u16 Max) { - return (u16)((r64)(Value - Min) / (r64)(Max - Min)); + return (u16)((r64)(Value - Min) / (r64)(Max - Min)); } internal u32 UnlerpU32(u32 Value, u32 Min, u32 Max) { - return (u32)((r64)(Value - Min) / (r64)(Max - Min)); + return (u32)((r64)(Value - Min) / (r64)(Max - Min)); } internal u64 UnlerpU64(u64 Value, u64 Min, u64 Max) { - return (u64)((r64)(Value - Min) / (r64)(Max - Min)); + return (u64)((r64)(Value - Min) / (r64)(Max - Min)); } internal s8 UnlerpS8(s8 Value, s8 Min, s8 Max) { - return (s8)((r64)(Value - Min) / (r64)(Max - Min)); + return (s8)((r64)(Value - Min) / (r64)(Max - Min)); } internal s16 UnlerpS16(s16 Value, s16 Min, s16 Max) { - return (s16)((r64)(Value - Min) / (r64)(Max - Min)); + return (s16)((r64)(Value - Min) / (r64)(Max - Min)); } internal s32 UnlerpS32(s32 Value, s32 Min, s32 Max) { - return (s32)((r64)(Value - Min) / (r64)(Max - Min)); + return (s32)((r64)(Value - Min) / (r64)(Max - Min)); } internal s64 UnlerpS64(s64 Value, s64 Min, s64 Max) { - return (s64)((r64)(Value - Min) / (r64)(Max - Min)); + return (s64)((r64)(Value - Min) / (r64)(Max - Min)); } internal r32 UnlerpR32(r32 Value, r32 Min, r32 Max) { - return (Value - Min) / (Max - Min); + return (Value - Min) / (Max - Min); } internal r64 UnlerpR64(r64 Value, r64 Min, r64 Max) { - return (Value - Min) / (Max - Min); + return (Value - Min) / (Max - Min); } internal u8 RemapU8(u8 Value, u8 OldMin, u8 OldMax, u8 NewMin, u8 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - u8 Result = (u8)((A * (NewMax - NewMin)) + NewMin); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + u8 Result = (u8)((A * (NewMax - NewMin)) + NewMin); + return Result; } internal u16 RemapU16(u16 Value, u16 OldMin, u16 OldMax, u16 NewMin, u16 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - u16 Result = (u16)((A * (NewMax - NewMin)) + NewMin); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + u16 Result = (u16)((A * (NewMax - NewMin)) + NewMin); + return Result; } internal u32 RemapU32(u32 Value, u32 OldMin, u32 OldMax, u32 NewMin, u32 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - u32 Result = (u32)((A * (NewMax - NewMin)) + NewMin); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + u32 Result = (u32)((A * (NewMax - NewMin)) + NewMin); + return Result; } internal u64 RemapU64(u64 Value, u64 OldMin, u64 OldMax, u64 NewMin, u64 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - u64 Result = (u64)((A * (NewMax - NewMin)) + NewMin); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + u64 Result = (u64)((A * (NewMax - NewMin)) + NewMin); + return Result; } internal s8 RemapS8(s8 Value, s8 OldMin, s8 OldMax, s8 NewMin, s8 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - s8 Result = (s8)((A * (NewMax - NewMin)) + NewMin); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + s8 Result = (s8)((A * (NewMax - NewMin)) + NewMin); + return Result; } internal s16 RemapS16(s16 Value, s16 OldMin, s16 OldMax, s16 NewMin, s16 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - s16 Result = (s16)((A * (NewMax - NewMin)) + NewMin); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + s16 Result = (s16)((A * (NewMax - NewMin)) + NewMin); + return Result; } internal s32 RemapS32(s32 Value, s32 OldMin, s32 OldMax, s32 NewMin, s32 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - s32 Result = (s32)((A * (NewMax - NewMin)) + NewMin); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + s32 Result = (s32)((A * (NewMax - NewMin)) + NewMin); + return Result; } internal s64 RemapS64(s64 Value, s64 OldMin, s64 OldMax, s64 NewMin, s64 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - s64 Result = (s64)((A * (NewMax - NewMin)) + NewMin); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + s64 Result = (s64)((A * (NewMax - NewMin)) + NewMin); + return Result; } internal r32 RemapR32(r32 Value, r32 OldMin, r32 OldMax, r32 NewMin, r32 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r32 Result = (r32)((A * (NewMax - NewMin)) + NewMin); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r32 Result = (r32)((A * (NewMax - NewMin)) + NewMin); + return Result; } internal r64 RemapR64(r64 Value, r64 OldMin, r64 OldMax, r64 NewMin, r64 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 Result = (r64)((A * (NewMax - NewMin)) + NewMin); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 Result = (r64)((A * (NewMax - NewMin)) + NewMin); + return Result; } internal u8 RemapClampedU8(u8 Value, u8 OldMin, u8 OldMax, u8 NewMin, u8 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 AClamped = Clamp01(A); - r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); - u8 Result = (u8)Clamp(NewMin, UnclampedResult, NewMax); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 AClamped = Clamp01(A); + r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); + u8 Result = (u8)Clamp(NewMin, UnclampedResult, NewMax); + return Result; } internal u16 RemapClampedU16(u16 Value, u16 OldMin, u16 OldMax, u16 NewMin, u16 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 AClamped = Clamp01(A); - r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); - u16 Result = (u16)Clamp(NewMin, UnclampedResult, NewMax); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 AClamped = Clamp01(A); + r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); + u16 Result = (u16)Clamp(NewMin, UnclampedResult, NewMax); + return Result; } internal u32 RemapClampedU32(u32 Value, u32 OldMin, u32 OldMax, u32 NewMin, u32 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 AClamped = Clamp01(A); - r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); - u32 Result = (u32)Clamp(NewMin, UnclampedResult, NewMax); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 AClamped = Clamp01(A); + r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); + u32 Result = (u32)Clamp(NewMin, UnclampedResult, NewMax); + return Result; } internal u64 RemapClampedU64(u64 Value, u64 OldMin, u64 OldMax, u64 NewMin, u64 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 AClamped = Clamp01(A); - r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); - u64 Result = (u64)Clamp(NewMin, UnclampedResult, NewMax); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 AClamped = Clamp01(A); + r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); + u64 Result = (u64)Clamp(NewMin, UnclampedResult, NewMax); + return Result; } internal s8 RemapClampedS8(s8 Value, s8 OldMin, s8 OldMax, s8 NewMin, s8 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 AClamped = Clamp01(A); - r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); - s8 Result = (s8)Clamp(NewMin, UnclampedResult, NewMax); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 AClamped = Clamp01(A); + r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); + s8 Result = (s8)Clamp(NewMin, UnclampedResult, NewMax); + return Result; } internal s16 RemapClampedS16(s16 Value, s16 OldMin, s16 OldMax, s16 NewMin, s16 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 AClamped = Clamp01(A); - r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); - s16 Result = (s16)Clamp(NewMin, UnclampedResult, NewMax); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 AClamped = Clamp01(A); + r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); + s16 Result = (s16)Clamp(NewMin, UnclampedResult, NewMax); + return Result; } internal s32 RemapClampedS32(s32 Value, s32 OldMin, s32 OldMax, s32 NewMin, s32 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 AClamped = Clamp01(A); - r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); - s32 Result = (s32)Clamp(NewMin, UnclampedResult, NewMax); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 AClamped = Clamp01(A); + r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); + s32 Result = (s32)Clamp(NewMin, UnclampedResult, NewMax); + return Result; } internal s64 RemapClampedS64(s64 Value, s64 OldMin, s64 OldMax, s64 NewMin, s64 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 AClamped = Clamp01(A); - r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); - s64 Result = (s64)Clamp(NewMin, UnclampedResult, NewMax); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 AClamped = Clamp01(A); + r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); + s64 Result = (s64)Clamp(NewMin, UnclampedResult, NewMax); + return Result; } internal r32 RemapClampedR32(r32 Value, r32 OldMin, r32 OldMax, r32 NewMin, r32 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 AClamped = Clamp01(A); - r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); - r32 Result = (r32)Clamp(NewMin, UnclampedResult, NewMax); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 AClamped = Clamp01(A); + r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); + r32 Result = (r32)Clamp(NewMin, UnclampedResult, NewMax); + return Result; } internal r64 RemapClampedR64(r64 Value, r64 OldMin, r64 OldMax, r64 NewMin, r64 NewMax) { - r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); - r64 AClamped = Clamp01(A); - r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); - r64 Result = (r64)Clamp(NewMin, UnclampedResult, NewMax); - return Result; + r64 A = (r64)(Value - OldMin) / (r64)(OldMax - OldMin); + r64 AClamped = Clamp01(A); + r64 UnclampedResult = ((AClamped * (NewMax - NewMin)) + NewMin); + r64 Result = (r64)Clamp(NewMin, UnclampedResult, NewMax); + return Result; } internal r32 FloorR32(r32 V) { - return (r32)((s64)V); + return (r32)((s64)V); } internal r64 FloorR64(r64 V) { - return (r64)((s64)V); + return (r64)((s64)V); } internal r32 FractR32(r32 V) { - return V - FloorR32(V); + return V - FloorR32(V); } internal r64 FractR64(r64 V) { - return V - FloorR64(V); + return V - FloorR64(V); } internal r32 SqrtR32(r32 V) { - return _mm_cvtss_f32(_mm_sqrt_ss(_mm_set_ss(V))); + return _mm_cvtss_f32(_mm_sqrt_ss(_mm_set_ss(V))); } internal u32 SqrtU32(u32 V) { - return sqrt(V); + return sqrt(V); } internal r32 ModR32(r32 Value, r32 Int) { - r32 Div = Value / Int; - r32 Fract = Abs(FractR32(Div)); - return Int * Fract; + r32 Div = Value / Int; + r32 Fract = Abs(FractR32(Div)); + return Int * Fract; } internal r64 ModR64(r64 Value, r64 Int) { - r64 Div = Value / Int; - r64 Fract = Abs(FractR64(Div)); - return Int * Fract; + r64 Div = Value / Int; + r64 Fract = Abs(FractR64(Div)); + return Int * Fract; } internal r32 SinR32(r32 Rad) { - return sinf(Rad); + return sinf(Rad); } internal r64 SinR64(r64 Rad) { - return sin(Rad); + return sin(Rad); } internal r32 CosR32(r32 Rad) { - return cosf(Rad); + return cosf(Rad); } internal r64 CosR64(r64 Rad) { - return cos(Rad); + return cos(Rad); } internal r32 TanR32(r32 Rad) { - return tanf(Rad); + return tanf(Rad); } internal r64 TanR64(r64 Rad) { - return tan(Rad); + return tan(Rad); } internal r32 ASinR32(r32 Rad) { - return asinf(Rad); + return asinf(Rad); } internal r64 ASinR64(r64 Rad) { - return asin(Rad); + return asin(Rad); } internal r32 ACosR32(r32 Rad) { - return acosf(Rad); + return acosf(Rad); } internal r64 ACosR64(r64 Rad) { - return acos(Rad); + return acos(Rad); } internal r32 ATanR32(r32 Rad) { - return atanf(Rad); + return atanf(Rad); } internal r64 ATanR64(r64 Rad) { - return atan(Rad); + return atan(Rad); } /////////////////////////// @@ -529,34 +529,34 @@ ATanR64(r64 Rad) internal v2 V2MultiplyPairwise(v2 A, v2 B) { - v2 Result = v2{ - A.x * B.x, - A.y * B.y, - }; - return Result; + v2 Result = v2{ + A.x * B.x, + A.y * B.y, + }; + return Result; } internal v3 V3MultiplyPairwise(v3 A, v3 B) { - v3 Result = v3{ - A.x * B.x, - A.y * B.y, - A.z * B.z, - }; - return Result; + v3 Result = v3{ + A.x * B.x, + A.y * B.y, + A.z * B.z, + }; + return Result; } internal v4 V4MultiplyPairwise(v4 A, v4 B) { - v4 Result = v4{ - A.x * B.x, - A.y * B.y, - A.z * B.z, - A.w * B.w, - }; - return Result; + v4 Result = v4{ + A.x * B.x, + A.y * B.y, + A.z * B.z, + A.w * B.w, + }; + return Result; } @@ -608,7 +608,7 @@ internal v3 ToV3(v2 V, r32 Z = 0) { return v3{V.x, V.y, Z}; } internal v4 V2ToV4(v2 V, r32 Z = 0, r32 W = 0) { return v4{V.x, V.y, Z, W}; } internal v4 ToV4_(v3 V, r32 W) { - return v4{V.x, V.y, V.z, W}; + return v4{V.x, V.y, V.z, W}; } #define ToV4Point(v) ToV4_((v), 1.0f) // all points have a w value of 1 #define ToV4Vec(v) ToV4_((v), 0.0f) // all vectors have a w value of 0 ie. they cannot be translated @@ -632,20 +632,20 @@ internal r32 V4Distance(v4 A, v4 B) { return V4Mag(A - B); } internal v2 V2Normalize(v2 A) { - r32 Magnitude = V2Mag(A); - return A / Magnitude; + r32 Magnitude = V2Mag(A); + return A / Magnitude; } internal v3 V3Normalize(v3 A) { - r32 Magnitude = V3Mag(A); - return A / Magnitude; + r32 Magnitude = V3Mag(A); + return A / Magnitude; } internal v4 V4Normalize(v4 A) { - r32 Magnitude = V4Mag(A); - return A / Magnitude; + r32 Magnitude = V4Mag(A); + return A / Magnitude; } internal r32 V2Dot(v2 A, v2 B) { return ((A.x * B.x) + (A.y * B.y)); } @@ -658,102 +658,102 @@ internal v2 V2PerpendicularCCW(v2 A) { return v2{A.y, A.x}; } internal r32 V2Cross(v2 A, v2 B) { - return ((A.x * B.y) - (A.y * B.x)); + return ((A.x * B.y) - (A.y * B.x)); } internal v3 V3Cross(v3 A, v3 B) { - v3 Result = { - (A.y * B.z) - (A.z * B.y), - (A.z * B.x) - (A.x * B.z), - (A.x * B.y) - (A.y * B.x) - }; - return Result; + v3 Result = { + (A.y * B.z) - (A.z * B.y), + (A.z * B.x) - (A.x * B.z), + (A.x * B.y) - (A.y * B.x) + }; + return Result; } internal v4 V4Cross(v4 A, v4 B) { - v4 Result = { - (A.y * B.z) - (A.z * B.y), - (A.z * B.x) - (A.x * B.z), - (A.x * B.y) - (A.y * B.x), - 0 - }; - return Result; + v4 Result = { + (A.y * B.z) - (A.z * B.y), + (A.z * B.x) - (A.x * B.z), + (A.x * B.y) - (A.y * B.x), + 0 + }; + return Result; } internal v2 V2Lerp(r32 T, v2 A, v2 B) { - v2 Result = v2{ - LerpR32(T, A.x, B.x), - LerpR32(T, A.y, B.y), - }; - return Result; + v2 Result = v2{ + LerpR32(T, A.x, B.x), + LerpR32(T, A.y, B.y), + }; + return Result; } internal v3 V3Lerp(r32 T, v3 A, v3 B) { - v3 Result = v3{ - LerpR32(T, A.x, B.x), - LerpR32(T, A.y, B.y), - LerpR32(T, A.z, B.z), - }; - return Result; + v3 Result = v3{ + LerpR32(T, A.x, B.x), + LerpR32(T, A.y, B.y), + LerpR32(T, A.z, B.z), + }; + return Result; } internal v4 V4Lerp(r32 T, v4 A, v4 B) { - v4 Result = v4{ - LerpR32(T, A.x, B.x), - LerpR32(T, A.y, B.y), - LerpR32(T, A.z, B.z), - LerpR32(T, A.w, B.w), - }; - return Result; + v4 Result = v4{ + LerpR32(T, A.x, B.x), + LerpR32(T, A.y, B.y), + LerpR32(T, A.z, B.z), + LerpR32(T, A.w, B.w), + }; + return Result; } internal v2 V2Remap(v2 P, v2 OldMin, v2 OldMax, v2 NewMin, v2 NewMax) { - v2 Result = {0}; - Result.x = RemapR32(P.x, OldMin.x, OldMax.x, NewMin.x, NewMax.x); - Result.y = RemapR32(P.y, OldMin.y, OldMax.y, NewMin.y, NewMax.y); - return Result; + v2 Result = {0}; + Result.x = RemapR32(P.x, OldMin.x, OldMax.x, NewMin.x, NewMax.x); + Result.y = RemapR32(P.y, OldMin.y, OldMax.y, NewMin.y, NewMax.y); + return Result; } internal v3 V3Remap(v3 P, v3 OldMin, v3 OldMax, v3 NewMin, v3 NewMax) { - v3 Result = {0}; - Result.x = RemapR32(P.x, OldMin.x, OldMax.x, NewMin.x, NewMax.x); - Result.y = RemapR32(P.y, OldMin.y, OldMax.y, NewMin.y, NewMax.y); - Result.z = RemapR32(P.z, OldMin.z, OldMax.z, NewMin.z, NewMax.z); - return Result; + v3 Result = {0}; + Result.x = RemapR32(P.x, OldMin.x, OldMax.x, NewMin.x, NewMax.x); + Result.y = RemapR32(P.y, OldMin.y, OldMax.y, NewMin.y, NewMax.y); + Result.z = RemapR32(P.z, OldMin.z, OldMax.z, NewMin.z, NewMax.z); + return Result; } internal v4 V4Remap(v4 P, v4 OldMin, v4 OldMax, v4 NewMin, v4 NewMax) { - v4 Result = {0}; - Result.x = RemapR32(P.x, OldMin.x, OldMax.x, NewMin.x, NewMax.x); - Result.y = RemapR32(P.y, OldMin.y, OldMax.y, NewMin.y, NewMax.y); - Result.z = RemapR32(P.z, OldMin.z, OldMax.z, NewMin.z, NewMax.z); - Result.w = RemapR32(P.w, OldMin.w, OldMax.w, NewMin.w, NewMax.w); - return Result; + v4 Result = {0}; + Result.x = RemapR32(P.x, OldMin.x, OldMax.x, NewMin.x, NewMax.x); + Result.y = RemapR32(P.y, OldMin.y, OldMax.y, NewMin.y, NewMax.y); + Result.z = RemapR32(P.z, OldMin.z, OldMax.z, NewMin.z, NewMax.z); + Result.w = RemapR32(P.w, OldMin.w, OldMax.w, NewMin.w, NewMax.w); + return Result; } internal v4 V4RemapAsV3(v4 P, v4 OldMin, v4 OldMax, v4 NewMin, v4 NewMax) { - v4 Result = {0}; - Result.xyz = V3Remap(P.xyz, OldMin.xyz, OldMax.xyz, NewMin.xyz, NewMax.xyz); - Result.w = P.w; - return Result; + v4 Result = {0}; + Result.xyz = V3Remap(P.xyz, OldMin.xyz, OldMax.xyz, NewMin.xyz, NewMax.xyz); + Result.w = P.w; + return Result; } /////////////////////////// @@ -762,47 +762,47 @@ V4RemapAsV3(v4 P, v4 OldMin, v4 OldMax, v4 NewMin, v4 NewMax) internal rect2 MakeRect2MinDim(v2 Min, v2 Dim) { - rect2 Result = {0}; - Result.Min = Min; - Result.Max = Min + Dim; - return Result; + rect2 Result = {0}; + Result.Min = Min; + Result.Max = Min + Dim; + return Result; } internal rect2 MakeRect2CenterDim(v2 Center, v2 Dim) { - v2 HalfDim = Dim / 2; - rect2 Result = {0}; - Result.Min = Center - HalfDim; - Result.Max = Center + HalfDim; - return Result; + v2 HalfDim = Dim / 2; + rect2 Result = {0}; + Result.Min = Center - HalfDim; + Result.Max = Center + HalfDim; + return Result; } internal b32 ValueInRangeR32(r32 Min, r32 Max, r32 V) { - return ((V >= Min) && (V <= Max)); + return ((V >= Min) && (V <= Max)); } internal b32 ValueInRange1(range1 Range, r32 V) { - return ValueInRangeR32(Range.Min, Range.Max, V); + return ValueInRangeR32(Range.Min, Range.Max, V); } internal b32 ValueInRange2(range2 Range, v2 V) { - return (ValueInRangeR32(Range.Min.x, Range.Max.x, V.x) && - ValueInRangeR32(Range.Min.y, Range.Max.y, V.y)); + return (ValueInRangeR32(Range.Min.x, Range.Max.x, V.x) && + ValueInRangeR32(Range.Min.y, Range.Max.y, V.y)); } internal b32 ValueInRange3(range3 Range, v3 V) { - return (ValueInRangeR32(Range.Min.x, Range.Max.x, V.x) && - ValueInRangeR32(Range.Min.y, Range.Max.y, V.y) && - ValueInRangeR32(Range.Min.z, Range.Max.z, V.z)); + return (ValueInRangeR32(Range.Min.x, Range.Max.x, V.x) && + ValueInRangeR32(Range.Min.y, Range.Max.y, V.y) && + ValueInRangeR32(Range.Min.z, Range.Max.z, V.z)); } internal b32 ValueInRange4(range4 Range, v4 V) { - return (ValueInRangeR32(Range.Min.x, Range.Max.x, V.x) && - ValueInRangeR32(Range.Min.y, Range.Max.y, V.y) && - ValueInRangeR32(Range.Min.z, Range.Max.z, V.z) && - ValueInRangeR32(Range.Min.w, Range.Max.w, V.w)); + return (ValueInRangeR32(Range.Min.x, Range.Max.x, V.x) && + ValueInRangeR32(Range.Min.y, Range.Max.y, V.y) && + ValueInRangeR32(Range.Min.z, Range.Max.z, V.z) && + ValueInRangeR32(Range.Min.w, Range.Max.w, V.w)); } #define PointIsInRect(range, point) ValueInRange2((range), (point)) @@ -843,19 +843,19 @@ internal range4 Range4Offset(range4 Range, v4 Delta) { return range4{ Range.Min internal v2 RectTopLeft(rect2 Rect) { - return v2{ Rect.Min.x, Rect.Max.y }; + return v2{ Rect.Min.x, Rect.Max.y }; } internal v2 RectTopRight(rect2 Rect) { - return Rect.Max; + return Rect.Max; } internal v2 RectBottomLeft(rect2 Rect) { - return Rect.Min; + return Rect.Min; } internal v2 RectBottomRight(rect2 Rect) { - return v2{ Rect.Max.x, Rect.Min.y }; + return v2{ Rect.Max.x, Rect.Min.y }; } internal r32 AspectRatio(r32 Width, r32 Height) { return Width / Height; } @@ -864,143 +864,143 @@ internal r32 RectAspectRatio(rect2 Rect) { return Range2SizeX(Rect) / Range2Size internal void RectHSplit(rect2 Rect, r32 YValue, rect2* Top, rect2* Bottom) { - r32 ClampedYValue = Clamp(Rect.Min.y, YValue, Rect.Max.y); - Top->Max = Rect.Max; - Top->Min = { Rect.Min.x, ClampedYValue }; - Bottom->Max = { Rect.Max.x, ClampedYValue }; - Bottom->Min = Rect.Min; + r32 ClampedYValue = Clamp(Rect.Min.y, YValue, Rect.Max.y); + Top->Max = Rect.Max; + Top->Min = { Rect.Min.x, ClampedYValue }; + Bottom->Max = { Rect.Max.x, ClampedYValue }; + Bottom->Min = Rect.Min; } internal void RectVSplit(rect2 Rect, r32 XValue, rect2* Left, rect2* Right) { - r32 ClampedXValue = Clamp(Rect.Min.x, XValue, Rect.Max.x); - Left->Max = { ClampedXValue, Rect.Max.y}; - Left->Min = Rect.Min; - Right->Max = Rect.Max; - Right->Min = { ClampedXValue, Rect.Min.y }; + r32 ClampedXValue = Clamp(Rect.Min.x, XValue, Rect.Max.x); + Left->Max = { ClampedXValue, Rect.Max.y}; + Left->Min = Rect.Min; + Right->Max = Rect.Max; + Right->Min = { ClampedXValue, Rect.Min.y }; } internal void RectHSplitAtDistanceFromTop(rect2 Rect, r32 YDist, rect2* Top, rect2* Bottom) { - RectHSplit(Rect, Rect.Max.y - YDist, Top, Bottom); + RectHSplit(Rect, Rect.Max.y - YDist, Top, Bottom); } internal void RectHSplitAtDistanceFromBottom(rect2 Rect, r32 YDist, rect2* Top, rect2* Bottom) { - RectHSplit(Rect, Rect.Min.y + YDist, Top, Bottom); + RectHSplit(Rect, Rect.Min.y + YDist, Top, Bottom); } internal void RectVSplitAtDistanceFromRight(rect2 Rect, r32 XDist, rect2* Left, rect2* Right) { - RectVSplit(Rect, Rect.Max.x - XDist, Left, Right); + RectVSplit(Rect, Rect.Max.x - XDist, Left, Right); } internal void RectVSplitAtDistanceFromLeft(rect2 Rect, r32 XDist, rect2* Left, rect2* Right) { - RectVSplit(Rect, Rect.Min.x + XDist, Left, Right); + RectVSplit(Rect, Rect.Min.x + XDist, Left, Right); } internal void RectHSplitAtPercent(rect2 Rect, r32 YPercent, rect2* Top, rect2* Bottom) { - RectHSplit(Rect, LerpR32(YPercent, Rect.Min.y, Rect.Max.y), Top, Bottom); + RectHSplit(Rect, LerpR32(YPercent, Rect.Min.y, Rect.Max.y), Top, Bottom); } internal void RectVSplitAtPercent(rect2 Rect, r32 XPercent, rect2* Left, rect2* Right) { - RectVSplit(Rect, LerpR32(XPercent, Rect.Min.x, Rect.Max.x), Left, Right); + RectVSplit(Rect, LerpR32(XPercent, Rect.Min.x, Rect.Max.x), Left, Right); } internal rect2 RectInset(rect2 Outer, v2 Amount) { - rect2 Result = { Outer.Min + Amount, Outer.Max - Amount }; - return Result; + rect2 Result = { Outer.Min + Amount, Outer.Max - Amount }; + return Result; } internal rect2 RectInset(rect2 Outer, r32 UniformAmount) { - return RectInset(Outer, v2{UniformAmount, UniformAmount}); + return RectInset(Outer, v2{UniformAmount, UniformAmount}); } internal range1 Range1Union(range1 A, range1 B) { - range1 Result = {}; - Result.Min = Max(A.Min, B.Min); - Result.Max = Min(A.Max, B.Max); - return Result; + range1 Result = {}; + Result.Min = Max(A.Min, B.Min); + Result.Max = Min(A.Max, B.Max); + return Result; } #define Rect2Union(a,b) Range2Union((a), (b)) internal range2 Range2Union(range2 A, range2 B) { - range2 Result = {}; - Result.Min.x = Max(A.Min.x, B.Min.x); - Result.Min.y = Max(A.Min.y, B.Min.y); - Result.Max.x = Min(A.Max.x, B.Max.x); - Result.Max.y = Min(A.Max.y, B.Max.y); - - if (Rect2Width(Result) < 0) { Result.Min.x = Result.Max.x; } - if (Rect2Height(Result) < 0) { Result.Min.y = Result.Max.y; } - - return Result; + range2 Result = {}; + Result.Min.x = Max(A.Min.x, B.Min.x); + Result.Min.y = Max(A.Min.y, B.Min.y); + Result.Max.x = Min(A.Max.x, B.Max.x); + Result.Max.y = Min(A.Max.y, B.Max.y); + + if (Rect2Width(Result) < 0) { Result.Min.x = Result.Max.x; } + if (Rect2Height(Result) < 0) { Result.Min.y = Result.Max.y; } + + return Result; } internal range3 Range3Union(range3 A, range3 B) { - range3 Result = {}; - Result.Min.x = Max(A.Min.x, B.Min.x); - Result.Min.y = Max(A.Min.y, B.Min.y); - Result.Min.z = Max(A.Min.z, B.Min.z); - Result.Max.x = Min(A.Max.x, B.Max.x); - Result.Max.y = Min(A.Max.y, B.Max.y); - Result.Max.z = Min(A.Max.z, B.Max.z); - return Result; + range3 Result = {}; + Result.Min.x = Max(A.Min.x, B.Min.x); + Result.Min.y = Max(A.Min.y, B.Min.y); + Result.Min.z = Max(A.Min.z, B.Min.z); + Result.Max.x = Min(A.Max.x, B.Max.x); + Result.Max.y = Min(A.Max.y, B.Max.y); + Result.Max.z = Min(A.Max.z, B.Max.z); + return Result; } internal v2 Rect2GetRectLocalPoint(rect2 Rect, v2 Point) { - v2 Result = Point - Rect.Min; - return Result; + v2 Result = Point - Rect.Min; + return Result; } internal r32 Rect2Area(rect2 Rect) { - r32 Result = Rect2Width(Rect) * Rect2Height(Rect); - return Result; + r32 Result = Rect2Width(Rect) * Rect2Height(Rect); + return Result; } internal v2 Rect2BottomLeft(rect2 Rect) { - v2 Result = Rect.Min; - return Result; + v2 Result = Rect.Min; + return Result; } internal v2 Rect2BottomRight(rect2 Rect) { - v2 Result = v2{ Rect.Max.x, Rect.Min.y }; - return Result; + v2 Result = v2{ Rect.Max.x, Rect.Min.y }; + return Result; } internal v2 Rect2TopRight(rect2 Rect) { - v2 Result = Rect.Max; - return Result; + v2 Result = Rect.Max; + return Result; } internal v2 Rect2TopLeft(rect2 Rect) { - v2 Result = v2{ Rect.Min.x, Rect.Max.y }; - return Result; + v2 Result = v2{ Rect.Min.x, Rect.Max.y }; + return Result; } /////////////////////////// @@ -1010,55 +1010,55 @@ Rect2TopLeft(rect2 Rect) internal v4 RayGetPointAlong(v4 RayOrigin, v4 RayDirection, r32 T) { - v4 Result = RayOrigin + (RayDirection * T); - return Result; + v4 Result = RayOrigin + (RayDirection * T); + return Result; } internal r32 RayPlaneIntersectionDistance(v4 RayOrigin, v4 RayDirection, v4 PlanePoint, v4 PlaneNormal) { - r32 T = 0.0f; - float Denominator = V4Dot(PlaneNormal, RayDirection); - if (Abs(Denominator) > 0.00001f) - { - T = V4Dot(PlanePoint - RayDirection, PlaneNormal) / Denominator; - } - return T; + r32 T = 0.0f; + float Denominator = V4Dot(PlaneNormal, RayDirection); + if (Abs(Denominator) > 0.00001f) + { + T = V4Dot(PlanePoint - RayDirection, PlaneNormal) / Denominator; + } + return T; } internal v4 GetRayPlaneIntersectionPoint(v4 RayOrigin, v4 RayDirection, v4 PlanePoint, v4 PlaneNormal) { - v4 Result = {0}; - r32 T = RayPlaneIntersectionDistance(RayOrigin, RayDirection, PlanePoint, PlaneNormal); - if (T >= 0) - { - Result = RayGetPointAlong(RayOrigin, RayDirection, T); - } - return Result; + v4 Result = {0}; + r32 T = RayPlaneIntersectionDistance(RayOrigin, RayDirection, PlanePoint, PlaneNormal); + if (T >= 0) + { + Result = RayGetPointAlong(RayOrigin, RayDirection, T); + } + return Result; } internal v4 GetRayPlaneIntersectionPoint(v4_ray Ray, v4 PlanePoint, v4 PlaneNormal) { - return GetRayPlaneIntersectionPoint(Ray.Origin, Ray.Direction, PlanePoint, PlaneNormal); + return GetRayPlaneIntersectionPoint(Ray.Origin, Ray.Direction, PlanePoint, PlaneNormal); } internal bool RayIntersectsPlane(v4 RayOrigin, v4 RayDirection, v4 PlanePoint, v4 PlaneNormal, v4* OutPoint) { - bool Result = false; - r32 T = RayPlaneIntersectionDistance(RayOrigin, RayDirection, PlanePoint, PlaneNormal); - if (T >= 0) - { - Result = true; - *OutPoint = RayGetPointAlong(RayOrigin, RayDirection, T); - } - return Result; + bool Result = false; + r32 T = RayPlaneIntersectionDistance(RayOrigin, RayDirection, PlanePoint, PlaneNormal); + if (T >= 0) + { + Result = true; + *OutPoint = RayGetPointAlong(RayOrigin, RayDirection, T); + } + return Result; } internal bool RayIntersectsPlane(v4_ray Ray, v4 PlanePoint, v4 PlaneNormal, v4* OutPoint) { - return RayIntersectsPlane(Ray.Origin, Ray.Direction, PlanePoint, PlaneNormal, OutPoint); + return RayIntersectsPlane(Ray.Origin, Ray.Direction, PlanePoint, PlaneNormal, OutPoint); } /////////////////////////// @@ -1068,286 +1068,286 @@ RayIntersectsPlane(v4_ray Ray, v4 PlanePoint, v4 PlaneNormal, v4* OutPoint) internal m44 M44Identity() { - m44 M = {0}; - M.AXx = 1.0f; - M.AYy = 1.0f; - M.AZz = 1.0f; - M.Tw = 1.0f; - return M; + m44 M = {0}; + M.AXx = 1.0f; + M.AYy = 1.0f; + M.AZz = 1.0f; + M.Tw = 1.0f; + return M; } internal m44 M44Transpose(m44 M) { - m44 Result = {0}; - for (u32 Y = 0; Y < 4; Y++) + m44 Result = {0}; + for (u32 Y = 0; Y < 4; Y++) + { + for (u32 X = 0; X < 4; X++) { - for (u32 X = 0; X < 4; X++) - { - Result.Array[(X * 4) + Y] = M.Array[(Y * 4) + X]; - } + Result.Array[(X * 4) + Y] = M.Array[(Y * 4) + X]; } - return Result; + } + return Result; } // Matrix * Matrix m44 operator* (m44 L, m44 R) { - m44 M = {0}; - - // ci ic ci ic ci ic i ic - M.AXx = (L.AXx * R.AXx) + (L.AYx * R.AXy) + (L.AZx * R.AXz) + (L.Tx * R.AXw); - M.AXy = (L.AXy * R.AXx) + (L.AYy * R.AXy) + (L.AZy * R.AXz) + (L.Ty * R.AXw); - M.AXz = (L.AXz * R.AXx) + (L.AYz * R.AXy) + (L.AZz * R.AXz) + (L.Tz * R.AXw); - M.AXw = (L.AXw * R.AXx) + (L.AYw * R.AXy) + (L.AZw * R.AXz) + (L.Tw * R.AXw); - - M.AYx = (L.AXx * R.AYx) + (L.AYx * R.AYy) + (L.AZx * R.AYz) + (L.Tx * R.AYw); - M.AYy = (L.AXy * R.AYx) + (L.AYy * R.AYy) + (L.AZy * R.AYz) + (L.Ty * R.AYw); - M.AYz = (L.AXz * R.AYx) + (L.AYz * R.AYy) + (L.AZz * R.AYz) + (L.Tz * R.AYw); - M.AYz = (L.AXw * R.AYx) + (L.AYw * R.AYy) + (L.AZw * R.AYz) + (L.Tw * R.AYw); - - M.AZx = (L.AXx * R.AZx) + (L.AYx * R.AZy) + (L.AZx * R.AZz) + (L.Tx * R.AZw); - M.AZy = (L.AXy * R.AZx) + (L.AYy * R.AZy) + (L.AZy * R.AZz) + (L.Ty * R.AZw); - M.AZz = (L.AXz * R.AZx) + (L.AYz * R.AZy) + (L.AZz * R.AZz) + (L.Tz * R.AZw); - M.AZw = (L.AXw * R.AZx) + (L.AYw * R.AZy) + (L.AZw * R.AZz) + (L.Tw * R.AZw); - - M.Tx = (L.AXx * R.Tx) + (L.AYx * R.Ty) + (L.AZx * R.Tz) + (L.Tx * R.Tw); - M.Ty = (L.AXy * R.Tx) + (L.AYy * R.Ty) + (L.AZy * R.Tz) + (L.Ty * R.Tw); - M.Tz = (L.AXz * R.Tx) + (L.AYz * R.Ty) + (L.AZz * R.Tz) + (L.Tz * R.Tw); - M.Tw = (L.AXw * R.Tx) + (L.AYw * R.Ty) + (L.AZw * R.Tz) + (L.Tw * R.Tw); - - return M; + m44 M = {0}; + + // ci ic ci ic ci ic i ic + M.AXx = (L.AXx * R.AXx) + (L.AYx * R.AXy) + (L.AZx * R.AXz) + (L.Tx * R.AXw); + M.AXy = (L.AXy * R.AXx) + (L.AYy * R.AXy) + (L.AZy * R.AXz) + (L.Ty * R.AXw); + M.AXz = (L.AXz * R.AXx) + (L.AYz * R.AXy) + (L.AZz * R.AXz) + (L.Tz * R.AXw); + M.AXw = (L.AXw * R.AXx) + (L.AYw * R.AXy) + (L.AZw * R.AXz) + (L.Tw * R.AXw); + + M.AYx = (L.AXx * R.AYx) + (L.AYx * R.AYy) + (L.AZx * R.AYz) + (L.Tx * R.AYw); + M.AYy = (L.AXy * R.AYx) + (L.AYy * R.AYy) + (L.AZy * R.AYz) + (L.Ty * R.AYw); + M.AYz = (L.AXz * R.AYx) + (L.AYz * R.AYy) + (L.AZz * R.AYz) + (L.Tz * R.AYw); + M.AYz = (L.AXw * R.AYx) + (L.AYw * R.AYy) + (L.AZw * R.AYz) + (L.Tw * R.AYw); + + M.AZx = (L.AXx * R.AZx) + (L.AYx * R.AZy) + (L.AZx * R.AZz) + (L.Tx * R.AZw); + M.AZy = (L.AXy * R.AZx) + (L.AYy * R.AZy) + (L.AZy * R.AZz) + (L.Ty * R.AZw); + M.AZz = (L.AXz * R.AZx) + (L.AYz * R.AZy) + (L.AZz * R.AZz) + (L.Tz * R.AZw); + M.AZw = (L.AXw * R.AZx) + (L.AYw * R.AZy) + (L.AZw * R.AZz) + (L.Tw * R.AZw); + + M.Tx = (L.AXx * R.Tx) + (L.AYx * R.Ty) + (L.AZx * R.Tz) + (L.Tx * R.Tw); + M.Ty = (L.AXy * R.Tx) + (L.AYy * R.Ty) + (L.AZy * R.Tz) + (L.Ty * R.Tw); + M.Tz = (L.AXz * R.Tx) + (L.AYz * R.Ty) + (L.AZz * R.Tz) + (L.Tz * R.Tw); + M.Tw = (L.AXw * R.Tx) + (L.AYw * R.Ty) + (L.AZw * R.Tz) + (L.Tw * R.Tw); + + return M; } // Matrix * Vector v4 operator* (m44 M, v4 V) { - v4 Result = {0}; - Result.x = (V.x * M.AXx) + (V.y * M.AYx) + (V.z * M.AZx) + (V.w * M.Tx); - Result.y = (V.x * M.AXy) + (V.y * M.AYy) + (V.z * M.AZy) + (V.w * M.Ty); - Result.z = (V.x * M.AXz) + (V.y * M.AYz) + (V.z * M.AZz) + (V.w * M.Tz); - Result.w = (V.x * M.AXw) + (V.y * M.AYw) + (V.z * M.AZw) + (V.w * M.Tw); - return Result; + v4 Result = {0}; + Result.x = (V.x * M.AXx) + (V.y * M.AYx) + (V.z * M.AZx) + (V.w * M.Tx); + Result.y = (V.x * M.AXy) + (V.y * M.AYy) + (V.z * M.AZy) + (V.w * M.Ty); + Result.z = (V.x * M.AXz) + (V.y * M.AYz) + (V.z * M.AZz) + (V.w * M.Tz); + Result.w = (V.x * M.AXw) + (V.y * M.AYw) + (V.z * M.AZw) + (V.w * M.Tw); + return Result; } internal m44 M44Translation(v4 Offset) { - m44 Result = M44Identity(); - Result.Tx = Offset.x; - Result.Ty = Offset.y; - Result.Tz = Offset.z; - return Result; + m44 Result = M44Identity(); + Result.Tx = Offset.x; + Result.Ty = Offset.y; + Result.Tz = Offset.z; + return Result; } internal m44 M44RotationX(r32 Radians) { - r32 CosRad = CosR32(Radians); - r32 SinRad = SinR32(Radians); - m44 Result = M44Identity(); - Result.AYy = CosRad; - Result.AZy = SinRad; - Result.AYz = -SinRad; - Result.AZz = CosRad; - return Result; + r32 CosRad = CosR32(Radians); + r32 SinRad = SinR32(Radians); + m44 Result = M44Identity(); + Result.AYy = CosRad; + Result.AZy = SinRad; + Result.AYz = -SinRad; + Result.AZz = CosRad; + return Result; } internal m44 M44RotationY(r32 Radians) { - r32 CosRad = CosR32(Radians); - r32 SinRad = SinR32(Radians); - m44 Result = M44Identity(); - Result.AXx = CosRad; - Result.AZx = SinRad; - Result.AXz = -SinRad; - Result.AZz = CosRad; - return Result; + r32 CosRad = CosR32(Radians); + r32 SinRad = SinR32(Radians); + m44 Result = M44Identity(); + Result.AXx = CosRad; + Result.AZx = SinRad; + Result.AXz = -SinRad; + Result.AZz = CosRad; + return Result; } internal m44 M44RotationZ(r32 Radians) { - r32 CosRad = CosR32(Radians); - r32 SinRad = SinR32(Radians); - m44 Result = M44Identity(); - Result.AXx = CosRad; - Result.AYx = -SinRad; - Result.AXy = SinRad; - Result.AYy = CosRad; - return Result; + r32 CosRad = CosR32(Radians); + r32 SinRad = SinR32(Radians); + m44 Result = M44Identity(); + Result.AXx = CosRad; + Result.AYx = -SinRad; + Result.AXy = SinRad; + Result.AYy = CosRad; + return Result; } internal m44 M44Rotation(v3 Radians) { - r32 CosX = CosR32(Radians.x); - r32 SinX = SinR32(Radians.x); - r32 CosY = CosR32(Radians.y); - r32 SinY = SinR32(Radians.y); - r32 CosZ = CosR32(Radians.z); - r32 SinZ = SinR32(Radians.z); - - m44 Result = {0}; - Result.AXx = CosY * CosZ; - Result.AXy = -(SinX * SinY * CosZ) + (CosX * SinZ); - Result.AXz = -(CosX * SinY * CosZ) - (SinX * SinZ); - Result.AXw = 0; - - Result.AYx = -(SinZ * CosY); - Result.AYy = (SinX * SinY * SinZ) + (CosX * CosZ); - Result.AYz = (CosX * SinY * SinZ) - (SinX * CosZ); - Result.AYw = 0; - - Result.AZx = SinY; - Result.AZy = SinX * CosY; - Result.AZz = CosX * CosY; - Result.AZw = 0; - - Result.Tx = 0; - Result.Ty = 0; - Result.Tz = 0; - Result.Tw = 1; - - return Result; + r32 CosX = CosR32(Radians.x); + r32 SinX = SinR32(Radians.x); + r32 CosY = CosR32(Radians.y); + r32 SinY = SinR32(Radians.y); + r32 CosZ = CosR32(Radians.z); + r32 SinZ = SinR32(Radians.z); + + m44 Result = {0}; + Result.AXx = CosY * CosZ; + Result.AXy = -(SinX * SinY * CosZ) + (CosX * SinZ); + Result.AXz = -(CosX * SinY * CosZ) - (SinX * SinZ); + Result.AXw = 0; + + Result.AYx = -(SinZ * CosY); + Result.AYy = (SinX * SinY * SinZ) + (CosX * CosZ); + Result.AYz = (CosX * SinY * SinZ) - (SinX * CosZ); + Result.AYw = 0; + + Result.AZx = SinY; + Result.AZy = SinX * CosY; + Result.AZz = CosX * CosY; + Result.AZw = 0; + + Result.Tx = 0; + Result.Ty = 0; + Result.Tz = 0; + Result.Tw = 1; + + return Result; } internal m44 M44Scale(v3 Scale) { - m44 Result = M44Identity(); - Result.AXx = Scale.x; - Result.AYy = Scale.y; - Result.AZz = Scale.z; - return Result; + m44 Result = M44Identity(); + Result.AXx = Scale.x; + Result.AYy = Scale.y; + Result.AZz = Scale.z; + return Result; } internal m44 M44ScaleUniform(r32 Scale) { - m44 Result = M44Identity(); - Result.AXx = Scale; - Result.AYy = Scale; - Result.AZz = Scale; - return Result; + m44 Result = M44Identity(); + Result.AXx = Scale; + Result.AYy = Scale; + Result.AZz = Scale; + return Result; } internal m44 M44CoordinateFrame(v4 Forward, v4 Right, v4 Up) { - m44 Result = {0}; - Result.AXx = Right.x; - Result.AYx = Right.y; - Result.AZx = Right.z; - Result.Tx = Right.w; - - Result.AXy = Up.x; - Result.AYy = Up.y; - Result.AZy = Up.z; - Result.Ty = Up.w; - - Result.AXz = Forward.x; - Result.AYz = Forward.y; - Result.AZz = Forward.z; - Result.Tz = Forward.w; - - Result.Tw = 1.0f; - return Result; + m44 Result = {0}; + Result.AXx = Right.x; + Result.AYx = Right.y; + Result.AZx = Right.z; + Result.Tx = Right.w; + + Result.AXy = Up.x; + Result.AYy = Up.y; + Result.AZy = Up.z; + Result.Ty = Up.w; + + Result.AXz = Forward.x; + Result.AYz = Forward.y; + Result.AZz = Forward.z; + Result.Tz = Forward.w; + + Result.Tw = 1.0f; + return Result; } internal m44 M44ModelMatrix(v4 Forward, v4 Right, v4 Up, v4 Position) { - m44 RotationMatrix = M44CoordinateFrame(Forward, Right, Up); - m44 PositionMatrix = M44Translation(-Position); - m44 ModelViewMatrix = PositionMatrix * RotationMatrix; - return ModelViewMatrix; + m44 RotationMatrix = M44CoordinateFrame(Forward, Right, Up); + m44 PositionMatrix = M44Translation(-Position); + m44 ModelViewMatrix = PositionMatrix * RotationMatrix; + return ModelViewMatrix; } internal m44 M44ProjectionOrtho(r32 Width, r32 Height, r32 Near, r32 Far, r32 Right, r32 Left, r32 Top, r32 Bottom) { - m44 Result = {0}; - Result.AXx = 2.0f / Width; - Result.AYy = 2.0f / Height; - Result.AZz = 2.0f / (Near - Far); - Result.AXw = -(Right + Left) / (Right - Left); - Result.AYw = -(Top + Bottom) / (Top - Bottom); - Result.AZw = -(Far + Near) / (Far - Near); - Result.Tw = 1; - return Result; + m44 Result = {0}; + Result.AXx = 2.0f / Width; + Result.AYy = 2.0f / Height; + Result.AZz = 2.0f / (Near - Far); + Result.AXw = -(Right + Left) / (Right - Left); + Result.AYw = -(Top + Bottom) / (Top - Bottom); + Result.AZw = -(Far + Near) / (Far - Near); + Result.Tw = 1; + return Result; } internal m44 M44ProjectionOrtho(r32 Aspect, r32 Scale, r32 Near, r32 Far) { - m44 Result = {0}; - r32 Width = Scale * Aspect; - r32 Height = Scale; - r32 Right = Width / 2.0f; - r32 Left = -Right; - r32 Top = Height / 2.0f; - r32 Bottom = -Top; - Result = M44ProjectionOrtho(Width, Height, Near, Far, Right, Left, Top, Bottom); - return Result; + m44 Result = {0}; + r32 Width = Scale * Aspect; + r32 Height = Scale; + r32 Right = Width / 2.0f; + r32 Left = -Right; + r32 Top = Height / 2.0f; + r32 Bottom = -Top; + Result = M44ProjectionOrtho(Width, Height, Near, Far, Right, Left, Top, Bottom); + return Result; } internal m44 M44ProjectionInterfaceOrtho(r32 Width, r32 Height, r32 Near, r32 Far) { - m44 Result = {0}; - r32 Aspect = Width / Height; - r32 Right = Width; - r32 Left = 0; - r32 Top = Height; - r32 Bottom = 0; - Result = M44ProjectionOrtho(Width, Height, Near, Far, Right, Left, Top, Bottom); - return Result; + m44 Result = {0}; + r32 Aspect = Width / Height; + r32 Right = Width; + r32 Left = 0; + r32 Top = Height; + r32 Bottom = 0; + Result = M44ProjectionOrtho(Width, Height, Near, Far, Right, Left, Top, Bottom); + return Result; } internal m44 M44ProjectionPerspective(r32 FieldOfViewDegrees, r32 AspectRatio, r32 Near, r32 Far) { - m44 Result = M44Identity(); - - // The perspective divide step involves dividing x and y by -z - // Making Tz = -1 will make Tw of the result = -z - Result.Tw = 0; - Result.AZw = -1; - - // Remap z' from the range [near clip : far clip] to [0 : 1] - r32 ViewRange = Far - Near; - Result.AZz = -((Far + Near) / ViewRange); - Result.Tz = -(2 * Near * Far) / ViewRange; - - // Adjust for field of view - adjust the x' and y coordinates based - // on how - r32 FovBasedScale = TanR32(DegToRadR32(FieldOfViewDegrees / 2)); - r32 Top = Near * FovBasedScale; - r32 Bottom = -Top; - r32 Right = Top * AspectRatio; - r32 Left = -Right; - Result.AXx = (2 * Near) / (Right - Left); - Result.AZx = (Right + Left) / (Right - Left); - Result.AYy = (2 * Near) / (Top - Bottom); - Result.AZy = (Top + Bottom) / (Top - Bottom); - - return Result; + m44 Result = M44Identity(); + + // The perspective divide step involves dividing x and y by -z + // Making Tz = -1 will make Tw of the result = -z + Result.Tw = 0; + Result.AZw = -1; + + // Remap z' from the range [near clip : far clip] to [0 : 1] + r32 ViewRange = Far - Near; + Result.AZz = -((Far + Near) / ViewRange); + Result.Tz = -(2 * Near * Far) / ViewRange; + + // Adjust for field of view - adjust the x' and y coordinates based + // on how + r32 FovBasedScale = TanR32(DegToRadR32(FieldOfViewDegrees / 2)); + r32 Top = Near * FovBasedScale; + r32 Bottom = -Top; + r32 Right = Top * AspectRatio; + r32 Left = -Right; + Result.AXx = (2 * Near) / (Right - Left); + Result.AZx = (Right + Left) / (Right - Left); + Result.AYy = (2 * Near) / (Top - Bottom); + Result.AZy = (Top + Bottom) / (Top - Bottom); + + return Result; } internal m44 M44LookAt(v4 Position, v4 Target) { - // NOTE(Peter): the camera usually points along the -z axis, hence - // Forward = a ray that points from the target back towards your position - v4 Forward = V4Normalize(Position - Target); - v4 Right = V4Normalize(V4Cross(v4{0, 1, 0, 0}, Forward)); - v4 Up = V4Normalize(V4Cross(Forward, Right)); - m44 Result = M44CoordinateFrame(Forward, Right, Up); - return Result; + // NOTE(Peter): the camera usually points along the -z axis, hence + // Forward = a ray that points from the target back towards your position + v4 Forward = V4Normalize(Position - Target); + v4 Right = V4Normalize(V4Cross(v4{0, 1, 0, 0}, Forward)); + v4 Up = V4Normalize(V4Cross(Forward, Right)); + m44 Result = M44CoordinateFrame(Forward, Right, Up); + return Result; } /////////////////////////// @@ -1358,37 +1358,44 @@ internal gs_const_string ConstString(char* Data, u64 Length) { return gs_const_s internal gs_const_string ConstString(char* Data) { return gs_const_string{Data, CStringLength(Data)}; } internal gs_string MakeString(char* Data, u64 Length, u64 Size) { - Assert(Length <= Size); - gs_string Result = {0}; - Result.Str = Data; - Result.Length = Length; - Result.Size = Size; - return Result; + Assert(Length <= Size); + gs_string Result = {0}; + Result.Str = Data; + Result.Length = Length; + Result.Size = Size; + return Result; } internal gs_string MakeString(char* Data, u64 Length) { - return MakeString(Data, Length, Length); + return MakeString(Data, Length, Length); } internal gs_string MakeString(char* Data) { - u64 StringLength = CStringLength(Data); - return MakeString(Data, StringLength, StringLength); + u64 StringLength = CStringLength(Data); + return MakeString(Data, StringLength, StringLength); } internal gs_string MakeString(gs_const_string ConstString) { - return MakeString(ConstString.Str, ConstString.Length); + return MakeString(ConstString.Str, ConstString.Length); } internal gs_data StringToData(gs_const_string String) { - gs_data Result = gs_data{0}; - Result.Memory = (u8*)String.Str; - Result.Size = String.Length * sizeof(char); - return Result; + gs_data Result = gs_data{0}; + Result.Memory = (u8*)String.Str; + Result.Size = String.Length * sizeof(char); + return Result; } internal gs_data StringToData(gs_string String) { - return StringToData(String.ConstString); + return StringToData(String.ConstString); +} +internal gs_const_string DataToString(gs_data Data) +{ + gs_const_string Result = {}; + Result.Str = (char*)Data.Memory; + Result.Length = Data.Size; + return Result; } internal bool IsSlash(char C) { return ((C == '/') || (C == '\\')); } @@ -1405,899 +1412,1002 @@ internal bool IsNumericExtended(char C) { return IsNumericDecimal(C) || (C == 'x internal bool IsAlpha(char C) { return( (('a' <= C) && (C <= 'z')) || (('A' <= C) && (C <= 'Z')) || C == '_'); } internal bool IsAlphaNumeric(char C) { return((('a' <= C) && (C <= 'z')) || (('A' <= C) && (C <= 'Z')) || (('0' <= C) && (C <= '9')) || C == '_'); } internal bool IsOperator(char C) { - return ((C == '+') || (C == '-') || (C == '*') || (C == '/') || - (C == '=') || (C == '%') || (C == '<') || (C == '>')); + return ((C == '+') || (C == '-') || (C == '*') || (C == '/') || + (C == '=') || (C == '%') || (C == '<') || (C == '>')); } internal char ToUpper(char C) { - if ((C >= 'a') && (C <= 'z')) - { - C -= 'a' - 'A'; - } - return C; + if ((C >= 'a') && (C <= 'z')) + { + C -= 'a' - 'A'; + } + return C; } internal char ToLower(char C) { - if ((C >= 'A') && (C <= 'Z')) - { - C += 'a' - 'A'; - } - return C; + if ((C >= 'A') && (C <= 'Z')) + { + C += 'a' - 'A'; + } + return C; } internal bool CharsEqualCaseInsensitive(char A, char B) { return ToLower(A) == ToLower(B); } internal u64 CharArrayLength (char* CS) { - char* At = CS; - while (*At) { At++; } - return (u64)(At - CS); + char* At = CS; + while (*At) { At++; } + return (u64)(At - CS); } internal bool IsNullTerminated(gs_const_string String) { - bool Result = false; - if (String.Str) - { - Result = (String.Str[String.Length] == 0); - } - return Result; + bool Result = false; + if (String.Str) + { + Result = (String.Str[String.Length] == 0); + } + return Result; } internal bool IsNullTerminated(gs_string String) { - return IsNullTerminated(String.ConstString); + return IsNullTerminated(String.ConstString); } internal char GetChar(gs_const_string String, u64 I) { - char Result = 0; - if (I < String.Length) - { - Result = String.Str[I]; - } - return Result; + char Result = 0; + if (I < String.Length) + { + Result = String.Str[I]; + } + return Result; } internal char GetChar(gs_string String, u64 I) { - char Result = 0; - if (I < String.Length) - { - Result = String.Str[I]; - } - return Result; + char Result = 0; + if (I < String.Length) + { + Result = String.Str[I]; + } + return Result; } internal gs_const_string GetStringPrefix(gs_const_string String, u64 Size) { - gs_const_string Result = String; - Result.Length = Min(Size, String.Length); - return Result; + gs_const_string Result = String; + Result.Length = Min(Size, String.Length); + return Result; } internal gs_const_string GetStringPostfix(gs_const_string String, u64 Size) { - gs_const_string Result = String; - u64 PostfixSize = Min(Size, String.Length); - Result.Str += (Result.Length - PostfixSize); - Result.Length = PostfixSize; - return Result; + gs_const_string Result = String; + u64 PostfixSize = Min(Size, String.Length); + Result.Str += (Result.Length - PostfixSize); + Result.Length = PostfixSize; + return Result; } internal gs_const_string GetStringAfter(gs_const_string String, u64 Cut) { - gs_const_string Result = String; - u64 CutSize = Min(Cut, String.Length); - Result.Str += CutSize; - Result.Length -= CutSize; - return Result; + gs_const_string Result = String; + u64 CutSize = Min(Cut, String.Length); + Result.Str += CutSize; + Result.Length -= CutSize; + return Result; } internal gs_string GetStringAfter(gs_string String, u64 Cut) { - gs_string Result = {0}; - Result.ConstString = GetStringAfter(String.ConstString, Cut); - Result.Size = String.Size - Cut; - return Result; + gs_string Result = {0}; + Result.ConstString = GetStringAfter(String.ConstString, Cut); + Result.Size = String.Size - Cut; + return Result; } internal gs_const_string GetStringBefore(gs_const_string String, u64 Cut) { - gs_const_string Result = String; - Result.Length = Min(Cut, String.Length); - return Result; + gs_const_string Result = String; + Result.Length = Min(Cut, String.Length); + return Result; } internal gs_const_string Substring(gs_const_string String, u64 First, u64 Last) { - gs_const_string Result = {0}; - Result.Str = String.Str + Min(First, String.Length); - Result.Length = Min(Last - First, String.Length); - return Result; + gs_const_string Result = {0}; + Result.Str = String.Str + Min(First, String.Length); + Result.Length = Min(Last - First, String.Length); + return Result; } -internal u64 +internal gs_const_string +Substring(gs_string String, u64 First, u64 Last) +{ + return Substring(String.ConstString, First, Last); +} + +internal s64 FindFirst(gs_const_string String, u64 StartIndex, char C) { - u64 Result = StartIndex; - for(; Result < String.Length && C != String.Str[Result]; Result++); - return Result; + s64 Result = -1; + for(u64 i = StartIndex; i < String.Length; i++) + { + if (String.Str[i] == C) { + Result = (s64)i; + break; + } + } + return Result; } -internal u64 +internal s64 FindFirst(gs_const_string String, char C) { - return FindFirst(String, 0, C); + return FindFirst(String, 0, C); +} +internal s64 +FindFirst(gs_string String, u64 StartIndex, char C) +{ + return FindFirst(String.ConstString, StartIndex, C); +} +internal s64 +FindFirst(gs_string String, char C) +{ + return FindFirst(String.ConstString, 0, C); } -internal u64 +internal s64 +FindLast(char* String, s64 StartIndex, char C) +{ + s64 Result = -1; + s64 i = 0; + while (String[i] != 0 && i < StartIndex) + { + i++; + } + while (String[i]) + { + if (String[i] == C) + { + Result = i; + } + i++; + } + return Result; +} +internal s64 FindLast(gs_const_string String, u64 StartIndex, char C) { - s64 Result = StartIndex; - for(; Result >= 0 && C != String.Str[Result]; Result--); - return (u64)Result; + s64 Result = -1; + for(s64 i= StartIndex; i >= 0; i--) + { + if (String.Str[i] == C) { + Result = i; + break; + } + } + return (u64)Result; } - -internal u64 +internal s64 FindLast(gs_const_string String, char C) { - return FindLast(String, String.Length - 1, C); + return FindLast(String, String.Length - 1, C); +} +internal s64 +FindLast(gs_string String, u64 StartIndex, char C) +{ + return FindLast(String.ConstString, StartIndex, C); +} +internal s64 +FindLast(gs_string String, char C) +{ + return FindLast(String.ConstString, String.Length - 1, C); } -internal u64 +internal s64 FindFirstFromSet(gs_const_string String, char* SetArray) { - gs_const_string Set = ConstString(SetArray); - u64 Result = String.Length - 1; - for(u64 At = 0; At < String.Length; At++) + gs_const_string Set = ConstString(SetArray); + s64 Result = -1; + + s64 CurrMin = String.Length; + for (u64 SetAt = 0; SetAt < Set.Length; SetAt++) + { + s64 Index = FindFirst(String, Set.Str[SetAt]); + if (Index >= 0 && Index < CurrMin) { - char CharAt = String.Str[At]; - for (u64 SetAt = 0; SetAt < Set.Length; SetAt++) - { - if (CharAt == Set.Str[SetAt]) - { - Result = At; - // NOTE(Peter): The alternative to this goto is a break in the inner loop - // followed by an if check in the outer loop, that must be evaluated - // every character you check. This is more efficient - goto find_last_from_set_complete; - } - } + CurrMin = Index; } - find_last_from_set_complete: - return Result; + } + + if (CurrMin < (s64)String.Length) + { + Result = CurrMin; + } + + return Result; } internal s64 FindLastFromSet(gs_const_string String, char* SetArray) { - gs_const_string Set = ConstString(SetArray); - s64 Result = -1; - for(s64 At = String.Length - 1; At >= 0; At--) + gs_const_string Set = ConstString(SetArray); + s64 Result = -1; + for(s64 At = String.Length - 1; At >= 0; At--) + { + char CharAt = String.Str[At]; + for (u64 SetAt = 0; SetAt < Set.Length; SetAt++) { - char CharAt = String.Str[At]; - for (u64 SetAt = 0; SetAt < Set.Length; SetAt++) - { - if (CharAt == Set.Str[SetAt]) - { - Result = (u64)At; - // NOTE(Peter): The alternative to this goto is a break in the inner loop - // followed by an if check in the outer loop, that must be evaluated - // every character you check. This is more efficient - goto find_first_from_set_complete; - } - } + if (CharAt == Set.Str[SetAt]) + { + Result = (u64)At; + // NOTE(Peter): The alternative to this goto is a break in the inner loop + // followed by an if check in the outer loop, that must be evaluated + // every character you check. This is more efficient + goto find_first_from_set_complete; + } } - find_first_from_set_complete: - return Result; + } + find_first_from_set_complete: + return Result; } internal bool StringContains(gs_const_string Str, char C) { - bool Result = false; - for (u32 i = 0; i < Str.Length; i++) + bool Result = false; + for (u32 i = 0; i < Str.Length; i++) + { + if (Str.Str[i] == C) { - if (Str.Str[i] == C) - { - Result = true; - break; - } + Result = true; + break; } - return Result; + } + return Result; } internal bool StringsEqualUpToLength(gs_const_string A, gs_const_string B, u64 Length) { - bool Result = false; - if (A.Length >= Length && B.Length >= Length) + bool Result = false; + if (A.Length >= Length && B.Length >= Length) + { + Result = true; + Length = Min(Length, A.Length); + for (u64 i = 0; i < Length; i++) { - Result = true; - Length = Min(Length, A.Length); - for (u64 i = 0; i < Length; i++) - { - if (A.Str[i] != B.Str[i]) - { - Result = false; - break; - } - } + if (A.Str[i] != B.Str[i]) + { + Result = false; + break; + } } - return Result; + } + return Result; } internal bool StringsEqual(gs_const_string A, gs_const_string B) { - bool Result = false; - if (A.Length == B.Length) - { - Result = StringsEqualUpToLength(A, B, A.Length); - } - return Result; + bool Result = false; + if (A.Length == B.Length) + { + Result = StringsEqualUpToLength(A, B, A.Length); + } + return Result; } internal bool StringEqualsCharArray(gs_const_string A, char* B, u64 Length) { - gs_const_string BStr = ConstString(B, Length); - return StringsEqual(A, BStr); + gs_const_string BStr = ConstString(B, Length); + return StringsEqual(A, BStr); +} +internal bool +StringEqualsCharArray(gs_const_string A, char* B) +{ + u64 Length = CStringLength(B); + return StringEqualsCharArray(A, B, Length); } internal bool StringsEqualUpToLength(gs_string A, gs_string B, u64 Length) { - return StringsEqualUpToLength(A.ConstString, B.ConstString, Length); + return StringsEqualUpToLength(A.ConstString, B.ConstString, Length); } internal bool StringsEqual(gs_string A, gs_string B) { - return StringsEqual(A.ConstString, B.ConstString); + return StringsEqual(A.ConstString, B.ConstString); } internal bool StringEqualsCharArray(gs_string A, char* B, u64 Length) { - gs_string BStr = MakeString(B, Length); - return StringsEqual(A, BStr); + return StringEqualsCharArray(A.ConstString, B, Length); +} +internal bool +StringEqualsCharArray(gs_string A, char* B) +{ + return StringEqualsCharArray(A.ConstString, B); } internal u64 StringSizeLeft(gs_string String) { - u64 Result = String.Size - String.Length; - return Result; + u64 Result = String.Size - String.Length; + return Result; } internal void ReverseStringInPlace(gs_string* String) { - char* Start = String->Str; - char* End = String->Str + String->Length; - while (Start < End) - { - End--; - char Temp = End[0]; - End[0] = Start[0]; - Start[0] = Temp; - Start++; - } + char* Start = String->Str; + char* End = String->Str + String->Length; + while (Start < End) + { + End--; + char Temp = End[0]; + End[0] = Start[0]; + Start[0] = Temp; + Start++; + } } internal gs_const_string GetCharSetForBase(u64 Base) { - gs_const_string Result = {0}; - switch(Base) - { - case 8: { Result = Base8Chars; }break; - case 10: { Result = Base10Chars; }break; - case 16: { Result = Base16Chars; }break; - InvalidDefaultCase; - } - return Result; + gs_const_string Result = {0}; + switch(Base) + { + case 8: { Result = Base8Chars; }break; + case 10: { Result = Base10Chars; }break; + case 16: { Result = Base16Chars; }break; + InvalidDefaultCase; + } + return Result; } internal u64 CharToUInt(char C, gs_const_string CharSet) { - return (u64)FindFirst(CharSet, C); + return (u64)FindFirst(CharSet, C); } internal u64 CharToUInt(char C) { - return (u64)CharToUInt(C, Base10Chars); + return (u64)CharToUInt(C, Base10Chars); } internal u64 CharToUInt(char C, u64 Base) { - return CharToUInt(C, GetCharSetForBase(Base)); + return CharToUInt(C, GetCharSetForBase(Base)); } struct parse_uint_result { - b8 Success; - u64 Value; - u32 ParsedLength; + b8 Success; + u64 Value; + u32 ParsedLength; }; internal parse_uint_result ValidateAndParseUInt(gs_const_string String, u64 Base = 10) { - parse_uint_result Result = {0}; - - gs_const_string CharSet = GetCharSetForBase(Base); - - bool StringIsValid = true; - for (u32 i = 0; i < String.Length; i++) + parse_uint_result Result = {0}; + + gs_const_string CharSet = GetCharSetForBase(Base); + + bool StringIsValid = true; + for (u32 i = 0; i < String.Length; i++) + { + if (!StringContains(CharSet, String.Str[i])) { - if (!StringContains(CharSet, String.Str[i])) - { - StringIsValid = false; - break; - } + StringIsValid = false; + break; + } + } + + if (StringIsValid) + { + u64 Acc = 0; + u64 i = 0; + for (; i < String.Length; i++) + { + u64 CharIndex = FindFirst(CharSet, String.Str[i]); + if (CharIndex < CharSet.Length) + { + Acc = CharToUInt(String.Str[i], CharSet) + (Acc * Base); + } + else + { + break; + } } - if (StringIsValid) - { - u64 Acc = 0; - u64 i = 0; - for (; i < String.Length; i++) - { - u64 CharIndex = FindFirst(CharSet, String.Str[i]); - if (CharIndex < CharSet.Length) - { - Acc = CharToUInt(String.Str[i], CharSet) + (Acc * Base); - } - else - { - break; - } - } - - Result.Success = true; - Result.Value = Acc; - Result.ParsedLength = i; - } - - return Result; + Result.Success = true; + Result.Value = Acc; + Result.ParsedLength = i; + } + + return Result; } internal u64 ParseUInt(gs_const_string String, u64 Base = 10, u64* ParsedLength = 0) { - parse_uint_result ParseResult = ValidateAndParseUInt(String, Base); - Assert(ParseResult.Success); - if (ParsedLength) - { - *ParsedLength = ParseResult.ParsedLength; - } - return ParseResult.Value; + parse_uint_result ParseResult = ValidateAndParseUInt(String, Base); + Assert(ParseResult.Success); + if (ParsedLength) + { + *ParsedLength = ParseResult.ParsedLength; + } + return ParseResult.Value; } internal u64 ParseUInt(u64 Length, char* String, u64 Base = 10, u64* ParsedLength = 0) { - return ParseUInt(ConstString(String, Length), Base, ParsedLength); + return ParseUInt(ConstString(String, Length), Base, ParsedLength); } internal u64 ParseUInt(char* String, u64 Base = 10, u64* ParsedLength = 0) { - return ParseUInt(LitString(String), Base, ParsedLength); + return ParseUInt(LitString(String), Base, ParsedLength); } internal s64 ParseInt(gs_const_string String, u64 Base = 10, u64* ParsedLength = 0) { - s64 Result = 0; - u64 TempParsedLength = 0; - if (String.Str[0] == '-') - { - Result = -1 * (s64)ParseUInt(GetStringAfter(String, 1), Base, &TempParsedLength); - TempParsedLength += 1; - } - else - { - Result = (s64)ParseUInt(String, Base, &TempParsedLength); - } - if (ParsedLength != 0) - { - *ParsedLength = TempParsedLength; - } - return Result; + s64 Result = 0; + u64 TempParsedLength = 0; + if (String.Str[0] == '-') + { + Result = -1 * (s64)ParseUInt(GetStringAfter(String, 1), Base, &TempParsedLength); + TempParsedLength += 1; + } + else + { + Result = (s64)ParseUInt(String, Base, &TempParsedLength); + } + if (ParsedLength != 0) + { + *ParsedLength = TempParsedLength; + } + return Result; } internal s64 ParseInt(char* String, u64 Base = 10, u64* ParsedLength = 0) { - return ParseInt(LitString(String), Base, ParsedLength); + return ParseInt(LitString(String), Base, ParsedLength); } struct parse_float_result { - b8 Success; - r64 Value; - u64 ParsedLength; + b8 Success; + r64 Value; + u64 ParsedLength; }; internal parse_float_result ValidateAndParseFloat(gs_const_string String) { - parse_float_result Result = {0}; - Result.Success = false; - - // Validate - bool StringIsValid = true; - for (u64 i = 0; i < String.Length; i++) + parse_float_result Result = {0}; + Result.Success = false; + + // Validate + bool StringIsValid = true; + for (u64 i = 0; i < String.Length; i++) + { + if (!IsNumericDecimal(String.Str[i]) && String.Str[i] != '-') { - if (!IsNumericDecimal(String.Str[i]) && String.Str[i] != '-') - { - StringIsValid = false; - break; - } + StringIsValid = false; + break; + } + } + + if (StringIsValid) + { + s64 DecimalIndex = FindFirst(String, '.'); + u64 TempParsedLength = 0; + u64 PlacesAfterPoint = 0; + + gs_const_string IntegerString = GetStringBefore(String, DecimalIndex); + gs_const_string DecimalString = {}; + if (DecimalIndex >= 0) + { + DecimalString = GetStringAfter(String, DecimalIndex + 1); } - if (StringIsValid) + r32 Polarity = 1; + if (IntegerString.Str[0] == '-') { - u64 DecimalIndex = FindFirst(String, '.'); - u64 TempParsedLength = 0; - u64 PlacesAfterPoint = 0; - - gs_const_string IntegerString = GetStringBefore(String, DecimalIndex); - gs_const_string DecimalString = GetStringAfter(String, DecimalIndex + 1); - - r32 Polarity = 1; - if (IntegerString.Str[0] == '-') - { - IntegerString = GetStringAfter(IntegerString, 1); - Polarity = -1; - } - - Result.Value = (r64)ParseInt(IntegerString, 10, &TempParsedLength); - - if (TempParsedLength == IntegerString.Length) - { - r64 AfterPoint = (r64)ParseUInt(DecimalString, 10, &PlacesAfterPoint); - r64 Decimal = (AfterPoint / PowR64(10, PlacesAfterPoint)); - Result.Value = Result.Value + Decimal; - Result.Value *= Polarity; - } - - Result.ParsedLength = TempParsedLength + PlacesAfterPoint; - if (DecimalIndex < String.Length) { Result.ParsedLength += 1; } - - Result.Success = true; + IntegerString = GetStringAfter(IntegerString, 1); + Polarity = -1; } - return Result; + Result.Value = (r64)ParseInt(IntegerString, 10, &TempParsedLength); + + if (TempParsedLength == IntegerString.Length) + { + r64 AfterPoint = (r64)ParseUInt(DecimalString, 10, &PlacesAfterPoint); + r64 Decimal = (AfterPoint / PowR64(10, PlacesAfterPoint)); + Result.Value = Result.Value + Decimal; + Result.Value *= Polarity; + } + + Result.ParsedLength = TempParsedLength + PlacesAfterPoint; + if (DecimalIndex < (s64)String.Length) { Result.ParsedLength += 1; } + + Result.Success = true; + } + + return Result; } internal r64 ParseFloat(gs_const_string String, u64* ParsedLength = 0) { - parse_float_result Result = ValidateAndParseFloat(String); - Assert(Result.Success); - if (ParsedLength != 0) - { - *ParsedLength = Result.ParsedLength; - } - return Result.Value; + parse_float_result Result = ValidateAndParseFloat(String); + Assert(Result.Success); + if (ParsedLength != 0) + { + *ParsedLength = Result.ParsedLength; + } + return Result.Value; } internal r64 ParseFloat(char* String, u64* ParsedLength = 0) { - return ParseFloat(LitString(String), ParsedLength); + return ParseFloat(LitString(String), ParsedLength); } internal u64 AppendString(gs_string* Base, gs_const_string Appendix) { - u64 StartIndex = Base->Length; - u64 LengthAvailable = Base->Size - Base->Length; - u64 Written = 0; - for (; Written < Min(LengthAvailable, Appendix.Length); Written++) - { - Base->Str[StartIndex + Written] = Appendix.Str[Written]; - } - Base->Length += Written; - Assert(Base->Length <= Base->Size); - return Written; + u64 StartIndex = Base->Length; + u64 LengthAvailable = Base->Size - Base->Length; + u64 Written = 0; + for (; Written < Min(LengthAvailable, Appendix.Length); Written++) + { + Base->Str[StartIndex + Written] = Appendix.Str[Written]; + } + Base->Length += Written; + Assert(Base->Length <= Base->Size); + return Written; } internal u64 AppendString(gs_string* Base, gs_string Appendix) { - return AppendString(Base, Appendix.ConstString); + return AppendString(Base, Appendix.ConstString); } + +internal void +InsertAt(gs_string* Str, u64 Index, char C) +{ + if (Str->Length > Index) + { + for (u64 i = Str->Length; i > Index; i--) + { + Str->Str[i] = Str->Str[i - 1]; + } + } + + if (Index < Str->Size) + { + Str->Str[Index] = C; + Str->Length += 1; + Assert(Str->Length < Str->Size); + } +} + +internal void +RemoveAt(gs_string* Str, u64 Index) +{ + if (Str->Length > 0 && Index < Str->Length) + { + for (u64 i = Index; i < Str->Length - 1; i++) + { + Str->Str[i] = Str->Str[i + 1]; + } + Str->Length -= 1; + } +} + internal void NullTerminate(gs_string* String) { - if (String->Length < String->Size) - { - String->Str[String->Length] = 0; - } - else - { - String->Str[String->Length - 1] = 0; - } + if (String->Length < String->Size) + { + String->Str[String->Length] = 0; + } + else + { + String->Str[String->Length - 1] = 0; + } } internal void OutChar(gs_string* String, char C) { - if (String->Length < String->Size) - { - String->Str[String->Length++] = C; - } + if (String->Length < String->Size) + { + String->Str[String->Length++] = C; + } } internal void U64ToASCII(gs_string* String, u64 Value, u64 Base, gs_const_string Digits) { - u64 ValueRemaining = Value; - u64 At = 0; - do { - u64 Index = ValueRemaining % Base; - char Digit = Digits.Str[Index]; - OutChar(String, Digit); - ValueRemaining /= Base; - }while(ValueRemaining); - char* End = String->Str + String->Length; - ReverseStringInPlace(String); + u64 ValueRemaining = Value; + u64 At = 0; + do { + u64 Index = ValueRemaining % Base; + char Digit = Digits.Str[Index]; + OutChar(String, Digit); + ValueRemaining /= Base; + }while(ValueRemaining); + char* End = String->Str + String->Length; + ReverseStringInPlace(String); } internal void U64ToASCII(gs_string* String, u64 Value, u64 Base) { - U64ToASCII(String, Value, Base, GetCharSetForBase(Base)); + U64ToASCII(String, Value, Base, GetCharSetForBase(Base)); } internal void R64ToASCII(gs_string* String, r64 Value, u64 Precision) { - if (Value < 0) + if (Value < 0) + { + OutChar(String, '-'); + Value = Abs(Value); + } + u64 IntegerPart = (u64)Value; + // NOTE(Peter): If we don't use the inner string, when U64ToASCII reverses the characters + // it'll put the negative sign at the end. + gs_string IntegerString = GetStringAfter(*String, String->Length); + U64ToASCII(&IntegerString, IntegerPart, 10); + String->Length += IntegerString.Length; + Value -= IntegerPart; + if (Value > 0) + { + OutChar(String, '.'); + for (u64 i = 0; i < Precision; i++) { - OutChar(String, '-'); - Value = Abs(Value); - } - u64 IntegerPart = (u64)Value; - // NOTE(Peter): If we don't use the inner string, when U64ToASCII reverses the characters - // it'll put the negative sign at the end. - gs_string IntegerString = GetStringAfter(*String, String->Length); - U64ToASCII(&IntegerString, IntegerPart, 10); - String->Length += IntegerString.Length; - Value -= IntegerPart; - if (Value > 0) - { - OutChar(String, '.'); - for (u64 i = 0; i < Precision; i++) - { - Value *= 10.0f; - u64 DecimalPlace = (u64)Value; - Value -= DecimalPlace; - OutChar(String, Base10Chars.Str[DecimalPlace]); - } + Value *= 10.0f; + u64 DecimalPlace = (u64)Value; + Value -= DecimalPlace; + OutChar(String, Base10Chars.Str[DecimalPlace]); } + } } internal s64 ReadVarArgsSignedInteger (s32 Width, va_list* Args) { - s64 Result = 0; - switch (Width) - { - // NOTE(Peter): For Width lower than 4 bytes, the C++ spec specifies - // that it will get promoted to an int anyways - case 1: { Result = (s64)va_arg(*Args, s32); } break; - case 2: { Result = (s64)va_arg(*Args, s32); } break; - case 4: { Result = (s64)va_arg(*Args, s32); } break; - case 8: { Result = (s64)va_arg(*Args, s64); } break; - InvalidDefaultCase; - } - return Result; + s64 Result = 0; + switch (Width) + { + // NOTE(Peter): For Width lower than 4 bytes, the C++ spec specifies + // that it will get promoted to an int anyways + case 1: { Result = (s64)va_arg(*Args, s32); } break; + case 2: { Result = (s64)va_arg(*Args, s32); } break; + case 4: { Result = (s64)va_arg(*Args, s32); } break; + case 8: { Result = (s64)va_arg(*Args, s64); } break; + InvalidDefaultCase; + } + return Result; } internal r64 ReadVarArgsUnsignedInteger (s32 Width, va_list* Args) { - u64 Result = 0; - switch (Width) - { - // NOTE(Peter): For Width lower than 4 bytes, the C++ spec specifies - // that it will get promoted to an int anyways - case 1: { Result = (u64)va_arg(*Args, u32); } break; - case 2: { Result = (u64)va_arg(*Args, u32); } break; - case 4: { Result = (u64)va_arg(*Args, u32); } break; - case 8: { Result = (u64)va_arg(*Args, u64); } break; - InvalidDefaultCase; - } - return Result; + u64 Result = 0; + switch (Width) + { + // NOTE(Peter): For Width lower than 4 bytes, the C++ spec specifies + // that it will get promoted to an int anyways + case 1: { Result = (u64)va_arg(*Args, u32); } break; + case 2: { Result = (u64)va_arg(*Args, u32); } break; + case 4: { Result = (u64)va_arg(*Args, u32); } break; + case 8: { Result = (u64)va_arg(*Args, u64); } break; + InvalidDefaultCase; + } + return Result; } internal r64 ReadVarArgsFloat (s32 Width, va_list* Args) { - r64 Result = 0; - switch (Width) - { - case 4: { Result = (r64)va_arg(*Args, r64); } break; - case 8: { Result = (r64)va_arg(*Args, r64); } break; - InvalidDefaultCase; - } - return Result; + r64 Result = 0; + switch (Width) + { + case 4: { Result = (r64)va_arg(*Args, r64); } break; + case 8: { Result = (r64)va_arg(*Args, r64); } break; + InvalidDefaultCase; + } + return Result; } internal s32 PrintFArgsList (gs_string* String, char* Format, va_list Args) { - char* FormatAt = Format; - while (*FormatAt) + char* FormatAt = Format; + while (*FormatAt) + { + if (FormatAt[0] != '%') { - if (FormatAt[0] != '%') - { - if (FormatAt[0] == '\\') - { - OutChar(String, *FormatAt++); - } - else - { - OutChar(String, *FormatAt++); - } - } - else if (FormatAt[0] == '%' && FormatAt[1] == '%') // Print the % symbol - { - OutChar(String, '%'); - FormatAt += 2; - } - else - { - FormatAt++; - - // Flags - if (FormatAt[0] == '-') - { - FormatAt++; - } - else if (FormatAt[0] == '+') - { - FormatAt++; - } - else if (FormatAt[0] == ' ') - { - FormatAt++; - } - else if (FormatAt[0] == '#') - { - FormatAt++; - } - else if (FormatAt[0] == '0') - { - FormatAt++; - } - - // Width - b32 WidthSpecified = false; - s32 Width = 0; - - if (IsBase10(FormatAt[0])) - { - WidthSpecified = true; - u64 Parsed = 0; - AssertMessage("ParseInt assumes whole string is an integer"); - Width = (s32)ParseInt(FormatAt, 10, &Parsed); - FormatAt += Parsed; - } - else if (FormatAt[0] == '*') - { - WidthSpecified = true; - Width = va_arg(Args, s32); - Assert(Width >= 0); - FormatAt++; - } - - // Precision - b32 PrecisionSpecified = false; - s32 Precision = 0; - - if (FormatAt[0] == '.') - { - FormatAt++; - if (IsBase10(FormatAt[0])) - { - PrecisionSpecified = true; - - gs_const_string PrecisionStr = {}; - PrecisionStr.Str = FormatAt; - for (char* C = FormatAt; *FormatAt && IsBase10(*C); C++) - { - PrecisionStr.Length++; - } - u64 Parsed = 0; - Precision = (s32)ParseInt(PrecisionStr, 10, &Parsed); - FormatAt += Parsed; - } - else if (FormatAt[0] == '*') - { - PrecisionSpecified = true; - Precision = va_arg(Args, s32); - Assert(Precision >= 0); - FormatAt++; - } - } - - // Length - b32 LengthSpecified = false; - s32 Length = 4; - - if (FormatAt[0] == 'h' && FormatAt[1] == 'h') - { - LengthSpecified = true; - Length = 1; - FormatAt += 2; - } - else if (FormatAt[0] == 'h') - { - LengthSpecified = true; - Length = 2; - FormatAt++; - } - else if (FormatAt[0] == 'l' && FormatAt[1] == 'l') - { - LengthSpecified = true; - Length = 8; - FormatAt += 2; - } - else if (FormatAt[0] == 'l') - { - LengthSpecified = true; - Length = 4; - FormatAt++; - } - else if (FormatAt[0] == 'j') - { - LengthSpecified = true; - Length = 8; - FormatAt++; - } - else if (FormatAt[0] == 'z') - { - FormatAt++; - } - else if (FormatAt[0] == 't') - { - FormatAt++; - } - else if (FormatAt[0] == 'L') - { - FormatAt++; - } - - // Format Specifiers - gs_string StringRemaining = GetStringAfter(*String, String->Length); - Assert(StringRemaining.Length == 0); - if (FormatAt[0] == 'd' || FormatAt[0] == 'i') - { - s64 SignedInt = ReadVarArgsSignedInteger(Length, &Args); - if (SignedInt < 0) - { - OutChar(&StringRemaining, '-'); - SignedInt *= -1; - } - U64ToASCII(&StringRemaining, (u64)SignedInt, 10, Base10Chars); - } - else if (FormatAt[0] == 'u') - { - u64 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); - U64ToASCII(&StringRemaining, UnsignedInt, 10, Base10Chars); - } - else if (FormatAt[0] == 'o') - { - u32 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); - U64ToASCII(&StringRemaining, UnsignedInt, 8, Base8Chars); - } - else if (FormatAt[0] == 'x' || FormatAt[0] == 'X') - { - u32 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); - U64ToASCII(&StringRemaining, UnsignedInt, 16, Base16Chars); - } - else if (FormatAt[0] == 'f' || FormatAt[0] == 'F') - { - r64 Float = ReadVarArgsFloat(Length, &Args); - s32 AfterPoint = 6; - if (PrecisionSpecified) - { - AfterPoint = Precision; - } - R64ToASCII(&StringRemaining, Float, AfterPoint); - } - else if (FormatAt[0] == 'c') - { - char InsertChar = va_arg(Args, s32); - OutChar(&StringRemaining, InsertChar); - } - else if (FormatAt[0] == 's') - { - char* InsertString = va_arg(Args, char*); - - s32 InsertStringLength = CStringLength(InsertString); - if (PrecisionSpecified) - { - InsertStringLength = Min(InsertStringLength, Precision); - } - InsertStringLength = Min(StringSizeLeft(StringRemaining), InsertStringLength); - - for (s32 c = 0; c < InsertStringLength; c++) - { - OutChar(&StringRemaining, InsertString[c]); - } - } - else if (FormatAt[0] == 'S') - { - gs_const_string InsertString = va_arg(Args, gs_const_string); - - for (s32 c = 0; c < InsertString.Length; c++) - { - OutChar(&StringRemaining, InsertString.Str[c]); - } - } - else if (FormatAt[0] == 'p') - { - // TODO(Peter): Pointer Address - } - else - { - // NOTE(Peter): Non-specifier character found - InvalidCodePath; - } - - String->Length += StringRemaining.Length; - FormatAt++; - } + if (FormatAt[0] == '\\') + { + OutChar(String, *FormatAt++); + } + else + { + OutChar(String, *FormatAt++); + } } - - return String->Length; + else if (FormatAt[0] == '%' && FormatAt[1] == '%') // Print the % symbol + { + OutChar(String, '%'); + FormatAt += 2; + } + else + { + FormatAt++; + + // Flags + if (FormatAt[0] == '-') + { + FormatAt++; + } + else if (FormatAt[0] == '+') + { + FormatAt++; + } + else if (FormatAt[0] == ' ') + { + FormatAt++; + } + else if (FormatAt[0] == '#') + { + FormatAt++; + } + else if (FormatAt[0] == '0') + { + FormatAt++; + } + + // Width + b32 WidthSpecified = false; + s32 Width = 0; + + if (IsBase10(FormatAt[0])) + { + WidthSpecified = true; + u64 Parsed = 0; + AssertMessage("ParseInt assumes whole string is an integer"); + Width = (s32)ParseInt(FormatAt, 10, &Parsed); + FormatAt += Parsed; + } + else if (FormatAt[0] == '*') + { + WidthSpecified = true; + Width = va_arg(Args, s32); + Assert(Width >= 0); + FormatAt++; + } + + // Precision + b32 PrecisionSpecified = false; + s32 Precision = 0; + + if (FormatAt[0] == '.') + { + FormatAt++; + if (IsBase10(FormatAt[0])) + { + PrecisionSpecified = true; + + gs_const_string PrecisionStr = {}; + PrecisionStr.Str = FormatAt; + for (char* C = FormatAt; *FormatAt && IsBase10(*C); C++) + { + PrecisionStr.Length++; + } + u64 Parsed = 0; + Precision = (s32)ParseInt(PrecisionStr, 10, &Parsed); + FormatAt += Parsed; + } + else if (FormatAt[0] == '*') + { + PrecisionSpecified = true; + Precision = va_arg(Args, s32); + Assert(Precision >= 0); + FormatAt++; + } + } + + // Length + b32 LengthSpecified = false; + s32 Length = 4; + + if (FormatAt[0] == 'h' && FormatAt[1] == 'h') + { + LengthSpecified = true; + Length = 1; + FormatAt += 2; + } + else if (FormatAt[0] == 'h') + { + LengthSpecified = true; + Length = 2; + FormatAt++; + } + else if (FormatAt[0] == 'l' && FormatAt[1] == 'l') + { + LengthSpecified = true; + Length = 8; + FormatAt += 2; + } + else if (FormatAt[0] == 'l') + { + LengthSpecified = true; + Length = 4; + FormatAt++; + } + else if (FormatAt[0] == 'j') + { + LengthSpecified = true; + Length = 8; + FormatAt++; + } + else if (FormatAt[0] == 'z') + { + FormatAt++; + } + else if (FormatAt[0] == 't') + { + FormatAt++; + } + else if (FormatAt[0] == 'L') + { + FormatAt++; + } + + // Format Specifiers + gs_string StringRemaining = GetStringAfter(*String, String->Length); + Assert(StringRemaining.Length == 0); + if (FormatAt[0] == 'd' || FormatAt[0] == 'i') + { + s64 SignedInt = ReadVarArgsSignedInteger(Length, &Args); + if (SignedInt < 0) + { + OutChar(&StringRemaining, '-'); + SignedInt *= -1; + } + U64ToASCII(&StringRemaining, (u64)SignedInt, 10, Base10Chars); + } + else if (FormatAt[0] == 'u') + { + u64 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); + U64ToASCII(&StringRemaining, UnsignedInt, 10, Base10Chars); + } + else if (FormatAt[0] == 'o') + { + u32 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); + U64ToASCII(&StringRemaining, UnsignedInt, 8, Base8Chars); + } + else if (FormatAt[0] == 'x' || FormatAt[0] == 'X') + { + u32 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); + U64ToASCII(&StringRemaining, UnsignedInt, 16, Base16Chars); + } + else if (FormatAt[0] == 'f' || FormatAt[0] == 'F') + { + r64 Float = ReadVarArgsFloat(Length, &Args); + s32 AfterPoint = 6; + if (PrecisionSpecified) + { + AfterPoint = Precision; + } + R64ToASCII(&StringRemaining, Float, AfterPoint); + } + else if (FormatAt[0] == 'c') + { + char InsertChar = va_arg(Args, s32); + OutChar(&StringRemaining, InsertChar); + } + else if (FormatAt[0] == 's') + { + char* InsertString = va_arg(Args, char*); + + s32 InsertStringLength = CStringLength(InsertString); + if (PrecisionSpecified) + { + InsertStringLength = Min(InsertStringLength, Precision); + } + InsertStringLength = Min(StringSizeLeft(StringRemaining), InsertStringLength); + + for (s32 c = 0; c < InsertStringLength; c++) + { + OutChar(&StringRemaining, InsertString[c]); + } + } + else if (FormatAt[0] == 'S') + { + gs_const_string InsertString = va_arg(Args, gs_const_string); + + for (s32 c = 0; c < InsertString.Length; c++) + { + OutChar(&StringRemaining, InsertString.Str[c]); + } + } + else if (FormatAt[0] == 'p') + { + // TODO(Peter): Pointer Address + } + else + { + // NOTE(Peter): Non-specifier character found + InvalidCodePath; + } + + String->Length += StringRemaining.Length; + FormatAt++; + } + } + + return String->Length; } internal void PrintF (gs_string* String, char* Format, ...) { - va_list Args; - va_start(Args, Format); - String->Length = 0; - PrintFArgsList(String, Format, Args); - va_end(Args); + va_list Args; + va_start(Args, Format); + String->Length = 0; + PrintFArgsList(String, Format, Args); + va_end(Args); } internal void PrintF (gs_string* String, const char* Format, ...) { - // NOTE(Peter): This variant is here for clang/gcc - C++ spec doesn't allow - // implicit conversion from a const char* (a static c string) to char*, so this - // version of the function just provides the conversion so the compiler will be quiet - // without removing the other implementation, which is more useful - va_list Args; - va_start(Args, Format); - String->Length = 0; - PrintFArgsList(String, (char*)Format, Args); - va_end(Args); + // NOTE(Peter): This variant is here for clang/gcc - C++ spec doesn't allow + // implicit conversion from a const char* (a static c string) to char*, so this + // version of the function just provides the conversion so the compiler will be quiet + // without removing the other implementation, which is more useful + va_list Args; + va_start(Args, Format); + String->Length = 0; + PrintFArgsList(String, (char*)Format, Args); + va_end(Args); } internal void AppendPrintF (gs_string* String, char* Format, ...) { - va_list Args; - va_start(Args, Format); - PrintFArgsList(String, Format, Args); - va_end(Args); + va_list Args; + va_start(Args, Format); + PrintFArgsList(String, Format, Args); + va_end(Args); } internal void AppendPrintF (gs_string* String, const char* Format, ...) { - // NOTE(Peter): This variant is here for clang/gcc - C++ spec doesn't allow - // implicit conversion from a const char* (a static c string) to char*, so this - // version of the function just provides the conversion so the compiler will be quiet - // without removing the other implementation, which is more useful - va_list Args; - va_start(Args, Format); - PrintFArgsList(String, (char*)Format, Args); - va_end(Args); + // NOTE(Peter): This variant is here for clang/gcc - C++ spec doesn't allow + // implicit conversion from a const char* (a static c string) to char*, so this + // version of the function just provides the conversion so the compiler will be quiet + // without removing the other implementation, which is more useful + va_list Args; + va_start(Args, Format); + PrintFArgsList(String, (char*)Format, Args); + va_end(Args); } /////////////////////////// @@ -2307,356 +2417,44 @@ AppendPrintF (gs_string* String, const char* Format, ...) internal gs_data CreateData(u8* Memory, u64 Size) { - gs_data Result = {Memory, Size}; - return Result; + gs_data Result = {Memory, Size}; + return Result; } internal bool DataIsNonEmpty(gs_data Data) { - return ((Data.Size > 0) && (Data.Memory != 0)); + return ((Data.Size > 0) && (Data.Memory != 0)); } -internal void* AllocatorAlloc_NoOp(u64 Size, u64* SizeResult) { - *SizeResult = 0; - return 0; -} -internal void AllocatorFree_NoOp(void* Base, u64 Size) { return; } - -internal gs_allocator -CreateAllocator_(allocator_allocate* Alloc, allocator_free* Free) -{ - if (Alloc == 0) - { - Alloc = AllocatorAlloc_NoOp; - } - if (Free == 0) - { - Free = AllocatorFree_NoOp; - } - gs_allocator Result = {0}; - Result.Alloc = Alloc; - Result.Free = Free; - return Result; -} -#define CreateAllocator(a, f) CreateAllocator_((allocator_allocate*)(a), (allocator_free*)(f)) - -internal gs_data -AllocatorAlloc_(gs_allocator Allocator, u64 Size, char* Location) -{ - // TODO(Peter): Memory Profiling with Location - u64 SizeResult = 0; - void* Memory = Allocator.Alloc(Size, &SizeResult); - return CreateData((u8*)Memory, SizeResult); -} -internal void -AllocatorFree_(gs_allocator Allocator, void* Base, u64 Size, char* Location) -{ - // TODO(Peter): Memory Profiling with Location - if (Base != 0 && Size != 0) - { - Allocator.Free(Base, Size); - } -} - -#define AllocatorAlloc(alloc,size) AllocatorAlloc_((alloc), (size), FileNameAndLineNumberString) -#define AllocatorAllocStruct(alloc, type) (type*)(AllocatorAlloc((alloc), sizeof(type)).Memory) -#define AllocatorAllocArray(alloc, type, count) (type*)(AllocatorAlloc((alloc), sizeof(type) * (count)).Memory) -#define AllocatorAllocString(alloc, size) gs_string{ AllocatorAllocArray((alloc), char, (size)), 0, (size) } -#define AllocatorFree(alloc,base,size) AllocatorFree_((alloc), (base), (size), FileNameAndLineNumberString) -#define AllocatorFreeArray(alloc,base,type,count) AllocatorFree_((alloc), (base), sizeof(type) * count, FileNameAndLineNumberString) -internal gs_memory_cursor -CreateMemoryCursor(u8* Base, u64 Size) -{ - gs_memory_cursor Result = {0}; - Result.Data.Memory = Base; - Result.Data.Size = Size; - return Result; -}; -internal gs_memory_cursor -CreateMemoryCursor(gs_data Data) -{ - return CreateMemoryCursor(Data.Memory, Data.Size); -} -internal gs_memory_cursor -CreateMemoryCursor(gs_allocator Allocator, u64 Size) -{ - gs_data Data = AllocatorAlloc(Allocator, Size); - return CreateMemoryCursor(Data); -} -internal bool -CursorHasRoom(gs_memory_cursor Cursor, u64 Size) -{ - bool Result = ((Cursor.Position + Size) <= Cursor.Data.Size); - return Result; -} -internal gs_data -PushSizeOnCursor_(gs_memory_cursor* Cursor, u64 Size, char* Location) -{ - gs_data Result = {0}; - if (CursorHasRoom(*Cursor, Size)) - { - Result.Memory = Cursor->Data.Memory + Cursor->Position; - Result.Size = Size; - Cursor->Position += Size; - } - return Result; -} - -#define PushSizeOnCursor(cursor,size) PushSizeOnCursor_((cursor), (size), FileNameAndLineNumberString) -#define PushStructOnCursor(cursor,type) (type*)PushSizeOnCursor_((cursor), sizeof(type), FileNameAndLineNumberString).Memory -#define PushArrayOnCursor(cursor,type,count) (type*)PushSizeOnCursor_((cursor), sizeof(type) * (count), FileNameAndLineNumberString).Memory - -#define MemoryCursor_WriteValue(cursor, type, value) *PushStructOnCursor(cursor, type) = value -#define MemoryCursor_WriteBuffer(cursor, buf, len) CopyMemoryTo((u8*)(buf), PushArrayOnCursor((cursor), u8, (len)), (len)) - -internal void -PopSizeOnCursor(gs_memory_cursor* Cursor, u64 Size) -{ - if (Cursor->Position > Size) - { - Cursor->Position -= Size; - } - else - { - Cursor->Position = 0; - } -} -internal gs_data -AlignCursor(gs_memory_cursor* Cursor, u64 Alignment) -{ - u64 Position = RoundUpTo64(Cursor->Position, Alignment); - Position = Min(Position, Cursor->Data.Size); - u64 NewSize = Position - Cursor->Position; - return PushSizeOnCursor(Cursor, NewSize); -} -internal void -ClearCursor(gs_memory_cursor* Cursor) -{ - Cursor->Position = 0; -} - -internal void -FreeCursorListEntry(gs_allocator Allocator, gs_memory_cursor_list* CursorEntry) -{ - AllocatorFree(Allocator, CursorEntry, CursorEntry->Cursor.Data.Size + sizeof(gs_memory_cursor)); -} - -internal gs_memory_arena -CreateMemoryArena_(arena_type ArenaType, gs_allocator Allocator, u64 ChunkSize, u64 Alignment, gs_memory_arena* ParentArena) -{ - // we only want a parent arena if the type is Arena_SubArena - Assert(((ArenaType == Arena_BaseArena) && (ParentArena == 0)) || - ((ArenaType == Arena_SubArena) && (ParentArena != 0))); - - gs_memory_arena Arena = {}; - Arena.Type = ArenaType; - Arena.Allocator = Allocator; - Arena.Parent = ParentArena; - Arena.MemoryChunkSize = ChunkSize; - Arena.MemoryAlignment = Alignment; - return Arena; -} - -internal gs_memory_arena -CreateMemoryArena(gs_allocator Allocator, u64 ChunkSize = KB(32), u64 Alignment = Bytes(8)) -{ - return CreateMemoryArena_(Arena_BaseArena, Allocator, ChunkSize, Alignment, 0); -} -internal gs_memory_arena -CreateMemorySubArena(gs_memory_arena* Parent, u64 ChunkSize = KB(32), u64 Alignment = Bytes(8)) -{ - return CreateMemoryArena_(Arena_SubArena, Parent->Allocator, ChunkSize, Alignment, Parent); -} - -internal gs_data PushSize_(gs_memory_arena* Arena, u64 Size, char* Location); - -internal void -FreeCursorList(gs_memory_cursor_list* List, gs_allocator Allocator) -{ - gs_memory_cursor_list* CursorAt = List; - while (CursorAt != 0) - { - gs_memory_cursor_list* Prev = CursorAt->Prev; - FreeCursorListEntry(Allocator, CursorAt); - CursorAt = Prev; - } -} - -internal gs_memory_cursor_list* -MemoryArenaNewCursor(gs_memory_arena* Arena, u64 MinSize, char* Location) -{ - // Allocate enough spcae for the minimum size needed + sizeo for the cursor list - u64 AllocSize = Max(MinSize, Arena->MemoryChunkSize) + sizeof(gs_memory_cursor_list); - - gs_data Data = {0}; - switch (Arena->Type) - { - case Arena_SubArena: - { - Data = PushSize_(Arena->Parent, AllocSize, Location); - }break; - - case Arena_BaseArena: - { - Data = AllocatorAlloc_(Arena->Allocator, AllocSize, Location); - }break; - - InvalidDefaultCase; - } - - // Fit the memory cursor into the region allocated - Assert(MinSize + sizeof(gs_memory_cursor_list) <= Data.Size); - gs_memory_cursor_list* Result = (gs_memory_cursor_list*)Data.Memory; - u8* CursorMemoryStart = (u8*)(Result + 1); - u64 CursorMemorySize = Data.Size - sizeof(gs_memory_cursor_list); - Result->Cursor = CreateMemoryCursor(CursorMemoryStart, CursorMemorySize); - - Result->Prev = Arena->CursorList; - Result->Next = 0; - if (Arena->CursorList != 0) - { - Arena->CursorList->Next = Result; - } - Arena->CursorList = Result; - return Result; -} - -internal gs_data -PushSize_(gs_memory_arena* Arena, u64 Size, char* Location) -{ - gs_data Result = {0}; - if (Size > 0) - { - gs_memory_cursor_list* CursorEntry = Arena->CursorList; - if (CursorEntry == 0) - { - CursorEntry = MemoryArenaNewCursor(Arena, Size, Location); - } - if (!CursorHasRoom(CursorEntry->Cursor, Size)) - { - while ((CursorEntry != 0) && !CursorHasRoom(CursorEntry->Cursor, Size)) - { - CursorEntry = CursorEntry->Next; - } - if (CursorEntry == 0) - { - CursorEntry = MemoryArenaNewCursor(Arena, Size, Location); - } - } - Assert(CursorEntry != 0); - Result = PushSizeOnCursor_(&CursorEntry->Cursor, Size, Location); - Assert(Result.Memory != 0); - - gs_data Alignment = AlignCursor(&CursorEntry->Cursor, Arena->MemoryAlignment); - Result.Size += Alignment.Size; - } - - // TODO(Peter): @Cleanup @Efficiency - // There is a case I want to handle at some point: - // You have a Cursor that is empty, but the size you want to allocate is bigger - // than the cursor. So you create a new cursor, of the exact size you need, - // immediately fill it up, and push it onto the head of the cursor list. Now, - // the list looks like this: - // [root] [cursor] ... [empty cursor] [full cursor] [new, empty cursor] - // and you'll never use the memory in 'empty cursor' - // What I'd like to do is, when you fill up a cursor, it gets pushed back until - // the next cursor is more full - // NOTE: Thought on this tho - you don't want this behavior in a scratch arena - // where usage across frames could change drastically. This matters way more in - // a permanent storage (i think) - return Result; -} - -internal void -PopSize(gs_memory_arena* Arena, u64 Size) -{ - gs_allocator Allocator = Arena->Allocator; - gs_memory_cursor_list* CursorEntry = Arena->CursorList; - for (gs_memory_cursor_list* Prev = 0; - CursorEntry != 0 && Size != 0; - CursorEntry = Prev) - { - Prev = CursorEntry->Prev; - if (Size >= CursorEntry->Cursor.Position) - { - Size -= CursorEntry->Cursor.Position; - FreeCursorListEntry(Allocator, CursorEntry); - } - else - { - PopSizeOnCursor(&CursorEntry->Cursor, Size); - break; - } - } - Arena->CursorList = CursorEntry; -} -internal void -FreeMemoryArena(gs_memory_arena* Arena) -{ - gs_allocator Allocator = Arena->Allocator; - gs_memory_cursor_list* CursorEntry = Arena->CursorList; - for (gs_memory_cursor_list* Prev = 0; - CursorEntry != 0; - CursorEntry = Prev) - { - Prev = CursorEntry->Prev; - if (CursorEntry != 0) - { - FreeCursorListEntry(Allocator, CursorEntry); - } - } -} - -#define PushSizeToData(arena, size) PushSize_((arena), (size), FileNameAndLineNumberString) -#define PushSize(arena, size) PushSize_((arena), (size), FileNameAndLineNumberString).Memory -#define PushStruct(arena, type) (type*)(PushSize_((arena), sizeof(type), FileNameAndLineNumberString).Memory) -#define PushArray(arena, type, count) (type*)(PushSize_((arena), sizeof(type) * (count), FileNameAndLineNumberString).Memory) -#define PushString(arena, length) MakeString(PushArray((arena), char, (length)), 0, (length)); - +#define PushStringF(a,l,f,...) PushStringF_((a),(l),(f), DEBUG_LOC, __VA_ARGS__) internal gs_string -PushStringF(gs_memory_arena* Arena, u32 MaxLength, char* Format, ...) +PushStringF_(gs_memory_arena* Arena, u32 MaxLength, char* Format, gs_debug_loc Loc, ...) { - gs_string Result = PushString(Arena, MaxLength); - - va_list Args; - va_start(Args, Format); - PrintFArgsList(&Result, Format, Args); - va_end(Args); - - return Result; + gs_string Result = gs_string { + (char*)PushSize_(Arena, sizeof(char) * MaxLength, Loc).Memory, // Str + 0, // Length + MaxLength, // Size + }; + + va_list Args; + va_start(Args, Loc); + PrintFArgsList(&Result, Format, Args); + va_end(Args); + + return Result; } internal gs_string PushStringCopy(gs_memory_arena* Arena, gs_const_string String) { - gs_string Result = PushString(Arena, String.Length); - Result.Size = String.Length; - Result.Length = String.Length; - for (u32 i = 0; i < String.Length; i++) - { - Result.Str[i] = String.Str[i]; - } - return Result; -} - -internal void -ClearArena(gs_memory_arena* Arena) -{ - gs_memory_cursor_list* First = 0; - for (gs_memory_cursor_list* CursorEntry = Arena->CursorList; - CursorEntry != 0; - CursorEntry = CursorEntry->Prev) - { - First = CursorEntry; - CursorEntry->Cursor.Position = 0; - } - Arena->CursorList = First; -} - -internal void -FreeArena(gs_memory_arena* Arena) -{ - FreeCursorList(Arena->CursorList, Arena->Allocator); + gs_string Result = PushString(Arena, String.Length); + Result.Size = String.Length; + Result.Length = String.Length; + for (u32 i = 0; i < String.Length; i++) + { + Result.Str[i] = String.Str[i]; + } + return Result; } /////////////////////////// @@ -2666,162 +2464,29 @@ FreeArena(gs_memory_arena* Arena) inline void DebugPrint(debug_output Output, gs_const_string Message) { - Output.Print(Output, Message); + Output.Print(Output, Message); } inline void DebugPrint(debug_output Output, char* Message) { - gs_const_string String = ConstString(Message); - Output.Print(Output, String); + gs_const_string String = ConstString(Message); + Output.Print(Output, String); } internal void DebugPrintF(debug_output Output, char* Format, ...) { - gs_string Message = PushString(Output.Storage, 1024); - va_list Args; - va_start(Args, Format); - PrintFArgsList(&Message, Format, Args); - NullTerminate(&Message); - Output.Print(Output, Message.ConstString); -} - -/////////////////////////// -// -// Dynamic Array - -internal gs_dynarray -CreateDynarrayWithStorage(gs_memory_arena Storage, u32 ElementSize, u32 ElementsPerBuffer) -{ - gs_dynarray Result = {}; - Result.Arena = Storage; - Result.ElementSize = ElementSize; - Result.ElementsPerBuffer = ElementsPerBuffer; - Result.ElementCount = 0; - return Result; -} - -internal gs_dynarray -CreateDynarray_(gs_allocator Allocator, u32 ElementSize, u32 ElementsPerBuffer) -{ - gs_memory_arena Storage = CreateMemoryArena(Allocator, ElementSize * ElementsPerBuffer); - return CreateDynarrayWithStorage(Storage, ElementSize, ElementsPerBuffer); -}; - -internal gs_dynarray -CreateDynarray_(gs_memory_arena* Arena, u32 ElementSize, u32 ElementsPerBuffer) -{ - gs_memory_arena Storage = CreateMemorySubArena(Arena, ElementSize * ElementsPerBuffer); - return CreateDynarrayWithStorage(Storage, ElementSize, ElementsPerBuffer); -}; - -internal u64 -CalculateBufferSize(gs_dynarray Array) -{ - u64 Result = Array.ElementsPerBuffer * Array.ElementSize; - return Result; -} - -internal void -GrowDynarray(gs_dynarray* Array) -{ - gs_dynarray_buffer* OldBufferList = Array->Buffers; - u64 NewBuffersCount = Array->BuffersCount + 1; - gs_dynarray_buffer* NewBufferList = AllocatorAllocArray(Array->Arena.Allocator, gs_dynarray_buffer, NewBuffersCount); - if (OldBufferList) - { - CopyArray(OldBufferList, NewBufferList, gs_dynarray_buffer, Array->BuffersCount); - AllocatorFree(Array->Arena.Allocator, OldBufferList, sizeof(gs_dynarray_buffer) * Array->BuffersCount); - } - u64 BufferSize = CalculateBufferSize(*Array); - NewBufferList[Array->BuffersCount].Memory = PushSize(&Array->Arena, BufferSize); - Array->Buffers = NewBufferList; - Array->BuffersCount = NewBuffersCount; -} -internal u64 -DynarraySize(gs_dynarray Array) -{ - u64 Result = Array.BuffersCount * Array.ElementsPerBuffer; - return Result; -} -internal gs_dynarray_handle -IndexToHandle(gs_dynarray* Array, u64 Index) -{ - gs_dynarray_handle Result = {0}; - Result.BufferIndex = Index / Array->ElementsPerBuffer; - Result.IndexInBuffer = Index % Array->ElementsPerBuffer; - return Result; -} -internal u64 -HandleToIndex(gs_dynarray Array, gs_dynarray_handle Handle) -{ - u64 Result = Handle.IndexInBuffer + (Handle.BufferIndex * Array.ElementsPerBuffer); - return Result; -} -internal gs_dynarray_handle -TakeFreeElement(gs_dynarray* Array) -{ - gs_dynarray_handle Result = {0}; - if (Array->ElementCount >= DynarraySize(*Array)) - { - GrowDynarray(Array); - } - Assert(Array->ElementCount < DynarraySize(*Array)); - u64 ElementIndex = Array->ElementCount++; - Result = IndexToHandle(Array, ElementIndex); - return Result; -} -internal bool -HandleIsValid(gs_dynarray Array, gs_dynarray_handle Handle) -{ - bool Result = Handle.IndexInBuffer < Array.ElementsPerBuffer; - Result &= Handle.BufferIndex < Array.BuffersCount; - return Result; -} -internal bool -IndexIsValid(gs_dynarray Array, u64 Index) -{ - bool Result = Index < DynarraySize(Array); - return Result; -} -internal gs_data -GetElementInList_(gs_dynarray* Array, gs_dynarray_handle Handle, u64 SizeRequested) -{ - Assert(SizeRequested == Array->ElementSize); - Assert(HandleIsValid(*Array, Handle)); - gs_dynarray_buffer Buffer = Array->Buffers[Handle.BufferIndex]; - - gs_data Result = {0}; - Result.Memory = Buffer.Memory + (Handle.IndexInBuffer * Array->ElementSize); - Result.Size = SizeRequested; - - return Result; -} -internal gs_data -GetElementInList_(gs_dynarray* Array, u64 Index, u64 SizeRequested) -{ - gs_dynarray_handle Handle = IndexToHandle(Array, Index); - return GetElementInList_(Array, Handle, SizeRequested); -} -internal void -FreeDynarray(gs_dynarray* Array) -{ - gs_allocator Allocator = Array->Arena.Allocator; - u64 BufferSize = CalculateBufferSize(*Array); - for (u64 i = 0; i < Array->BuffersCount; i++) - { - AllocatorFree(Allocator, Array->Buffers[i].Memory, BufferSize); - } - AllocatorFree(Allocator, Array->Buffers, sizeof(gs_dynarray_buffer) * Array->BuffersCount); + gs_string Message = PushString(Output.Storage, 1024); + va_list Args; + va_start(Args, Format); + PrintFArgsList(&Message, Format, Args); + NullTerminate(&Message); + Output.Print(Output, Message.ConstString); } #define HandlesAreEqual(ha, hb) ((ha.IndexInBuffer == hb.IndexInBuffer) && (ha.BufferIndex == hb.BufferIndex)) -#define CreateDynarray(allocator,type,elePerBuf) CreateDynarray_((allocator), sizeof(type), (elePerBuf)) -#define GetElement_(array,type,size,indexOrHandle) (type*)GetElementInList_(array, indexOrHandle, size).Memory -#define GetElement(array,type,indexOrHandle) GetElement_(array, type, sizeof(type), indexOrHandle) - /////////////////////////// // // String Builder @@ -2829,19 +2494,19 @@ FreeDynarray(gs_dynarray* Array) internal void GrowStringBuilder_(gs_string_builder* StringBuilder) { - gs_string_builder_buffer* NewBuffer = PushStruct(StringBuilder->Arena, gs_string_builder_buffer); - NewBuffer->String = PushString(StringBuilder->Arena, StringBuilder->BufferSize); - SLLPushOrInit(StringBuilder->Root, StringBuilder->Head, NewBuffer); + gs_string_builder_buffer* NewBuffer = PushStruct(StringBuilder->Arena, gs_string_builder_buffer); + NewBuffer->String = PushString(StringBuilder->Arena, StringBuilder->BufferSize); + SLLPushOrInit(StringBuilder->Root, StringBuilder->Head, NewBuffer); } internal void OutChar(gs_string_builder* Builder, char C) { - if (Builder->Head == 0 || Builder->Head->String.Length >= Builder->Head->String.Size) - { - GrowStringBuilder_(Builder); - } - OutChar(&Builder->Head->String, C); + if (Builder->Head == 0 || Builder->Head->String.Length >= Builder->Head->String.Size) + { + GrowStringBuilder_(Builder); + } + OutChar(&Builder->Head->String, C); } #if 0 @@ -2850,264 +2515,264 @@ OutChar(gs_string_builder* Builder, char C) internal void StringBuilderWriteFArgsList(gs_string_builder* Builder, char* Format, va_list Args) { - char* FormatAt = Format; - while (*FormatAt) + char* FormatAt = Format; + while (*FormatAt) + { + if (FormatAt[0] != '%') { - if (FormatAt[0] != '%') + if (FormatAt[0] == '\\') + { + FormatAt++; + Assert(IsBase8(FormatAt[0]) || // Octal Escape Sequences - \0 is in this set + FormatAt[0] == '\'' || + FormatAt[0] == '\"' || + FormatAt[0] == '\?' || + FormatAt[0] == '\\' || + FormatAt[0] == 'a' || // Audible Bell + FormatAt[0] == 'b' || // Backspace + FormatAt[0] == 'f' || // Form Feed - New Page + FormatAt[0] == 'n' || // Line Feed - New Line + FormatAt[0] == 'r' || // Carriage Return + FormatAt[0] == 't' || // Tab + FormatAt[0] == 'v'); // Vertical Tab + + // Not Handled (see cpp spec) \nnn \xnn \unnnn \Unnnnnnnn + Assert(FormatAt[0] != 'x' || FormatAt[0] != 'u' || FormatAt[0] != 'U'); + + if (IsBase8(FormatAt[0])) { - if (FormatAt[0] == '\\') - { - FormatAt++; - Assert(IsBase8(FormatAt[0]) || // Octal Escape Sequences - \0 is in this set - FormatAt[0] == '\'' || - FormatAt[0] == '\"' || - FormatAt[0] == '\?' || - FormatAt[0] == '\\' || - FormatAt[0] == 'a' || // Audible Bell - FormatAt[0] == 'b' || // Backspace - FormatAt[0] == 'f' || // Form Feed - New Page - FormatAt[0] == 'n' || // Line Feed - New Line - FormatAt[0] == 'r' || // Carriage Return - FormatAt[0] == 't' || // Tab - FormatAt[0] == 'v'); // Vertical Tab - - // Not Handled (see cpp spec) \nnn \xnn \unnnn \Unnnnnnnn - Assert(FormatAt[0] != 'x' || FormatAt[0] != 'u' || FormatAt[0] != 'U'); - - if (IsBase8(FormatAt[0])) - { - // TODO(Peter): this should keep going until it finds a non-octal character code - // but the only one we really need is \0 atm so I'm just handling that one - Assert(FormatAt[0] == '0'); - OutChar(Builder, (char)0); - FormatAt++; - } - else - { - OutChar(Builder, *FormatAt++); - } - } - else - { - OutChar(Builder, *FormatAt++); - } - } - else if (FormatAt[0] == '%' && FormatAt[1] == '%') // Print the % symbol - { - OutChar(Builder, '%'); - FormatAt += 2; + // TODO(Peter): this should keep going until it finds a non-octal character code + // but the only one we really need is \0 atm so I'm just handling that one + Assert(FormatAt[0] == '0'); + OutChar(Builder, (char)0); + FormatAt++; } else { - FormatAt++; - - // Flags - if (FormatAt[0] == '-') - { - FormatAt++; - } - else if (FormatAt[0] == '+') - { - FormatAt++; - } - else if (FormatAt[0] == ' ') - { - FormatAt++; - } - else if (FormatAt[0] == '#') - { - FormatAt++; - } - else if (FormatAt[0] == '0') - { - FormatAt++; - } - - // Width - b32 WidthSpecified = false; - s32 Width = 0; - - if (IsBase10(FormatAt[0])) - { - WidthSpecified = true; - u64 Parsed = 0; - AssertMessage("ParseInt assumes whole string is an integer"); - Width = (s32)ParseInt(FormatAt, 10, &Parsed); - FormatAt += Parsed; - } - else if (FormatAt[0] == '*') - { - WidthSpecified = true; - Width = va_arg(Args, s32); - Assert(Width >= 0); - FormatAt++; - } - - // Precision - b32 PrecisionSpecified = false; - s32 Precision = 0; - - if (FormatAt[0] == '.') - { - FormatAt++; - if (IsBase10(FormatAt[0])) - { - - PrecisionSpecified = true; - u64 Parsed = 0; - AssertMessage("ParseInt assumes whole string is an integer"); - Precision = (s32)ParseInt(FormatAt, 10, &Parsed); - FormatAt += Parsed; - } - else if (FormatAt[0] == '*') - { - PrecisionSpecified = true; - Precision = va_arg(Args, s32); - Assert(Precision >= 0); - FormatAt++; - } - } - - // Length - b32 LengthSpecified = false; - s32 Length = 4; - - if (FormatAt[0] == 'h' && FormatAt[1] == 'h') - { - LengthSpecified = true; - LengthSpecified = 1; - FormatAt += 2; - } - else if (FormatAt[0] == 'h') - { - LengthSpecified = true; - LengthSpecified = 2; - FormatAt++; - } - else if (FormatAt[0] == 'l' && FormatAt[1] == 'l') - { - LengthSpecified = true; - LengthSpecified = 8; - FormatAt += 2; - } - else if (FormatAt[0] == 'l') - { - LengthSpecified = true; - LengthSpecified = 4; - FormatAt++; - } - else if (FormatAt[0] == 'j') - { - LengthSpecified = true; - LengthSpecified = 8; - FormatAt++; - } - else if (FormatAt[0] == 'z') - { - FormatAt++; - } - else if (FormatAt[0] == 't') - { - FormatAt++; - } - else if (FormatAt[0] == 'L') - { - FormatAt++; - } - - // Format Specifiers - gs_string StringRemaining = GetStringAfter(*String, String->Length); - Assert(StringRemaining.Length == 0); - if (FormatAt[0] == 'd' || FormatAt[0] == 'i') - { - s64 SignedInt = ReadVarArgsSignedInteger(Length, &Args); - if (SignedInt < 0) - { - OutChar(&StringRemaining, '-'); - SignedInt *= -1; - } - U64ToASCII(&StringRemaining, (u64)SignedInt, 10, Base10Chars); - } - else if (FormatAt[0] == 'u') - { - u32 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); - U64ToASCII(&StringRemaining, UnsignedInt, 10, Base10Chars); - } - else if (FormatAt[0] == 'o') - { - u32 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); - U64ToASCII(&StringRemaining, UnsignedInt, 8, Base8Chars); - } - else if (FormatAt[0] == 'x' || FormatAt[0] == 'X') - { - u32 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); - U64ToASCII(&StringRemaining, UnsignedInt, 16, Base16Chars); - } - else if (FormatAt[0] == 'f' || FormatAt[0] == 'F') - { - r64 Float = ReadVarArgsFloat(Length, &Args); - s32 AfterPoint = 6; - if (PrecisionSpecified) - { - AfterPoint = Precision; - } - R64ToASCII(&StringRemaining, Float, AfterPoint); - } - else if (FormatAt[0] == 'c') - { - char InsertChar = va_arg(Args, s32); - OutChar(&StringRemaining, InsertChar); - } - else if (FormatAt[0] == 's') - { - char* InsertString = va_arg(Args, char*); - - s32 InsertStringLength = CStringLength(InsertString); - if (PrecisionSpecified) - { - InsertStringLength = Min(InsertStringLength, Precision); - } - InsertStringLength = Min(StringSizeLeft(StringRemaining), InsertStringLength); - - for (s32 c = 0; c < InsertStringLength; c++) - { - OutChar(&StringRemaining, InsertString[c]); - } - } - else if (FormatAt[0] == 'S') - { - gs_const_string InsertString = va_arg(Args, gs_const_string); - - for (s32 c = 0; c < InsertString.Length; c++) - { - OutChar(&StringRemaining, InsertString.Str[c]); - } - } - else if (FormatAt[0] == 'p') - { - // TODO(Peter): Pointer Address - } - else - { - // NOTE(Peter): Non-specifier character found - InvalidCodePath; - } - - String->Length += StringRemaining.Length; - FormatAt++; + OutChar(Builder, *FormatAt++); } + } + else + { + OutChar(Builder, *FormatAt++); + } } - - return String->Length; + else if (FormatAt[0] == '%' && FormatAt[1] == '%') // Print the % symbol + { + OutChar(Builder, '%'); + FormatAt += 2; + } + else + { + FormatAt++; + + // Flags + if (FormatAt[0] == '-') + { + FormatAt++; + } + else if (FormatAt[0] == '+') + { + FormatAt++; + } + else if (FormatAt[0] == ' ') + { + FormatAt++; + } + else if (FormatAt[0] == '#') + { + FormatAt++; + } + else if (FormatAt[0] == '0') + { + FormatAt++; + } + + // Width + b32 WidthSpecified = false; + s32 Width = 0; + + if (IsBase10(FormatAt[0])) + { + WidthSpecified = true; + u64 Parsed = 0; + AssertMessage("ParseInt assumes whole string is an integer"); + Width = (s32)ParseInt(FormatAt, 10, &Parsed); + FormatAt += Parsed; + } + else if (FormatAt[0] == '*') + { + WidthSpecified = true; + Width = va_arg(Args, s32); + Assert(Width >= 0); + FormatAt++; + } + + // Precision + b32 PrecisionSpecified = false; + s32 Precision = 0; + + if (FormatAt[0] == '.') + { + FormatAt++; + if (IsBase10(FormatAt[0])) + { + + PrecisionSpecified = true; + u64 Parsed = 0; + AssertMessage("ParseInt assumes whole string is an integer"); + Precision = (s32)ParseInt(FormatAt, 10, &Parsed); + FormatAt += Parsed; + } + else if (FormatAt[0] == '*') + { + PrecisionSpecified = true; + Precision = va_arg(Args, s32); + Assert(Precision >= 0); + FormatAt++; + } + } + + // Length + b32 LengthSpecified = false; + s32 Length = 4; + + if (FormatAt[0] == 'h' && FormatAt[1] == 'h') + { + LengthSpecified = true; + LengthSpecified = 1; + FormatAt += 2; + } + else if (FormatAt[0] == 'h') + { + LengthSpecified = true; + LengthSpecified = 2; + FormatAt++; + } + else if (FormatAt[0] == 'l' && FormatAt[1] == 'l') + { + LengthSpecified = true; + LengthSpecified = 8; + FormatAt += 2; + } + else if (FormatAt[0] == 'l') + { + LengthSpecified = true; + LengthSpecified = 4; + FormatAt++; + } + else if (FormatAt[0] == 'j') + { + LengthSpecified = true; + LengthSpecified = 8; + FormatAt++; + } + else if (FormatAt[0] == 'z') + { + FormatAt++; + } + else if (FormatAt[0] == 't') + { + FormatAt++; + } + else if (FormatAt[0] == 'L') + { + FormatAt++; + } + + // Format Specifiers + gs_string StringRemaining = GetStringAfter(*String, String->Length); + Assert(StringRemaining.Length == 0); + if (FormatAt[0] == 'd' || FormatAt[0] == 'i') + { + s64 SignedInt = ReadVarArgsSignedInteger(Length, &Args); + if (SignedInt < 0) + { + OutChar(&StringRemaining, '-'); + SignedInt *= -1; + } + U64ToASCII(&StringRemaining, (u64)SignedInt, 10, Base10Chars); + } + else if (FormatAt[0] == 'u') + { + u32 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); + U64ToASCII(&StringRemaining, UnsignedInt, 10, Base10Chars); + } + else if (FormatAt[0] == 'o') + { + u32 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); + U64ToASCII(&StringRemaining, UnsignedInt, 8, Base8Chars); + } + else if (FormatAt[0] == 'x' || FormatAt[0] == 'X') + { + u32 UnsignedInt = ReadVarArgsUnsignedInteger(Length, &Args); + U64ToASCII(&StringRemaining, UnsignedInt, 16, Base16Chars); + } + else if (FormatAt[0] == 'f' || FormatAt[0] == 'F') + { + r64 Float = ReadVarArgsFloat(Length, &Args); + s32 AfterPoint = 6; + if (PrecisionSpecified) + { + AfterPoint = Precision; + } + R64ToASCII(&StringRemaining, Float, AfterPoint); + } + else if (FormatAt[0] == 'c') + { + char InsertChar = va_arg(Args, s32); + OutChar(&StringRemaining, InsertChar); + } + else if (FormatAt[0] == 's') + { + char* InsertString = va_arg(Args, char*); + + s32 InsertStringLength = CStringLength(InsertString); + if (PrecisionSpecified) + { + InsertStringLength = Min(InsertStringLength, Precision); + } + InsertStringLength = Min(StringSizeLeft(StringRemaining), InsertStringLength); + + for (s32 c = 0; c < InsertStringLength; c++) + { + OutChar(&StringRemaining, InsertString[c]); + } + } + else if (FormatAt[0] == 'S') + { + gs_const_string InsertString = va_arg(Args, gs_const_string); + + for (s32 c = 0; c < InsertString.Length; c++) + { + OutChar(&StringRemaining, InsertString.Str[c]); + } + } + else if (FormatAt[0] == 'p') + { + // TODO(Peter): Pointer Address + } + else + { + // NOTE(Peter): Non-specifier character found + InvalidCodePath; + } + + String->Length += StringRemaining.Length; + FormatAt++; + } + } + + return String->Length; } internal void StringBuilderWriteF(gs_string_builder* Builder, char* Format, ...) { - va_list Args; - va_start(Args, Format); - StringBuilderWriteFArgsList(Builder, Format, Args); - va_end(Args); + va_list Args; + va_start(Args, Format); + StringBuilderWriteFArgsList(Builder, Format, Args); + va_end(Args); } #endif // String builder @@ -3119,25 +2784,25 @@ StringBuilderWriteF(gs_string_builder* Builder, char* Format, ...) internal u64 FileHandlerGetFileInfo_NoOp(gs_file_handler FileHandler, gs_const_string Path) { - return 0; + return 0; } internal gs_file FileHandlerReadFile_NoOp(gs_const_string Path) { - return gs_file{0}; + return gs_file{0}; } internal bool FileHandlerWriteFile_NoOp(gs_const_string Path, gs_data Data) { - return false; + return false; } internal gs_const_string_array FileHandlerEnumerateDirectory_NoOp(gs_const_string Path, bool Recursive, bool IncludeDirs) { - return gs_const_string_array{0}; + return gs_const_string_array{0}; } internal gs_file_handler @@ -3147,110 +2812,110 @@ CreateFileHandler(file_handler_get_file_info* GetFileInfo, file_handler_enumerate_directory* EnumerateDirectory, gs_memory_arena* Transient) { - if (GetFileInfo == 0) - { - GetFileInfo = (file_handler_get_file_info*)FileHandlerGetFileInfo_NoOp; - } - if (ReadEntireFile == 0) - { - ReadEntireFile = (file_handler_read_entire_file*)FileHandlerReadFile_NoOp; - } - if (WriteEntireFile == 0) - { - WriteEntireFile = (file_handler_write_entire_file*)FileHandlerWriteFile_NoOp; - } - if (EnumerateDirectory == 0) - { - EnumerateDirectory = (file_handler_enumerate_directory*)FileHandlerEnumerateDirectory_NoOp; - } - gs_file_handler Result = {0}; - Result.GetFileInfo = GetFileInfo; - Result.ReadEntireFile = ReadEntireFile; - Result.WriteEntireFile = WriteEntireFile; - Result.EnumerateDirectory = EnumerateDirectory; - Result.Transient = Transient; - - return Result; + if (GetFileInfo == 0) + { + GetFileInfo = (file_handler_get_file_info*)FileHandlerGetFileInfo_NoOp; + } + if (ReadEntireFile == 0) + { + ReadEntireFile = (file_handler_read_entire_file*)FileHandlerReadFile_NoOp; + } + if (WriteEntireFile == 0) + { + WriteEntireFile = (file_handler_write_entire_file*)FileHandlerWriteFile_NoOp; + } + if (EnumerateDirectory == 0) + { + EnumerateDirectory = (file_handler_enumerate_directory*)FileHandlerEnumerateDirectory_NoOp; + } + gs_file_handler Result = {0}; + Result.GetFileInfo = GetFileInfo; + Result.ReadEntireFile = ReadEntireFile; + Result.WriteEntireFile = WriteEntireFile; + Result.EnumerateDirectory = EnumerateDirectory; + Result.Transient = Transient; + + return Result; } internal gs_const_string GetNullTerminatedPath(gs_file_handler FileHandler, gs_const_string Path) { - gs_const_string Result = {}; - if (!IsNullTerminated(Path)) - { - gs_string NullTermPath = PushString(FileHandler.Transient, Path.Length + 1); - PrintF(&NullTermPath, "%S", Path); - NullTerminate(&NullTermPath); - Result = NullTermPath.ConstString; - } - else - { - Result = Path; - } - return Result; + gs_const_string Result = {}; + if (!IsNullTerminated(Path)) + { + gs_string NullTermPath = PushString(FileHandler.Transient, Path.Length + 1); + PrintF(&NullTermPath, "%S", Path); + NullTerminate(&NullTermPath); + Result = NullTermPath.ConstString; + } + else + { + Result = Path; + } + return Result; } internal gs_file_info GetFileInfo(gs_file_handler FileHandler, gs_const_string Path) { - Assert(FileHandler.GetFileInfo != 0); - - Path = GetNullTerminatedPath(FileHandler, Path); - gs_file_info Result = FileHandler.GetFileInfo(FileHandler, Path); - return Result; + Assert(FileHandler.GetFileInfo != 0); + + Path = GetNullTerminatedPath(FileHandler, Path); + gs_file_info Result = FileHandler.GetFileInfo(FileHandler, Path); + return Result; } internal gs_file ReadEntireFile(gs_file_handler FileHandler, gs_const_string Path, gs_data Memory) { - Assert(FileHandler.ReadEntireFile != 0); - - Path = GetNullTerminatedPath(FileHandler, Path); - gs_file Result = FileHandler.ReadEntireFile(FileHandler, Path, Memory); - return Result; + Assert(FileHandler.ReadEntireFile != 0); + + Path = GetNullTerminatedPath(FileHandler, Path); + gs_file Result = FileHandler.ReadEntireFile(FileHandler, Path, Memory); + return Result; } internal gs_file ReadEntireFile(gs_file_handler FileHandler, gs_const_string Path) { - Assert(FileHandler.GetFileInfo != 0); - Assert(FileHandler.ReadEntireFile != 0); - - Path = GetNullTerminatedPath(FileHandler, Path); - gs_file Result = {0}; - gs_file_info FileInfo = FileHandler.GetFileInfo(FileHandler, Path); - if (FileInfo.FileSize > 0) - { - gs_data FileMemory = PushSizeToData(FileHandler.Transient, FileInfo.FileSize); - Result = ReadEntireFile(FileHandler, Path, FileMemory); - } - return Result; + Assert(FileHandler.GetFileInfo != 0); + Assert(FileHandler.ReadEntireFile != 0); + + Path = GetNullTerminatedPath(FileHandler, Path); + gs_file Result = {0}; + gs_file_info FileInfo = FileHandler.GetFileInfo(FileHandler, Path); + if (FileInfo.FileSize > 0) + { + gs_data FileMemory = PushSize(FileHandler.Transient, FileInfo.FileSize); + Result = ReadEntireFile(FileHandler, Path, FileMemory); + } + return Result; } internal bool WriteEntireFile(gs_file_handler FileHandler, gs_const_string Path, gs_data Memory) { - Assert(FileHandler.WriteEntireFile != 0); - - Path = GetNullTerminatedPath(FileHandler, Path); - return FileHandler.WriteEntireFile(FileHandler, Path, Memory); + Assert(FileHandler.WriteEntireFile != 0); + + Path = GetNullTerminatedPath(FileHandler, Path); + return FileHandler.WriteEntireFile(FileHandler, Path, Memory); } internal gs_file_info_array EnumerateDirectory(gs_file_handler FileHandler, gs_memory_arena* Storage, gs_const_string Path, u32 Flags) { - Assert(FileHandler.EnumerateDirectory != 0); - - Path = GetNullTerminatedPath(FileHandler, Path); - return FileHandler.EnumerateDirectory(FileHandler, Storage, Path, Flags); + Assert(FileHandler.EnumerateDirectory != 0); + + Path = GetNullTerminatedPath(FileHandler, Path); + return FileHandler.EnumerateDirectory(FileHandler, Storage, Path, Flags); } internal bool FileNoError(gs_file File) { - bool Result = (File.Size > 0); - return Result; + bool Result = (File.Size > 0); + return Result; } ////////////////////////// @@ -3260,15 +2925,15 @@ FileNoError(gs_file File) internal s64 TimeHandlerGetWallClock(gs_time_handler TimeHandler) { - s64 Result = TimeHandler.GetWallClock(); - return Result; + s64 Result = TimeHandler.GetWallClock(); + return Result; } internal s64 TimeHandlerGetSecondsElapsed(gs_time_handler TimeHandler, s64 StartCycles, s64 EndCycles) { - s64 Result = TimeHandler.GetSecondsElapsed(StartCycles, EndCycles); - return Result; + s64 Result = TimeHandler.GetSecondsElapsed(StartCycles, EndCycles); + return Result; } ////////////////////////// @@ -3277,71 +2942,71 @@ TimeHandlerGetSecondsElapsed(gs_time_handler TimeHandler, s64 StartCycles, s64 E CREATE_THREAD(CreateThreadStub) { - return {}; + return {}; } KILL_THREAD(KillThreadStub) { - return false; + return false; } internal platform_thread_manager CreatePlatformThreadManager(platform_create_thread* CreateThreadProc, platform_kill_thread* KillThreadProc) { - platform_thread_manager Result = {}; - Result.CreateThreadProc = CreateThreadProc; - Result.KillThreadProc = KillThreadProc; - - if (!CreateThreadProc) - { - Result.CreateThreadProc = CreateThreadStub; - } - if (!KillThreadProc) - { - Result.KillThreadProc = KillThreadStub; - } - - return Result; + platform_thread_manager Result = {}; + Result.CreateThreadProc = CreateThreadProc; + Result.KillThreadProc = KillThreadProc; + + if (!CreateThreadProc) + { + Result.CreateThreadProc = CreateThreadStub; + } + if (!KillThreadProc) + { + Result.KillThreadProc = KillThreadStub; + } + + return Result; } internal platform_thread_handle -CreateThread(platform_thread_manager* Manager, thread_proc_* Proc, u8* Arg) +CreateThread(platform_thread_manager* Manager, thread_proc_* Proc, u8* Arg, gs_thread_context Ctx) { - platform_thread_handle Result = {}; - - for (u32 i = 1; i < THREADS_MAX; i++) + platform_thread_handle Result = {}; + + for (u32 i = 1; i < THREADS_MAX; i++) + { + if (!Manager->ThreadsUsed[i]) { - if (!Manager->ThreadsUsed[i]) - { - Result.Index = i; - break; - } + Result.Index = i; + break; } - Assert(Result.Index != 0); - - Manager->ThreadsUsed[Result.Index] = true; - Manager->CreateThreadProc(&Manager->Threads[Result.Index], Proc, Arg); - - return Result; + } + Assert(Result.Index != 0); + + Manager->ThreadsUsed[Result.Index] = true; + Manager->CreateThreadProc(&Manager->Threads[Result.Index], Proc, Arg, Ctx); + + return Result; } internal bool KillThread(platform_thread_manager* Manager, platform_thread_handle Handle) { - Assert(Manager->ThreadsUsed[Handle.Index]); - - platform_thread* Thread = &Manager->Threads[Handle.Index]; - bool Result = Manager->KillThreadProc(Thread); - - if (Result) - { - Manager->ThreadsUsed[Handle.Index] = false; - Manager->Threads[Handle.Index] = {}; - } - - return Result; + Assert(Manager->ThreadsUsed[Handle.Index]); + + platform_thread* Thread = &Manager->Threads[Handle.Index]; + bool Result = Manager->KillThreadProc(Thread); + + if (Result) + { + Manager->ThreadsUsed[Handle.Index] = false; + Manager->Threads[Handle.Index] = {}; + } + + return Result; } @@ -3351,32 +3016,32 @@ KillThread(platform_thread_manager* Manager, platform_thread_handle Handle) CONNECT_SOCKET(PlatformConnectSocket_Stub) { - return false; + return false; } CLOSE_SOCKET(PlatformCloseSocket_Stub) { - return false; + return false; } SOCKET_QUERY_STATUS(PlatformSocketQueryStatus_Stub) { - return false; + return false; } SOCKET_PEEK(PlatformSocketPeek_Stub) { - return 0; + return 0; } SOCKET_RECEIVE(PlatformSocketRecieve_Stub) { - return {}; + return {}; } SOCKET_SEND(PlatformSocketSend_Stub) { - return false; + return false; } internal platform_socket_manager @@ -3387,159 +3052,194 @@ CreatePlatformSocketManager(platform_connect_socket* ConnectSocketProc, platform_socket_receive* SocketRecieveProc, platform_socket_send* SocketSendProc) { - platform_socket_manager Result = {}; - Result.ConnectSocketProc = ConnectSocketProc; - Result.CloseSocketProc = CloseSocketProc; - Result.SocketQueryStatusProc = SocketQueryStatusProc; - Result.SocketPeekProc = SocketPeekProc; - Result.SocketRecieveProc = SocketRecieveProc; - Result.SocketSendProc = SocketSendProc; - - if (!ConnectSocketProc) - { - Result.ConnectSocketProc = PlatformConnectSocket_Stub; - } - if (!CloseSocketProc) - { - Result.CloseSocketProc = PlatformCloseSocket_Stub; - } - if (!SocketQueryStatusProc) - { - Result.SocketQueryStatusProc = PlatformSocketQueryStatus_Stub; - } - if (!SocketPeekProc) - { - Result.SocketPeekProc = PlatformSocketPeek_Stub; - } - if (!SocketRecieveProc) - { - Result.SocketRecieveProc = PlatformSocketRecieve_Stub; - } - if (!SocketSendProc) - { - Result.SocketSendProc = PlatformSocketSend_Stub; - } - return Result; + platform_socket_manager Result = {}; + Result.ConnectSocketProc = ConnectSocketProc; + Result.CloseSocketProc = CloseSocketProc; + Result.SocketQueryStatusProc = SocketQueryStatusProc; + Result.SocketPeekProc = SocketPeekProc; + Result.SocketRecieveProc = SocketRecieveProc; + Result.SocketSendProc = SocketSendProc; + + if (!ConnectSocketProc) + { + Result.ConnectSocketProc = PlatformConnectSocket_Stub; + } + if (!CloseSocketProc) + { + Result.CloseSocketProc = PlatformCloseSocket_Stub; + } + if (!SocketQueryStatusProc) + { + Result.SocketQueryStatusProc = PlatformSocketQueryStatus_Stub; + } + if (!SocketPeekProc) + { + Result.SocketPeekProc = PlatformSocketPeek_Stub; + } + if (!SocketRecieveProc) + { + Result.SocketRecieveProc = PlatformSocketRecieve_Stub; + } + if (!SocketSendProc) + { + Result.SocketSendProc = PlatformSocketSend_Stub; + } + return Result; +} + +internal bool +SocketHandleIsValid(platform_socket_handle_ Handle) +{ + return Handle.Index != 0; } internal platform_socket* SocketManagerGetSocket(platform_socket_manager* Manager, platform_socket_handle_ Handle) { - platform_socket* Result = 0; - if (Manager->SocketsUsed[Handle.Index]) + platform_socket* Result = 0; + if (Manager->SocketsUsed[Handle.Index]) + { + platform_socket* Socket = &Manager->Sockets[Handle.Index]; + if (Socket->PlatformHandle != 0) { - platform_socket* Socket = &Manager->Sockets[Handle.Index]; - if (Socket->PlatformHandle != 0) - { - Result = Socket; - } + Result = Socket; } - return Result; + } + return Result; } internal bool ConnectSocket(platform_socket_manager* Manager, platform_socket_handle_ Handle) { - bool Result = false; - platform_socket* Socket = SocketManagerGetSocket(Manager, Handle); - if (Socket) - { - Result = Manager->ConnectSocketProc(Socket); - } - return Result; + bool Result = false; + platform_socket* Socket = SocketManagerGetSocket(Manager, Handle); + if (Socket) + { + Result = Manager->ConnectSocketProc(Manager, Socket); + } + return Result; +} + +internal bool +RemoveSocket (platform_socket_manager* Manager, platform_socket_handle_ Handle) +{ + bool Result = Manager->SocketsUsed[Handle.Index]; + Manager->SocketsUsed[Handle.Index] = false; + return Result; } internal platform_socket_handle_ CreateSocket(platform_socket_manager* Manager, char* Addr, char* Port) { - platform_socket_handle_ Result = {}; - for (u32 i = 1; i < SOCKETS_COUNT_MAX; i++) + platform_socket_handle_ Result = {}; + for (u32 i = 1; i < SOCKETS_COUNT_MAX; i++) + { + if (!Manager->SocketsUsed[i]) { - if (!Manager->SocketsUsed[i]) - { - Result.Index = i; - Manager->SocketsUsed[i] = true; - break; - } + Result.Index = i; + Manager->SocketsUsed[i] = true; + break; } - - Assert(Result.Index != 0); - platform_socket* Socket = &Manager->Sockets[Result.Index]; - CopyArray(Addr, Socket->Addr, char, CStringLength(Addr) + 1); - CopyArray(Port, Socket->Port, char, CStringLength(Port) + 1); - - bool Success = Manager->ConnectSocketProc(Socket); - Assert(Success); - - return Result; + } + + Assert(Result.Index != 0); + platform_socket* Socket = &Manager->Sockets[Result.Index]; + Socket->Handle = Result; + CopyArray(Addr, Socket->Addr, char, CStringLength(Addr) + 1); + CopyArray(Port, Socket->Port, char, CStringLength(Port) + 1); + + bool Success = Manager->ConnectSocketProc(Manager, Socket); + if (!Success) + { + if (RemoveSocket(Manager, Result)) + { + Result = {}; + } + else + { + InvalidCodePath; + } + } + + return Result; +} + +internal bool +CloseSocket(platform_socket_manager* Manager, platform_socket* Socket) +{ + bool Result = false; + if (Socket) + { + if (Manager->CloseSocketProc(Manager, Socket)) + { + RemoveSocket(Manager, Socket->Handle); + *Socket = {}; + Result = true; + } + else + { + InvalidCodePath; + } + } + return Result; } internal bool CloseSocket(platform_socket_manager* Manager, platform_socket_handle_ Handle) { - bool Result = false; - platform_socket* Socket = SocketManagerGetSocket(Manager, Handle); - if (Socket) - { - if (Manager->CloseSocketProc(Socket)) - { - Manager->SocketsUsed[Handle.Index] = false; - *Socket = {}; - Result = true; - } - } - return Result; + bool Result = false; + platform_socket* Socket = SocketManagerGetSocket(Manager, Handle); + return CloseSocket(Manager, Socket); } // NOTE(pjs): returns true if the socket is connected -// TODO(pjs): make this more descriptive? internal bool SocketQueryStatus(platform_socket_manager* Manager, platform_socket_handle_ SocketHandle) { - bool Result = false; - platform_socket* Socket = SocketManagerGetSocket(Manager, SocketHandle); - if (Socket) - { - Result = Manager->SocketQueryStatusProc(Socket); - } - return Result; + bool Result = false; + platform_socket* Socket = SocketManagerGetSocket(Manager, SocketHandle); + if (Socket) + { + Result = Manager->SocketQueryStatusProc(Manager, Socket); + } + return Result; } internal u32 SocketPeek(platform_socket_manager* Manager, platform_socket_handle_ SocketHandle) { - u32 Result = 0; - platform_socket* Socket = SocketManagerGetSocket(Manager, SocketHandle); - if (Socket) - { - Result = Manager->SocketPeekProc(Socket); - } - return Result; + u32 Result = 0; + platform_socket* Socket = SocketManagerGetSocket(Manager, SocketHandle); + if (Socket) + { + Result = Manager->SocketPeekProc(Manager, Socket); + } + return Result; } internal gs_data SocketRecieve(platform_socket_manager* Manager, platform_socket_handle_ SocketHandle, gs_memory_arena* Storage) { - gs_data Result = {}; - platform_socket* Socket = SocketManagerGetSocket(Manager, SocketHandle); - if (Socket) - { - Result = Manager->SocketRecieveProc(Socket, Storage); - } - return Result; + gs_data Result = {}; + platform_socket* Socket = SocketManagerGetSocket(Manager, SocketHandle); + if (Socket) + { + Result = Manager->SocketRecieveProc(Manager, Socket, Storage); + } + return Result; } internal bool SocketSend(platform_socket_manager* Manager, platform_socket_handle_ SocketHandle, u32 Address, u32 Port, gs_data Data, s32 Flags) { - bool Result = false; - platform_socket* Socket = SocketManagerGetSocket(Manager, SocketHandle); - if (Socket) - { - s32 SizeSent = Manager->SocketSendProc(Socket, Address, Port, Data, Flags); - Result = (SizeSent == Data.Size); - } - return Result; + bool Result = false; + platform_socket* Socket = SocketManagerGetSocket(Manager, SocketHandle); + if (Socket) + { + s32 SizeSent = Manager->SocketSendProc(Manager, Socket, Address, Port, Data, Flags); + Result = (SizeSent == Data.Size); + } + return Result; } /////////////////////////// @@ -3549,63 +3249,83 @@ SocketSend(platform_socket_manager* Manager, platform_socket_handle_ SocketHandl internal u32 HashAppendDJB2ToU32(u32 Hash, u8 Byte) { - u32 Result = Hash; - if (Result == 0) { Result = 5381; } - Result = ((Result << 5) + Result) + Byte; - return Result; + u32 Result = Hash; + if (Result == 0) { Result = 5381; } + Result = ((Result << 5) + Result) + Byte; + return Result; } internal u64 HashAppendDJB2ToU32(u64 Hash, u8 Byte) { - u64 Result = Hash; - if (Result == 0) { Result = 5381; } - Result = ((Result << 5) + Result) + Byte; - return Result; + u64 Result = Hash; + if (Result == 0) { Result = 5381; } + Result = ((Result << 5) + Result) + Byte; + return Result; } internal u32 HashDJB2ToU32(char* String) { - u32 Hash = 5381; - char* C = String; - while(*C) - { - Hash = ((Hash << 5) + Hash) + *C++; - } - return Hash; + u32 Hash = 5381; + char* C = String; + while(*C) + { + Hash = ((Hash << 5) + Hash) + *C++; + } + return Hash; } internal u32 HashDJB2ToU32(u32 Length, char* String) { - u32 Hash = 5381; - for (u32 i = 0; i < Length; i++) - { - Hash = ((Hash << 5) + Hash) + String[i]; - } - return Hash; + u32 Hash = 5381; + for (u32 i = 0; i < Length; i++) + { + Hash = ((Hash << 5) + Hash) + String[i]; + } + return Hash; +} +internal u32 +HashDJB2ToU32(gs_const_string Str) +{ + return HashDJB2ToU32(StringExpand(Str)); +} +internal u32 +HashDJB2ToU32(gs_string Str) +{ + return HashDJB2ToU32(StringExpand(Str)); } internal u64 HashDJB2ToU64(char* String) { - u64 Hash = 5381; - char* C = String; - while(*C) - { - Hash = ((Hash << 5) + Hash) + *C++; - } - return Hash; + u64 Hash = 5381; + char* C = String; + while(*C) + { + Hash = ((Hash << 5) + Hash) + *C++; + } + return Hash; } internal u64 HashDJB2ToU64(u32 Length, char* String) { - u64 Hash = 5381; - for (u32 i = 0; i < Length; i++) - { - Hash = ((Hash << 5) + Hash) + String[i]; - } - return Hash; + u64 Hash = 5381; + for (u32 i = 0; i < Length; i++) + { + Hash = ((Hash << 5) + Hash) + String[i]; + } + return Hash; +} +internal u64 +HashDJB2ToU64(gs_const_string Str) +{ + return HashDJB2ToU64(StringExpand(Str)); +} +internal u64 +HashDJB2ToU64(gs_string Str) +{ + return HashDJB2ToU64(StringExpand(Str)); } /////////////////////////// @@ -3615,36 +3335,36 @@ HashDJB2ToU64(u32 Length, char* String) internal gs_random_series InitRandomSeries(u32 Seed) { - gs_random_series Result = {0}; - Result.Value = Seed; - return Result; + gs_random_series Result = {0}; + Result.Value = Seed; + return Result; } internal u32 NextRandom(gs_random_series* Series) { - u32 Result = Series->Value; - Result ^= Result << 13; - Result ^= Result >> 17; - Result ^= Result << 5; - Series->Value = Result; - return Result; + u32 Result = Series->Value; + Result ^= Result << 13; + Result ^= Result >> 17; + Result ^= Result << 5; + Series->Value = Result; + return Result; } internal r32 NextRandomUnilateral(gs_random_series* Series) { - r32 Result = (r32)NextRandom(Series) / (r32)UINT32_MAX; - return Result; + r32 Result = (r32)NextRandom(Series) / (r32)UINT32_MAX; + return Result; } internal r32 NextRandomBilateral(gs_random_series* Series) { - r32 Result = (r32)NextRandom(Series); - Result = Result / (r32)0xFFFFFFFF; - Result = (Result * 2.0f) - 1.0f; - return Result; + r32 Result = (r32)NextRandom(Series); + Result = Result / (r32)0xFFFFFFFF; + Result = (Result * 2.0f) - 1.0f; + return Result; } @@ -3656,62 +3376,62 @@ NextRandomBilateral(gs_random_series* Series) static void RadixSortInPlace_ (gs_radix_list* List, u32 Start, u32 End, u32 Iteration) { - u32 Shift = Iteration; - u32 ZerosBoundary = Start; - u32 OnesBoundary = End - 1; - - for (u32 d = Start; d < End; d++) + u32 Shift = Iteration; + u32 ZerosBoundary = Start; + u32 OnesBoundary = End - 1; + + for (u32 d = Start; d < End; d++) + { + u64 CurrentIndex = ZerosBoundary; + u64 Radix = List->Radixes.Values[CurrentIndex]; + u64 Place = (Radix >> Shift) & 0x1; + if (Place) { - u64 CurrentIndex = ZerosBoundary; - u64 Radix = List->Radixes.Values[CurrentIndex]; - u64 Place = (Radix >> Shift) & 0x1; - if (Place) - { - u64 EvictedIndex = OnesBoundary; - u64 EvictedRadix = List->Radixes.Values[EvictedIndex]; - u64 EvictedID = List->IDs.Values[EvictedIndex]; - - List->Radixes.Values[EvictedIndex] = Radix; - List->IDs.Values[EvictedIndex] = List->IDs.Values[CurrentIndex]; - - List->Radixes.Values[CurrentIndex] = EvictedRadix; - List->IDs.Values[CurrentIndex] = EvictedID; - - OnesBoundary -= 1; - } - else - { - ZerosBoundary += 1; - } + u64 EvictedIndex = OnesBoundary; + u64 EvictedRadix = List->Radixes.Values[EvictedIndex]; + u64 EvictedID = List->IDs.Values[EvictedIndex]; + + List->Radixes.Values[EvictedIndex] = Radix; + List->IDs.Values[EvictedIndex] = List->IDs.Values[CurrentIndex]; + + List->Radixes.Values[CurrentIndex] = EvictedRadix; + List->IDs.Values[CurrentIndex] = EvictedID; + + OnesBoundary -= 1; } - - if (Iteration > 0) + else { - RadixSortInPlace_(List, Start, ZerosBoundary, Iteration - 1); - RadixSortInPlace_(List, ZerosBoundary, End, Iteration - 1); + ZerosBoundary += 1; } + } + + if (Iteration > 0) + { + RadixSortInPlace_(List, Start, ZerosBoundary, Iteration - 1); + RadixSortInPlace_(List, ZerosBoundary, End, Iteration - 1); + } } static void RadixSortInPlace (gs_radix_list* List) { - u32 Highest = 0; - for (u32 i = 0; i < List->Radixes.Count; i++) + u32 Highest = 0; + for (u32 i = 0; i < List->Radixes.Count; i++) + { + if (List->Radixes.Values[i] > Highest) { - if (List->Radixes.Values[i] > Highest) - { - Highest = List->Radixes.Values[i]; - } + Highest = List->Radixes.Values[i]; } - - u32 Iterations = 0; - while (Highest > 1) - { - ++Iterations; - Highest = Highest >> 1; - } - - RadixSortInPlace_(List, 0, List->Radixes.Count, Iterations); + } + + u32 Iterations = 0; + while (Highest > 1) + { + ++Iterations; + Highest = Highest >> 1; + } + + RadixSortInPlace_(List, 0, List->Radixes.Count, Iterations); } @@ -3722,105 +3442,105 @@ RadixSortInPlace (gs_radix_list* List) inline bool KeyIsMouseButton(gs_key Key) { - bool Result = (Key >= gs_Key_MouseLeftButton); - Result = Result && Key <= gs_Key_MouseRightButton; - return Result; + bool Result = (Key >= gs_Key_MouseLeftButton); + Result = Result && Key <= gs_Key_MouseRightButton; + return Result; } inline u32 GetMouseButtonIndex(gs_key Button) { - Assert(KeyIsMouseButton(Button)); - u32 Result = Button - gs_Key_MouseLeftButton; - return Result; + Assert(KeyIsMouseButton(Button)); + u32 Result = Button - gs_Key_MouseLeftButton; + return Result; } inline bool MouseButtonTransitionedDown(gs_mouse_state Mouse, u32 Index) { - bool IsDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_IsDownBit)) != 0; - bool WasDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_WasDownBit)) != 0; - return IsDown && !WasDown; + bool IsDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_IsDownBit)) != 0; + bool WasDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_WasDownBit)) != 0; + return IsDown && !WasDown; } inline bool MouseButtonTransitionedDown(gs_mouse_state Mouse, gs_key Button) { - u32 Index = GetMouseButtonIndex(Button); - return MouseButtonTransitionedDown(Mouse, Index); + u32 Index = GetMouseButtonIndex(Button); + return MouseButtonTransitionedDown(Mouse, Index); } inline bool MouseButtonIsDown(gs_mouse_state Mouse, u32 Index) { - bool IsDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_IsDownBit)) != 0; - return IsDown; + bool IsDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_IsDownBit)) != 0; + return IsDown; } inline bool MouseButtonIsDown(gs_mouse_state Mouse, gs_key Button) { - u32 Index = GetMouseButtonIndex(Button); - return MouseButtonIsDown(Mouse, Index); + u32 Index = GetMouseButtonIndex(Button); + return MouseButtonIsDown(Mouse, Index); } inline bool MouseButtonTransitionedUp(gs_mouse_state Mouse, u32 Index) { - bool IsDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_IsDownBit)) != 0; - bool WasDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_WasDownBit)) != 0; - return !IsDown && WasDown; + bool IsDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_IsDownBit)) != 0; + bool WasDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_WasDownBit)) != 0; + return !IsDown && WasDown; } inline bool MouseButtonTransitionedUp(gs_mouse_state Mouse, gs_key Button) { - u32 Index = GetMouseButtonIndex(Button); - return MouseButtonTransitionedUp(Mouse, Index); + u32 Index = GetMouseButtonIndex(Button); + return MouseButtonTransitionedUp(Mouse, Index); } inline bool MouseButtonIsUp(gs_mouse_state Mouse, u32 Index) { - bool IsDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_IsDownBit)) != 0; - return !IsDown; + bool IsDown = (Mouse.ButtonStates[Index] & (1 << MouseButton_IsDownBit)) != 0; + return !IsDown; } inline bool MouseButtonIsUp(gs_mouse_state Mouse, gs_key Button) { - u32 Index = GetMouseButtonIndex(Button); - return MouseButtonIsUp(Mouse, Index); + u32 Index = GetMouseButtonIndex(Button); + return MouseButtonIsUp(Mouse, Index); } internal void SetMouseButtonTransitionedDown(gs_mouse_state* Mouse, gs_key Button) { - u32 Index = GetMouseButtonIndex(Button); - - Mouse->ButtonStates[Index] = 0; - Mouse->ButtonStates[Index] |= MouseButton_IsDown << MouseButton_IsDownBit; - Mouse->ButtonStates[Index] |= MouseButton_WasNotDown << MouseButton_WasDownBit; + u32 Index = GetMouseButtonIndex(Button); + + Mouse->ButtonStates[Index] = 0; + Mouse->ButtonStates[Index] |= MouseButton_IsDown << MouseButton_IsDownBit; + Mouse->ButtonStates[Index] |= MouseButton_WasNotDown << MouseButton_WasDownBit; } internal void SetMouseButtonTransitionedUp(gs_mouse_state* Mouse, gs_key Button) { - u32 Index = GetMouseButtonIndex(Button); - - Mouse->ButtonStates[Index] = 0; - Mouse->ButtonStates[Index] |= MouseButton_IsNotDown << MouseButton_IsDownBit; - Mouse->ButtonStates[Index] |= MouseButton_WasDown << MouseButton_WasDownBit; + u32 Index = GetMouseButtonIndex(Button); + + Mouse->ButtonStates[Index] = 0; + Mouse->ButtonStates[Index] |= MouseButton_IsNotDown << MouseButton_IsDownBit; + Mouse->ButtonStates[Index] |= MouseButton_WasDown << MouseButton_WasDownBit; } internal void AdvanceMouseButtonState(gs_mouse_state* Mouse, gs_key Button) { - u32 Index = GetMouseButtonIndex(Button); - - if (MouseButtonIsDown(*Mouse, Index)) - { - Mouse->ButtonStates[Index] |= MouseButton_WasDown << MouseButton_WasDownBit; - } - else - { - Mouse->ButtonStates[Index] &= MouseButton_WasNotDown << MouseButton_WasDownBit; - } + u32 Index = GetMouseButtonIndex(Button); + + if (MouseButtonIsDown(*Mouse, Index)) + { + Mouse->ButtonStates[Index] |= MouseButton_WasDown << MouseButton_WasDownBit; + } + else + { + Mouse->ButtonStates[Index] &= MouseButton_WasNotDown << MouseButton_WasDownBit; + } } internal void AdvanceMouseButtonsState(gs_mouse_state* Mouse) { - AdvanceMouseButtonState(Mouse, gs_Key_MouseLeftButton); - AdvanceMouseButtonState(Mouse, gs_Key_MouseMiddleButton); - AdvanceMouseButtonState(Mouse, gs_Key_MouseRightButton); + AdvanceMouseButtonState(Mouse, gs_Key_MouseLeftButton); + AdvanceMouseButtonState(Mouse, gs_Key_MouseMiddleButton); + AdvanceMouseButtonState(Mouse, gs_Key_MouseRightButton); } /////////////////////////// @@ -3831,17 +3551,17 @@ AdvanceMouseButtonsState(gs_mouse_state* Mouse) static u32 HostToNetU32(u32 In) { - unsigned char *s = (unsigned char *)&In; - u32 Result = (u32)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]); - return Result; + unsigned char *s = (unsigned char *)&In; + u32 Result = (u32)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]); + return Result; } static u16 HostToNetU16(u16 In) { - unsigned char *s = (unsigned char *)&In; - u16 Result = (u16)(s[0] << 8 | s[1]); - return Result; + unsigned char *s = (unsigned char *)&In; + u16 Result = (u16)(s[0] << 8 | s[1]); + return Result; } diff --git a/src/gs_libs/gs_types.h b/src/gs_libs/gs_types.h index e6ab857..2a1051e 100644 --- a/src/gs_libs/gs_types.h +++ b/src/gs_libs/gs_types.h @@ -66,46 +66,46 @@ typedef double r64; enum gs_basic_type { - gs_BasicType_char, - gs_BasicType_b8, - gs_BasicType_b32, - gs_BasicType_b64, - gs_BasicType_u8, - gs_BasicType_u16, - gs_BasicType_u32, - gs_BasicType_u64, - gs_BasicType_s8, - gs_BasicType_s16, - gs_BasicType_s32, - gs_BasicType_s64, - gs_BasicType_r32, - gs_BasicType_r64, - - gs_BasicType_Count, + gs_BasicType_char, + gs_BasicType_b8, + gs_BasicType_b32, + gs_BasicType_b64, + gs_BasicType_u8, + gs_BasicType_u16, + gs_BasicType_u32, + gs_BasicType_u64, + gs_BasicType_s8, + gs_BasicType_s16, + gs_BasicType_s32, + gs_BasicType_s64, + gs_BasicType_r32, + gs_BasicType_r64, + + gs_BasicType_Count, }; global_const u64 gs_BasicTypeSizes[] = { - sizeof(char), - sizeof(b8), - sizeof(b32), - sizeof(b64), - sizeof(u8), - sizeof(u16), - sizeof(u32), - sizeof(u64), - sizeof(s8), - sizeof(s16), - sizeof(s32), - sizeof(s64), - sizeof(r32), - sizeof(r64), + sizeof(char), + sizeof(b8), + sizeof(b32), + sizeof(b64), + sizeof(u8), + sizeof(u16), + sizeof(u32), + sizeof(u64), + sizeof(s8), + sizeof(s16), + sizeof(s32), + sizeof(s64), + sizeof(r32), + sizeof(r64), }; internal u64 BasicTypeSize(gs_basic_type Type) { - return gs_BasicTypeSizes[(u32)Type]; + return gs_BasicTypeSizes[(u32)Type]; } global_const u8 MaxU8 = 0xFF; @@ -137,74 +137,75 @@ global_const r64 MinR64 = -MaxR64; global_const r64 SmallestPositiveR64 = 4.94065645841247e-324; global_const r64 EpsilonR64 = 1.11022302462515650e-16; -// TODO: va_start and va_arg replacements +global_const r64 NanosToSeconds = 1 / 10000000.0; +global_const r64 SecondsToNanos = 10000000.0; internal r32 DegToRadR32(r32 Degrees) { - return (Degrees * (PiR32 / 180.0f)); + return (Degrees * (PiR32 / 180.0f)); } internal r32 RadToDegR32(r32 Radians) { - return (Radians * (180.0f / PiR32)); + return (Radians * (180.0f / PiR32)); } struct s8_array { - s8* Values; - u32 Count; - u32 CountMax; + s8* Values; + u32 Count; + u32 CountMax; }; struct s16_array { - s16* Values; - u32 Count; - u32 CountMax; + s16* Values; + u32 Count; + u32 CountMax; }; struct s32_array { - s32* Values; - u32 Count; - u32 CountMax; + s32* Values; + u32 Count; + u32 CountMax; }; struct s64_array { - s64* Values; - u32 Count; - u32 CountMax; + s64* Values; + u32 Count; + u32 CountMax; }; struct u8_array { - u8* Values; - u32 Count; - u32 CountMax; + u8* Values; + u32 Count; + u32 CountMax; }; struct u16_array { - u16* Values; - u32 Count; - u32 CountMax; + u16* Values; + u32 Count; + u32 CountMax; }; struct u32_array { - u32* Values; - u32 Count; - u32 CountMax; + u32* Values; + u32 Count; + u32 CountMax; }; struct u64_array { - u64* Values; - u32 Count; - u32 CountMax; + u64* Values; + u32 Count; + u32 CountMax; }; @@ -232,7 +233,7 @@ struct u64_array # define InvalidDefaultCase default: { AssertBreak("invalid default case"); } break; # define StaticAssert(c) \ enum { \ - Glue(gs_AssertFail_, __LINE__) = 1 / (int)(!!(c)), \ +Glue(gs_AssertFail_, __LINE__) = 1 / (int)(!!(c)), \ } #else # define Assert(c) @@ -247,7 +248,7 @@ enum { \ #define DontCompile ImAfraidICantDoThat #define LineNumberString Stringify(__LINE__) -#define FileNameAndLineNumberString_ __FILE__ ":" LineNumberString ":" +#define FileNameAndLineNumberString_ __FILE__ ":" LineNumberString ":" __FUNCTION__ #define FileNameAndLineNumberString (char*)FileNameAndLineNumberString_ // @@ -273,22 +274,24 @@ enum { \ #define IsPowerOfTwo(x) (((x) & ((x) - 1)) == 0) #define IsOdd(x) (((x) & 1) != 0) +#define CArrayLength(arr) (sizeof(arr) / (sizeof(arr[0]))) + internal void ZeroMemory_(u8* Memory, u64 Size) { - for (u64 i = 0; i < Size; i++) - { - Memory[i] = 0; - } + for (u64 i = 0; i < Size; i++) + { + Memory[i] = 0; + } } internal void CopyMemory_(u8* From, u8* To, u64 Size) { - for (u64 i = 0; i < Size; i++) - { - To[i] = From[i]; - } + for (u64 i = 0; i < Size; i++) + { + To[i] = From[i]; + } } #define StaticArrayLength(arr) sizeof(arr) / sizeof((arr)[0]) @@ -306,8 +309,8 @@ CopyMemory_(u8* From, u8* To, u64 Size) #define SLLPop_(list_tail) list_tail=list_tail=list_tail->next #define SLLPop(list_tail) (SLLPop_((list_tail))) -#define SLLNext(ele_at) ele_at = ele_at->Next; -#define SLLPrev(ele_at) ele_at = ele_at->Prev; +#define SLLNext(ele_at) ele_at = ele_at->Next +#define SLLPrev(ele_at) ele_at = ele_at->Prev #define SLLInit(head,tail,first_ele) head=first_ele, tail=first_ele; @@ -319,80 +322,80 @@ else { SLLInit(first,last,new_ele); } union v2 { - struct - { - r32 x; - r32 y; - }; - r32 E[2]; + struct + { + r32 x; + r32 y; + }; + r32 E[2]; }; union v3 { - struct - { - r32 x; - r32 y; - r32 z; - }; - struct - { - r32 r; - r32 g; - r32 b; - }; - struct - { - v2 xy; - r32 _z0; - }; - struct - { - r32 _x0; - v2 yz; - }; - r32 E[3]; + struct + { + r32 x; + r32 y; + r32 z; + }; + struct + { + r32 r; + r32 g; + r32 b; + }; + struct + { + v2 xy; + r32 _z0; + }; + struct + { + r32 _x0; + v2 yz; + }; + r32 E[3]; }; union v4 { - struct - { - r32 x; - r32 y; - r32 z; - r32 w; - }; - struct - { - r32 r; - r32 g; - r32 b; - r32 a; - }; - struct - { - v2 xy; - v2 zw; - }; - struct - { - r32 _x0; - v2 yz; - r32 _w0; - }; - struct - { - v3 xyz; - r32 _w1; - }; - r32 E[4]; + struct + { + r32 x; + r32 y; + r32 z; + r32 w; + }; + struct + { + r32 r; + r32 g; + r32 b; + r32 a; + }; + struct + { + v2 xy; + v2 zw; + }; + struct + { + r32 _x0; + v2 yz; + r32 _w0; + }; + struct + { + v3 xyz; + r32 _w1; + }; + r32 E[4]; }; struct v4_ray { - v4 Origin; - v4 Direction; + v4 Origin; + v4 Direction; }; #define WhiteV4 v4{1, 1, 1, 1} @@ -410,76 +413,76 @@ struct v4_ray struct v2_array { - v2* Vectors; - u32 Count; - u32 CountMax; + v2* Vectors; + u32 Count; + u32 CountMax; }; struct v3_array { - v3* Vectors; - u32 Count; - u32 CountMax; + v3* Vectors; + u32 Count; + u32 CountMax; }; struct v4_array { - v4* Vectors; - u32 Count; - u32 CountMax; + v4* Vectors; + u32 Count; + u32 CountMax; }; struct range1 { - r32 Min; - r32 Max; + r32 Min; + r32 Max; }; struct range2 { - v2 Min; - v2 Max; + v2 Min; + v2 Max; }; typedef range2 rect2; struct range3 { - v3 Min; - v3 Max; + v3 Min; + v3 Max; }; struct range4 { - v4 Min; - v4 Max; + v4 Min; + v4 Max; }; struct range1_array { - range1* Ranges; - u32 Count; - u32 CountMax; + range1* Ranges; + u32 Count; + u32 CountMax; }; struct range2_array { - range2* Ranges; - u32 Count; - u32 CountMax; + range2* Ranges; + u32 Count; + u32 CountMax; }; struct range3_array { - range3* Ranges; - u32 Count; - u32 CountMax; + range3* Ranges; + u32 Count; + u32 CountMax; }; struct range4_array { - range4* Ranges; - u32 Count; - u32 CountMax; + range4* Ranges; + u32 Count; + u32 CountMax; }; #define Range1Expand(r) (r).Min, (r).Max @@ -493,39 +496,39 @@ struct range4_array union m33 { - float Array[9]; - struct - { - r32 AXx; r32 AYx; r32 AZx; - r32 AXy; r32 AYy; r32 AZy; - r32 AXz; r32 AYz; r32 AZz; - }; + float Array[9]; + struct + { + r32 AXx; r32 AYx; r32 AZx; + r32 AXy; r32 AYy; r32 AZy; + r32 AXz; r32 AYz; r32 AZz; + }; }; union m44 { - float Array[16]; - struct - { - r32 AXx; r32 AYx; r32 AZx; r32 Tx; - r32 AXy; r32 AYy; r32 AZy; r32 Ty; - r32 AXz; r32 AYz; r32 AZz; r32 Tz; - r32 AXw; r32 AYw; r32 AZw; r32 Tw; - }; + float Array[16]; + struct + { + r32 AXx; r32 AYx; r32 AZx; r32 Tx; + r32 AXy; r32 AYy; r32 AZy; r32 Ty; + r32 AXz; r32 AYz; r32 AZz; r32 Tz; + r32 AXw; r32 AYw; r32 AZw; r32 Tw; + }; }; struct m33_array { - m33* Matrices; - u32 Count; - u32 CountMax; + m33* Matrices; + u32 Count; + u32 CountMax; }; struct m44_array { - m44* Matrices; - u32 Count; - u32 CountMax; + m44* Matrices; + u32 Count; + u32 CountMax; }; ////////////////////////// @@ -534,49 +537,70 @@ struct m44_array struct gs_const_string { - union - { - char* Str; - u8* Data;; - }; - u64 Length; + union + { + char* Str; + u8* Data;; + }; + u64 Length; }; struct gs_string { - union + union + { + gs_const_string ConstString; + struct { - gs_const_string ConstString; - struct - { - char* Str; - u64 Length; - }; + char* Str; + u64 Length; }; - u64 Size; + }; + u64 Size; }; struct gs_const_string_array { - gs_const_string* Strings; - u64 Count; - u64 Used; + gs_const_string* Strings; + u64 Count; + u64 CountMax; }; struct gs_string_array { - gs_string* Strings; - u64 Count; - u64 CountMax; + gs_string* Strings; + u64 Count; + u64 CountMax; }; internal u64 CStringLength(char* Str) { - char* At = Str; - while (*At) { At++; } - u64 Result = PointerDifference(At, Str); - return Result; + char* At = Str; + while (*At) { At++; } + u64 Result = PointerDifference(At, Str); + return Result; +} + +internal bool +CStringsEqual(char* A, char* B) +{ + bool Result = true; + + char* AAt = A; + char* BAt = B; + while (AAt[0] && BAt[0]) + { + if (AAt[0] != BAt[0]) + { + Result = false; + break; + } + AAt++; + BAt++; + } + if (AAt[0] != 0 || BAt[0] != 0) { Result = false; } + return Result; } #define StringExpand(str) (int)(str).Length, (str).Str @@ -602,79 +626,35 @@ typedef struct gs_thread_context gs_thread_context; struct gs_data { - u8* Memory; - u64 Size; + u8* Memory; + u64 Size; }; struct gs_data_array { - gs_data* Data; - u64 Count; - u64 CountMax; + gs_data* Data; + u64 Count; + u64 CountMax; }; enum gs_access_flag { - gs_AccessFlag_Read = 1 << 0, - gs_AccessFlag_Write = 1 << 1, - gs_AccessFlag_Exec = 1 << 2, + gs_AccessFlag_Read = 1 << 0, + gs_AccessFlag_Write = 1 << 1, + gs_AccessFlag_Exec = 1 << 2, }; typedef s32 gs_scan_direction; enum { - gs_Scan_Backward = -1, - gs_Scan_Forward = 1, + gs_Scan_Backward = -1, + gs_Scan_Forward = 1, }; -#define ALLOCATOR_ALLOC(name) void* name(u64 Size, u64* ResultSize) -typedef ALLOCATOR_ALLOC(allocator_allocate); -#define ALLOCATOR_FREE(name) void name(void* Ptr, u64 Size) -typedef ALLOCATOR_FREE(allocator_free); +internal u64 RoundUpTo64(u64 Value, u64 Alignment); -struct gs_allocator -{ - allocator_allocate* Alloc; - allocator_free* Free; -}; - -struct gs_memory_cursor -{ - gs_data Data; - u64 Position; -}; - -struct gs_memory_cursor_list -{ - gs_memory_cursor Cursor; - gs_memory_cursor_list* Next; - gs_memory_cursor_list* Prev; -}; - -enum arena_type -{ - Arena_BaseArena, - Arena_SubArena, -}; - -struct gs_memory_arena -{ - arena_type Type; - gs_allocator Allocator; - gs_memory_arena* Parent; - - gs_memory_cursor_list* CursorList; - u64 MemoryChunkSize; - u64 MemoryAlignment; -}; - -struct gs_memory_arena_array -{ - gs_memory_arena* Arenas; - u32 Count; - u32 Size; -}; +#include "gs_memory.h" /////////////////////////////// // @@ -683,16 +663,16 @@ struct gs_memory_arena_array struct gs_string_builder_buffer { - gs_string String; - gs_string_builder_buffer* Next; + gs_string String; + gs_string_builder_buffer* Next; }; struct gs_string_builder { - gs_memory_arena* Arena; - u32 BufferSize; - gs_string_builder_buffer* Root; - gs_string_builder_buffer* Head; + gs_memory_arena* Arena; + u32 BufferSize; + gs_string_builder_buffer* Root; + gs_string_builder_buffer* Head; }; /////////////////////////////// @@ -707,8 +687,8 @@ typedef DEBUG_PRINT(debug_print); struct debug_output { - gs_memory_arena* Storage; - debug_print* Print; + gs_memory_arena* Storage; + debug_print* Print; }; /////////////////////////////// @@ -723,34 +703,34 @@ struct debug_output struct gs_dynarray_buffer { - u8* Memory; + u8* Memory; }; struct gs_dynarray { - gs_memory_arena Arena; - - gs_dynarray_buffer* Buffers; - u64 BuffersCount; - u64 ElementCount; - - u64 ElementSize; - u64 ElementsPerBuffer; + gs_memory_arena Arena; + + gs_dynarray_buffer* Buffers; + u64 BuffersCount; + u64 ElementCount; + + u64 ElementSize; + u64 ElementsPerBuffer; }; struct gs_dynarray_handle { - u64 BufferIndex; - u64 IndexInBuffer; + u64 BufferIndex; + u64 IndexInBuffer; }; #define INVALID_DYNARRAY_HANDLE gs_dynarray_handle{0, 0} struct gs_dynarray_handle_list { - gs_dynarray_handle* Handles; - u32 Count; - u32 Size; + gs_dynarray_handle* Handles; + u32 Count; + u32 Size; }; /////////////////////////////// @@ -763,39 +743,39 @@ struct gs_dynarray_handle_list enum enumerate_directory_flag { - EnumerateDirectory_Recurse = 1 << 0, - EnumerateDirectory_IncludeDirectories = 1 << 1, + EnumerateDirectory_Recurse = 1 << 0, + EnumerateDirectory_IncludeDirectories = 1 << 1, }; struct gs_file_info { - gs_const_string Path; - gs_const_string AbsolutePath; - u64 FileSize; - u64 CreationTime; - u64 LastWriteTime; - b32 IsDirectory; + gs_const_string Path; + gs_const_string AbsolutePath; + u64 FileSize; + u64 CreationTime; + u64 LastWriteTime; + b32 IsDirectory; }; struct gs_file_info_array { - gs_file_info* Values; - u32 Count; - u32 MaxCount; + gs_file_info* Values; + u32 Count; + u32 MaxCount; }; struct gs_file { - union + union + { + gs_data Data; + struct { - gs_data Data; - struct - { - u8* Memory; - u64 Size; - }; + u8* Memory; + u64 Size; }; - gs_file_info FileInfo; + }; + gs_file_info FileInfo; }; typedef struct gs_file_handler gs_file_handler; @@ -814,11 +794,11 @@ typedef ENUMERATE_DIRECTORY(file_handler_enumerate_directory); struct gs_file_handler { - file_handler_get_file_info* GetFileInfo; - file_handler_read_entire_file* ReadEntireFile; - file_handler_write_entire_file* WriteEntireFile; - file_handler_enumerate_directory* EnumerateDirectory; - gs_memory_arena* Transient; + file_handler_get_file_info* GetFileInfo; + file_handler_read_entire_file* ReadEntireFile; + file_handler_write_entire_file* WriteEntireFile; + file_handler_enumerate_directory* EnumerateDirectory; + gs_memory_arena* Transient; }; @@ -834,8 +814,8 @@ typedef GET_SECONDS_ELAPSED(get_seconds_elapsed); struct gs_time_handler { - get_wall_clock* GetWallClock; - get_seconds_elapsed* GetSecondsElapsed; + get_wall_clock* GetWallClock; + get_seconds_elapsed* GetSecondsElapsed; }; /////////////////////////////// @@ -844,7 +824,7 @@ struct gs_time_handler struct gs_random_series { - u32 Value; + u32 Value; }; /////////////////////////////// @@ -853,8 +833,8 @@ struct gs_random_series struct gs_radix_list { - u64_array Radixes; - u64_array IDs; + u64_array Radixes; + u64_array IDs; }; @@ -864,115 +844,115 @@ struct gs_radix_list enum gs_event_type { - gs_EventType_Unknown, - - // Reached end of event stream - gs_EventType_NoMoreEvents, - // There was an event but it requires no action from the using program - gs_EventType_NoEvent, - - gs_EventType_KeyPressed, - gs_EventType_KeyReleased, - - gs_EventType_MouseMoved, - gs_EventType_MouseWheel, - - gs_EventType_Count, + gs_EventType_Unknown, + + // Reached end of event stream + gs_EventType_NoMoreEvents, + // There was an event but it requires no action from the using program + gs_EventType_NoEvent, + + gs_EventType_KeyPressed, + gs_EventType_KeyReleased, + + gs_EventType_MouseMoved, + gs_EventType_MouseWheel, + + gs_EventType_Count, }; enum gs_key { - gs_Key_Invalid, - - gs_Key_Esc, - - gs_Key_Space, - gs_Key_Tab, - gs_Key_CapsLock, - gs_Key_Shift, gs_Key_LeftShift, gs_Key_RightShift, - gs_Key_Control, gs_Key_LeftCtrl, gs_Key_RightCtrl, - gs_Key_Fn, - gs_Key_Alt, - gs_Key_PageUp, gs_Key_PageDown, - gs_Key_End, gs_Key_Home, gs_Key_Select, - gs_Key_Backspace, gs_Key_Delete, - gs_Key_Enter, - - // Function Keys - gs_Key_F0, gs_Key_F1, gs_Key_F2, gs_Key_F3, gs_Key_F4, gs_Key_F5, gs_Key_F6, gs_Key_F7, - gs_Key_F8, gs_Key_F9, gs_Key_F10, gs_Key_F11, gs_Key_F12, - - // Letters - gs_Key_a, gs_Key_b, gs_Key_c, gs_Key_d, gs_Key_e, gs_Key_f, gs_Key_g, gs_Key_h, - gs_Key_i, gs_Key_j, gs_Key_k, gs_Key_l, gs_Key_m, gs_Key_n, gs_Key_o, gs_Key_p, - gs_Key_q, gs_Key_r, gs_Key_s, gs_Key_t, gs_Key_u, gs_Key_v, gs_Key_w, gs_Key_x, - gs_Key_y, gs_Key_z, - - gs_Key_A, gs_Key_B, gs_Key_C, gs_Key_D, gs_Key_E, gs_Key_F, gs_Key_G, gs_Key_H, - gs_Key_I, gs_Key_J, gs_Key_K, gs_Key_L, gs_Key_M, gs_Key_N, gs_Key_O, gs_Key_P, - gs_Key_Q, gs_Key_R, gs_Key_S, gs_Key_T, gs_Key_U, gs_Key_V, gs_Key_W, gs_Key_X, - gs_Key_Y, gs_Key_Z, - - // Numbers - gs_Key_0, gs_Key_1, gs_Key_2, gs_Key_3, gs_Key_4, gs_Key_5, gs_Key_6, gs_Key_7, - gs_Key_8, gs_Key_9, - - gs_Key_Num0, gs_Key_Num1, gs_Key_Num2, gs_Key_Num3, gs_Key_Num4, gs_Key_Num5, - gs_Key_Num6, gs_Key_Num7, gs_Key_Num8, gs_Key_Num9, - - // Symbols - gs_Key_Bang, gs_Key_At, gs_Key_Pound, gs_Key_Dollar, gs_Key_Percent, gs_Key_Carrot, - gs_Key_Ampersand, gs_Key_Star, gs_Key_LeftParen, gs_Key_RightParen, gs_Key_Minus, gs_Key_Plus, - gs_Key_Equals, gs_Key_Underscore, gs_Key_OpenSquareBracket, gs_Key_CloseSquareBracket, gs_Key_OpenCurlyBracket, - gs_Key_CloseCurlyBracket, gs_Key_Colon, gs_Key_SemiColon, gs_Key_SingleQuote, gs_Key_DoubleQuote, - gs_Key_ForwardSlash, gs_Key_Backslash, gs_Key_Pipe, gs_Key_Comma, gs_Key_Period, - gs_Key_QuestionMark, gs_Key_LessThan, gs_Key_GreaterThan, gs_Key_Tilde, gs_Key_BackQuote, - - // Arrows - gs_Key_UpArrow, - gs_Key_DownArrow, - gs_Key_LeftArrow, - gs_Key_RightArrow, - - // Mouse - // NOTE(Peter): Including this here so we can utilize the same KeyDown, KeyUp etc. functions - gs_Key_MouseLeftButton, - gs_Key_MouseMiddleButton, - gs_Key_MouseRightButton, - gs_Key_MouseX1Button, - gs_Key_MouseX2Button, - - gs_Key_Count, + gs_Key_Invalid, + + gs_Key_Esc, + + gs_Key_Space, + gs_Key_Tab, + gs_Key_CapsLock, + gs_Key_Shift, gs_Key_LeftShift, gs_Key_RightShift, + gs_Key_Control, gs_Key_LeftCtrl, gs_Key_RightCtrl, + gs_Key_Fn, + gs_Key_Alt, + gs_Key_PageUp, gs_Key_PageDown, + gs_Key_End, gs_Key_Home, gs_Key_Select, + gs_Key_Backspace, gs_Key_Delete, + gs_Key_Enter, + + // Function Keys + gs_Key_F0, gs_Key_F1, gs_Key_F2, gs_Key_F3, gs_Key_F4, gs_Key_F5, gs_Key_F6, gs_Key_F7, + gs_Key_F8, gs_Key_F9, gs_Key_F10, gs_Key_F11, gs_Key_F12, + + // Letters + gs_Key_a, gs_Key_b, gs_Key_c, gs_Key_d, gs_Key_e, gs_Key_f, gs_Key_g, gs_Key_h, + gs_Key_i, gs_Key_j, gs_Key_k, gs_Key_l, gs_Key_m, gs_Key_n, gs_Key_o, gs_Key_p, + gs_Key_q, gs_Key_r, gs_Key_s, gs_Key_t, gs_Key_u, gs_Key_v, gs_Key_w, gs_Key_x, + gs_Key_y, gs_Key_z, + + gs_Key_A, gs_Key_B, gs_Key_C, gs_Key_D, gs_Key_E, gs_Key_F, gs_Key_G, gs_Key_H, + gs_Key_I, gs_Key_J, gs_Key_K, gs_Key_L, gs_Key_M, gs_Key_N, gs_Key_O, gs_Key_P, + gs_Key_Q, gs_Key_R, gs_Key_S, gs_Key_T, gs_Key_U, gs_Key_V, gs_Key_W, gs_Key_X, + gs_Key_Y, gs_Key_Z, + + // Numbers + gs_Key_0, gs_Key_1, gs_Key_2, gs_Key_3, gs_Key_4, gs_Key_5, gs_Key_6, gs_Key_7, + gs_Key_8, gs_Key_9, + + gs_Key_Num0, gs_Key_Num1, gs_Key_Num2, gs_Key_Num3, gs_Key_Num4, gs_Key_Num5, + gs_Key_Num6, gs_Key_Num7, gs_Key_Num8, gs_Key_Num9, + + // Symbols + gs_Key_Bang, gs_Key_At, gs_Key_Pound, gs_Key_Dollar, gs_Key_Percent, gs_Key_Carrot, + gs_Key_Ampersand, gs_Key_Star, gs_Key_LeftParen, gs_Key_RightParen, gs_Key_Minus, gs_Key_Plus, + gs_Key_Equals, gs_Key_Underscore, gs_Key_OpenSquareBracket, gs_Key_CloseSquareBracket, gs_Key_OpenCurlyBracket, + gs_Key_CloseCurlyBracket, gs_Key_Colon, gs_Key_SemiColon, gs_Key_SingleQuote, gs_Key_DoubleQuote, + gs_Key_ForwardSlash, gs_Key_Backslash, gs_Key_Pipe, gs_Key_Comma, gs_Key_Period, + gs_Key_QuestionMark, gs_Key_LessThan, gs_Key_GreaterThan, gs_Key_Tilde, gs_Key_BackQuote, + + // Arrows + gs_Key_UpArrow, + gs_Key_DownArrow, + gs_Key_LeftArrow, + gs_Key_RightArrow, + + // Mouse + // NOTE(Peter): Including this here so we can utilize the same KeyDown, KeyUp etc. functions + gs_Key_MouseLeftButton, + gs_Key_MouseMiddleButton, + gs_Key_MouseRightButton, + gs_Key_MouseX1Button, + gs_Key_MouseX2Button, + + gs_Key_Count, }; enum gs_modifier_key_flags { - gs_ModifierKeyFlag_Shift = 1 << 0, - gs_ModifierKeyFlag_Ctrl = 1 << 1, - gs_ModifierKeyFlag_Alt = 1 << 2, + gs_ModifierKeyFlag_Shift = 1 << 0, + gs_ModifierKeyFlag_Ctrl = 1 << 1, + gs_ModifierKeyFlag_Alt = 1 << 2, }; struct gs_input_event { - gs_event_type Type; - gs_key Key; - v2 Position; - r32 Amount; - b32 Modifiers; + gs_event_type Type; + gs_key Key; + v2 Position; + r32 Amount; + b32 Modifiers; }; struct gs_input_event_buffer { - gs_input_event* Values; - u32 Count; - u32 MaxCount; + gs_input_event* Values; + u32 Count; + u32 MaxCount; }; struct gs_mouse_state { - v2 Position; - b32 ButtonStates[3]; - v2 DownPosition; + v2 Position; + b32 ButtonStates[3]; + v2 DownPosition; }; #define MouseButton_IsDownBit 0 @@ -988,29 +968,29 @@ struct gs_mouse_state struct gs_thread_info { - u32 ThreadID; + u32 ThreadID; }; struct gs_thread_context { - gs_thread_info ThreadInfo; - - // TODO(Peter): Pull these handlers out into just a gs_context struct so - // they can be shared across threads. - // specifically the allocator - gs_allocator Allocator; - gs_file_handler FileHandler; - debug_output DebugOutput; - gs_time_handler TimeHandler; - - gs_memory_arena* Transient; + gs_thread_info ThreadInfo; + + // TODO(Peter): Pull these handlers out into just a gs_context struct so + // they can be shared across threads. + // specifically the allocator + gs_allocator Allocator; + gs_file_handler FileHandler; + debug_output DebugOutput; + gs_time_handler TimeHandler; + + gs_memory_arena* Transient; }; // Threads typedef struct platform_thread_handle { - u32 Index; + u32 Index; } platform_thread_handle; typedef struct platform_thread_manager platform_thread_manager; @@ -1020,13 +1000,12 @@ typedef THREAD_PROC_(thread_proc_); typedef struct platform_thread { - u8* PlatformHandle; - thread_proc_* Proc; - u8* UserData; - // TODO(pjs): Some kind of platform thread handle + u8* PlatformHandle; + thread_proc_* Proc; + u8* UserData; } platform_thread; -#define CREATE_THREAD(name) bool name(platform_thread* Thread, thread_proc_* Proc, u8* UserData) +#define CREATE_THREAD(name) bool name(platform_thread* Thread, thread_proc_* Proc, u8* UserData, gs_thread_context Ctx) typedef CREATE_THREAD(platform_create_thread); #define KILL_THREAD(name) bool name(platform_thread* Thread) @@ -1035,11 +1014,11 @@ typedef KILL_THREAD(platform_kill_thread); #define THREADS_MAX 32 typedef struct platform_thread_manager { - b8 ThreadsUsed[THREADS_MAX]; - platform_thread Threads[THREADS_MAX]; - - platform_create_thread* CreateThreadProc; - platform_kill_thread* KillThreadProc; + b8 ThreadsUsed[THREADS_MAX]; + platform_thread Threads[THREADS_MAX]; + + platform_create_thread* CreateThreadProc; + platform_kill_thread* KillThreadProc; } platform_thread_manager; // Work Queue @@ -1048,9 +1027,9 @@ typedef struct gs_work_queue gs_work_queue; typedef struct gs_worker_thread { - gs_thread_context Context; - gs_work_queue* Queue; - b32 ShouldExit; + gs_thread_context Context; + gs_work_queue* Queue; + b32 ShouldExit; } gs_worker_thread; #define THREAD_PROC(name) void name(gs_thread_context Context, gs_data Data) @@ -1058,9 +1037,9 @@ typedef THREAD_PROC(thread_proc); struct gs_threaded_job { - thread_proc* WorkProc; - gs_data Data; - gs_const_string JobName; + thread_proc* WorkProc; + gs_data Data; + gs_const_string JobName; }; #define PUSH_WORK_ON_QUEUE(name) void name(gs_work_queue* Queue, thread_proc* WorkProc, gs_data Data, gs_const_string JobName) @@ -1074,67 +1053,70 @@ typedef RESET_WORK_QUEUE(reset_work_queue); struct gs_work_queue { - void* SemaphoreHandle; - - u32 JobsMax; - u32 volatile JobsCount; - u32 volatile NextJobIndex; - u32 volatile JobsCompleted; - gs_threaded_job* Jobs; - - // Work Queue - push_work_on_queue* PushWorkOnQueue; - complete_queue_work* CompleteQueueWork; + void* SemaphoreHandle; + + u32 JobsMax; + u32 volatile JobsCount; + u32 volatile NextJobIndex; + u32 volatile JobsCompleted; + gs_threaded_job* Jobs; + + // Work Queue + push_work_on_queue* PushWorkOnQueue; + complete_queue_work* CompleteQueueWork; }; // Sockets typedef struct platform_socket_handle_ { - u32 Index; + u32 Index; } platform_socket_handle_; typedef struct platform_socket { - char Addr[128]; - char Port[32]; - u8* PlatformHandle; + platform_socket_handle_ Handle; + char Addr[128]; + char Port[32]; + u8* PlatformHandle; } platform_socket; -#define CONNECT_SOCKET(name) bool name(platform_socket* Socket) +typedef struct platform_socket_manager platform_socket_manager; + +#define CONNECT_SOCKET(name) bool name(platform_socket_manager* Manager, platform_socket* Socket) typedef CONNECT_SOCKET(platform_connect_socket); -#define CLOSE_SOCKET(name) bool name(platform_socket* Socket) +#define CLOSE_SOCKET(name) bool name(platform_socket_manager* Manager, platform_socket* Socket) typedef CLOSE_SOCKET(platform_close_socket); -#define SOCKET_QUERY_STATUS(name) bool name(platform_socket* Socket) +#define SOCKET_QUERY_STATUS(name) bool name(platform_socket_manager* Manager, platform_socket* Socket) typedef SOCKET_QUERY_STATUS(platform_socket_query_status); -#define SOCKET_PEEK(name) u32 name(platform_socket* Socket) +#define SOCKET_PEEK(name) u32 name(platform_socket_manager* Manager, platform_socket* Socket) typedef SOCKET_PEEK(platform_socket_peek); // TODO(pjs): allow for a size parameter that can be zero // if provided, that is how big the message it expects to be // if it equals zero, the proc will peek at the message first to determine // the needed size -#define SOCKET_RECEIVE(name) gs_data name(platform_socket* Socket, gs_memory_arena* Storage) +#define SOCKET_RECEIVE(name) gs_data name(platform_socket_manager* Manager, platform_socket* Socket, gs_memory_arena* Storage) typedef SOCKET_RECEIVE(platform_socket_receive); -#define SOCKET_SEND(name) s32 name(platform_socket* Socket, u32 Address, u32 Port, gs_data Data, s32 Flags) +#define SOCKET_SEND(name) s32 name(platform_socket_manager* Manager, platform_socket* Socket, u32 Address, u32 Port, gs_data Data, s32 Flags) typedef SOCKET_SEND(platform_socket_send); #define SOCKETS_COUNT_MAX 32 typedef struct platform_socket_manager { - b8 SocketsUsed[SOCKETS_COUNT_MAX]; - platform_socket Sockets[SOCKETS_COUNT_MAX]; - - platform_connect_socket* ConnectSocketProc; - platform_close_socket* CloseSocketProc; - platform_socket_query_status* SocketQueryStatusProc; - platform_socket_peek* SocketPeekProc; - platform_socket_receive* SocketRecieveProc; - platform_socket_send* SocketSendProc; + b8 SocketsUsed[SOCKETS_COUNT_MAX]; + platform_socket Sockets[SOCKETS_COUNT_MAX]; + + platform_connect_socket* ConnectSocketProc; + platform_close_socket* CloseSocketProc; + platform_socket_query_status* SocketQueryStatusProc; + platform_socket_peek* SocketPeekProc; + platform_socket_receive* SocketRecieveProc; + platform_socket_send* SocketSendProc; } platform_socket_manager; #define GS_TYPES_H diff --git a/src/gs_libs/gs_win32.cpp b/src/gs_libs/gs_win32.cpp index b96ae2e..18074c6 100644 --- a/src/gs_libs/gs_win32.cpp +++ b/src/gs_libs/gs_win32.cpp @@ -9,39 +9,39 @@ struct win32_state { - b32 Initialized; - b32 Running; + b32 Initialized; + b32 Running; }; struct win32_opengl_window_info { - s32 ColorBits; - s32 AlphaBits; - s32 DepthBits; - HGLRC RenderContext; + s32 ColorBits; + s32 AlphaBits; + s32 DepthBits; + HGLRC RenderContext; }; struct window { - char* Name; - char* ClassName; - s32 Width; - s32 Height; - WNDPROC WindowEventHandler; - - WNDCLASS Class; - HWND Handle; - HDC DeviceContext; - - // TODO(peter): Make this a union? - win32_opengl_window_info OpenGLInfo; + char* Name; + char* ClassName; + s32 Width; + s32 Height; + WNDPROC WindowEventHandler; + + WNDCLASS Class; + HWND Handle; + HDC DeviceContext; + + // TODO(peter): Make this a union? + win32_opengl_window_info OpenGLInfo; }; struct handle_window_msg_result { - b32 NeedsUpdate; -#ifdef DEBUG - char MessageType[128]; + b32 NeedsUpdate; +#if DEBUG + char MessageType[128]; #endif }; @@ -54,8 +54,8 @@ internal s32 Win32ConcatStrings(s32 ALen, char* A, s32 BLen, char* B, s32 DestLe // Windowing & Graphics struct win32_offscreen_buffer { - texture_buffer Buffer; - BITMAPINFO Info; + texture_buffer Buffer; + BITMAPINFO Info; }; LRESULT CALLBACK Win32HandleWindowsEvents (HWND WindowHandle, UINT Msg, WPARAM wParam, LPARAM lParam); @@ -64,11 +64,6 @@ internal void Win32UpdateWindowDimension(window* Window); internal void Win32ResizeDIBSection(win32_offscreen_buffer *Buffer, int Width, int Height); internal void Win32DisplayBufferInWindow(win32_offscreen_buffer* Buffer, window Window); -// Memory - -internal ALLOCATOR_ALLOC(Win32Alloc); -internal ALLOCATOR_FREE(Win32Free); - /// // Utils /// @@ -76,32 +71,32 @@ internal ALLOCATOR_FREE(Win32Free); internal s32 Win32StringLength(char* String) { - char* At = String; - while (*At) { At++; }; - return At - String; + char* At = String; + while (*At) { At++; }; + return At - String; } internal s32 Win32ConcatStrings(s32 ALength, char* A, s32 BLength, char* B, s32 DestLength, char* Dest) { - char* Dst = Dest; - char* AAt = A; - int ALengthToCopy = ALength < DestLength ? ALength : DestLength; - for (s32 a = 0; a < ALength; a++) - { - *Dst++ = *AAt++; - } - char* BAt = B; - int DestLengthRemaining = DestLength - (Dst - Dest); - int BLengthToCopy = BLength < DestLengthRemaining ? BLength : DestLength; - for (s32 b = 0; b < BLengthToCopy; b++) - { - *Dst++ = *BAt++; - } - int DestLengthOut = Dst - Dest; - int NullTermIndex = DestLengthOut < DestLength ? DestLengthOut : DestLength; - Dest[NullTermIndex] = 0; - return DestLengthOut; + char* Dst = Dest; + char* AAt = A; + int ALengthToCopy = ALength < DestLength ? ALength : DestLength; + for (s32 a = 0; a < ALength; a++) + { + *Dst++ = *AAt++; + } + char* BAt = B; + int DestLengthRemaining = DestLength - (Dst - Dest); + int BLengthToCopy = BLength < DestLengthRemaining ? BLength : DestLength; + for (s32 b = 0; b < BLengthToCopy; b++) + { + *Dst++ = *BAt++; + } + int DestLengthOut = Dst - Dest; + int NullTermIndex = DestLengthOut < DestLength ? DestLengthOut : DestLength; + Dest[NullTermIndex] = 0; + return DestLengthOut; } /// @@ -112,158 +107,158 @@ internal window Win32CreateWindow (HINSTANCE HInstance, char* WindowName, s32 Width, s32 Height, WNDPROC WindowEventHandler) { - window Result = {}; - Result.Name = WindowName; - Result.ClassName = WindowName; - Result.Width = Width; - Result.Height = Height; - Result.WindowEventHandler = WindowEventHandler; - - Result.Class = {}; - Result.Class.style = CS_HREDRAW | CS_VREDRAW; - Result.Class.lpfnWndProc = WindowEventHandler; - Result.Class.hInstance = HInstance; - Result.Class.lpszClassName = WindowName; - - if (RegisterClass(&Result.Class)) - { - Result.Handle = CreateWindowEx( - 0, - Result.Class.lpszClassName, - WindowName, - WS_OVERLAPPEDWINDOW | WS_VISIBLE, - CW_USEDEFAULT, - CW_USEDEFAULT, - Width, - Height, - 0, - 0, - HInstance, - 0); - Result.DeviceContext = GetDC(Result.Handle); - } - - return Result; + window Result = {}; + Result.Name = WindowName; + Result.ClassName = WindowName; + Result.Width = Width; + Result.Height = Height; + Result.WindowEventHandler = WindowEventHandler; + + Result.Class = {}; + Result.Class.style = CS_HREDRAW | CS_VREDRAW; + Result.Class.lpfnWndProc = WindowEventHandler; + Result.Class.hInstance = HInstance; + Result.Class.lpszClassName = WindowName; + + if (RegisterClass(&Result.Class)) + { + Result.Handle = CreateWindowEx( + 0, + Result.Class.lpszClassName, + WindowName, + WS_OVERLAPPEDWINDOW | WS_VISIBLE, + CW_USEDEFAULT, + CW_USEDEFAULT, + Width, + Height, + 0, + 0, + HInstance, + 0); + Result.DeviceContext = GetDC(Result.Handle); + } + + return Result; }; internal window PlatformCreateWindow (char* WindowName, s32 Width, s32 Height) { - HINSTANCE HInstance = GetModuleHandle(NULL); - return Win32CreateWindow(HInstance, WindowName, Width, Height, Win32HandleWindowsEvents); + HINSTANCE HInstance = GetModuleHandle(NULL); + return Win32CreateWindow(HInstance, WindowName, Width, Height, Win32HandleWindowsEvents); } internal void CreateOpenGLWindowContext (win32_opengl_window_info Info, window* Window) { - // Setup pixel format - { - PIXELFORMATDESCRIPTOR PixelFormatDesc = { 0 }; - // TODO: Program seems to work perfectly fine without all other params except dwFlags. - // Can we skip other params for the sake of brevity? - PixelFormatDesc.nSize = sizeof(PIXELFORMATDESCRIPTOR); - PixelFormatDesc.nVersion = 1; - PixelFormatDesc.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER; - PixelFormatDesc.iPixelType = PFD_TYPE_RGBA;// TODO(Peter): include this in win32_opengl_window_info? - PixelFormatDesc.cColorBits = Info.ColorBits; - PixelFormatDesc.cAlphaBits = Info.AlphaBits; - PixelFormatDesc.cDepthBits = Info.DepthBits; - PixelFormatDesc.dwLayerMask = PFD_MAIN_PLANE; // TODO(Peter): include this in win32_opengl_window_info? - // - - s32 PixelFormat = ChoosePixelFormat(Window->DeviceContext, &PixelFormatDesc); - if (!PixelFormat) { InvalidCodePath; } // TODO: Log: Choose pixel format failed - if (!SetPixelFormat(Window->DeviceContext, PixelFormat, &PixelFormatDesc)) { InvalidCodePath; } // TODO: Log: Set pixel format failed - } + // Setup pixel format + { + PIXELFORMATDESCRIPTOR PixelFormatDesc = { 0 }; + // TODO: Program seems to work perfectly fine without all other params except dwFlags. + // Can we skip other params for the sake of brevity? + PixelFormatDesc.nSize = sizeof(PIXELFORMATDESCRIPTOR); + PixelFormatDesc.nVersion = 1; + PixelFormatDesc.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER; + PixelFormatDesc.iPixelType = PFD_TYPE_RGBA;// TODO(Peter): include this in win32_opengl_window_info? + PixelFormatDesc.cColorBits = Info.ColorBits; + PixelFormatDesc.cAlphaBits = Info.AlphaBits; + PixelFormatDesc.cDepthBits = Info.DepthBits; + PixelFormatDesc.dwLayerMask = PFD_MAIN_PLANE; // TODO(Peter): include this in win32_opengl_window_info? + // - // Create rendering context - { - // TODO: Create "proper" context? - // https://www.opengl.org/wiki/Creating_an_OpenGL_Context_(WGL)#Proper_Context_Creation - - Info.RenderContext = wglCreateContext(Window->DeviceContext); - wglMakeCurrent(Window->DeviceContext, Info.RenderContext); - - // TODO(Peter): do we want this? - /* - glGetIntegerv(GL_MAJOR_VERSION, ); - glGetIntegerv(GL_MINOR_VERSION, ); - (char*)glGetString(GL_VENDOR); - (char*)glGetString(GL_RENDERER); - */ - } + s32 PixelFormat = ChoosePixelFormat(Window->DeviceContext, &PixelFormatDesc); + if (!PixelFormat) { InvalidCodePath; } // TODO: Log: Choose pixel format failed + if (!SetPixelFormat(Window->DeviceContext, PixelFormat, &PixelFormatDesc)) { InvalidCodePath; } // TODO: Log: Set pixel format failed + } + + // Create rendering context + { + // TODO: Create "proper" context? + // https://www.opengl.org/wiki/Creating_an_OpenGL_Context_(WGL)#Proper_Context_Creation - Window->OpenGLInfo = Info; + Info.RenderContext = wglCreateContext(Window->DeviceContext); + wglMakeCurrent(Window->DeviceContext, Info.RenderContext); + + // TODO(Peter): do we want this? + /* + glGetIntegerv(GL_MAJOR_VERSION, ); + glGetIntegerv(GL_MINOR_VERSION, ); + (char*)glGetString(GL_VENDOR); + (char*)glGetString(GL_RENDERER); + */ + } + + Window->OpenGLInfo = Info; } struct handle_window_event_result { - LRESULT Result; - b32 Handled; + LRESULT Result; + b32 Handled; }; internal void Win32UpdateInputFrameMouseButtonState (input_frame* InputFrame, key_code KeyCode, int Win32VirtualKey) { - InputFrame->KeysDown[KeyCode] = (GetKeyState(Win32VirtualKey) & (1 << 15)) != 0; + InputFrame->KeysDown[KeyCode] = (GetKeyState(Win32VirtualKey) & (1 << 15)) != 0; } internal void Win32UpdateInputFrameMouseState (input_frame* InputFrame) { - Win32UpdateInputFrameMouseButtonState(InputFrame, KeyCode_MouseLeftButton, VK_LBUTTON); - Win32UpdateInputFrameMouseButtonState(InputFrame, KeyCode_MouseMiddleButton, VK_MBUTTON); - Win32UpdateInputFrameMouseButtonState(InputFrame, KeyCode_MouseRightButton, VK_RBUTTON); - // NOTE(Peter): If you decide to support extra mouse buttons, on windows the key codes are - // VK_XBUTTON1 and VK_XBUTTON2 + Win32UpdateInputFrameMouseButtonState(InputFrame, KeyCode_MouseLeftButton, VK_LBUTTON); + Win32UpdateInputFrameMouseButtonState(InputFrame, KeyCode_MouseMiddleButton, VK_MBUTTON); + Win32UpdateInputFrameMouseButtonState(InputFrame, KeyCode_MouseRightButton, VK_RBUTTON); + // NOTE(Peter): If you decide to support extra mouse buttons, on windows the key codes are + // VK_XBUTTON1 and VK_XBUTTON2 } internal void Win32UpdateInputFrameMouseWheelDelta (input_frame* InputFrame, MSG Message) { - int MouseWheel = GET_WHEEL_DELTA_WPARAM(Message.wParam); - InputFrame->MouseScroll = MouseWheel; + int MouseWheel = GET_WHEEL_DELTA_WPARAM(Message.wParam); + InputFrame->MouseScroll = MouseWheel; } internal handle_window_event_result HandleWindowEventUnlessWouldUseDefault (HWND WindowHandle, UINT Msg, WPARAM wParam, LPARAM lParam) { - handle_window_event_result Result = {}; - Result.Handled = false; - - switch (Msg) + handle_window_event_result Result = {}; + Result.Handled = false; + + switch (Msg) + { + case WM_SIZE: { - case WM_SIZE: - { - - Result.Handled = true; - }break; - - case WM_CLOSE: - { - Result.Result = DefWindowProc(WindowHandle, Msg, wParam, lParam); - Result.Handled = true; - }break; - - case WM_DESTROY: - { - GlobalWin32State.Running = false; - Result.Handled = true; - }break; - - case WM_PAINT: - { - PAINTSTRUCT PaintStruct; - HDC DeviceContext; - b32 PaintResult; - - DeviceContext = BeginPaint(WindowHandle, &PaintStruct); - PaintResult = EndPaint(WindowHandle, &PaintStruct); - Result.Handled = true; - }break; - } + + Result.Handled = true; + }break; - return Result; + case WM_CLOSE: + { + Result.Result = DefWindowProc(WindowHandle, Msg, wParam, lParam); + Result.Handled = true; + }break; + + case WM_DESTROY: + { + GlobalWin32State.Running = false; + Result.Handled = true; + }break; + + case WM_PAINT: + { + PAINTSTRUCT PaintStruct; + HDC DeviceContext; + b32 PaintResult; + + DeviceContext = BeginPaint(WindowHandle, &PaintStruct); + PaintResult = EndPaint(WindowHandle, &PaintStruct); + Result.Handled = true; + }break; + } + + return Result; } LRESULT CALLBACK @@ -274,124 +269,124 @@ Win32HandleWindowsEvents ( LPARAM lParam ) { - handle_window_event_result EventResult = HandleWindowEventUnlessWouldUseDefault( - WindowHandle, - Msg, - wParam, - lParam); - - if (!EventResult.Handled) - { - EventResult.Result = DefWindowProc(WindowHandle, Msg, wParam, lParam); - } - - return EventResult.Result; + handle_window_event_result EventResult = HandleWindowEventUnlessWouldUseDefault( + WindowHandle, + Msg, + wParam, + lParam); + + if (!EventResult.Handled) + { + EventResult.Result = DefWindowProc(WindowHandle, Msg, wParam, lParam); + } + + return EventResult.Result; } static key_code Win32GetKeyCode (int Win32VirtualKey, bool NumpadValid, bool TranslateToChar) { - key_code Result = KeyCode_Invalid; + key_code Result = KeyCode_Invalid; + + if (Win32VirtualKey == VK_ESCAPE) { Result = KeyCode_Esc; } + + if (!TranslateToChar) + { + if (Win32VirtualKey == VK_SPACE) { Result = KeyCode_Space; } - if (Win32VirtualKey == VK_ESCAPE) { Result = KeyCode_Esc; } + } + + if (Win32VirtualKey == VK_CAPITAL) { Result = KeyCode_CapsLock; } + else if (Win32VirtualKey == VK_TAB) { Result = KeyCode_Tab; } + else if (Win32VirtualKey == VK_LSHIFT) { Result = KeyCode_LeftShift; } + else if (Win32VirtualKey == VK_RSHIFT) { Result = KeyCode_RightShift; } + else if (Win32VirtualKey == VK_LCONTROL) { Result = KeyCode_LeftCtrl; } + else if (Win32VirtualKey == VK_RCONTROL) { Result = KeyCode_RightCtrl; } + + // TODO(Peter): support the function key? + //else if (Win32VirtualKey == VK_) { Result = KeyCode_Fn; } + + else if (Win32VirtualKey == VK_MENU) { Result = KeyCode_Alt; } + else if (Win32VirtualKey == VK_PRIOR) { Result = KeyCode_PageUp; } + else if (Win32VirtualKey == VK_NEXT) { Result = KeyCode_PageDown; } + else if (Win32VirtualKey == VK_BACK) { Result = KeyCode_Backspace; } + else if (Win32VirtualKey == VK_DELETE) { Result = KeyCode_Delete; } + else if (Win32VirtualKey == VK_RETURN) { Result = KeyCode_Enter; } + + else if (Win32VirtualKey == VK_F1) { Result = KeyCode_F1; } + else if (Win32VirtualKey == VK_F2) { Result = KeyCode_F2; } + else if (Win32VirtualKey == VK_F3) { Result = KeyCode_F3; } + else if (Win32VirtualKey == VK_F4) { Result = KeyCode_F4; } + else if (Win32VirtualKey == VK_F5) { Result = KeyCode_F5; } + else if (Win32VirtualKey == VK_F6) { Result = KeyCode_F6; } + else if (Win32VirtualKey == VK_F7) { Result = KeyCode_F7; } + else if (Win32VirtualKey == VK_F8) { Result = KeyCode_F8; } + else if (Win32VirtualKey == VK_F9) { Result = KeyCode_F9; } + else if (Win32VirtualKey == VK_F10) { Result = KeyCode_F10; } + else if (Win32VirtualKey == VK_F11) { Result = KeyCode_F11; } + else if (Win32VirtualKey == VK_F12) { Result = KeyCode_F12; } + + if (!TranslateToChar) + { + if (Win32VirtualKey == 0x30) { Result = KeyCode_0; } + else if (Win32VirtualKey == 0x31) { Result = KeyCode_1; } + else if (Win32VirtualKey == 0x32) { Result = KeyCode_2; } + else if (Win32VirtualKey == 0x33) { Result = KeyCode_3; } + else if (Win32VirtualKey == 0x34) { Result = KeyCode_4; } + else if (Win32VirtualKey == 0x35) { Result = KeyCode_5; } + else if (Win32VirtualKey == 0x36) { Result = KeyCode_6; } + else if (Win32VirtualKey == 0x37) { Result = KeyCode_7; } + else if (Win32VirtualKey == 0x38) { Result = KeyCode_8; } + else if (Win32VirtualKey == 0x39) { Result = KeyCode_9; } - if (!TranslateToChar) - { - if (Win32VirtualKey == VK_SPACE) { Result = KeyCode_Space; } - - } - - if (Win32VirtualKey == VK_CAPITAL) { Result = KeyCode_CapsLock; } - else if (Win32VirtualKey == VK_TAB) { Result = KeyCode_Tab; } - else if (Win32VirtualKey == VK_LSHIFT) { Result = KeyCode_LeftShift; } - else if (Win32VirtualKey == VK_RSHIFT) { Result = KeyCode_RightShift; } - else if (Win32VirtualKey == VK_LCONTROL) { Result = KeyCode_LeftCtrl; } - else if (Win32VirtualKey == VK_RCONTROL) { Result = KeyCode_RightCtrl; } - - // TODO(Peter): support the function key? - //else if (Win32VirtualKey == VK_) { Result = KeyCode_Fn; } - - else if (Win32VirtualKey == VK_MENU) { Result = KeyCode_Alt; } - else if (Win32VirtualKey == VK_PRIOR) { Result = KeyCode_PageUp; } - else if (Win32VirtualKey == VK_NEXT) { Result = KeyCode_PageDown; } - else if (Win32VirtualKey == VK_BACK) { Result = KeyCode_Backspace; } - else if (Win32VirtualKey == VK_DELETE) { Result = KeyCode_Delete; } - else if (Win32VirtualKey == VK_RETURN) { Result = KeyCode_Enter; } - - else if (Win32VirtualKey == VK_F1) { Result = KeyCode_F1; } - else if (Win32VirtualKey == VK_F2) { Result = KeyCode_F2; } - else if (Win32VirtualKey == VK_F3) { Result = KeyCode_F3; } - else if (Win32VirtualKey == VK_F4) { Result = KeyCode_F4; } - else if (Win32VirtualKey == VK_F5) { Result = KeyCode_F5; } - else if (Win32VirtualKey == VK_F6) { Result = KeyCode_F6; } - else if (Win32VirtualKey == VK_F7) { Result = KeyCode_F7; } - else if (Win32VirtualKey == VK_F8) { Result = KeyCode_F8; } - else if (Win32VirtualKey == VK_F9) { Result = KeyCode_F9; } - else if (Win32VirtualKey == VK_F10) { Result = KeyCode_F10; } - else if (Win32VirtualKey == VK_F11) { Result = KeyCode_F11; } - else if (Win32VirtualKey == VK_F12) { Result = KeyCode_F12; } - - if (!TranslateToChar) - { - if (Win32VirtualKey == 0x30) { Result = KeyCode_0; } - else if (Win32VirtualKey == 0x31) { Result = KeyCode_1; } - else if (Win32VirtualKey == 0x32) { Result = KeyCode_2; } - else if (Win32VirtualKey == 0x33) { Result = KeyCode_3; } - else if (Win32VirtualKey == 0x34) { Result = KeyCode_4; } - else if (Win32VirtualKey == 0x35) { Result = KeyCode_5; } - else if (Win32VirtualKey == 0x36) { Result = KeyCode_6; } - else if (Win32VirtualKey == 0x37) { Result = KeyCode_7; } - else if (Win32VirtualKey == 0x38) { Result = KeyCode_8; } - else if (Win32VirtualKey == 0x39) { Result = KeyCode_9; } - - else if (Win32VirtualKey == 0x41) { Result = KeyCode_A; } - else if (Win32VirtualKey == 0x42) { Result = KeyCode_B; } - else if (Win32VirtualKey == 0x43) { Result = KeyCode_C; } - else if (Win32VirtualKey == 0x44) { Result = KeyCode_D; } - else if (Win32VirtualKey == 0x45) { Result = KeyCode_E; } - else if (Win32VirtualKey == 0x46) { Result = KeyCode_F; } - else if (Win32VirtualKey == 0x47) { Result = KeyCode_G; } - else if (Win32VirtualKey == 0x48) { Result = KeyCode_H; } - else if (Win32VirtualKey == 0x49) { Result = KeyCode_I; } - else if (Win32VirtualKey == 0x4A) { Result = KeyCode_J; } - else if (Win32VirtualKey == 0x4B) { Result = KeyCode_K; } - else if (Win32VirtualKey == 0x4C) { Result = KeyCode_L; } - else if (Win32VirtualKey == 0x4D) { Result = KeyCode_M; } - else if (Win32VirtualKey == 0x4E) { Result = KeyCode_N; } - else if (Win32VirtualKey == 0x4F) { Result = KeyCode_O; } - else if (Win32VirtualKey == 0x50) { Result = KeyCode_P; } - else if (Win32VirtualKey == 0x51) { Result = KeyCode_Q; } - else if (Win32VirtualKey == 0x52) { Result = KeyCode_R; } - else if (Win32VirtualKey == 0x53) { Result = KeyCode_S; } - else if (Win32VirtualKey == 0x54) { Result = KeyCode_T; } - else if (Win32VirtualKey == 0x55) { Result = KeyCode_U; } - else if (Win32VirtualKey == 0x56) { Result = KeyCode_V; } - else if (Win32VirtualKey == 0x57) { Result = KeyCode_W; } - else if (Win32VirtualKey == 0x58) { Result = KeyCode_X; } - else if (Win32VirtualKey == 0x59) { Result = KeyCode_Y; } - else if (Win32VirtualKey == 0x5A) { Result = KeyCode_Z; } - } - - if (NumpadValid) - { - if (Win32VirtualKey == VK_NUMPAD0) { Result = KeyCode_Num0; } - else if (Win32VirtualKey == VK_NUMPAD1) { Result = KeyCode_Num1; } - else if (Win32VirtualKey == VK_NUMPAD2) { Result = KeyCode_Num2; } - else if (Win32VirtualKey == VK_NUMPAD3) { Result = KeyCode_Num3; } - else if (Win32VirtualKey == VK_NUMPAD4) { Result = KeyCode_Num4; } - else if (Win32VirtualKey == VK_NUMPAD5) { Result = KeyCode_Num5; } - else if (Win32VirtualKey == VK_NUMPAD6) { Result = KeyCode_Num6; } - else if (Win32VirtualKey == VK_NUMPAD7) { Result = KeyCode_Num7; } - else if (Win32VirtualKey == VK_NUMPAD8) { Result = KeyCode_Num8; } - else if (Win32VirtualKey == VK_NUMPAD9) { Result = KeyCode_Num9; } - } - - if (Win32VirtualKey == VK_UP) { Result = KeyCode_UpArrow; } - else if (Win32VirtualKey == VK_DOWN) { Result = KeyCode_DownArrow; } - else if (Win32VirtualKey == VK_LEFT) { Result = KeyCode_LeftArrow; } - else if (Win32VirtualKey == VK_RIGHT) { Result = KeyCode_RightArrow; } - - return Result; + else if (Win32VirtualKey == 0x41) { Result = KeyCode_A; } + else if (Win32VirtualKey == 0x42) { Result = KeyCode_B; } + else if (Win32VirtualKey == 0x43) { Result = KeyCode_C; } + else if (Win32VirtualKey == 0x44) { Result = KeyCode_D; } + else if (Win32VirtualKey == 0x45) { Result = KeyCode_E; } + else if (Win32VirtualKey == 0x46) { Result = KeyCode_F; } + else if (Win32VirtualKey == 0x47) { Result = KeyCode_G; } + else if (Win32VirtualKey == 0x48) { Result = KeyCode_H; } + else if (Win32VirtualKey == 0x49) { Result = KeyCode_I; } + else if (Win32VirtualKey == 0x4A) { Result = KeyCode_J; } + else if (Win32VirtualKey == 0x4B) { Result = KeyCode_K; } + else if (Win32VirtualKey == 0x4C) { Result = KeyCode_L; } + else if (Win32VirtualKey == 0x4D) { Result = KeyCode_M; } + else if (Win32VirtualKey == 0x4E) { Result = KeyCode_N; } + else if (Win32VirtualKey == 0x4F) { Result = KeyCode_O; } + else if (Win32VirtualKey == 0x50) { Result = KeyCode_P; } + else if (Win32VirtualKey == 0x51) { Result = KeyCode_Q; } + else if (Win32VirtualKey == 0x52) { Result = KeyCode_R; } + else if (Win32VirtualKey == 0x53) { Result = KeyCode_S; } + else if (Win32VirtualKey == 0x54) { Result = KeyCode_T; } + else if (Win32VirtualKey == 0x55) { Result = KeyCode_U; } + else if (Win32VirtualKey == 0x56) { Result = KeyCode_V; } + else if (Win32VirtualKey == 0x57) { Result = KeyCode_W; } + else if (Win32VirtualKey == 0x58) { Result = KeyCode_X; } + else if (Win32VirtualKey == 0x59) { Result = KeyCode_Y; } + else if (Win32VirtualKey == 0x5A) { Result = KeyCode_Z; } + } + + if (NumpadValid) + { + if (Win32VirtualKey == VK_NUMPAD0) { Result = KeyCode_Num0; } + else if (Win32VirtualKey == VK_NUMPAD1) { Result = KeyCode_Num1; } + else if (Win32VirtualKey == VK_NUMPAD2) { Result = KeyCode_Num2; } + else if (Win32VirtualKey == VK_NUMPAD3) { Result = KeyCode_Num3; } + else if (Win32VirtualKey == VK_NUMPAD4) { Result = KeyCode_Num4; } + else if (Win32VirtualKey == VK_NUMPAD5) { Result = KeyCode_Num5; } + else if (Win32VirtualKey == VK_NUMPAD6) { Result = KeyCode_Num6; } + else if (Win32VirtualKey == VK_NUMPAD7) { Result = KeyCode_Num7; } + else if (Win32VirtualKey == VK_NUMPAD8) { Result = KeyCode_Num8; } + else if (Win32VirtualKey == VK_NUMPAD9) { Result = KeyCode_Num9; } + } + + if (Win32VirtualKey == VK_UP) { Result = KeyCode_UpArrow; } + else if (Win32VirtualKey == VK_DOWN) { Result = KeyCode_DownArrow; } + else if (Win32VirtualKey == VK_LEFT) { Result = KeyCode_LeftArrow; } + else if (Win32VirtualKey == VK_RIGHT) { Result = KeyCode_RightArrow; } + + return Result; } internal handle_window_msg_result @@ -399,173 +394,173 @@ HandleWindowsMessage ( HWND WindowHandle, MSG Message) { - handle_window_msg_result Result = {}; - Result.NeedsUpdate = 0; - - switch (Message.message) + handle_window_msg_result Result = {}; + Result.NeedsUpdate = 0; + + switch (Message.message) + { + case WM_HOTKEY: { - case WM_HOTKEY: - { - }break; - - case WM_MOUSEWHEEL: - { - int MouseWheel = GET_WHEEL_DELTA_WPARAM(Message.wParam); - /* - Input.New->MouseScroll = MouseWheel; - Result.NeedsUpdate = true; - */ - }break; - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MBUTTONDOWN: - case WM_MBUTTONUP: - case WM_RBUTTONDOWN: - case WM_RBUTTONUP: - { - /* - Input.New->KeyStates[KeyCode_MouseLeftButton] = (GetKeyState(VK_LBUTTON) & (1 << 15)) != 0; - Input.New->KeyStates[KeyCode_MouseMiddleButton] = (GetKeyState(VK_MBUTTON) & (1 << 15)) != 0; - Input.New->KeyStates[KeyCode_MouseRightButton] = (GetKeyState(VK_RBUTTON) & (1 << 15)) != 0; - // NOTE(Peter): If you decide to support extra mouse buttons, on windows the key codes are - // VK_XBUTTON1 and VK_XBUTTON2 - - if (KeyTransitionedDown(KeyCode_MouseLeftButton, Input)) - { - Input.MouseDownX = Input.New->MouseX; - Input.MouseDownY = Input.New->MouseY; - } - Result.NeedsUpdate = true;*/ - }break; - - case WM_MOUSEMOVE: - { - POINT MousePos; - GetCursorPos(&MousePos); - ScreenToClient(WindowHandle, &MousePos); - - /* - Input.New->MouseX = MousePos.x; - Input.New->MouseY = App.WindowHeight - MousePos.y; - - Result.NeedsUpdate = true; - */ - }break; - - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - case WM_KEYDOWN: - case WM_KEYUP: - { - int VirtualKey = (int)Message.wParam; - bool KeyDown = (Message.lParam & (1 << 31)) == 0; - int KeyIndex = Win32GetKeyCode(VirtualKey, true, true); - /* - if (KeyIndex >= 0) - { - DEBUG_GET_MESSAGE_NAME(Result.MessageType, "WM_KEYEvent "); - Input.New->KeyStates[KeyIndex] = KeyDown; - Result.NeedsUpdate = true; - } - else - { - if (Input.TranslateInputToCharValues && KeyDown) - { - // NOTE(Peter): Took this out b/c we're translating the WM_CHAR messages - // in the message pump, and if we do it here as well, character producing - // key messages get put on the message queue twice - TranslateMessage(&Message); - DispatchMessage(&Message); - } - else - { - DEBUG_GET_MESSAGE_NAME(Result.MessageType, "WM_KEYEvent "); - // NOTE(Peter): This is so that when you lift up a key that was generating a WM_CHAR, - // the app still has a chance to respond to it. - Result.NeedsUpdate = true; - } - } - */ - }break; - - case WM_CHAR: - { - /* - char TranslatedChar = (char)Message.wParam; - int KeyIndex = GetKeyIndexFromChar(TranslatedChar); - - if (KeyIndex >= 0) - { - // NOTE(Peter): Always setting this to true becuase windows is stupid and doesn't - // pass the press/release bit through correctly. So now the KEYDOWN/KEYUP Messages above - // only translate the message to a WM_CHAR message if its a key down. Since we clear all - // keystates to false at the beginning of an input frame, this will make transitions - // get registered correctly. - Input.New->KeyStates[KeyIndex] = true; - Result.NeedsUpdate = true; - } - else - { - printf("Translated Char Not Recognized: %c\n", TranslatedChar); - } - */ - }break; - - default: - { - TranslateMessage(&Message); - DispatchMessage(&Message); - }break; - } + }break; - return Result; + case WM_MOUSEWHEEL: + { + int MouseWheel = GET_WHEEL_DELTA_WPARAM(Message.wParam); + /* + Input.New->MouseScroll = MouseWheel; + Result.NeedsUpdate = true; + */ + }break; + + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + case WM_MBUTTONDOWN: + case WM_MBUTTONUP: + case WM_RBUTTONDOWN: + case WM_RBUTTONUP: + { + /* + Input.New->KeyStates[KeyCode_MouseLeftButton] = (GetKeyState(VK_LBUTTON) & (1 << 15)) != 0; + Input.New->KeyStates[KeyCode_MouseMiddleButton] = (GetKeyState(VK_MBUTTON) & (1 << 15)) != 0; + Input.New->KeyStates[KeyCode_MouseRightButton] = (GetKeyState(VK_RBUTTON) & (1 << 15)) != 0; + // NOTE(Peter): If you decide to support extra mouse buttons, on windows the key codes are + // VK_XBUTTON1 and VK_XBUTTON2 + + if (KeyTransitionedDown(KeyCode_MouseLeftButton, Input)) + { + Input.MouseDownX = Input.New->MouseX; + Input.MouseDownY = Input.New->MouseY; + } + Result.NeedsUpdate = true;*/ + }break; + + case WM_MOUSEMOVE: + { + POINT MousePos; + GetCursorPos(&MousePos); + ScreenToClient(WindowHandle, &MousePos); + + /* + Input.New->MouseX = MousePos.x; + Input.New->MouseY = App.WindowHeight - MousePos.y; + + Result.NeedsUpdate = true; + */ + }break; + + case WM_SYSKEYDOWN: + case WM_SYSKEYUP: + case WM_KEYDOWN: + case WM_KEYUP: + { + int VirtualKey = (int)Message.wParam; + bool KeyDown = (Message.lParam & (1 << 31)) == 0; + int KeyIndex = Win32GetKeyCode(VirtualKey, true, true); + /* + if (KeyIndex >= 0) + { + DEBUG_GET_MESSAGE_NAME(Result.MessageType, "WM_KEYEvent "); + Input.New->KeyStates[KeyIndex] = KeyDown; + Result.NeedsUpdate = true; + } + else + { + if (Input.TranslateInputToCharValues && KeyDown) + { + // NOTE(Peter): Took this out b/c we're translating the WM_CHAR messages + // in the message pump, and if we do it here as well, character producing + // key messages get put on the message queue twice + TranslateMessage(&Message); + DispatchMessage(&Message); + } + else + { + DEBUG_GET_MESSAGE_NAME(Result.MessageType, "WM_KEYEvent "); + // NOTE(Peter): This is so that when you lift up a key that was generating a WM_CHAR, + // the app still has a chance to respond to it. + Result.NeedsUpdate = true; + } + } + */ + }break; + + case WM_CHAR: + { + /* + char TranslatedChar = (char)Message.wParam; + int KeyIndex = GetKeyIndexFromChar(TranslatedChar); + + if (KeyIndex >= 0) + { + // NOTE(Peter): Always setting this to true becuase windows is stupid and doesn't + // pass the press/release bit through correctly. So now the KEYDOWN/KEYUP Messages above + // only translate the message to a WM_CHAR message if its a key down. Since we clear all + // keystates to false at the beginning of an input frame, this will make transitions + // get registered correctly. + Input.New->KeyStates[KeyIndex] = true; + Result.NeedsUpdate = true; + } + else + { + printf("Translated Char Not Recognized: %c\n", TranslatedChar); + } + */ + }break; + + default: + { + TranslateMessage(&Message); + DispatchMessage(&Message); + }break; + } + + return Result; } internal void Win32UpdateWindowDimension(window* Window) { - RECT ClientRect; - GetClientRect(Window->Handle, &ClientRect); - Window->Width = ClientRect.right - ClientRect.left; - Window->Height = ClientRect.bottom - ClientRect.top; + RECT ClientRect; + GetClientRect(Window->Handle, &ClientRect); + Window->Width = ClientRect.right - ClientRect.left; + Window->Height = ClientRect.bottom - ClientRect.top; } internal void Win32ResizeDIBSection(win32_offscreen_buffer *Win32Buffer, int Width, int Height) { - if(Win32Buffer->Buffer.Memory) - { - VirtualFree(Win32Buffer->Buffer.Memory, 0, MEM_RELEASE); - } - - Win32Buffer->Buffer.Width = Width; - Win32Buffer->Buffer.Height = Height; - - int BytesPerPixel = 4; - Win32Buffer->Buffer.BytesPerPixel = BytesPerPixel; - - Win32Buffer->Info.bmiHeader.biSize = sizeof(Win32Buffer->Info.bmiHeader); - Win32Buffer->Info.bmiHeader.biWidth = Win32Buffer->Buffer.Width; - Win32Buffer->Info.bmiHeader.biHeight = -Win32Buffer->Buffer.Height; // Top down, not bottom up - Win32Buffer->Info.bmiHeader.biPlanes = 1; - Win32Buffer->Info.bmiHeader.biBitCount = 32; - Win32Buffer->Info.bmiHeader.biCompression = BI_RGB; - - int BitmapMemorySize = (Win32Buffer->Buffer.Width * Win32Buffer->Buffer.Height)*BytesPerPixel; - Win32Buffer->Buffer.Memory = (u8*)VirtualAlloc(0, BitmapMemorySize, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); - Win32Buffer->Buffer.Pitch = Width*BytesPerPixel; + if(Win32Buffer->Buffer.Memory) + { + VirtualFree(Win32Buffer->Buffer.Memory, 0, MEM_RELEASE); + } + + Win32Buffer->Buffer.Width = Width; + Win32Buffer->Buffer.Height = Height; + + int BytesPerPixel = 4; + Win32Buffer->Buffer.BytesPerPixel = BytesPerPixel; + + Win32Buffer->Info.bmiHeader.biSize = sizeof(Win32Buffer->Info.bmiHeader); + Win32Buffer->Info.bmiHeader.biWidth = Win32Buffer->Buffer.Width; + Win32Buffer->Info.bmiHeader.biHeight = -Win32Buffer->Buffer.Height; // Top down, not bottom up + Win32Buffer->Info.bmiHeader.biPlanes = 1; + Win32Buffer->Info.bmiHeader.biBitCount = 32; + Win32Buffer->Info.bmiHeader.biCompression = BI_RGB; + + int BitmapMemorySize = (Win32Buffer->Buffer.Width * Win32Buffer->Buffer.Height)*BytesPerPixel; + Win32Buffer->Buffer.Memory = (u8*)VirtualAlloc(0, BitmapMemorySize, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + Win32Buffer->Buffer.Pitch = Width*BytesPerPixel; } internal void Win32DisplayBufferInWindow(win32_offscreen_buffer* Win32Buffer, window Window) { - StretchDIBits(Window.DeviceContext, - 0, 0, Win32Buffer->Buffer.Width, Win32Buffer->Buffer.Height, - 0, 0, Win32Buffer->Buffer.Width, Win32Buffer->Buffer.Height, - Win32Buffer->Buffer.Memory, - &Win32Buffer->Info, - DIB_RGB_COLORS, SRCCOPY); + StretchDIBits(Window.DeviceContext, + 0, 0, Win32Buffer->Buffer.Width, Win32Buffer->Buffer.Height, + 0, 0, Win32Buffer->Buffer.Width, Win32Buffer->Buffer.Height, + Win32Buffer->Buffer.Memory, + &Win32Buffer->Info, + DIB_RGB_COLORS, SRCCOPY); } ///////////////////////////////////////// @@ -581,20 +576,20 @@ OpenGLRenderTriBuffer (u8* Vertecies, s32 VertexElements, u8* Colors, s32 ColorsElements, s32 TriCount) { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(VertexElements, GL_FLOAT, VertexElements * sizeof(r32), Vertecies); - - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(UVElements, GL_FLOAT, UVElements * sizeof(r32), UVs); - - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(ColorsElements, GL_FLOAT, ColorsElements * sizeof(r32), Colors); - - glDrawArrays(GL_TRIANGLES, 0, TriCount); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(VertexElements, GL_FLOAT, VertexElements * sizeof(r32), Vertecies); + + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(UVElements, GL_FLOAT, UVElements * sizeof(r32), UVs); + + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(ColorsElements, GL_FLOAT, ColorsElements * sizeof(r32), Colors); + + glDrawArrays(GL_TRIANGLES, 0, TriCount); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); } internal void @@ -602,21 +597,21 @@ OpenGLDraw3DTri (v4 P0, v4 P1, v4 P2, v2 UV0, v2 UV1, v2 UV2, v4 C0, v4 C1, v4 C2) { - glBegin(GL_TRIANGLES); - - glTexCoord2f(UV0.x, UV0.y); - glColor4f(C0.r, C0.g, C0.b, C0.a); - glVertex4f(P0.x, P0.y, P0.z, P0.w); - - glTexCoord2f(UV1.x, UV1.y); - glColor4f(C1.r, C1.g, C1.b, C1.a); - glVertex4f(P1.x, P1.y, P1.z, P1.w); - - glTexCoord2f(UV2.x, UV2.y); - glColor4f(C2.r, C2.g, C2.b, C2.a); - glVertex4f(P2.x, P2.y, P2.z, P2.w); - - glEnd(); + glBegin(GL_TRIANGLES); + + glTexCoord2f(UV0.x, UV0.y); + glColor4f(C0.r, C0.g, C0.b, C0.a); + glVertex4f(P0.x, P0.y, P0.z, P0.w); + + glTexCoord2f(UV1.x, UV1.y); + glColor4f(C1.r, C1.g, C1.b, C1.a); + glVertex4f(P1.x, P1.y, P1.z, P1.w); + + glTexCoord2f(UV2.x, UV2.y); + glColor4f(C2.r, C2.g, C2.b, C2.a); + glVertex4f(P2.x, P2.y, P2.z, P2.w); + + glEnd(); } internal void @@ -624,72 +619,72 @@ OpenGLDraw2DTri (v2 P0, v2 P1, v2 P2, v2 UV0, v2 UV1, v2 UV2, v4 C0, v4 C1, v4 C2) { - glBegin(GL_TRIANGLES); - - glTexCoord2f(UV0.x, UV0.y); - glColor4f(C0.r, C0.g, C0.b, C0.a); - glVertex2f(P0.x, P0.y); - - glTexCoord2f(UV1.x, UV1.y); - glColor4f(C1.r, C1.g, C1.b, C1.a); - glVertex2f(P1.x, P1.y); - - glTexCoord2f(UV2.x, UV2.y); - glColor4f(C2.r, C2.g, C2.b, C2.a); - glVertex2f(P2.x, P2.y); - - glEnd(); + glBegin(GL_TRIANGLES); + + glTexCoord2f(UV0.x, UV0.y); + glColor4f(C0.r, C0.g, C0.b, C0.a); + glVertex2f(P0.x, P0.y); + + glTexCoord2f(UV1.x, UV1.y); + glColor4f(C1.r, C1.g, C1.b, C1.a); + glVertex2f(P1.x, P1.y); + + glTexCoord2f(UV2.x, UV2.y); + glColor4f(C2.r, C2.g, C2.b, C2.a); + glVertex2f(P2.x, P2.y); + + glEnd(); } internal void LoadModelView (r32 Matrix[16]) { - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(Matrix); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(Matrix); } internal void LoadProjection (r32 Matrix[16]) { - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(Matrix); + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(Matrix); } internal void ClearRenderBuffer () { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } s32 NextTextureHandle = 1; internal s32 SubmitTexture (u8* Memory, s32 Width, s32 Height) { - s32 TextureHandle = NextTextureHandle++; - glBindTexture(GL_TEXTURE_2D, TextureHandle); - glTexImage2D(GL_TEXTURE_2D, - 0, // mip map level - GL_RGBA8, - Width, - Height, - 0, // border - GL_RGBA, - GL_UNSIGNED_BYTE, - Memory); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexParameteri(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - return TextureHandle; + s32 TextureHandle = NextTextureHandle++; + glBindTexture(GL_TEXTURE_2D, TextureHandle); + glTexImage2D(GL_TEXTURE_2D, + 0, // mip map level + GL_RGBA8, + Width, + Height, + 0, // border + GL_RGBA, + GL_UNSIGNED_BYTE, + Memory); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + return TextureHandle; } internal void BindTexture (s32 TextureHandle) { - glBindTexture(GL_TEXTURE_2D, TextureHandle); + glBindTexture(GL_TEXTURE_2D, TextureHandle); } #define GS_WIN32_CPP diff --git a/src/sculpture_gen/gen_blumen_lumen.cpp b/src/sculpture_gen/gen_blumen_lumen.cpp index dce5c4a..9edceb6 100644 --- a/src/sculpture_gen/gen_blumen_lumen.cpp +++ b/src/sculpture_gen/gen_blumen_lumen.cpp @@ -10,6 +10,9 @@ #include "../gs_libs/gs_types.h" #include "../gs_libs/gs_types.cpp" +#include "../app/engine/foldhaus_log.h" +global log_buffer* GlobalLogBuffer; + #include "../app/platform_win32/win32_foldhaus_utils.h" #include "../app/platform_win32/win32_foldhaus_memory.h" #include "../app/platform_win32/win32_foldhaus_fileio.h" @@ -26,6 +29,11 @@ typedef struct u32 SubsegmentsCount; u32 SubsegmentLeds; + // SACN + u32 SACNUniverseStart; + u32 SACNChannelStart; + + // UART // Only one of these two values is needed. // If ChannelsArray != 0, then it will be used, and assumed to // have SegmentsCount values @@ -58,7 +66,8 @@ BuildLoop(gs_string* OutputBuffer, loop_desc Desc) Channel = Desc.ChannelStart + i; } - WriteLedStripOpen(OutputBuffer, Channel, Desc.ComPort); + WriteLedStripOpen(OutputBuffer, Channel, Desc.ComPort, + Desc.SACNUniverseStart, Desc.SACNChannelStart); WriteSegmentSequenceOpen(OutputBuffer, Desc.SubsegmentsCount); for (u32 j = 0; j < Desc.SubsegmentsCount; j++) @@ -94,6 +103,13 @@ typedef struct v3 Pos; char* ComPort; char* FlowerTagValue; + + // SACN + u32 SACNStemInnerStartUniverse; + u32 SACNStemOuterStartUniverse; + u32 SACNFlowerStemStartUniverse; + + // UART u32* StemChannels; u32* BloomOuterChannels; u32* BloomInnerChannels; @@ -106,12 +122,15 @@ BuildFlower(gs_string* OutputBuffer, flower_desc Desc) #if 1 // the bloom stem inner loop_desc BloomStemInner = {}; - BloomStemInner.CenterStart = v3{0, 1.4f, 0} + Desc.Pos; - BloomStemInner.CenterEnd = v3{0, .9f, 0} + Desc.Pos; + BloomStemInner.CenterStart = v3{0, 1.4f, 0}; + BloomStemInner.CenterEnd = v3{0, .9f, 0}; BloomStemInner.Radius = .05f; - BloomStemInner.SegmentsCount = 6; + //BloomStemInner.SegmentsCount = 6; + BloomStemInner.SegmentsCount = 1; BloomStemInner.SubsegmentsCount = 3; BloomStemInner.SubsegmentLeds = 35; + BloomStemInner.SACNUniverseStart = Desc.SACNStemInnerStartUniverse; + BloomStemInner.SACNChannelStart = 1; BloomStemInner.ChannelsArray = Desc.BloomInnerChannels; BloomStemInner.ComPort = Desc.ComPort; BloomStemInner.SectionTagValue = "inner_bloom"; @@ -120,12 +139,15 @@ BuildFlower(gs_string* OutputBuffer, flower_desc Desc) // the bloom stem outer loop_desc BloomStemOuter = {}; - BloomStemOuter.CenterStart = v3{0, .5f, 0} + Desc.Pos; - BloomStemOuter.CenterEnd = v3{0, .9f, 0} + Desc.Pos; + BloomStemOuter.CenterStart = v3{0, .5f, 0}; + BloomStemOuter.CenterEnd = v3{0, .9f, 0}; BloomStemOuter.Radius = .07f; - BloomStemOuter.SegmentsCount = 9; + //BloomStemOuter.SegmentsCount = 9; + BloomStemOuter.SegmentsCount = 1; BloomStemOuter.SubsegmentsCount = 3; BloomStemOuter.SubsegmentLeds = 41; + BloomStemOuter.SACNUniverseStart = Desc.SACNStemOuterStartUniverse; + BloomStemOuter.SACNChannelStart = 1; BloomStemOuter.ChannelsArray = Desc.BloomOuterChannels; BloomStemOuter.ComPort = Desc.ComPort; BloomStemOuter.SectionTagValue = "outer_bloom"; @@ -136,12 +158,15 @@ BuildFlower(gs_string* OutputBuffer, flower_desc Desc) #if 1 // the flower stem loop_desc FlowerStem = {}; - FlowerStem.CenterStart = v3{0, -1.5f, 0} + Desc.Pos; - FlowerStem.CenterEnd = v3{0, .5f, 0} + Desc.Pos; + FlowerStem.CenterStart = v3{0, .5f, 0}; + FlowerStem.CenterEnd = v3{0, -1.5f, 0}; FlowerStem.Radius = .05f; - FlowerStem.SegmentsCount = 6; + //FlowerStem.SegmentsCount = 6; + FlowerStem.SegmentsCount = 1; FlowerStem.SubsegmentsCount = 1; FlowerStem.SubsegmentLeds = 300; + FlowerStem.SACNUniverseStart = Desc.SACNFlowerStemStartUniverse; + FlowerStem.SACNChannelStart = 1; FlowerStem.ChannelsArray = Desc.StemChannels; FlowerStem.ComPort = Desc.ComPort; FlowerStem.SectionTagValue = "stem"; @@ -174,51 +199,102 @@ FlowerStripToChannel(u8 Flower, u8 Channel) int main(int ArgCount, char** Args) { gs_thread_context Ctx = Win32CreateThreadContext(); + GlobalLogBuffer = PushStruct(Ctx.Transient, log_buffer); + *GlobalLogBuffer = Log_Init(Ctx.Transient, 32); - gs_string OutputBuffer = PushString(Ctx.Transient, MB(4)); + gs_string OutputBuffer0 = PushString(Ctx.Transient, MB(4)); + gs_string OutputBuffer1 = PushString(Ctx.Transient, MB(4)); + gs_string OutputBuffer2 = PushString(Ctx.Transient, MB(4)); - WriteAssemblyUARTOpen(&OutputBuffer, - "Blumen Lumen - Silver Spring", + u32 StripCount = 3; // used to be 21 +#if 0 + WriteAssemblyUARTOpen(&OutputBuffer0, + "Blumen Lumen - Silver Spring - 00", + 100, + v3{-1, 0, 0}, + StripCount, + ""); + WriteAssemblyUARTOpen(&OutputBuffer1, + "Blumen Lumen - Silver Spring - 01", 100, v3{0, 0, 0}, - 63, + StripCount, ""); + WriteAssemblyUARTOpen(&OutputBuffer2, + "Blumen Lumen - Silver Spring - 02", + 100, + v3{1, 0, 0}, + StripCount, + ""); +#else + WriteAssemblySACNOpen(&OutputBuffer0, + "Blumen Lumen - Silver Spring - 00", + 100, + v3{-1, 0, 0}, + StripCount); + WriteAssemblySACNOpen(&OutputBuffer1, + "Blumen Lumen - Silver Spring - 01", + 100, + v3{0, 0, 0}, + StripCount); + WriteAssemblySACNOpen(&OutputBuffer2, + "Blumen Lumen - Silver Spring - 02", + 100, + v3{1, 0, 0}, + StripCount); +#endif - u32 StripCount = 0; + u32 StripCountOut = 0; u32 StemChannels[] = { FSC(2, 1), FSC(2, 2), FSC(2, 3), FSC(2, 4), FSC(2, 5), FSC(2, 6) }; u32 BloomOuterChannels[] = { FSC(1, 0), FSC(1, 1), FSC(1, 2), FSC(1, 3), FSC(1, 4), FSC(1, 5), FSC(1, 6), FSC(1, 7), FSC(2, 0) }; u32 BloomInnerChannels[] = { FSC(0, 0), FSC(0, 1), FSC(0, 2), FSC(0, 3), FSC(0, 4), FSC(0, 5) }; flower_desc F0 = {}; - F0.Pos = v3{-1, 0, 0}; - F0.ComPort = "\\\\.\\COM4"; + F0.Pos = v3{0, 0, 0}; + F0.ComPort = "\\\\.\\COM11"; F0.FlowerTagValue = "left"; + F0.SACNStemInnerStartUniverse = 4; + F0.SACNStemOuterStartUniverse = 3; + F0.SACNFlowerStemStartUniverse = 1; F0.StemChannels = StemChannels; F0.BloomOuterChannels = BloomOuterChannels; F0.BloomInnerChannels = BloomInnerChannels; - StripCount += BuildFlower(&OutputBuffer, F0); + StripCountOut += BuildFlower(&OutputBuffer0, F0); flower_desc F1 = {}; F1.Pos = v3{0, 0, 0}; - F1.ComPort = "\\\\.\\COM5"; + F1.ComPort = "\\\\.\\COM12"; F1.FlowerTagValue = "center"; + F1.SACNStemInnerStartUniverse = 9; + F1.SACNStemOuterStartUniverse = 8; + F1.SACNFlowerStemStartUniverse = 6; F1.StemChannels = StemChannels; F1.BloomInnerChannels = BloomInnerChannels; F1.BloomOuterChannels = BloomOuterChannels; - StripCount += BuildFlower(&OutputBuffer, F1); + StripCountOut += BuildFlower(&OutputBuffer1, F1); flower_desc F2 = {}; - F2.Pos = v3{1, 0, 0}; + F2.Pos = v3{0, 0, 0}; F2.ComPort = "\\\\.\\COM6"; F2.FlowerTagValue = "right"; + F2.SACNStemInnerStartUniverse = 14; + F2.SACNStemOuterStartUniverse = 13; + F2.SACNFlowerStemStartUniverse = 11; F2.StemChannels = StemChannels; F2.BloomInnerChannels = BloomInnerChannels; F2.BloomOuterChannels = BloomOuterChannels; - StripCount += BuildFlower(&OutputBuffer, F2); + StripCountOut += BuildFlower(&OutputBuffer2, F2); - printf("%.*s\n", (u32)OutputBuffer.Length, OutputBuffer.Str); + WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_one.fold"), StringToData(OutputBuffer0)); + WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_two.fold"), StringToData(OutputBuffer1)); + WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_three.fold"), StringToData(OutputBuffer2)); + + //printf("%.*s\n", (u32)OutputBuffer.Length, OutputBuffer.Str); //printf("%d\n", StripCount); + + + return 0; } diff --git a/src/sculpture_gen/sculpture_gen.h b/src/sculpture_gen/sculpture_gen.h index bbba18c..6336f46 100644 --- a/src/sculpture_gen/sculpture_gen.h +++ b/src/sculpture_gen/sculpture_gen.h @@ -8,87 +8,109 @@ internal void WriteIndented(gs_string* Buffer, u32 Indent, char* Format, ...) { - va_list Args; - va_start(Args, Format); - - for (u32 i = 0; i < Indent; i++) - { - OutChar(Buffer, '\t'); - } - - PrintFArgsList(Buffer, Format, Args); - va_end(Args); + va_list Args; + va_start(Args, Format); + + for (u32 i = 0; i < Indent; i++) + { + OutChar(Buffer, '\t'); + } + + PrintFArgsList(Buffer, Format, Args); + va_end(Args); +} + +internal void +WriteAssemblyCommonOpen(gs_string* Buffer, char* Name, u32 Scale, v3 Center, u32 StripCount) +{ + WriteIndented(Buffer, 0, "assembly_name: \"%s\";\n", Name); + WriteIndented(Buffer, 0, "assembly_scale: %d;\n", Scale); + WriteIndented(Buffer, 0, "assembly_center: (%f, %f, %f);\n", Center.x, Center.y, Center.z); + WriteIndented(Buffer, 0, "led_strip_count: %d;\n", StripCount); } internal void WriteAssemblyUARTOpen(gs_string* Buffer, char* Name, u32 Scale, v3 Center, u32 StripCount, char* ComPort) { - WriteIndented(Buffer, 0, "assembly_name: \"%s\";\n", Name); - WriteIndented(Buffer, 0, "assembly_scale: %d;\n", Scale); - WriteIndented(Buffer, 0, "assembly_center: (%f, %f, %f);\n", Center.x, Center.y, Center.z); - WriteIndented(Buffer, 0, "led_strip_count: %d;\n", StripCount); - WriteIndented(Buffer, 0, "output_mode: \"UART\";\n"); - - if (ComPort) - { - WriteIndented(Buffer, 0, "com_port: \"%s\";\n", ComPort); - } + WriteAssemblyCommonOpen(Buffer, Name, Scale, Center, StripCount); + WriteIndented(Buffer, 0, "output_mode: \"UART\";\n"); + + if (ComPort) + { + WriteIndented(Buffer, 0, "com_port: \"%s\";\n", ComPort); + } } internal void -WriteLedStripOpen(gs_string* Buffer, u32 Channel, char* ComPort) +WriteAssemblySACNOpen(gs_string* Buffer, char* Name, u32 Scale, v3 Center, u32 StripCount) { - WriteIndented(Buffer, 0, "led_strip:\n{\n"); - WriteIndented(Buffer, 1, "output_uart: {\n"); - WriteIndented(Buffer, 2, "channel: %d;\n", Channel); - WriteIndented(Buffer, 2, "com_port: \"%s\";\n", ComPort); - WriteIndented(Buffer, 1, "};\n\n"); + WriteAssemblyCommonOpen(Buffer, Name, Scale, Center, StripCount); + WriteIndented(Buffer, 0, "output_mode: \"SACN\";\n"); +} + +internal void +WriteLedStripOpen(gs_string* Buffer, u32 UARTChannel, char* UARTComPort, u32 SACNStartUniverse, u32 SACNStartChannel) +{ + WriteIndented(Buffer, 0, "led_strip:\n{\n"); + + // SACN + WriteIndented(Buffer, 1, "output_sacn: {\n"); + WriteIndented(Buffer, 2, "start_universe: %d;\n", SACNStartUniverse); + WriteIndented(Buffer, 2, "start_channel: %d;\n", SACNStartChannel); + WriteIndented(Buffer, 1, "};\n\n"); + + // UART + WriteIndented(Buffer, 1, "output_uart: {\n"); + WriteIndented(Buffer, 2, "channel: %d;\n", UARTChannel); + WriteIndented(Buffer, 2, "com_port: \"%s\";\n", UARTComPort); + WriteIndented(Buffer, 1, "};\n\n"); + } internal void WriteSegmentSequenceOpen(gs_string* Buffer, u32 SegmentCount) { - WriteIndented(Buffer, 1, "segment: {\n"); - WriteIndented(Buffer, 2, "point_placement_type: \"SegmentSequence\";\n"); - WriteIndented(Buffer, 2, "segment_sequence:\n"); - WriteIndented(Buffer, 2, "{\n"); - WriteIndented(Buffer, 3, "segment_count: %d;\n", SegmentCount); + WriteIndented(Buffer, 1, "segment: {\n"); + WriteIndented(Buffer, 2, "point_placement_type: \"SegmentSequence\";\n"); + WriteIndented(Buffer, 2, "segment_sequence:\n"); + WriteIndented(Buffer, 2, "{\n"); + WriteIndented(Buffer, 3, "segment_count: %d;\n", SegmentCount); } internal void WriteSegmentSequenceSegment(gs_string* Buffer, v3 P0, v3 P1, u32 LedCount) { - WriteIndented(Buffer, 3, "segment: {\n"); - WriteIndented(Buffer, 4, "point_placement_type: \"InterpolatePoints\";\n"); - WriteIndented(Buffer, 4, "interpolate_points: {\n"); - WriteIndented(Buffer, 5, "start: (%f, %f, %f);\n", P0.x, P0.y, P0.z); - WriteIndented(Buffer, 5, "end: (%f, %f, %f);\n", P1.x, P1.y, P1.z); - WriteIndented(Buffer, 5, "led_count: %d;\n", LedCount); - WriteIndented(Buffer, 4, "};\n"); - WriteIndented(Buffer, 3, "};\n"); + WriteIndented(Buffer, 3, "segment: {\n"); + WriteIndented(Buffer, 4, "point_placement_type: \"InterpolatePoints\";\n"); + WriteIndented(Buffer, 4, "interpolate_points: {\n"); + WriteIndented(Buffer, 5, "start: (%f, %f, %f);\n", P0.x, P0.y, P0.z); + WriteIndented(Buffer, 5, "end: (%f, %f, %f);\n", P1.x, P1.y, P1.z); + WriteIndented(Buffer, 5, "led_count: %d;\n", LedCount); + WriteIndented(Buffer, 4, "};\n"); + WriteIndented(Buffer, 3, "};\n"); } internal void WriteSegmentSequenceClose(gs_string* Buffer) { - WriteIndented(Buffer, 2, "};\n"); - WriteIndented(Buffer, 1, "};\n"); + WriteIndented(Buffer, 2, "};\n"); + WriteIndented(Buffer, 1, "};\n"); } internal void WriteSegmentTagsOpen(gs_string* Buffer, u32 TagCount) { - WriteIndented(Buffer, 1, "tags_count: %d;\n", TagCount); + WriteIndented(Buffer, 1, "tags_count: %d;\n", TagCount); } internal void WriteSegmentTag(gs_string* Buffer, char* TagName, char* TagValue) { - WriteIndented(Buffer, 1, "tag: {\n"); - WriteIndented(Buffer, 2, "name: \"%s\";\n", TagName); - WriteIndented(Buffer, 2, "value: \"%s\";\n", TagValue); - WriteIndented(Buffer, 1, "};\n"); - + WriteIndented(Buffer, 1, "tag: {\n"); + WriteIndented(Buffer, 2, "name: \"%s\";\n", TagName); + WriteIndented(Buffer, 2, "value: \"%s\";\n", TagValue); + WriteIndented(Buffer, 1, "};\n"); + } internal void @@ -99,7 +121,7 @@ WriteSegmentTagsClose(gs_string* Buffer) internal void WriteLedStripClose(gs_string* Buffer) { - WriteIndented(Buffer, 0, "};\n"); + WriteIndented(Buffer, 0, "};\n"); } #define SCULPTURE_GEN_H diff --git a/src/serial_monitor/first.cpp b/src/serial_monitor/first.cpp index 1f0c6d6..a87e7c7 100644 --- a/src/serial_monitor/first.cpp +++ b/src/serial_monitor/first.cpp @@ -6,13 +6,16 @@ #ifndef FIRST_CPP +#include +#include + #include "../gs_libs/gs_types.h" #include "../gs_libs/gs_types.cpp" +#include "../app/engine/foldhaus_log.h" +global log_buffer* GlobalLogBuffer; #define DEBUG_TRACK_FUNCTION -#include -#include //#include "../app/foldhaus_platform.h" //#include "../gs_libs/gs_win32.cpp" @@ -27,193 +30,195 @@ u8* FindNextHeader(gs_data Data, u8* StartAt) { - u8* At = StartAt; - while (!(At[0] == 'U' && - At[1] == 'P' && - At[2] == 'X' && - At[3] == 'L') && - (u32)(At - Data.Memory) < Data.Size) - { - At++; - } - return At; + u8* At = StartAt; + while (!(At[0] == 'U' && + At[1] == 'P' && + At[2] == 'X' && + At[3] == 'L') && + (u32)(At - Data.Memory) < Data.Size) + { + At++; + } + return At; } void CreateMessage(gs_data* Data, u8 Count) { - gs_memory_cursor WriteCursor = CreateMemoryCursor(*Data); + gs_memory_cursor WriteCursor = MemoryCursorCreateFromData(*Data); + + u32 Channels[] = { + 0, 1, 2, 3, 4, 5, 6, 7, + 16, 17, 18, 19, 20, 21, 22, 23, + //40, 41, 42, 43, 44, 45, 46, 47, + }; + + u8* FirstHeaderAddr = 0; + + for (u32 j = 0; j < sizeof(Channels) / sizeof(u32); j++) + { + u32 ChannelIndex = Channels[j]; + uart_header* Header = MemoryCursorPushStruct(&WriteCursor, uart_header); + UART_FillHeader(Header, ChannelIndex, UART_SET_CHANNEL_WS2812); - u32 Channels[] = { - 0, 1, 2, 3, 4, 5, 6, 7, - 16, 17, 18, 19, 20, 21, 22, 23, - //40, 41, 42, 43, 44, 45, 46, 47, - }; - - u8* FirstHeaderAddr = 0; - - for (u32 j = 0; j < sizeof(Channels) / sizeof(u32); j++) + if (FirstHeaderAddr == 0) { - u32 ChannelIndex = Channels[j]; - uart_header* Header = PushStructOnCursor(&WriteCursor, uart_header); - UART_FillHeader(Header, ChannelIndex, UART_SET_CHANNEL_WS2812); - - if (FirstHeaderAddr == 0) - { - FirstHeaderAddr = (u8*)Header; - } - - uart_channel* Channel = PushStructOnCursor(&WriteCursor, uart_channel); - Channel->ElementsCount = 3; - Channel->ColorPackingOrder = 36; // 10010000 - Channel->PixelsCount = 300; - - for (u32 i = 0; i < Channel->PixelsCount; i++) - { - u8* Pixel = PushArrayOnCursor(&WriteCursor, u8, 3); - Pixel[0] = Count; - Pixel[1] = 0; - Pixel[2] = 255 - Count; - } - - uart_footer* Footer = PushStructOnCursor(&WriteCursor, uart_footer); - Footer->CRC = UART_CalculateCRC((u8*)Header, (u8*)(Footer)); + FirstHeaderAddr = (u8*)Header; } - uart_header* DrawAllHeader = PushStructOnCursor(&WriteCursor, uart_header); - UART_FillHeader(DrawAllHeader, 255, UART_DRAW_ALL); - uart_footer* DrawAllFooter = - PushStructOnCursor(&WriteCursor, uart_footer); - DrawAllFooter->CRC = UART_CalculateCRC((u8*)DrawAllHeader, (u8*)(DrawAllFooter)); + uart_channel* Channel = MemoryCursorPushStruct(&WriteCursor, uart_channel); + Channel->ElementsCount = 3; + Channel->ColorPackingOrder = 36; // 10010000 + Channel->PixelsCount = 300; - Data->Size = ((u8*)DrawAllFooter - (u8*)FirstHeaderAddr) + sizeof(uart_footer); + for (u32 i = 0; i < Channel->PixelsCount; i++) + { + u8* Pixel = MemoryCursorPushArray(&WriteCursor, u8, 3); + Pixel[0] = Count; + Pixel[1] = 0; + Pixel[2] = 255 - Count; + } + + uart_footer* Footer = MemoryCursorPushStruct(&WriteCursor, uart_footer); + Footer->CRC = UART_CalculateCRC((u8*)Header, (u8*)(Footer)); + } + + uart_header* DrawAllHeader = MemoryCursorPushStruct(&WriteCursor, uart_header); + UART_FillHeader(DrawAllHeader, 255, UART_DRAW_ALL); + uart_footer* DrawAllFooter = + MemoryCursorPushStruct(&WriteCursor, uart_footer); + DrawAllFooter->CRC = UART_CalculateCRC((u8*)DrawAllHeader, (u8*)(DrawAllFooter)); + + Data->Size = ((u8*)DrawAllFooter - (u8*)FirstHeaderAddr) + sizeof(uart_footer); } int main(int ArgCount, char** Args) { - gs_thread_context Ctx = Win32CreateThreadContext(); + gs_thread_context Ctx = Win32CreateThreadContext(); + GlobalLogBuffer = PushStruct(Ctx.Transient, log_buffer); + *GlobalLogBuffer = Log_Init(Ctx.Transient, 32); + + HANDLE SerialHandle = Win32SerialPort_Open("\\\\.\\COM9", Ctx.Transient); + Win32SerialPort_SetState(SerialHandle, 2000000, 8, 0, 1); + + gs_const_string OutFileName = ConstString("./serial_dump.data"); + + + if (false) + { + Win32SerialPort_SetRead(SerialHandle); - HANDLE SerialHandle = Win32SerialPort_Open("\\\\.\\COM9"); - Win32SerialPort_SetState(SerialHandle, 2000000, 8, 0, 1); + gs_data Data = PushSize(Ctx.Transient, KB(32)); - gs_const_string OutFileName = ConstString("./serial_dump.data"); + Win32SerialPort_SetRead(SerialHandle); + u32 ReadSize = Win32SerialPort_ReadMessageWhenReady(SerialHandle, Data); - - if (false) + u8* SetChannelHeaderAddr = 0; + uart_header* SetChannelHeader = 0; + uart_header* DrawAllHeader = 0; + u8* ScanAt = Data.Memory; + do { - Win32SerialPort_SetRead(SerialHandle); - - gs_data Data = PushSizeToData(Ctx.Transient, KB(32)); - - Win32SerialPort_SetRead(SerialHandle); - u32 ReadSize = Win32SerialPort_ReadMessageWhenReady(SerialHandle, Data); - - u8* SetChannelHeaderAddr = 0; - uart_header* SetChannelHeader = 0; - uart_header* DrawAllHeader = 0; - u8* ScanAt = Data.Memory; - do + ScanAt = FindNextHeader(Data, ScanAt); + uart_header* Header = (uart_header*)ScanAt; + + if (Header->RecordType == UART_SET_CHANNEL_WS2812) + { + printf("Set Channel:\n"); + printf(" Channel: %d\n", Header->Channel); + printf(" Pixels: %d\n", ((uart_channel*)(Header + 1))->PixelsCount); + if (!SetChannelHeader) { - ScanAt = FindNextHeader(Data, ScanAt); - uart_header* Header = (uart_header*)ScanAt; - - if (Header->RecordType == UART_SET_CHANNEL_WS2812) - { - printf("Set Channel:\n"); - printf(" Channel: %d\n", Header->Channel); - printf(" Pixels: %d\n", ((uart_channel*)(Header + 1))->PixelsCount); - if (!SetChannelHeader) - { - SetChannelHeaderAddr = (u8*)Header; - SetChannelHeader = Header; - } - } - - if (Header->RecordType == UART_DRAW_ALL) - { - printf("Draw All:\n"); - printf(" Channel: %d\n", Header->Channel); - if (!DrawAllHeader) - { - DrawAllHeader= Header; - } - } - - ScanAt += sizeof(uart_header); - }while(((u32)(ScanAt - Data.Memory + sizeof(uart_header)) < Data.Size)); - - uart_channel* Channel = (uart_channel*)(SetChannelHeader + 1); - - u8* DataStart = (u8*)(Channel + 1); - - uart_footer* Footer = (uart_footer*)(DataStart + (Channel->ElementsCount * Channel->PixelsCount)); - - u32 TestCRC = UART_CalculateCRC((u8*)SetChannelHeader, (u8*)(Footer)); - - uart_footer* DrawAllFooter = (uart_footer*)(DrawAllHeader + 1); - u32 DrawwAllCRC = UART_CalculateCRC((u8*)DrawAllHeader, (u8*)(DrawAllFooter)); - - HANDLE FileHandle = CreateFileA(OutFileName.Str, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (FileHandle != INVALID_HANDLE_VALUE) - { - DWORD BytesWritten = 0; - if (!WriteFile(FileHandle, Data.Memory, Data.Size, &BytesWritten, NULL)) - { - InvalidCodePath; - } + SetChannelHeaderAddr = (u8*)Header; + SetChannelHeader = Header; } - CloseHandle(FileHandle); - Win32SerialPort_Close(SerialHandle); - - } - else if (true) - { - gs_data Data = PushSizeToData(Ctx.Transient, KB(32)); - - u8 Count = 0; - while(true) + } + + if (Header->RecordType == UART_DRAW_ALL) + { + printf("Draw All:\n"); + printf(" Channel: %d\n", Header->Channel); + if (!DrawAllHeader) { - CreateMessage(&Data, ++Count); - Win32SerialPort_Write(SerialHandle, Data); - Sleep(100); + DrawAllHeader= Header; } - } - else if (false) - { - gs_data Data = PushSizeToData(Ctx.Transient, KB(32)); - gs_file File = Win32ReadEntireFile(Ctx.FileHandler, OutFileName, Data); - - gs_data Messages = {0}; - u8* ScanAt = Data.Memory; - ScanAt = FindNextHeader(Data, ScanAt); - uart_header* FirstHeader = (uart_header*)ScanAt; - ScanAt += sizeof(uart_header); - - uart_header* LastHeader = 0; - do - { - ScanAt = FindNextHeader(Data, ScanAt); - uart_header* Header = (uart_header*)ScanAt; - if (Header->RecordType == UART_DRAW_ALL) - { - LastHeader = Header; - } - ScanAt += sizeof(uart_header); - }while((u32)(ScanAt - Data.Memory) < Data.Size); - - u8* OnePastLastByte = ((u8*)(LastHeader + 1)) + sizeof(uart_footer); - - Messages.Memory = (u8*)FirstHeader; - Messages.Size = OnePastLastByte - Messages.Memory; - - while (true) - { - Win32SerialPort_Write(SerialHandle, Messages); - Sleep(100); - } - } + } + + ScanAt += sizeof(uart_header); + }while(((u32)(ScanAt - Data.Memory + sizeof(uart_header)) < Data.Size)); - return 0; + uart_channel* Channel = (uart_channel*)(SetChannelHeader + 1); + + u8* DataStart = (u8*)(Channel + 1); + + uart_footer* Footer = (uart_footer*)(DataStart + (Channel->ElementsCount * Channel->PixelsCount)); + + u32 TestCRC = UART_CalculateCRC((u8*)SetChannelHeader, (u8*)(Footer)); + + uart_footer* DrawAllFooter = (uart_footer*)(DrawAllHeader + 1); + u32 DrawwAllCRC = UART_CalculateCRC((u8*)DrawAllHeader, (u8*)(DrawAllFooter)); + + HANDLE FileHandle = CreateFileA(OutFileName.Str, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (FileHandle != INVALID_HANDLE_VALUE) + { + DWORD BytesWritten = 0; + if (!WriteFile(FileHandle, Data.Memory, Data.Size, &BytesWritten, NULL)) + { + InvalidCodePath; + } + } + CloseHandle(FileHandle); + Win32SerialPort_Close(SerialHandle); + + } + else if (true) + { + gs_data Data = PushSize(Ctx.Transient, KB(32)); + + u8 Count = 0; + while(true) + { + CreateMessage(&Data, ++Count); + Win32SerialPort_Write(SerialHandle, Data); + Sleep(100); + } + } + else if (false) + { + gs_data Data = PushSize(Ctx.Transient, KB(32)); + gs_file File = Win32ReadEntireFile(Ctx.FileHandler, OutFileName, Data); + + gs_data Messages = {0}; + u8* ScanAt = Data.Memory; + ScanAt = FindNextHeader(Data, ScanAt); + uart_header* FirstHeader = (uart_header*)ScanAt; + ScanAt += sizeof(uart_header); + + uart_header* LastHeader = 0; + do + { + ScanAt = FindNextHeader(Data, ScanAt); + uart_header* Header = (uart_header*)ScanAt; + if (Header->RecordType == UART_DRAW_ALL) + { + LastHeader = Header; + } + ScanAt += sizeof(uart_header); + }while((u32)(ScanAt - Data.Memory) < Data.Size); + + u8* OnePastLastByte = ((u8*)(LastHeader + 1)) + sizeof(uart_footer); + + Messages.Memory = (u8*)FirstHeader; + Messages.Size = OnePastLastByte - Messages.Memory; + + while (true) + { + Win32SerialPort_Write(SerialHandle, Messages); + Sleep(100); + } + } + + return 0; } diff --git a/src/app/interface_test.cpp b/src/tests/interface_test.cpp similarity index 100% rename from src/app/interface_test.cpp rename to src/tests/interface_test.cpp diff --git a/src/tests/memory_arena_tests.cpp b/src/tests/memory_arena_tests.cpp new file mode 100644 index 0000000..82d446f --- /dev/null +++ b/src/tests/memory_arena_tests.cpp @@ -0,0 +1,202 @@ +internal u32 +NextRandom(u32* LastRandomValue) +{ + u32 Result = *LastRandomValue; + Result ^= Result << 13; + Result ^= Result >> 17; + Result ^= Result << 5; + *LastRandomValue = Result; + return Result; +} + +void +MemoryArenaTests() +{ + Test("Allocator") + { + gs_allocator A = CreatePlatformAllocator(); + + u8* Data = AllocArray(A, u8, 4096, "root"); + for (int i = 0; i < 4096; i++) Data[i] = (i % MaxU8); + bool Success = true; + for (int i = 0; i < 4096; i++) Success &= Data[i] == (i % MaxU8); + TestResult(Success); + + FreeArray(A, Data, u8, 4096); + TestResult(true); // TODO(PS): How do we test free? + } + + Test("Memory Cursor") + { + gs_allocator A = CreatePlatformAllocator(); + + u64 Size = 4096; + gs_data D = AllocData(A, Size, "root"); + gs_memory_cursor C = MemoryCursorCreate(D.Memory, D.Size); + + u64 RoomLeft = MemoryCursorRoomLeft(C); + TestResult(RoomLeft == Size); + TestResult(MemoryCursorHasRoom(C)); + + TestResult(MemoryCursorCanPush(C, 2048)); + TestResult(MemoryCursorCanPush(C, Size)); + TestResult(!MemoryCursorCanPush(C, Size + 1)); + + for (u64 i = 0; i < 2048; i++) + { + u8* Byte = MemoryCursorPushSize(&C, 1).Memory; + *Byte = (u8)(i % 256); + } + RoomLeft = MemoryCursorRoomLeft(C); + TestResult(RoomLeft == (Size - 2048)); + + MemoryCursorPopSize(&C, 2048); + TestResult(C.Position == 0); + + bool Success = true; + for (u64 i = 0; i < 2048; i++) + { + u8* Byte = MemoryCursorPushSize(&C, 1).Memory; + Success &= *Byte == (u8)(i % 256); + } + TestResult(Success); + } + + Test("Memory Arena") + { + gs_allocator Al = CreatePlatformAllocator(); + gs_memory_arena A = MemoryArenaCreate(128, 4, Al, 0, 0, "Test"); + + // NOTE(PS): We loop through this block 3 times + // 1. Make sure the arena works out of the box + // 2. Make sure the arena works the same way after clearing + // 3. Make sure the arena works the same way after freeing + for (int i = 0; i < 3; i++) + { + gs_data D0 = PushSize_(&A, 32, DEBUG_LOC); + TestResult(D0.Size == 32); + + // NOTE(PS): This should still result in 32 bytes + // because its going to align the Cursor after + // it allocates to a multiple of 4 bytes + gs_data D1 = PushSize_(&A, 30, DEBUG_LOC); + TestResult(D1.Size == 32); + + // NOTE(PS): Allocating bigger than the size remaining + // in the current cursor + gs_data D2 = PushSize_(&A, 128, DEBUG_LOC); + TestResult(D2.Size == 128); + TestResult(A.CursorsRoot != A.CursorsHead); + + // NOTE(PS): Because there is still room in cursor + // 0, the head of this gs_data should be one byte + // past the end of D1 + gs_data D3 = PushSize_(&A, 32, DEBUG_LOC); + TestResult(D3.Memory == D1.Memory + D1.Size); + + if (i == 0) + { + MemoryArenaClear(&A); + } else if (i == 1) { + MemoryArenaFree(&A); + } + } + } + + Test("Memory Arena - Push") + { + gs_allocator Al = CreatePlatformAllocator(); + gs_memory_arena A = MemoryArenaCreate(128, 8, Al, 0, 0, "Test"); + + // NOTE(PS): This makes sure that the Arena is moving its next allocation + // pointer forward the appropriate amount after each allocation. If it isnt' + // then Array1 should be overlapping with Array0 in the event that the arena + // doesn't push the pointer forward enough + u32* Array0 = PushArray(&A, u32, 32); + u32* Array1 = PushArray(&A, u32, 32); + + for (u32 i = 0; i < 32; i++) + { + Array0[i] = i; + Array1[i] = i * 4; + } + + bool Success = true; + for (u32 i = 0; i < 32; i++) + { + Success &= Array0[i] == i && Array1[i] == i * 4; + } + TestResult(Success); + + } + + int FreeCount = 0; + int ClearCount = 0; + + gs_debug_allocations_list* DEBUGAllocations = 0; + + Test("Memory Arena - Stress Test") + { + // NOTE(PS): We're going to create thousands of allocations + // on the allocator of varying sizes. We're also going to clear + // and free the arena at random times to make sure it all works. + + gs_allocator Al = CreatePlatformAllocator(); + gs_memory_arena A = MemoryArenaCreate(4096, 4, Al, 0, 0, "Test"); + + // NOTE(PS): This is an array of allocation sizes + // As we repeat the loop we will get values out of this array + // semi-randomly. + // * if the value is 0, we will clear the arena + // * if the value is 2, we will free the arena + // * otherwise we will push a value sized allocation on the arena + u64 RandomSizes[] = { 8, 32, 128, 93, 1256, 4098, 0, 1024, 7, 18, 967, 53, 1, 2 }; + u32 RandomSizesCount = sizeof(RandomSizes) / sizeof(u64); + + bool Success = true; + u32 RandomSeed = 1923; + for (u64 i = 0; i < (4096 * 14); i++) + { + NextRandom(&RandomSeed); + u32 SizeIndex = RandomSeed % RandomSizesCount; + u64 RandomSize = RandomSizes[SizeIndex]; + + if (RandomSize == 0) + { + MemoryArenaClear(&A); + ClearCount++; + } else if (RandomSize == 2) { + MemoryArenaFree(&A); + FreeCount++; + } else { + gs_data D = PushSize_(&A, RandomSize, DEBUG_LOC); + // NOTE(PS): This check has to be >= because the arena + // might have adjusted to maintain alignment on this + // allocation. + Success &= D.Size >= RandomSize; + } + } + + TestResult(Success); + + DEBUGAllocations = Al.DEBUGAllocList; + } + + printf("\tMemory Arena Cleared: %d times\n", ClearCount); + printf("\tMemory Arena Freed: %d times\n", FreeCount); + +#if 0 + printf("\n\nAllocations:\n"); + for (gs_debug_memory_allocation* ARecord = DEBUGAllocations->Root; + ARecord != 0; + ARecord = ARecord->Next) + { + printf("\t"); + printf("%lld\t%s:%d - %s\n", + ARecord->Size, + ARecord->Loc.File, + ARecord->Loc.Line, + ARecord->Loc.Function); + } +#endif +} \ No newline at end of file diff --git a/src/tests/sanity_tests.cpp b/src/tests/sanity_tests.cpp new file mode 100644 index 0000000..440d4e6 --- /dev/null +++ b/src/tests/sanity_tests.cpp @@ -0,0 +1,202 @@ +// +// File: sanity_tests.cpp +// Author: Peter Slattery +// Creation Date: 2021-03-06 +// +#ifndef SANITY_TESTS_CPP + +#include +#include +#include "../gs_libs/gs_types.h" +#include "../gs_libs/gs_types.cpp" +#include "../gs_libs/gs_tests.h" + +#include "../gs_libs/gs_path.h" +#include "../gs_libs/gs_csv.h" + +#include "../app/platform_win32/win32_foldhaus_memory.h" +#include "./memory_arena_tests.cpp" + +gs_memory_arena Scratch = {}; + +bool StringTest (gs_const_string StrA, gs_const_string StrB) +{ + return StringsEqual(StrA, StrB); +} +bool StringTest (gs_string StrA, gs_string StrB) +{ + return StringsEqual(StrA, StrB); +} + +bool PathTest (char* In, char* Out) { + return StringsEqual(SanitizePath(ConstString(In), &Scratch), ConstString(Out)); +} + +global char* SampleCSV = R"FOO(Flower Primary Hue (0-365) Secondary Hue (0-365) Tertiary Hue (0-365) Homonyms +Flower A 55 32 128 foo, bar, blah, baz, whatever +Flower B 123 344 32 foo, bar, blah, baz, whatever +Flower C 55 32 128 foo, bar, blah, baz, whatever)FOO"; + +struct test_sll +{ + u32 Val; + test_sll* Next; +}; + +int main (int ArgCount, char** Args) +{ + gs_allocator Al = CreatePlatformAllocator(); + Scratch = MemoryArenaCreate(KB(4), Bytes(8), Al, 0, 0, "Scratch"); + + Test("SLL 1") + { + test_sll* Root = 0; + test_sll* Head = 0; + + test_sll* First = PushStruct(&Scratch, test_sll); + First->Val = 0; + SLLInit(Root, Head, First); + TestResult((Root == First) && (Head == First)); + + for (u32 i = 1; i < 4; i++) + { + test_sll* New = PushStruct(&Scratch, test_sll); + New->Val = i; + SLLPush(Head, New); + TestResult((Root == First) && (Head == New)); + } + + bool Success = true; + u32 i = 0; + for (test_sll* At = Root; + At && At->Next != 0; + SLLNext(At)) + { + Success &= (At->Val == i); + i += 1; + } + TestResult(Success); + } + + Test("SLL Push Or Init") + { + test_sll* Root = 0; + test_sll* Head = 0; + + test_sll* First = PushStruct(&Scratch, test_sll); + First->Val = 0; + SLLPushOrInit(Root, Head, First); + TestResult((Root == First) && (Head == First)); + + for (u32 i = 1; i < 4; i++) + { + test_sll* New = PushStruct(&Scratch, test_sll); + New->Val = i; + SLLPushOrInit(Root, Head, New); + TestResult((Root == First) && (Head == New)); + } + + bool Success = true; + u32 i = 0; + for (test_sll* At = Root; + At && At->Next != 0; + SLLNext(At)) + { + Success &= (At->Val == i); + i += 1; + } + TestResult(Success); + } + + Test("gs_string") + { + gs_string TestString = PushStringF(&Scratch, 256, "Hello there, Sailor!"); + + NullTerminate(&TestString); + TestResult(IsNullTerminated(TestString)); + + TestResult(StringTest(GetStringPrefix(TestString.ConstString, 5), ConstString("Hello"))); + TestResult(StringTest(GetStringPostfix(TestString.ConstString, 5), ConstString("ilor!"))); + TestResult(StringTest(GetStringAfter(TestString.ConstString, 13), ConstString("Sailor!"))); + TestResult(StringTest(GetStringBefore(TestString.ConstString, 5), ConstString("Hello"))); + TestResult(StringTest(Substring(TestString.ConstString, 5, 11), ConstString(" there"))); + + TestResult(FindFirst(TestString, 5, 'l') == 16); + TestResult(FindFirst(TestString, 0, 'k') == -1); + TestResult(FindLast(TestString, 10, 'l') == 3); + TestResult(FindLast(TestString, 'k') == -1); + + TestResult(FindFirstFromSet(TestString.ConstString, "re") == 1); + TestResult(FindFirstFromSet(TestString.ConstString, "er") == 1); + TestResult(FindFirstFromSet(TestString.ConstString, "bk") == -1); + TestResult(FindFirstFromSet(TestString.ConstString, "ek") == 1); + + TestResult(FindLastFromSet(TestString.ConstString, "re") == 18); + TestResult(FindLastFromSet(TestString.ConstString, "er") == 18); + TestResult(FindLastFromSet(TestString.ConstString, "bk") == -1); + TestResult(FindLastFromSet(TestString.ConstString, "rk") == 18); + + TestResult(StringContains(TestString.ConstString, ',')); + TestResult(!StringContains(TestString.ConstString, '@')); + TestResult(StringsEqual(TestString, TestString)); + + TestResult(StringEqualsCharArray(TestString, "Hello there, Sailor!")); + TestResult(!StringEqualsCharArray(TestString, "Hello there, Sailor")); + TestResult(!StringEqualsCharArray(TestString, "Foobar")); + + ReverseStringInPlace(&TestString); + TestResult(StringTest(TestString, MakeString("!roliaS ,ereht olleH"))); + ReverseStringInPlace(&TestString); + + TestResult(ParseUInt(ConstString("532")) == 532); + TestResult(ParseInt(ConstString("-1234567890")) == -1234567890); + TestResult(ParseFloat(ConstString("-12345.6789")) == -12345.6789); + TestResult(ParseFloat(ConstString("-1")) == -1); + TestResult(ParseFloat(ConstString("-.035")) == -.035); + + TestString.Length = 0; + U64ToASCII(&TestString, 53298, 10); + TestResult(StringTest(TestString.ConstString, ConstString("53298"))); + + TestString.Length = 0; + R64ToASCII(&TestString, -145732.321, 2); + TestResult(StringTest(TestString.ConstString, ConstString("-145732.32"))); + } + + Test("gs_path.h") + { + TestResult(PathTest(".", ".")); + TestResult(PathTest(".\\", ".\\")); + TestResult(PathTest("./", ".\\")); + TestResult(PathTest("./../", "..\\")); + TestResult(PathTest("C:/users/pslattery\\test.foo", "C:\\users\\pslattery\\test.foo")); + TestResult(PathTest("./test/../foo.bar", ".\\foo.bar")); + TestResult(PathTest("C:\\hello\\world\\.\\test", "C:\\hello\\world\\test")); + } + + Test("gs_csv.h") + { + gs_const_string TestCSV = ConstString(SampleCSV); + gscsv_sheet Sheet = CSV_Parse(TestCSV, { '\t' }, &Scratch); + + gs_const_string Cell = CSVSheet_GetCell(Sheet, 0, 0); + TestResult(StringsEqual(Cell, ConstString("Flower"))); + + Cell = CSVSheet_GetCell(Sheet, 1, 1); + TestResult(StringsEqual(Cell, ConstString("55"))); + + Cell = CSVSheet_GetCell(Sheet, 4, 1); + TestResult(StringsEqual(Cell, ConstString("foo, bar, blah, baz, whatever"))); + + Cell = CSVSheet_GetCell(Sheet, 4, 3); + TestResult(StringsEqual(Cell, ConstString("foo, bar, blah, baz, whatever"))); + } + + MemoryArenaTests(); + + return 0; +} + + +#define SANITY_TESTS_CPP +#endif // SANITY_TESTS_CPP \ No newline at end of file diff --git a/src/app/test_patterns.h b/src/tests/test_patterns.h similarity index 100% rename from src/app/test_patterns.h rename to src/tests/test_patterns.h diff --git a/src_v2/core/lumenarium_core.h b/src_v2/core/lumenarium_core.h new file mode 100644 index 0000000..38607a8 --- /dev/null +++ b/src_v2/core/lumenarium_core.h @@ -0,0 +1,44 @@ +// NOTE(PS): +// need to include before this: +// #include +// #include +// #include + +#if defined(__clang__) +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wvarargs" +# pragma GCC diagnostic ignored "-Wwritable-strings" +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + +#if defined(DEBUG) +# define USE_ASSERTS 1 +#endif + +#include "lumenarium_core_assert.h" + +#define STB_TRUETYPE_IMPLEMENTATION +#define STB_SPRINTF_IMPLEMENTATION +#define STBTT_assert(x) assert(x) +#include "../libs/stb_truetype.h" +#include "../libs/stb_sprintf.h" + +#define HANDMADE_MATH_IMPLEMENTATION +#define HANDMADE_MATH_STATIC +#include "../libs/HandmadeMath.h" +typedef hmm_v2 v2; +typedef hmm_v3 v3; +typedef hmm_v4 v4; +typedef hmm_mat4 m44; + +#include "lumenarium_core_types.h" +#include "lumenarium_core_memory.h" +#include "lumenarium_core_string.h" +#include "lumenarium_core_hash.h" +#include "lumenarium_core_random.h" + +#include "lumenarium_core_file.h" +#include "lumenarium_core_window.h" +#include "lumenarium_core_time.h" +#include "lumenarium_core_threads.h" +#include "lumenarium_core_socket.h" \ No newline at end of file diff --git a/src_v2/core/lumenarium_core_assert.h b/src_v2/core/lumenarium_core_assert.h new file mode 100644 index 0000000..ca7896d --- /dev/null +++ b/src_v2/core/lumenarium_core_assert.h @@ -0,0 +1,60 @@ +/* date = March 26th 2022 3:42 pm */ + +#ifndef LUMENARIUM_CORE_ASSERT_H +#define LUMENARIUM_CORE_ASSERT_H + +#if defined(PRINT_ASSERTS) +# include +# define err_write(s,...) err_write_(s,__VA_ARGS__) +static FILE* file_err; +void err_write_(char* fmt, ...) { + if (!file_err) return; + va_list args; + va_start(args, fmt); + vfprintf(file_err, fmt, args); + va_end(args); +} +void open_err_file() { file_err = fopen("./err.txt", "wb"); } +void close_err_file() { fclose(file_err); } +#else +# define err_write(s,...) +void open_err_file() {} +void close_err_file() {} +#endif + +#if !defined(PLATFORM_wasm) + +// this assert works by simply trying to write to an invalid address +// (in this case, 0x0), which will crash in most debuggers +# define assert_always (*((volatile int*)0) = 0xFFFF) + +#else +WASM_EXTERN void wasm_assert_always(char* file, unsigned int file_len, unsigned int line); +# define assert_always wasm_assert_always(__FILE__, sizeof(__FILE__), __LINE__) +#endif // defined(PLATFORM_WASM) + +#ifdef USE_ASSERTS +# define assert(c) do { \ +if (!(c)) { \ +err_write("Assert Hit: %s:%u\n", __FILE__, (u32)__LINE__); \ +close_err_file(); \ +assert_always; \ +} \ +} while(false) + +// useful for catching cases that you aren't sure you'll hit, but +// want to be alerted when they happen +# define invalid_code_path assert(0); + +// useful for switch statements on enums that might grow. You'll +// break in the debugger the first time the default case is hit +// with a new enum value +# define invalid_default_case default: { assert(0); } break; + +#else +# define assert(c) +# define invalid_code_path +# define invalid_default_case default: { } break; +#endif + +#endif //LUMENARIUM_CORE_ASSERT_H diff --git a/src_v2/core/lumenarium_core_file.h b/src_v2/core/lumenarium_core_file.h new file mode 100644 index 0000000..6113182 --- /dev/null +++ b/src_v2/core/lumenarium_core_file.h @@ -0,0 +1,252 @@ +#if !defined(LUMENARIUM_CORE_FILE_H) +#define LUMENARIUM_CORE_FILE_H + +typedef struct File_Handle File_Handle; +struct File_Handle +{ + u64 value; +}; + +typedef u32 File_Access_Flags; +enum +{ + FileAccess_None = 0, + FileAccess_Read = 1, + FileAccess_Write = 2, +}; + +typedef u32 File_Create_Flags; +enum +{ + // these match https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea + FileCreate_None = 0, + + // Creates a new file, only if it does not already exist. + // If the file exists, an error is returned + FileCreate_New = 1, + + // Creates a new file, always. + // If the specified file exists and is writable, the file is overwritten + FileCreate_CreateAlways = 2, + + // Opens a file or device, only if it exists. + FileCreate_OpenExisting = 3, + + // Opens a file, always. + FileCreate_OpenAlways = 4, +}; + +typedef u32 File_Flags; +enum +{ + FileFlag_IsFile = 0, + FileFlag_IsDir = 1, +}; + +typedef struct File_Info File_Info; +struct File_Info +{ + String path; + String path_abs; + u64 size; + u64 time_created; + u64 time_last_write; + File_Flags flags; +}; + +typedef struct File_Info_List_Ele File_Info_List_Ele; +struct File_Info_List_Ele +{ + File_Info info; + File_Info_List_Ele* next; +}; + +typedef struct File_Info_List File_Info_List; +struct File_Info_List +{ + File_Info_List_Ele* first; + File_Info_List_Ele* last; +}; + +// For Cross Platform File Operations use these: + +typedef u32 File_Async_Job_Flags; +enum +{ + FileAsyncJob_Invalid = 0, + FileAsyncJob_Read = 1 << 0, + FileAsyncJob_Write = 1 << 1, + FileAsyncJob_InFlight = 1 << 2, + FileAsyncJob_Success = 1 << 3, + FileAsyncJob_Failed = 1 << 4, +}; + +typedef struct File_Async_Job_Args File_Async_Job_Args; +struct File_Async_Job_Args +{ + String path; + Data data; + File_Async_Job_Flags flags; + u32 error; +}; + +typedef void File_Async_Cb(File_Async_Job_Args args, u8* user_data); + +typedef struct File_Async_Job File_Async_Job; +struct File_Async_Job +{ + Data job_memory; + File_Async_Job_Args args; + File_Async_Cb* cb; +}; + +typedef void File_Async_Job_System_Do_Job(File_Async_Job* job); + +typedef struct File_Async_Job_System File_Async_Job_System; +struct File_Async_Job_System +{ + File_Async_Job_System_Do_Job* do_job; +}; + +global Allocator* file_jobs_arena = 0; +#define FILE_ASYNC_MAX_JOBS 32 +global File_Async_Job file_async_jobs[FILE_ASYNC_MAX_JOBS]; +global u32 file_async_jobs_len = 0; + +internal File_Async_Job_System file_async_jobs_init(File_Async_Job_System_Do_Job* do_job); +internal bool file_async_job_add(File_Async_Job job); +internal File_Async_Job file_async_job_rem(u64 index); +internal bool file_async_read(String path, File_Async_Cb* cb); +internal bool file_async_write(String path, Data data, File_Async_Cb* cb); +internal void file_async_job_complete(File_Async_Job* job, u8* user_data); +internal void file_async_jobs_do_work(File_Async_Job_System* system, u64 max_jobs, u8* user_data); +internal void file_async_jobs_do_work(File_Async_Job_System* system, u64 max_jobs, u8* user_data); + +typedef u32 Platform_Enum_Dir_Flags; +enum +{ + EnumDir_Recursive = 1, + EnumDir_IncludeDirectories = 2, +}; + +/////////////////////////////////////// +/////////////////////////////////////// +// IMPLEMENTATION +/////////////////////////////////////// +/////////////////////////////////////// + +internal File_Async_Job_System +file_async_jobs_init(File_Async_Job_System_Do_Job* do_job) +{ + file_jobs_arena = paged_allocator_create_reserve(MB(4), 256); + File_Async_Job_System result = {}; + result.do_job = do_job; + return result; +} + +internal bool +file_async_job_add(File_Async_Job job) +{ + if (file_async_jobs_len >= FILE_ASYNC_MAX_JOBS) return false; + + // Copy data to job local memory + u64 size_needed = job.args.path.len + job.args.data.size + 1; + u8* job_mem = allocator_alloc(file_jobs_arena, size_needed); + String job_path = string_create(job_mem, 0, job.args.path.len + 1); + u64 copied = string_copy_to(&job_path, job.args.path); + Data job_data = data_create(job_mem + job_path.cap + 1, size_needed - (job_path.cap + 1)); + memory_copy(job.args.data.base, job_data.base, job.args.data.size); + job.args.path = job_path; + job.args.data = job_data; + job.job_memory = data_create(job_mem, size_needed); + + file_async_jobs[file_async_jobs_len++] = job; + return true; +} + +internal File_Async_Job +file_async_job_rem(u64 index) +{ + assert(index < file_async_jobs_len); + File_Async_Job result = file_async_jobs[index]; + + file_async_jobs_len -= 1; + if (file_async_jobs_len > 0) + { + u32 last_job = file_async_jobs_len; + file_async_jobs[index] = file_async_jobs[last_job]; + } + + return result; +} + +internal bool +file_async_read(String path, File_Async_Cb* cb) +{ + File_Async_Job job = {}; + job.args.path = path; + job.args.flags = ( + FileAsyncJob_Read | + FileAsyncJob_InFlight + ); + job.cb = cb; + bool result = file_async_job_add(job); + return result; +} + +internal bool +file_async_write(String path, Data data, File_Async_Cb* cb) +{ + File_Async_Job job = {}; + job.args.path = path; + job.args.data = data; + job.args.flags = ( + FileAsyncJob_Write | + FileAsyncJob_InFlight + ); + job.cb = cb; + bool result = file_async_job_add(job); + return result; +} + +internal void +file_async_job_complete(File_Async_Job* job, u8* user_data) +{ + job->cb(job->args, user_data); + allocator_free(file_jobs_arena, job->job_memory.base, job->job_memory.size); + if (has_flag(job->args.flags, FileAsyncJob_Write)) + { + allocator_free(file_jobs_arena, job->args.data.base, job->args.data.size); + } +} + +internal void +file_async_jobs_do_work(File_Async_Job_System* system, u64 max_jobs, u8* user_data) +{ + assert(system->do_job); + + u64 to_do = max_jobs; + if (max_jobs > file_async_jobs_len) to_do = file_async_jobs_len; + + File_Async_Job_Flags completed = ( + FileAsyncJob_Success | + FileAsyncJob_Failed + ); + + for (u64 i = to_do - 1; i < to_do; i--) + { + File_Async_Job* job = file_async_jobs + i; + system->do_job(job); + if (has_flag(job->args.flags, completed)) + { + if (has_flag_exact(job->args.flags, FileAsyncJob_Success)) + { + file_async_job_complete(job, user_data); + } + file_async_job_rem(i); + } + } +} + + +#endif // LUMENARIUM_CORE_FILE_H \ No newline at end of file diff --git a/src_v2/core/lumenarium_core_hash.h b/src_v2/core/lumenarium_core_hash.h new file mode 100644 index 0000000..1598a5a --- /dev/null +++ b/src_v2/core/lumenarium_core_hash.h @@ -0,0 +1,64 @@ +/* date = April 1st 2022 7:29 pm */ + +#ifndef LUMENARIUM_CORE_HASH_H +#define LUMENARIUM_CORE_HASH_H + +// +// DJB2 +// Source: http://www.cse.yorku.ca/~oz/hash.html + +internal u32 +hash_djb2_append_str_to_u32(u32 base, char* str, u64 len) +{ + u32 result = base; + for (u64 i = 0; i < len; i++) + { + result = ((result << 5) + result) + (u8)str[i]; + } + return result; +} + +internal u32 +hash_djb2_str_to_u32(char* str, u64 len) +{ + return hash_djb2_append_str_to_u32(5381, str, len); +} + +internal u32 +hash_djb2_cstr_to_u32(char* str) +{ + u64 len = c_str_len(str); + return hash_djb2_str_to_u32(str, len); +} + +internal u32 +hash_djb2_string_to_u32(String str) +{ + return hash_djb2_str_to_u32((char*)str.str, str.len); +} + +internal u64 +hash_djb2_str_to_u64(char* str, u64 len) +{ + u64 result = 5381; + for (u64 i = 0; i < len; i++) + { + result = ((result << 5) + result) + (u8)str[i]; + } + return result; +} + +internal u64 +hash_djb2_cstr_to_u64(char* str) +{ + u64 len = c_str_len(str); + return hash_djb2_str_to_u64(str, len); +} + +internal u64 +hash_djb2_string_to_u64(String str) +{ + return hash_djb2_str_to_u64((char*)str.str, str.len); +} + +#endif //LUMENARIUM_HASH_H diff --git a/src_v2/core/lumenarium_core_memory.h b/src_v2/core/lumenarium_core_memory.h new file mode 100644 index 0000000..8ab17ca --- /dev/null +++ b/src_v2/core/lumenarium_core_memory.h @@ -0,0 +1,810 @@ +#ifndef LUMENARIUM_CORE_MEMORY_H +#define LUMENARIUM_CORE_MEMORY_H + +#if !defined(OS_MEM_PAGE_SIZE) +# error "You must define OS_MEM_PAGE_SIZE for core_memory.h to compile properly" +#endif + +////////////////////////////////////////////// +// Memory Helpers + +#define Bytes(x) (x) +#define KB(x) ((x) << 10) +#define MB(x) ((x) << 20) +#define GB(x) (((u64)x) << 30) +#define TB(x) (((u64)x) << 40) + +#define memory_zero_array(b,t,c) memory_zero((u8*)(b), sizeof(t) * (c)) +internal void memory_zero(u8* base, u64 size); +internal void memory_copy(u8* from, u8* to, u64 size); + +////////////////////////////////////////////// +// Data + +#define get_byte(value, byte_index) ((value >> (8 * byte_index)) & 0xFF) + +typedef struct Data Data; +struct Data +{ + u8* base; + u64 size; +}; + +internal Data +data_create(u8* base, u64 size) +{ + Data result = {}; + result.base = base; + result.size = size; + return result; +} + +////////////////////////////////////////////// +// Data Writer + +typedef struct Data_Writer Data_Writer; +struct Data_Writer +{ + Data data; + u64 at; +}; + +// NOTE(PS): functions ending in _b treat data in the Data_Writer as big endian +// order (network ordering) where functions ending in _l treat data into little +// endian order +// It is always assumed that values not in the Data_Writer (ie the other args +// to the function or the functions return value) are in little endian order + +internal u8 dw_get_u8(Data_Writer* w); +// TODO(PS): get functions + +internal void dw_put_u8(Data_Writer* w, u8 b); +internal void dw_put_u16_b(Data_Writer* w, u16 b); +internal void dw_put_u16_l(Data_Writer* w, u16 b); +internal void dw_put_u32_b(Data_Writer* w, u32 b); +internal void dw_put_u32_l(Data_Writer* w, u32 b); +internal void dw_put_u64_b(Data_Writer* w, u64 b); +internal void dw_put_u64_l(Data_Writer* w, u64 b); + +////////////////////////////////////////////// +// Allocator + +typedef struct Allocator Allocator; + +typedef u8* Allocator_Alloc(Allocator* allocator, u64 size); +typedef void Allocator_Free(Allocator* allocator, u8* base, u64 size); +typedef u8* Allocator_Realloc(Allocator* allocator, u8* base, u64 old_size, u64 new_size); +typedef void Allocator_Clear(Allocator* allocator); +typedef void Allocator_Destroy(Allocator* allocator); + +struct Allocator +{ + Allocator_Alloc* alloc; + Allocator_Free* free; + Allocator_Realloc* realloc; + Allocator_Clear* clear; + Allocator_Destroy* destroy; + + Allocator* parent; + + u8* allocator_data; +}; + +#define allocator_alloc(a,s) (a)->alloc((a),(s)) +#define allocator_alloc_struct(a,t) (t*)(a)->alloc((a),sizeof(t)) +#define allocator_alloc_array(a,t,c) (t*)(a)->alloc((a),sizeof(t)*(c)) + +#define allocator_free(a,b,s) (a)->free((a),(b),(s)) +#define allocator_free_struct(a,b,t) (a)->free((a),(b),sizeof(t)) +#define allocator_free_array(a,b,t,c) (a)->free((a),(b),sizeof(t)*(c)) + +#define allocator_realloc(a,b,os,ns) (a)->realloc((a),(b),(os),(ns)) +#define allocator_realloc_array(a,b,t,oc,nc) (t*)(a)->realloc((a),(b),sizeof(t)*(oc),sizeof(t)*(nc)) + +#define allocator_clear(a) (a)->clear(a) +#define allocator_destroy(a) (a)->destroy(a) + +internal Allocator* paged_allocator_create_reserve(u64 reserve_size, u64 page_size); + +////////////////////////////////////////////// +////////////////////////////////////////////// +// IMPLEMENTATION +////////////////////////////////////////////// +////////////////////////////////////////////// + +///////////////////////////////////////// +// Memory Functions + +void +memory_zero_no_simd(u8* base, u64 size) +{ + for (u64 i = 0; i < size; i++) base[i] = 0; +} + +void +memory_copy_no_simd(u8* from, u8* to, u64 size) +{ + for (u64 i = 0; i < size; i++) to[i] = from[i]; +} + +#if defined(PLATFORM_HAS_SIMD) + +// TODO(PS): +// TODO(PS): +// TODO(PS): + +void +memory_zero_simd(u8* base, u64 size) +{ + memory_zero_no_simd(base, size); +} + +void +memory_copy_simd(u8* from, u8* to, u64 size) +{ + memory_copy_no_simd(from, to, size); +} + +# define memory_zero_(b,s) memory_zero_simd((b),(s)) +# define memory_copy_(f,t,s) memory_copy_simd((f),(t),(s)) + +#else +# define memory_zero_(b,s) memory_zero_no_simd((b),(s)) +# define memory_copy_(f,t,s) memory_copy_no_simd((f),(t),(s)) + +#endif // defined(PLATFORM_HAS_SIMD) + +#define zero_struct(s) memory_zero((u8*)(&s), sizeof(s)) + +internal void memory_zero(u8* base, u64 size) { memory_zero_(base, size); } +internal void memory_copy(u8* from, u8* to, u64 size) { + memory_copy_(from, to, size); +} + +// @Maintenance - if the function only has one argument, it should become +// round_to_os_page_multiple +u64 +round_size_to_page_multiple(u64 size, u64 page_size) +{ + u64 rem = size % page_size; + if (rem != 0 || size < page_size) + { + u64 grow = page_size - rem; + size += grow; + } + return size; +} + +u64 +round_size_to_os_page_multiple(u64 size) +{ + return round_size_to_page_multiple(size, OS_MEM_PAGE_SIZE); +} + +///////////////////////////////////////// +// Data Writer + +internal void +dw_put_u8(Data_Writer* w, u8 b) +{ + if (w->at < w->data.size) + { + w->data.base[w->at++] = b; + } +} + +internal u8 +dw_get_u8(Data_Writer* w) +{ + u8 result = 0; + if (w->at < w->data.size) + { + result = w->data.base[w->at]; + } + return result; +} + +internal void +dw_put_u16_b(Data_Writer* w, u16 b) +{ + dw_put_u8(w, get_byte(b, 1)); + dw_put_u8(w, get_byte(b, 0)); +} + +internal void +dw_put_u16_l(Data_Writer* w, u16 b) +{ + dw_put_u8(w, get_byte(b, 0)); + dw_put_u8(w, get_byte(b, 1)); +} + +internal void +dw_put_u32_b(Data_Writer* w, u32 b) +{ + dw_put_u8(w, get_byte(b, 3)); + dw_put_u8(w, get_byte(b, 2)); + dw_put_u8(w, get_byte(b, 1)); + dw_put_u8(w, get_byte(b, 0)); +} + +internal void +dw_put_u32_l(Data_Writer* w, u32 b) +{ + dw_put_u8(w, get_byte(b, 0)); + dw_put_u8(w, get_byte(b, 1)); + dw_put_u8(w, get_byte(b, 2)); + dw_put_u8(w, get_byte(b, 3)); +} + +internal void +dw_put_u64_b(Data_Writer* w, u64 b) +{ + dw_put_u8(w, get_byte(b, 7)); + dw_put_u8(w, get_byte(b, 6)); + dw_put_u8(w, get_byte(b, 5)); + dw_put_u8(w, get_byte(b, 4)); + dw_put_u8(w, get_byte(b, 3)); + dw_put_u8(w, get_byte(b, 2)); + dw_put_u8(w, get_byte(b, 1)); + dw_put_u8(w, get_byte(b, 0)); +} + +internal void +dw_put_u64_l(Data_Writer* w, u64 b) +{ + dw_put_u8(w, get_byte(b, 0)); + dw_put_u8(w, get_byte(b, 1)); + dw_put_u8(w, get_byte(b, 2)); + dw_put_u8(w, get_byte(b, 3)); + dw_put_u8(w, get_byte(b, 4)); + dw_put_u8(w, get_byte(b, 5)); + dw_put_u8(w, get_byte(b, 6)); + dw_put_u8(w, get_byte(b, 7)); +} + +//////////////////////////////////////// +// Allocator +// +// A generic interface for any memory-providing construct +// +// To implement a complete allocator, all that is really required +// is to create its Allocator_Alloc function + +internal void +allocator_destroy_(Allocator* allocator, u64 custom_data_size) +{ + zero_struct(*allocator); + u64 size = sizeof(Allocator) + custom_data_size; + os_mem_decommit((u8*)allocator, size); + os_mem_release((u8*)allocator, size); +} + +///////////////////////////////////////// +// Bump Allocator + +typedef struct Allocator_Bump Allocator_Bump; +struct Allocator_Bump +{ + u8* base; + u64 at; + u64 size_committed; + u64 size_reserved; + u64 page_size; + u64 high_water_mark; +}; + +#if defined(DEBUG) +# define bump_allocator_validate(a) bump_allocator_validate_(a) +#else +# define bump_allocator_validate(a) +#endif +internal void +bump_allocator_validate_(Allocator* allocator) +{ + Allocator_Bump* bump = (Allocator_Bump*)allocator->allocator_data; + assert(bump != 0); + if (bump->size_reserved > 0) + { + assert(bump->base != 0); + } + assert(bump->at <= bump->size_committed); + assert(bump->size_committed <= bump->size_reserved); + assert(bump->page_size > 0); + assert(bump->high_water_mark <= bump->size_reserved); +} + +internal u8* +bump_allocator_alloc_inner(Allocator* allocator, Allocator_Bump* bump, u64 size) +{ + bump_allocator_validate(allocator); + u64 at_after = bump->at + size; + // TODO(PS): align up to 8 bytes + + if (at_after >= bump->size_committed) + { + // determine new size of the arena + u64 new_size = bump->size_committed * 2; + if (new_size == 0) + { + if (bump->page_size == 0) bump->page_size = OS_MEM_PAGE_SIZE; + new_size = bump->page_size; + } + if (new_size < at_after) + { + new_size = round_size_to_page_multiple(at_after, bump->page_size); + } + + if (allocator->parent) + { + bump->base = allocator_realloc( + allocator->parent, + bump->base, + bump->size_committed, + new_size + ); + if (bump->base != 0) + { + bump->size_reserved = new_size; + bump->size_committed = new_size; + } + } + else + { + if (new_size <= bump->size_reserved) + { + u64 next_page = round_size_to_os_page_multiple(bump->at); + if (bump->at == 0 && bump->size_committed == 0) next_page = 0; + u64 commit_amt = new_size - next_page; + u8* new_page = os_mem_commit(bump->base + next_page, commit_amt); + if (new_page != 0) + { + bump->size_committed = new_size; + } + } + else + { + invalid_code_path; // out of reserved memory + } + } + } + + u8* result = bump->base + bump->at; + bump->at = at_after; + bump->high_water_mark = max(bump->at, bump->high_water_mark); + + bump_allocator_validate(allocator); + return result; +} + +internal u8* +bump_allocator_alloc(Allocator* allocator, u64 size) +{ + Allocator_Bump* bump = (Allocator_Bump*)allocator->allocator_data; + u8* result = bump_allocator_alloc_inner(allocator, bump, size); + return result; +} + +internal u8* +bump_allocator_realloc(Allocator* allocator, u8* base, u64 old_size, u64 new_size) +{ + u8* result = bump_allocator_alloc(allocator, new_size); + memory_copy(base, result, old_size); + return result; +} + +internal void +bump_allocator_clear(Allocator* allocator) +{ + if (!allocator->allocator_data) return; + Allocator_Bump* bump = (Allocator_Bump*)allocator->allocator_data; + bump->at = 0; + bump_allocator_validate(allocator); +} + +internal void +bump_allocator_destroy_(Allocator_Bump* bump) +{ + os_mem_decommit(bump->base, bump->size_committed); + os_mem_release(bump->base, bump->size_reserved); +} + +internal void +bump_allocator_destroy(Allocator* allocator) +{ + Allocator_Bump* bump = (Allocator_Bump*)allocator->allocator_data; + bump_allocator_destroy_(bump); + allocator_destroy_(allocator, sizeof(Allocator_Bump)); +} + +internal u64 +bump_allocator_at(Allocator* allocator) +{ + Allocator_Bump* bump = (Allocator_Bump*)allocator->allocator_data; + bump_allocator_validate(allocator); + return bump->at; +} + +internal void +bump_allocator_rewind(Allocator* allocator, u64 to_point) +{ + Allocator_Bump* bump = (Allocator_Bump*)allocator->allocator_data; + bump_allocator_validate(allocator); +#if defined(DEBUG) + memory_zero(bump->base + to_point, bump->at - to_point); +#endif + bump->at = to_point; + bump_allocator_validate(allocator); +} + +internal Allocator* +bump_allocator_create_(u64 page_size) +{ + u64 size_needed = sizeof(Allocator) + sizeof(Allocator_Bump); + + u8* base = os_mem_reserve(size_needed); + base = os_mem_commit(base, size_needed); + + Allocator* result = (Allocator*)base; + zero_struct(*result); + + Allocator_Bump* bump = (Allocator_Bump*)base + sizeof(Allocator); + zero_struct(*bump); + bump->page_size = page_size; + + result->alloc = bump_allocator_alloc; + result->realloc = bump_allocator_realloc; + result->clear = bump_allocator_clear; + result->destroy = bump_allocator_destroy; + result->allocator_data = (u8*)bump; + + bump_allocator_validate(result); + return result; +} + +internal Allocator* +bump_allocator_create_reserve(u64 reserve_size) +{ + Allocator* result = bump_allocator_create_(OS_MEM_PAGE_SIZE); + Allocator_Bump* bump = (Allocator_Bump*)result->allocator_data; + + u64 reserve_pages = round_size_to_os_page_multiple(reserve_size); + bump->base = os_mem_reserve(reserve_pages); + if (bump->base != 0) bump->size_reserved = reserve_pages; + + bump_allocator_validate(result); + return result; +} + +internal Allocator* +bump_allocator_create_child(Allocator* parent, u64 init_size) +{ + Allocator* result = bump_allocator_create_(OS_MEM_PAGE_SIZE); + result->parent = parent; + + Allocator_Bump* bump = (Allocator_Bump*)result->allocator_data; + zero_struct(*bump); + bump->base = allocator_alloc(result->parent, init_size); + if (bump->base != 0) + { + bump->size_reserved = init_size; + bump->size_committed = init_size; + } + + bump_allocator_validate(result); + return result; +} + + +///////////////////////////////////////// +// Scratch Allocator + +typedef struct Allocator_Scratch Allocator_Scratch; +struct Allocator_Scratch +{ + Allocator* a; + u64 at_before; +}; + +internal Allocator_Scratch +allocator_scratch_begin(Allocator* allocator) +{ + Allocator_Scratch result = {}; + result.a = allocator; + Allocator_Bump* bump = (Allocator_Bump*)result.a->allocator_data; + result.at_before = bump->at; + return result; +} + +internal void +allocator_scratch_end(Allocator_Scratch* scratch) +{ + bump_allocator_rewind(scratch->a, scratch->at_before); + zero_struct(*scratch); +} + +///////////////////////////////////////// +// Paged Allocator + +typedef struct Allocator_Paged_Free_Region Allocator_Paged_Free_Region; +struct Allocator_Paged_Free_Region +{ + u64 pages; + Allocator_Paged_Free_Region* prev; + Allocator_Paged_Free_Region* next; +}; + +typedef struct Allocator_Paged Allocator_Paged; +struct Allocator_Paged +{ + Allocator_Bump bump; + Allocator_Paged_Free_Region* free_first; +}; + +internal u8* +paged_allocator_alloc(Allocator* allocator, u64 size) +{ + // 1. Find the number of pages we need + // 2. Find a run of free pages that we can use + // If found, + // remove those pages from the run they are in + // return those pages of memory + // 3. Commit pages on the end + + Allocator_Paged* paged = (Allocator_Paged*)allocator->allocator_data; + if (paged->bump.page_size == 0) paged->bump.page_size = OS_MEM_PAGE_SIZE; + + u64 rounded_size = round_size_to_page_multiple(size, paged->bump.page_size); + u64 pages_needed = rounded_size / paged->bump.page_size; + + u8* result = 0; + + // Find free pages + if (paged->free_first) + { + Allocator_Paged_Free_Region* found = 0; + for (Allocator_Paged_Free_Region* at = paged->free_first; at != 0; at = at->next) + { + // NOTE(PS): this set of conditions checks to see if is bigger than what + // we need. If it is, we also check to see if this is smaller than any + // region we've found before. And we abort the search if this region + // perfectly fits the size needed. + // + // This should make sure that we are always choosing the closest fit we + // can. I'm not sure this is the best strategy for dealing with fragmentation + // but its a decent first pass + if (at->pages >= pages_needed) + { + if (!found || (found->pages > at->pages)) + { + found = at; + if (found->pages == pages_needed) break; + } + } + } + + if (found) + { + result = (u8*)found; + if (found->pages > pages_needed) + { + Allocator_Paged_Free_Region* region_after = (Allocator_Paged_Free_Region*)(result + rounded_size); + if (found->prev != 0) found->prev->next = region_after; + region_after = found->next; + } + else + { + if (found->prev != 0) found->prev->next = found->next; + } + } + } + + if (!result) + { + result = bump_allocator_alloc_inner(allocator, &paged->bump, size); + } + + return result; +} + +#define region_end(r,page_size) ((u8*)(r) + ((r)->pages * page_size)) + +internal void +paged_region_insert( + Allocator_Paged_Free_Region* before, + Allocator_Paged_Free_Region* new_region, + Allocator_Paged_Free_Region* after, + u64 page_size + ){ + assert(after == 0 || before < after); + assert(before < new_region); + assert(after == 0 || new_region < after); + assert(new_region->prev == 0 && new_region->next == 0); + + u8* before_end = region_end(before, page_size); + u8* new_region_end = region_end(new_region, page_size); + + // Before + if (before_end == (u8*)new_region) + { + // merge the regions + before->pages += new_region->pages; + new_region = before; + assert(new_region_end == region_end(new_region, page_size)); + } + else + { + assert(before_end < (u8*)new_region); + before->next = new_region; + new_region->prev = before; + } + + // After + if (after != 0) + { + if (new_region_end == (u8*)after) + { + // merge the regions + new_region->pages += after->pages; + u8* a = region_end(after, page_size); + u8* b = region_end(new_region, page_size); + assert(a == b); + } + else + { + assert(new_region_end < (u8*)after); + new_region->next = after; + after->prev = new_region; + } + } +} + +internal void +paged_allocator_free(Allocator* allocator, u8* base, u64 size) +{ + // Figure out which page base is the base of, assert its the base + // figure out how many pages size represents. + // create a free range + // stick it in between contiguous free ranges + // if the ranges before or after meet this new one, merge them all + + Allocator_Paged* paged = (Allocator_Paged*)allocator->allocator_data; + + u64 page_base_rel = (base - paged->bump.base); + assert((page_base_rel % paged->bump.page_size) == 0); + u64 page_index = page_base_rel / paged->bump.page_size; + u64 size_pages_mult = round_size_to_page_multiple(size, paged->bump.page_size); + assert((size_pages_mult % paged->bump.page_size) == 0); + u64 page_count = size_pages_mult / paged->bump.page_size; + + Allocator_Paged_Free_Region* region = (Allocator_Paged_Free_Region*)base; + zero_struct(*region); + region->pages = page_count; + + Allocator_Paged_Free_Region* prev = 0; + Allocator_Paged_Free_Region* next = 0; + for (Allocator_Paged_Free_Region* at = paged->free_first; at != 0; at = at->next) + { + if (at < region) + { + prev = at; + next = at->next; + if (next != 0) + { + assert(next > region); + assert((u8*)next >= ((u8*)region + size_pages_mult)); + } + } + } + + if (prev && next) + { + // found a region to insert into + paged_region_insert(prev, region, next, paged->bump.page_size); + } + else if (prev) + { + // got to the end and all were before the free region in memory + paged_region_insert(prev, region, 0, paged->bump.page_size); + } + else + { + // free list is empty + paged->free_first = region; + } +} + +internal u8* +paged_allocator_realloc(Allocator* allocator, u8* base, u64 old_size, u64 new_size) +{ + // TODO(PS): + // Process: + // 1. Figure out which page base starts on + // 2. Find if there is a free region after base that is big enough to house + // the new size + // 3. If there is a free region, pull the needed memory out of it + // 4. Otherwise, alloc new_size, copy base into it, and free base + + // TODO(PS): you could do a simple version where you just always alloc, copy, free + return 0; +} + +internal void +paged_allocator_clear(Allocator* allocator) +{ + if (!allocator->allocator_data) return; + Allocator_Paged* paged = (Allocator_Paged*)allocator->allocator_data; + paged->bump.at = 0; + paged->free_first = 0; +} + +internal void +paged_allocator_destroy(Allocator* allocator) +{ + Allocator_Paged* paged = (Allocator_Paged*)allocator->allocator_data; + bump_allocator_destroy_(&paged->bump); + allocator_destroy_(allocator, sizeof(Allocator_Paged)); +} + +internal Allocator* +paged_allocator_create_() +{ + u64 size_needed = sizeof(Allocator) + sizeof(Allocator_Bump); + + u8* base = os_mem_reserve(size_needed); + base = os_mem_commit(base, size_needed); + + Allocator* result = (Allocator*)base; + zero_struct(*result); + + Allocator_Paged* paged = (Allocator_Paged*)base + sizeof(Allocator); + zero_struct(*paged); + + result->alloc = paged_allocator_alloc; + result->free = paged_allocator_free; + result->realloc = paged_allocator_realloc; + result->clear = paged_allocator_clear; + result->destroy = paged_allocator_destroy; + result->allocator_data = (u8*)paged; + + return result; +} + +internal Allocator* +paged_allocator_create_reserve(u64 reserve_size, u64 page_size) +{ + Allocator* result = paged_allocator_create_(); + Allocator_Paged* paged = (Allocator_Paged*)result->allocator_data; + + u64 reserve_pages = round_size_to_os_page_multiple(reserve_size); + paged->bump.page_size = page_size; + paged->bump.base = os_mem_reserve(reserve_pages); + if (paged->bump.base != 0) paged->bump.size_reserved = reserve_pages; + + return result; +} + +internal Allocator* +paged_allocator_create_reserve_os_page_size(u64 reserve_size) +{ + u64 page_size = OS_MEM_PAGE_SIZE; + return paged_allocator_create_reserve(reserve_size, page_size); +} + +internal Allocator* +paged_allocator_create_child(Allocator* parent, u64 init_size) +{ + Allocator* result = bump_allocator_create_(OS_MEM_PAGE_SIZE); + result->parent = parent; + + Allocator_Paged* paged = (Allocator_Paged*)result->allocator_data; + paged->bump.base = allocator_alloc(result->parent, init_size); + if (paged->bump.base != 0) + { + paged->bump.size_reserved = init_size; + paged->bump.size_committed = init_size; + } + + return result; +} + +#endif \ No newline at end of file diff --git a/src_v2/core/lumenarium_core_random.h b/src_v2/core/lumenarium_core_random.h new file mode 100644 index 0000000..09bceac --- /dev/null +++ b/src_v2/core/lumenarium_core_random.h @@ -0,0 +1,72 @@ +/* date = April 11th 2022 6:11 pm */ + +#ifndef LUMENARIUM_RANDOM_H +#define LUMENARIUM_RANDOM_H + +typedef struct Random_Series Random_Series; +struct Random_Series +{ + u32 last_value; +}; + +internal Random_Series +random_series_create(u32 seed) +{ + Random_Series result = {}; + result.last_value = seed; + return result; +} + +internal u32 +random_from_u32(u32 input) +{ + u32 result = input; + result ^= result << 13; + result ^= result >> 17; + result ^= result << 5; + return result; +} + +internal r32 +random_unilateral_from_u32(u32 input) +{ + r32 result = random_from_u32(input) / (r32)(0xFFFFFFFF); + return result; +} + +internal u32 +random_series_next(Random_Series* s) +{ + u32 result = random_from_u32(s->last_value); + s->last_value = result; + return result; +} + +internal r32 +random_series_next_unilateral(Random_Series* s) +{ + r32 result = random_series_next(s) / (r32)(0xFFFFFFFF); + return result; +} + +internal r32 +random_series_next_bilateral(Random_Series* s) +{ + r32 result = random_series_next(s) / (r32)(0xFFFFFFFF); + result = (result * 2.0f) - 1.0f; + return result; +} + +internal v4 +random_series_next_v4(Random_Series* s) +{ + v4 result = { + .x = random_series_next_unilateral(s), + .y = random_series_next_unilateral(s), + .z = random_series_next_unilateral(s), + .w = 1, + }; + return result; +} + +#endif //LUMENARIUM_RANDOM_H diff --git a/src_v2/core/lumenarium_core_socket.h b/src_v2/core/lumenarium_core_socket.h new file mode 100644 index 0000000..7a38b45 --- /dev/null +++ b/src_v2/core/lumenarium_core_socket.h @@ -0,0 +1,124 @@ +#if !defined(LUMENARIUM_CORE_SOCKET_H) +#define LUMENARIUM_CORE_SOCKET_H + +typedef struct Socket_Handle Socket_Handle; +struct Socket_Handle { u64 value; }; + +typedef s32 Socket_Error; +enum { + SocketError_Invalid, + SocketError_NOERROR, + SocketError_EAGAIN, + SocketError_EBADF, + SocketError_ECONNREFUSED, + SocketError_EFAULT, + SocketError_EINTR, + SocketError_EINVAL, + SocketError_ENOMEM, + SocketError_ENOTCONN, + SocketError_ENOTSOCK, + SocketError_Count, +}; + +global char* socket_error_strings[] = { + "Invalid", + "SocketError_NOERROR", + "SocketError_EAGAIN", + "SocketError_EBADF", + "SocketError_ECONNREFUSED", + "SocketError_EFAULT", + "SocketError_EINTR", + "SocketError_EINVAL", + "SocketError_ENOMEM", + "SocketError_ENOTCONN", + "SocketError_ENOTSOCK", +}; + +u16 endian_swap_u16(u16 v); +u32 endian_swap_u32(u32 v); +u64 endian_swap_u64(u64 v); + +#define hton_u16(v) endian_swap_u16(v) +#define hton_u32(v) endian_swap_u32(v) +#define hton_u64(v) endian_swap_u64(v) +#define ntoh_s16(v) endian_swap_u16(v) +#define ntoh_s32(v) endian_swap_u32(v) +#define ntoh_s64(v) endian_swap_u64(v) + + +////////////////////////////////////////// +// Implementation + +u16 +endian_swap_u16(u16 v) +{ + u8* p = (u8*)&v; + u16 result = (u16)( + (p[0] << 8) | + (p[1] << 0) + ); + return result; +} + +u32 +endian_swap_u32(u32 v) +{ + u8* p = (u8*)&v; + u32 result = (u32)( + (p[0] << 24) | + (p[1] << 16) | + (p[2] << 8) | + (p[3] << 0) + ); + return result; +} + +u64 +endian_swap_u64(u64 v) +{ + u8* p = (u8*)&v; + u64 result = (u64)( + ((u64)p[0] << 56) | + ((u64)p[1] << 48) | + ((u64)p[2] << 40) | + ((u64)p[3] << 32) | + ((u64)p[4] << 24) | + ((u64)p[5] << 16) | + ((u64)p[6] << 8) | + ((u64)p[7] << 0) + ); + return result; +} + +#if defined(DEBUG) + +void +core_socket_tests() +{ + // u16 endian swap + u16 a_0 = 0xABCD; + u16 a_1 = endian_swap_u16(a_0); + u16 a_2 = endian_swap_u16(a_1); + assert(a_1 == 0xCDAB); + assert(a_2 == a_0); + + // u32 endian swap + u32 b_0 = 0x89ABCDEF; + u32 b_1 = endian_swap_u32(b_0); + u32 b_2 = endian_swap_u32(b_1); + assert(b_1 == 0xEFCDAB89); + assert(b_2 == b_0); + + // u64 endian swap + u64 c_0 = 0x7654321089ABCDEF; + u64 c_1 = endian_swap_u64(c_0); + u64 c_2 = endian_swap_u64(c_1); + assert(c_1 == 0xEFCDAB8910325476); + assert(c_2 == c_0); +} + +#else +# define core_socket_tests() +#endif + +#endif // LUMENARIUM_CORE_SOCKET_H \ No newline at end of file diff --git a/src_v2/core/lumenarium_core_string.h b/src_v2/core/lumenarium_core_string.h new file mode 100644 index 0000000..17fc27e --- /dev/null +++ b/src_v2/core/lumenarium_core_string.h @@ -0,0 +1,319 @@ +////////////////////////////////////////////// +// String + +internal u64 c_str_len(char* s); + +// NOTE(PS): even though this has a len and cap, it should always be +// null terminated +typedef struct String String; +struct String +{ + u8* str; + u64 len; + u64 cap; +}; + +internal String string_create(u8* str, u64 len, u64 cap); +internal u64 string_copy_to(String* dest, String src); + +////////////////////////////////////////////// +////////////////////////////////////////////// +// IMPLEMENTATION +////////////////////////////////////////////// +////////////////////////////////////////////// + +internal u64 +c_str_len(char* s) +{ + u64 result = 0; + for (; s[result] != 0; result++) {} + return result; +} + +#define str_varg(s) (int)(s).len, (char*)(s).str +#define str_expand(s) (char*)(s).str, (u64)(s).len +#define lit_str(s) (String){ (u8*)(s), (u64)sizeof(s)-1, (u64)sizeof(s)-1 } + +internal String +allocator_alloc_string(Allocator* a, u64 cap) +{ + String result = {}; + result.str = allocator_alloc_array(a, u8, cap); + result.cap = cap; + return result; +} + +///////////////////////////////////// +// Char Operations + +bool +char_is_space(u8 c) +{ + return c == ' ' || c == '\r' || c == '\t' || c == '\f' || c == '\v' || c == '\n'; +} + +u8 +char_to_upper(u8 c) +{ + return (c >= 'a' && c <= 'z') ? ('A' + (c - 'a')) : c; +} + +u8 +char_to_lower(u8 c) +{ + return (c >= 'A' && c <= 'Z') ? ('a' + (c - 'A')) : c; +} + +u8 +char_to_forward_slash(u8 c) +{ + return (c == '\\' ? '/' : c); +} + + +///////////////////////////////////// +// String Operations +// +// Note that these don't actually modify any memory +// just return structures that let you view it differently + +internal String +string_create(u8* str, u64 len, u64 cap) +{ + String result = {}; + result.str = str; + result.len = len; + result.cap = cap; + return result; +} + +internal String +string_substring(String s, u64 min, u64 max) +{ + if (max > s.len) max = s.len; + if (min > s.len) min = s.len; + if (min > max) { + u64 t = min; + min = max; + max = t; + } + String result = {}; + result.str = s.str + min; + result.len = max - min; + result.cap = result.len; + return result; +} + +internal String +string_skip(String s, u64 min) +{ + return string_substring(s, min, s.len - min); +} + +internal String +string_chop(String s, u64 nmax) +{ + return string_substring(s, 0, s.len - nmax); +} + +internal String +string_get_prefix(String s, u64 max) +{ + return string_substring(s, 0, max); +} + +internal String +string_get_suffix(String s, u64 nmax) +{ + return string_substring(s, s.len - nmax, s.len); +} + +typedef u32 String_Match_Flags; +enum +{ + StringMatch_FindLast = 1, + StringMatch_CaseInsensitive = 2, + StringMatch_SlashInsensitive = 4, +}; + +internal bool +string_match(String a, String b, String_Match_Flags flags) +{ + bool result = false; + if (a.len == b.len) + { + result = true; + for (u64 i = 0; i < a.len; i++) + { + bool match = a.str[i] == b.str[i]; + if(flags & StringMatch_CaseInsensitive) + { + match |= (char_to_lower(a.str[i]) == char_to_lower(b.str[i])); + } + if(flags & StringMatch_SlashInsensitive) + { + match |= (char_to_forward_slash(a.str[i]) == char_to_forward_slash(b.str[i])); + } + if(match == 0) + { + result = 0; + break; + } + } + } + return result; +} + +internal u64 +string_find_substring(String s, String substr, u64 start_pos, String_Match_Flags flags) +{ + bool found = false; + u64 found_i = s.len; + for (u64 i = start_pos; i < s.len; i++) + { + if (i + substr.len <= s.len) + { + String at = string_substring(s, i, i + substr.len); + if (string_match(at, substr, flags)) + { + found = true; + found_i = i; + if (!(flags & StringMatch_FindLast)) break; + } + } + } + return found_i; +} + +///////////////////////////////////// +// Path Operations + +// good for removing extensions +internal String +string_chop_last_period(String s) +{ + u64 period_pos = string_find_substring(s, lit_str("."), 0, StringMatch_FindLast); + if(period_pos < s.len) + { + s.len = period_pos; + s.cap = s.len; + } + return s; +} + +// get the filename +internal String +string_skip_last_slash(String s) +{ + u64 slash_pos = string_find_substring(s, lit_str("/"), 0, StringMatch_FindLast | StringMatch_SlashInsensitive); + if(slash_pos < s.len) + { + s.str += slash_pos + 1; + s.len -= slash_pos + 1; + s.cap = s.len; + } + return s; +} + +// get the extension +internal String +string_skip_last_period(String s) +{ + u64 period_pos = string_find_substring(s, lit_str("."), 0, StringMatch_FindLast); + if(period_pos < s.len) + { + s.str += period_pos + 1; + s.len -= period_pos + 1; + s.cap = s.len; + } + return s; +} + +// good for getting the path to a file +internal String +string_chop_last_slash(String s) +{ + u64 slash_pos = string_find_substring(s, lit_str("/"), 0, StringMatch_FindLast | StringMatch_SlashInsensitive); + if(slash_pos < s.len) + { + s.len = slash_pos; + s.cap = s.len; + } + return s; +} + + +///////////////////////////////////// +// String Modifications + +internal u64 +string_copy_to(String* dest, String src) +{ + u64 len_to_copy = dest->cap < src.len ? dest->cap : src.len; + memory_copy(src.str, dest->str, len_to_copy); + u64 null_term_index = len_to_copy; + if (null_term_index >= dest->cap) null_term_index -= 1; + dest->str[null_term_index] = 0; + dest->len = null_term_index; + return null_term_index; +} + +internal String +string_copy(String s, Allocator* a) +{ + u64 size = s.cap; + if (s.str[s.cap] != 0) size += 1; + String result = allocator_alloc_string(a, size); + string_copy_to(&result, s); + return result; +} + +internal String +string_fv(Allocator* a, char* fmt, va_list args) +{ + va_list args1; + va_copy(args1, args); + s32 needed = stbsp_vsnprintf(0, 0, fmt, args); + String result = allocator_alloc_string(a, needed + 1); + result.len = stbsp_vsnprintf((char*)result.str, (int)result.cap, fmt, args1); + result.str[result.len] = 0; + va_end(args1); + return result; +} + +internal String +string_f(Allocator* a, char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + String result = string_fv(a, fmt, args); + va_end(args); + return result; +} + +internal void +dw_put_str(Data_Writer* w, String str) +{ + for (u64 i = 0; i < str.len; i++) + { + dw_put_u8(w, str.str[i]); + } +} + +internal void +dw_put_str_min_len(Data_Writer* w, String str, u64 min_len) +{ + u64 start = w->at; + dw_put_str(w, str); + if (str.len < min_len) + { + w->at = start + min_len; + } +} + +internal void +dw_put_str_min_len_nullterm(Data_Writer* w, String str, u64 min_len) +{ + dw_put_str_min_len(w, str, min_len); + w->data.base[w->at - 1] = '\0'; +} \ No newline at end of file diff --git a/src_v2/core/lumenarium_core_threads.h b/src_v2/core/lumenarium_core_threads.h new file mode 100644 index 0000000..48848ba --- /dev/null +++ b/src_v2/core/lumenarium_core_threads.h @@ -0,0 +1,27 @@ +#if !defined(LUMENARIUM_CORE_THREADS_H) +#define LUMENARIUM_CORE_THREADS_H + +typedef struct Thread_Handle Thread_Handle; +struct Thread_Handle { u64 value; }; + +typedef struct Thread_Result Thread_Result; +struct Thread_Result { u32 code; }; + +// TODO(PS): In the interest of time while getting Incenter +// up and running, you made Thread_Proc take a u8* rather than +// the whole Thread_Data structure, whcih currently isnt' being +// used at all +typedef struct Thread_Data Thread_Data; +typedef Thread_Result Thread_Proc(u8* data); +struct Thread_Data +{ + Thread_Handle thread_handle; + u32 thread_id; + Thread_Proc* thread_proc; + Allocator* thread_memory; + u8* user_data; +}; + + + +#endif // LUMENARIUM_CORE_THREADS_H \ No newline at end of file diff --git a/src_v2/core/lumenarium_core_time.h b/src_v2/core/lumenarium_core_time.h new file mode 100644 index 0000000..27e57d0 --- /dev/null +++ b/src_v2/core/lumenarium_core_time.h @@ -0,0 +1,44 @@ +#if !defined(LUMENARIUM_CORE_TIME_H) +#define LUMENARIUM_CORE_TIME_H + +// Ticks is a container that each os will use differently +// the value of tick should never be accessed outside of +// lumenarium_core_time.h or the various os_time implementations. +// Instead, treat it as an opaque struct and use the values returned +// from the functions defined below. +typedef struct { s64 value; } Ticks; + +internal Ticks get_ticks_elapsed(Ticks start, Ticks end); +internal r64 ticks_to_seconds(Ticks t, r64 ticks_per_second); +internal r64 get_seconds_elapsed(Ticks start, Ticks end, r64 ticks_per_second); + +/////////////////////////////////////// +/////////////////////////////////////// +// Implementation +/////////////////////////////////////// +/////////////////////////////////////// + +internal Ticks +get_ticks_elapsed(Ticks start, Ticks end) +{ + Ticks result = {}; + result.value = end.value - start.value; + return result; +} + +internal r64 +ticks_to_seconds(Ticks t, r64 ticks_per_second) +{ + r64 result = t.value / ticks_per_second; + return result; +} + +internal r64 +get_seconds_elapsed(Ticks start, Ticks end, r64 ticks_per_second) +{ + Ticks diff = get_ticks_elapsed(start, end); + return ticks_to_seconds(diff, ticks_per_second); +} + + +#endif // LUMENARIUM_CORE_TIME_H \ No newline at end of file diff --git a/src_v2/core/lumenarium_core_types.h b/src_v2/core/lumenarium_core_types.h new file mode 100644 index 0000000..44d60ac --- /dev/null +++ b/src_v2/core/lumenarium_core_types.h @@ -0,0 +1,231 @@ +#ifndef LUMENARIUM_CORE_TYPES_H +#define LUMENARIUM_CORE_TYPES_H + +////////////////////////////////////////////// +// Explicit Names for static keyword +#define internal static +#define local_persist static +#define global static +#define local_const static const +#define global_const static const +#define external extern "C" + +#define STMT(x) do {(x);}while(false) + +////////////////////////////////////////////// +// Integer Sizing +#if defined(GUESS_INTS) + +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; +typedef signed long long s64; +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; + +#else // !defined(GUESS_INTS) + +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +#endif // defined(GUESS_INTS) + +////////////////////////////////////////////// +// Basic Types + +typedef s8 b8; +typedef s32 b32; +typedef s64 b64; + +typedef float r32; +typedef double r64; + +////////////////////////////////////////////// +// Basic Type Constants + +#define u8_max 0xFF +#define u16_max 0xFFFF +#define u32_max 0xFFFFFFFF +#define u64_max 0xFFFFFFFFFFFFFFFF + +#define s8_max 127 +#define s16_max 32767 +#define s32_max 2147483647 +#define s64_max 9223372036854775807 + +#define s8_min -127 - 1 +#define s16_min -32767 - 1 +#define s32_min -2147483647 - 1 +#define s64_min -9223372036854775807 - 1 + +#define r32_max 3.402823466e+38f +#define r32_min -3.402823466e+38f +#define r32_smallest_positive 1.1754943508e-38f +#define r32_epsilon 5.96046448e-8f +#define r32_pi 3.14159265359f +#define r32_half_pi 1.5707963267f +#define r32_tau 6.28318530717f + +#define r64_max 1.79769313486231e+308 +#define r64_min -1.79769313486231e+308 +#define r64_smallest_positive 4.94065645841247e-324 +#define r64_epsilon 1.11022302462515650e-16 +#define r64_pi 3.14159265359 +#define r64_half_pi 1.5707963267 +#define r64_tau 6.28318530717 + +#define NanosToSeconds 1 / 10000000.0 +#define SecondsToNanos 10000000.0 + +////////////////////////////////////////////// +// Math + +#ifndef max +# define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + +#ifndef min +# define min(a,b) ((a) > (b) ? (b) : (a)) +#endif + +#define lerp(a,t,b) (a) + ((b - a) * (t)) +#define clamp(r0,v,r1) min((r1),max((r0),(v))) +#define lerp_clamp(a,t,b) clamp((a),lerp((a),(t),(b)),(b)) + +internal r32 +remap_r32(r32 v, r32 old_min, r32 old_max, r32 new_min, r32 new_max) +{ + r32 result = (v - old_min) / (old_max - old_min); + result = (result * (new_max - new_min)) + new_min; + return result; +} + +internal r64 +remap_r64(r64 v, r64 old_min, r64 old_max, r64 new_min, r64 new_max) +{ + r64 result = (v - old_min) / (old_max - old_min); + result = (result * (new_max - new_min)) + new_min; + return result; +} + +internal u32 +round_up_to_pow2_u32(u32 v) +{ + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v++; + return v; +} + +////////////////////////////////////////////// +// Flags + +#define has_flag(data, flag) (((data) & (flag)) != 0) +#define has_flag_exact(data, flag) (((data) & (flag)) == (flag)) +#define add_flag(data, flag) STMT((data) |= (flag)) +#define rem_flag(data, flag) STMT((data) &= (~(flag))) + +////////////////////////////////////////////// +// List Helper Macros + +#define sll_push(first,last,ele) \ +if (!(first)) { (first) = (ele); }\ +else { (last)->next = (ele); } \ +(last) = (ele); (ele)->next = 0; + +// TODO(PS): Stack, Queue, DLL ops + +////////////////////////////////////////////// +// Hash Table +// +// Rather than define a data structure, to allow the most flexibility, +// this is just a set of functions that can be integrated into other +// routines. +// In general, they expect you to track a u32* of ids and a u32 capacity + +internal void +hash_table_init(u32* ids, u32 cap) +{ + for (u32 i = 0; i < cap; i++) ids[i] = 0; +} + +internal u32 +hash_table_find_(u32* ids, u32 cap, u32 start_id, u32 target_value) +{ + u32 index = start_id % cap; + u32 start = index; + do { + if (ids[index] == target_value) break; + index = (index + 1) % cap; + } while (index != start); + return index; +} + +internal u32 +hash_table_register(u32* ids, u32 cap, u32 new_id) +{ + u32 index = hash_table_find_(ids, cap, new_id, 0); + if (ids[index] != 0) return cap; + ids[index] = new_id; + return index; +} + +internal u32 +hash_table_find(u32* ids, u32 cap, u32 value) +{ + u32 result = hash_table_find_(ids, cap, value, value); + if (ids[result] != value) return cap; + return result; +} + +////////////////////////////////////////////// +// Predeclaring Memory Functions + +u64 round_size_to_page_multiple(u64 size, u64 page_size); +u64 round_size_to_os_page_multiple(u64 size); + +////////////////////////////////////////////// +// Vector Extensions + +#if defined(HANDMADE_MATH_IMPLEMENTATION) + +#define v2_to_v3(xy,z) (v3){(xy).x, (xy).y, (z)} +#define v2_floor(v) (v2){ floorf(v.x), floorf(v.y) } +#define v3_floor(v) (v3){ floorf(v.x), floorf(v.y), floorf(v.z) } + +internal bool +rect2_contains(v2 min, v2 max, v2 point) +{ + return ( + min.x <= point.x && min.y <= point.y && + max.x >= point.x && max.y >= point.y + ); +} + +#endif // defined(HANDMADE_MATH_IMPLEMENTATION) + +////////////////////////////////////////////// +// Color Constants + +#define WHITE_V4 (v4){1,1,1,1} +#define BLACK_V4 (v4){0,0,0,1} +#define RED_V4 (v4){1,0,0,1} +#define GREEN_V4 (v4){0,1,0,1} +#define BLUE_V4 (v4){0,0,1,1} +#define YELLOW_V4 (v4){1,1,0,1} +#define TEAL_V4 (v4){0,1,1,1} +#define PINK_V4 (v4){1,0,1,1} + +#endif \ No newline at end of file diff --git a/src_v2/core/lumenarium_core_window.h b/src_v2/core/lumenarium_core_window.h new file mode 100644 index 0000000..ae2e6a7 --- /dev/null +++ b/src_v2/core/lumenarium_core_window.h @@ -0,0 +1,244 @@ +#if !defined(LUMENARIUM_CORE_WINDOW_H) +#define LUMENARIUM_CORE_WINDOW_H + +typedef u32 Window_Event_Kind; +enum +{ + WindowEvent_Invalid = 0, + + WindowEvent_MouseScroll, + WindowEvent_MouseMoved, + WindowEvent_ButtonDown, + WindowEvent_ButtonUp, + WindowEvent_Char, + WindowEvent_WindowClosed, + + WindowEvent_Count, +}; + +typedef u32 Key_Code; +enum +{ + KeyCode_Invalid = 0, + + KeyCode_Esc, + + KeyCode_Space, + KeyCode_Tab, + KeyCode_CapsLock, + KeyCode_LeftShift, KeyCode_RightShift, + KeyCode_LeftCtrl, KeyCode_RightCtrl, + KeyCode_Fn, + KeyCode_Alt, + KeyCode_PageUp, KeyCode_PageDown, + KeyCode_Backspace, KeyCode_Delete, + KeyCode_Enter, + + // Function Keys + KeyCode_F0, KeyCode_F1, KeyCode_F2, KeyCode_F3, KeyCode_F4, KeyCode_F5, KeyCode_F6, KeyCode_F7, + KeyCode_F8, KeyCode_F9, KeyCode_F10, KeyCode_F11, KeyCode_F12, + + // Letters + KeyCode_a, KeyCode_b, KeyCode_c, KeyCode_d, KeyCode_e, KeyCode_f, KeyCode_g, KeyCode_h, + KeyCode_i, KeyCode_j, KeyCode_k, KeyCode_l, KeyCode_m, KeyCode_n, KeyCode_o, KeyCode_p, + KeyCode_q, KeyCode_r, KeyCode_s, KeyCode_t, KeyCode_u, KeyCode_v, KeyCode_w, KeyCode_x, + KeyCode_y, KeyCode_z, + + KeyCode_A, KeyCode_B, KeyCode_C, KeyCode_D, KeyCode_E, KeyCode_F, KeyCode_G, KeyCode_H, + KeyCode_I, KeyCode_J, KeyCode_K, KeyCode_L, KeyCode_M, KeyCode_N, KeyCode_O, KeyCode_P, + KeyCode_Q, KeyCode_R, KeyCode_S, KeyCode_T, KeyCode_U, KeyCode_V, KeyCode_W, KeyCode_X, + KeyCode_Y, KeyCode_Z, + + // Numbers + KeyCode_0, KeyCode_1, KeyCode_2, KeyCode_3, KeyCode_4, KeyCode_5, KeyCode_6, KeyCode_7, + KeyCode_8, KeyCode_9, + + KeyCode_Num0, KeyCode_Num1, KeyCode_Num2, KeyCode_Num3, KeyCode_Num4, KeyCode_Num5, + KeyCode_Num6, KeyCode_Num7, KeyCode_Num8, KeyCode_Num9, + + // Symbols + KeyCode_Bang, KeyCode_At, KeyCode_Pound, KeyCode_Dollar, KeyCode_Percent, KeyCode_Carrot, + KeyCode_Ampersand, KeyCode_Star, KeyCode_LeftParen, KeyCode_RightParen, KeyCode_Minus, KeyCode_Plus, + KeyCode_Equals, KeyCode_Underscore, KeyCode_LeftBrace, KeyCode_RightBrace, KeyCode_LeftBracket, + KeyCode_RightBracket, KeyCode_Colon, KeyCode_SemiColon, KeyCode_SingleQuote, KeyCode_DoubleQuote, + KeyCode_ForwardSlash, KeyCode_Backslash, KeyCode_Pipe, KeyCode_Comma, KeyCode_Period, + KeyCode_QuestionMark, KeyCode_LessThan, KeyCode_GreaterThan, KeyCode_Tilde, KeyCode_BackQuote, + + // Arrows + KeyCode_UpArrow, + KeyCode_DownArrow, + KeyCode_LeftArrow, + KeyCode_RightArrow, + + // Mouse + // NOTE(Peter): Including this here so we can utilize the same KeyDown, KeyUp etc. functions + KeyCode_MouseLeftButton, + KeyCode_MouseMiddleButton, + KeyCode_MouseRightButton, + + KeyCode_Count, +}; + +typedef u8 Key_Flags; +enum +{ + KeyFlag_None = 0, + + KeyFlag_Mod_Shift = 1, + KeyFlag_Mod_Ctrl = 2, + KeyFlag_Mod_Alt = 4, + KeyFlag_Mod_Sys = 8, + + KeyFlag_State_WasDown = 16, + KeyFlag_State_IsDown = 32, +}; + +typedef struct Window_Event Window_Event; +struct Window_Event +{ + Window_Event_Kind kind; + Key_Code key_code; + Key_Flags key_flags; + s32 mouse_x; + s32 mouse_y; + s32 scroll_amt; + char char_value; +}; + +typedef u32 Cursor_Kind; +enum +{ + Cursor_Arrow, + Cursor_Pointer, + Cursor_Loading, + Cursor_HArrows, + Cursor_VArrows, + Cursor_DTopLeftArrows, + Cursor_DTopRightArrows, + Cursor_Count, +}; + +#define INPUT_FRAME_STRING_LENGTH 32 +typedef struct Input_Frame Input_Frame; +struct Input_Frame +{ + Key_Flags key_flags[KeyCode_Count]; + + char string_input[INPUT_FRAME_STRING_LENGTH]; + u32 string_input_len; + + v2 mouse_pos; + s32 mouse_scroll; +}; + +typedef struct Input_State Input_State; +struct Input_State +{ + Input_Frame frames[2]; + Input_Frame* frame_hot; + Input_Frame* frame_cold; + + // cross frame state tracking + v2 mouse_pos_delta; + v2 mouse_pos_down; +}; + +#define key_was_down(key_flags) has_flag((key_flags), KeyFlag_State_WasDown) +#define key_is_down(key_flags) has_flag((key_flags), KeyFlag_State_IsDown) +#define key_was_up(key_flags) (!has_flag((key_flags), KeyFlag_State_WasDown)) +#define key_is_up(key_flags) (!has_flag((key_flags), KeyFlag_State_IsDown)) + +internal Input_State* input_state_create(Allocator* a); +internal Key_Flags input_key_advance(Key_Flags flag); +internal void input_state_swap_frames(Input_State* input_state); +internal bool input_key_is_down(Input_State* input_state, Key_Code key); +internal bool input_key_went_down(Input_State* input_state, Key_Code key); +internal bool input_key_is_up(Input_State* input_state, Key_Code key); +internal bool input_key_went_up(Input_State* input_state, Key_Code key); + +////////////////////////////////////////// +////////////////////////////////////////// +// IMPLEMENTATION +////////////////////////////////////////// +////////////////////////////////////////// + +internal Input_State* +input_state_create(Allocator* a) +{ + Input_State* result = allocator_alloc_struct(a, Input_State); + result->frame_hot = result->frames + 0; + result->frame_cold = result->frames + 1; + + // Clear the new hot input frame + Key_Flags* hot_key_flags = result->frame_hot->key_flags; + Key_Flags* cold_key_flags = result->frame_cold->key_flags; + for (u32 i = 0; i < KeyCode_Count; i++) + { + hot_key_flags[i] = 0; + cold_key_flags[i] = 0; + } + return result; +} + +internal Key_Flags +input_key_advance(Key_Flags flag) +{ + Key_Flags result = flag; + if (key_is_down(flag)) + { + add_flag(result, KeyFlag_State_WasDown); + } + if (key_is_up(flag)) + { + rem_flag(result, KeyFlag_State_WasDown); + } + return result; +} + +internal void +input_state_swap_frames(Input_State* input_state) +{ + Input_Frame* next_hot = input_state->frame_cold; + input_state->frame_cold = input_state->frame_hot; + input_state->frame_hot = next_hot; + + // Clear the new hot input frame + Key_Flags* hot_key_flags = input_state->frame_hot->key_flags; + Key_Flags* cold_key_flags = input_state->frame_cold->key_flags; + for (u32 i = 0; i < KeyCode_Count; i++) + { + hot_key_flags[i] = input_key_advance(cold_key_flags[i]); + } + input_state->frame_hot->string_input_len = 0; +} + +// Key State Queries + +internal bool +input_key_is_down(Input_State* input_state, Key_Code key) +{ + Key_Flags flags = input_state->frame_hot->key_flags[key]; + return key_is_down(flags); +} + +internal bool +input_key_went_down(Input_State* input_state, Key_Code key) +{ + Key_Flags flags = input_state->frame_hot->key_flags[key]; + return key_is_down(flags) && !key_was_down(flags); +} + +internal bool +input_key_is_up(Input_State* input_state, Key_Code key) +{ + Key_Flags flags = input_state->frame_hot->key_flags[key]; + return !key_is_down(flags); +} + +internal bool +input_key_went_up(Input_State* input_state, Key_Code key) +{ + Key_Flags flags = input_state->frame_hot->key_flags[key]; + return !key_is_down(flags) && key_was_down(flags); +} +#endif // LUMENARIUM_CORE_WINDOW_H \ No newline at end of file diff --git a/src_v2/editor/graphics/lumenarium_editor_graphics.h b/src_v2/editor/graphics/lumenarium_editor_graphics.h new file mode 100644 index 0000000..a651995 --- /dev/null +++ b/src_v2/editor/graphics/lumenarium_editor_graphics.h @@ -0,0 +1,456 @@ +#if !defined(LUMENARIUM_EDITOR_GRAPHICS_H) +#define LUMENARIUM_EDITOR_GRAPHICS_H + +#define os_gl_no_error() os_gl_no_error_((char*)__FILE__, (u32)__LINE__) +void os_gl_no_error_(char* file, u32 line); + +#define GL_NULL (u32)0 + +#define SHADER_MAX_ATTRS 8 +#define SHADER_ATTR_LAST (u32)(1 << 31) +typedef struct Shader Shader; +struct Shader +{ + u32 id; + u32 attrs[SHADER_MAX_ATTRS]; + u32 uniforms[SHADER_MAX_ATTRS]; +}; + +typedef struct XPlatform_Shader_Program_Src XPlatform_Shader_Program_Src; +struct XPlatform_Shader_Program_Src +{ + String win32_vert; + String win32_frag; + + String osx_vert; + String osx_frag; + + String wasm_vert; + String wasm_frag; +}; + +String xplatform_shader_program_get_vert(XPlatform_Shader_Program_Src src); +String xplatform_shader_program_get_frag(XPlatform_Shader_Program_Src src); + +typedef struct Geometry_Buffer Geometry_Buffer; +struct Geometry_Buffer +{ + u32 buffer_id_vao; + u32 buffer_id_vertices; + u32 buffer_id_indices; + u32 vertices_len; + u32 indices_len; +}; + +typedef struct Texture_Desc Texture_Desc; +struct Texture_Desc +{ + u32 w, h, s; + u32 mag_filter, min_filter, fmt_internal, fmt_data; +}; + +typedef struct Texture Texture; +struct Texture +{ + u32 id; + Texture_Desc desc; +}; + +typedef struct Graphics_Frame_Desc Graphics_Frame_Desc; +struct Graphics_Frame_Desc +{ + v4 clear_color; + v2 viewport_min; + v2 viewport_max; +}; + +void frame_begin(Graphics_Frame_Desc desc); +void frame_clear(); + +// Geometry +Geometry_Buffer geometry_buffer_create(r32* vertices, u32 vertices_len, u32* indices, u32 indices_len); +Shader shader_create(String code_vert, String code_frag, String* attribs, u32 attribs_len, String* uniforms, u32 uniforms_len); +void geometry_buffer_update(Geometry_Buffer* buffer, r32* verts, u32 verts_offset, u32 verts_len, u32* indices, u32 indices_offset, u32 indices_len); + +Geometry_Buffer unit_quad_create(); + +// Shaders +void geometry_bind(Geometry_Buffer geo); +void shader_bind(Shader shader); +void geometry_drawi(Geometry_Buffer geo, u32 indices, u32 offset); +void geometry_draw(Geometry_Buffer geo); +void vertex_attrib_pointer(Geometry_Buffer geo, Shader shader, u32 count, u32 attr_index, u32 stride, u32 offset); +void set_uniform(Shader shader, u32 index, m44 u); + +// Textures +Texture texture_create(Texture_Desc desc, u8* pixels); +void texture_bind(Texture tex); +void texture_update(Texture tex, u8* new_pixels, u32 width, u32 height, u32 stride); + +////////////////////////////////////////// +////////////////////////////////////////// +// IMPLEMENTATION +////////////////////////////////////////// +////////////////////////////////////////// + +Geometry_Buffer +geometry_buffer_create( + r32* vertices, u32 vertices_len, + u32* indices, u32 indices_len +){ + Geometry_Buffer result = {}; + + gl.glGenVertexArrays(1, &result.buffer_id_vao); + os_gl_no_error(); + + GLuint buffers[2]; + gl.glGenBuffers(2, (GLuint*)buffers); + os_gl_no_error(); + + result.buffer_id_vertices = buffers[0]; + result.buffer_id_indices = buffers[1]; + + // Vertices + gl.glBindVertexArray(result.buffer_id_vao); + gl.glBindBuffer(GL_ARRAY_BUFFER, result.buffer_id_vertices); + os_gl_no_error(); + + gl.glBufferData(GL_ARRAY_BUFFER, sizeof(r32) * vertices_len, vertices, GL_STATIC_DRAW); + os_gl_no_error(); + result.vertices_len = vertices_len; + + // Indices + gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.buffer_id_indices); + os_gl_no_error(); + + gl.glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(u32) * indices_len, indices, GL_STATIC_DRAW); + os_gl_no_error(); + result.indices_len = indices_len; + + gl.glBindBuffer(GL_ARRAY_BUFFER, GL_NULL); + gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_NULL); + + return result; +} + +void +geometry_buffer_update( + Geometry_Buffer* buffer, + r32* verts, + u32 verts_offset, + u32 verts_len, + u32* indices, + u32 indices_offset, + u32 indices_len +){ + gl.glBindVertexArray(buffer->buffer_id_vao); + gl.glBindBuffer(GL_ARRAY_BUFFER, buffer->buffer_id_vertices); + os_gl_no_error(); + + if (verts_len > buffer->vertices_len) + { + // NOTE(PS): this is because we're going to delete the old buffer and + // create a new one. In order to do that and not lose data, the update + // function needs to have been passed all the buffer's data + assert(verts_offset == 0); + gl.glBufferData(GL_ARRAY_BUFFER, verts_len * sizeof(r32), (void*)verts, GL_STATIC_DRAW); + } + else + { + gl.glBufferSubData(GL_ARRAY_BUFFER, verts_offset * sizeof(r32), verts_len * sizeof(r32), (void*)verts); + } + os_gl_no_error(); + + gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer->buffer_id_indices); + os_gl_no_error(); + if (indices_len > buffer->indices_len) + { + // NOTE(PS): this is because we're going to delete the old buffer and + // create a new one. In order to do that and not lose data, the update + // function needs to have been passed all the buffer's data + assert(indices_offset == 0); + gl.glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices_len * sizeof(u32), (void*)indices, GL_STATIC_DRAW); + } + else + { + gl.glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, indices_offset * sizeof(u32), indices_len * sizeof(u32), (void*)indices); + } + os_gl_no_error(); +} + +Geometry_Buffer +unit_quad_create() +{ + r32 z = 0; + r32 r = 1; + r32 verts[] = { + // pos uv + -r, -r, z, 0, 0, + r, -r, z, 1, 0, + r, r, z, 1, 1, + -1, r, z, 0, 1, + }; + u32 indices[] = { 0, 1, 2, 0, 2, 3 }; + return geometry_buffer_create(verts, sizeof(verts) / sizeof(r32), indices, 6); +} + +Shader +shader_create(String code_vert, String code_frag, String* attrs, u32 attrs_len, String* uniforms, u32 uniforms_len){ + Shader result = {}; + + GLuint shader_vert = gl.glCreateShader(GL_VERTEX_SHADER); + s32* code_vert_len = (s32*)&code_vert.len; + gl.glShaderSource(shader_vert, 1, (const char**)&code_vert.str, code_vert_len); + gl.glCompileShader(shader_vert); + { // errors + GLint shader_vert_compiled; + gl.glGetShaderiv(shader_vert, GL_COMPILE_STATUS, &shader_vert_compiled); + if (!shader_vert_compiled) + { + GLsizei log_length = 0; + GLchar message[1024]; + gl.glGetShaderInfoLog(shader_vert, 1024, &log_length, message); + printf("GLSL Error: %s\n", message); + invalid_code_path; + } + } + + GLuint shader_frag = gl.glCreateShader(GL_FRAGMENT_SHADER); + s32* code_frag_len = (s32*)&code_frag.len; + gl.glShaderSource(shader_frag, 1, (const char**)&code_frag.str, code_frag_len); + gl.glCompileShader(shader_frag); + { // errors + GLint shader_frag_compiled; + gl.glGetShaderiv(shader_frag, GL_COMPILE_STATUS, &shader_frag_compiled); + if (!shader_frag_compiled) + { + GLsizei log_length = 0; + GLchar message[1024]; + gl.glGetShaderInfoLog(shader_frag, 1024, &log_length, message); + printf("GLSL Error: %s\n", message); + printf("%.*s\n", str_varg(code_frag)); + invalid_code_path; + } + } + + result.id = (u32)gl.glCreateProgram(); + gl.glAttachShader(result.id, shader_vert); + gl.glAttachShader(result.id, shader_frag); + gl.glLinkProgram(result.id); + + GLint program_linked; + gl.glGetProgramiv(result.id, GL_LINK_STATUS, &program_linked); + if (program_linked != GL_TRUE) + { + GLsizei log_length = 0; + GLchar message[1024]; + gl.glGetProgramInfoLog(result.id, 1024, &log_length, message); + printf("GLSL Error: %s\n", message); + invalid_code_path; + } + + gl.glUseProgram(result.id); + + // TODO(PS): delete the vert and frag programs + + assert(attrs_len < SHADER_MAX_ATTRS); + for (u32 i = 0; i < attrs_len; i++) + { + result.attrs[i] = gl.glGetAttribLocation(result.id, (char*)attrs[i].str); + os_gl_no_error(); + } + result.attrs[attrs_len] = SHADER_ATTR_LAST; + + assert(uniforms_len < SHADER_MAX_ATTRS); + for (GLuint i = 0; i < uniforms_len; i++) + { + s32 len = (s32)uniforms[i].len; + result.uniforms[i] = gl.glGetUniformLocation(result.id, (char*)uniforms[i].str); + } + result.uniforms[uniforms_len] = SHADER_ATTR_LAST; + + return result; +} + +void +set_uniform(Shader shader, u32 index, m44 u) +{ + gl.glUniformMatrix4fv(shader.uniforms[index], 1, GL_FALSE, (r32*)u.Elements); +} + +void +geometry_bind(Geometry_Buffer geo) +{ + gl.glBindVertexArray(geo.buffer_id_vao); + os_gl_no_error(); + + gl.glBindBuffer(GL_ARRAY_BUFFER, geo.buffer_id_vertices); + os_gl_no_error(); + + gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, geo.buffer_id_indices); + os_gl_no_error(); +} + +void +shader_bind(Shader shader) +{ + gl.glUseProgram(shader.id); + os_gl_no_error(); + for (u32 i = 0; + ((i < SHADER_MAX_ATTRS) && (shader.attrs[i] != SHADER_ATTR_LAST)); + i++) + { + gl.glEnableVertexAttribArray(shader.attrs[i]); + os_gl_no_error(); + } +} + +void +geometry_drawi(Geometry_Buffer geo, u32 indices, u32 offset){ + glDrawElements(GL_TRIANGLES, indices, GL_UNSIGNED_INT, (void*)(offset * sizeof(u32))); + os_gl_no_error(); +} + +void +geometry_draw(Geometry_Buffer geo){ + geometry_drawi(geo, geo.indices_len, 0); +} + +void vertex_attrib_pointer(Geometry_Buffer geo, Shader shader, GLuint count, GLuint attr_index, GLuint stride, GLuint offset){ + geometry_bind(geo); + gl.glVertexAttribPointer(shader.attrs[attr_index], count, GL_FLOAT, false, stride * sizeof(float), (void*)(offset * sizeof(float))); + os_gl_no_error(); + gl.glEnableVertexAttribArray(shader.attrs[attr_index]); + os_gl_no_error(); +} + +Texture_Desc +texture_desc_default(u32 width, u32 height) +{ + return (Texture_Desc){ + .w = width, + .h = height, + .s = width, + .min_filter = GL_NEAREST, + .mag_filter = GL_LINEAR, + .fmt_internal = GL_RGBA, + .fmt_data = GL_RGBA + }; +} + +Texture +texture_create(Texture_Desc desc, u8* pixels) +{ + Texture result = {}; + glGenTextures(1, &result.id); + os_gl_no_error(); + + glBindTexture(GL_TEXTURE_2D, result.id); + os_gl_no_error(); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, desc.min_filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, desc.mag_filter); + os_gl_no_error(); + + glTexImage2D( + GL_TEXTURE_2D, + 0, + desc.fmt_internal, + desc.w, + desc.h, + 0, + desc.fmt_data, + GL_UNSIGNED_BYTE, + pixels + ); + os_gl_no_error(); + + result.desc = desc; + + glBindTexture(GL_TEXTURE_2D, 0); + return result; +} + +void +texture_update(Texture tex, u8* new_pixels, u32 width, u32 height, u32 stride) +{ + // NOTE(PS): this function simply replaces the entire image + // we can write a more granular version if we need it + + assert(tex.desc.w == width && tex.desc.h == height && tex.desc.s == stride); + texture_bind(tex); + glTexSubImage2D( + GL_TEXTURE_2D, + 0, + 0, 0, // offset + width, height, + GL_RGBA, + GL_UNSIGNED_BYTE, + new_pixels + ); + os_gl_no_error(); +} + +void +texture_bind(Texture tex) +{ + glBindTexture(GL_TEXTURE_2D, tex.id); + os_gl_no_error(); +} + +void +frame_begin(Graphics_Frame_Desc desc) +{ + v4 cc = desc.clear_color; + glClearColor(cc.r, cc.g, cc.b, cc.a); + + v2 vmin = desc.viewport_min; + v2 vdim = HMM_SubtractVec2(desc.viewport_max, desc.viewport_min); + glViewport((GLsizei)vmin.x, (GLsizei)vmin.y, (GLint)vdim.x, (GLint)vdim.y); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glDisable(GL_CULL_FACE); + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + os_gl_no_error(); +} + +void +frame_clear() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +} + + +String +xplatform_shader_program_get_vert(XPlatform_Shader_Program_Src src) +{ +#if defined(PLATFORM_win32) + return src.win32_vert; +#elif defined(PLATFORM_osx) + return src.osx_vert; +#elif defined(PLATFORM_wasm) + return src.wasm_vert; +#endif +} + +String +xplatform_shader_program_get_frag(XPlatform_Shader_Program_Src src) +{ +#if defined(PLATFORM_win32) + return src.win32_frag; +#elif defined(PLATFORM_osx) + return src.osx_frag; +#elif defined(PLATFORM_wasm) + return src.wasm_frag; +#endif +} + + +#endif // LUMENARIUM_EDITOR_GRAPHICS_H \ No newline at end of file diff --git a/src_v2/editor/graphics/lumenarium_editor_opengl.h b/src_v2/editor/graphics/lumenarium_editor_opengl.h new file mode 100644 index 0000000..094882b --- /dev/null +++ b/src_v2/editor/graphics/lumenarium_editor_opengl.h @@ -0,0 +1,121 @@ +/* date = March 24th 2022 6:05 pm */ + +#ifndef LUMENARIUM_EDITOR_OPENGL_H +#define LUMENARIUM_EDITOR_OPENGL_H + +// glext.h - https://github.com/KhronosGroup/OpenGL-Registry/blob/main/api/GL/glext.h +// wglext.h - + +void os_gl_no_error(); + +// type mocking +// so far, this is only for platforms that won't be using the editor +// but which still need to compile it. +#if !defined(GL_GLEXT_VERSION) +typedef u32 GLsizei; +typedef u32 GLuint; +typedef u32 GLenum; +typedef s32 GLint; +typedef float GLfloat; +typedef u8 GLchar; +typedef bool GLboolean; + +#define GL_ARRAY_BUFFER 0 +#define GL_ELEMENT_ARRAY_BUFFER 0 +#define GL_VERTEX_SHADER 0 +#define GL_COMPILE_STATUS 0 +#define GL_FRAGMENT_SHADER 0 +#define GL_LINK_STATUS 0 +#define GL_TRUE true +#define GL_FALSE false +#define GL_UNSIGNED_INT 0 +#define GL_FLOAT 0 +#define GL_NEAREST 0 +#define GL_LINEAR 0 +#define GL_RGBA 0 +#define GL_TEXTURE_2D 0 +#define GL_TEXTURE_WRAP_S 0 +#define GL_TEXTURE_WRAP_T 0 +#define GL_TEXTURE_MIN_FILTER 0 +#define GL_TEXTURE_MAG_FILTER 0 +#define GL_UNSIGNED_BYTE 0 +#define GL_SRC_ALPHA 0 +#define GL_ONE_MINUS_SRC_ALPHA 0 +#define GL_CULL_FACE 0 +#define GL_DEPTH_TEST 0 +#define GL_LESS 0 +#define GL_COLOR_BUFFER_BIT 0 +#define GL_DEPTH_BUFFER_BIT 0 +#define GL_STATIC_DRAW 0 +#define GL_TRIANGLES 0 +#define GL_REPEAT 0 +#define GL_BLEND 0 + +#endif + +// OpenGL 3.3+ Context Creation +#if defined(PLATFORM_win32) +typedef const char *WINAPI proc_wglGetExtensionsStringARB(HDC hdc); +typedef BOOL proc_wglChoosePixelFormatARB(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +typedef HGLRC proc_wglCreateContextAttribsARB(HDC hDC, HGLRC hshareContext, const int *attribList); +#endif + +// OpenGL 3.3+ Extensions +typedef void proc_glGenVertexArrays(GLsizei n, GLuint *arrays); +typedef void proc_glBindVertexArray(GLuint array); +typedef void proc_glGenBuffers (GLsizei n, GLuint *buffers); +typedef void proc_glBindBuffer(GLenum target, GLuint buffer); +typedef void proc_glBufferData(GLenum target, size_t size, const void *data, GLenum usage); +typedef void proc_glBufferSubData(GLenum target, size_t offset, size_t size, const void* data); +typedef GLuint proc_glCreateShader(GLenum type); +typedef void proc_glShaderSource(GLuint shader, u32 count, const char* const* string, const GLint *length); +typedef void proc_glCompileShader(GLuint shader); +typedef GLuint proc_glCreateProgram(void); +typedef void proc_glAttachShader(GLuint program, GLuint shader); +typedef void proc_glLinkProgram(GLuint program); +typedef void proc_glUseProgram(GLuint program); +typedef GLuint proc_glGetAttribLocation(GLuint program, const char* name); +typedef void proc_glVertexAttribPointer(GLuint attr, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void proc_glEnableVertexAttribArray(GLuint index); +typedef void proc_glGetShaderiv(GLuint shader, GLenum ele, GLint* value_out); +typedef void proc_glGetShaderInfoLog(GLuint shader, GLuint buf_len, GLsizei* len_out, GLchar* buf); +typedef void proc_glGetProgramiv(GLuint program, GLenum ele, GLint* value_out); +typedef void proc_glGetProgramInfoLog(GLuint program, GLuint cap, GLsizei* len_out, GLchar* buf); +typedef GLuint proc_glGetUniformLocation(GLuint program, const char* name); +typedef void proc_glUniformMatrix4fv(GLuint uniform, GLuint count, GLenum normalize, GLfloat* elements); +typedef struct OpenGL_Extensions OpenGL_Extensions; +struct OpenGL_Extensions +{ + #if defined(PLATFORM_win32) + proc_wglGetExtensionsStringARB* wglGetExtensionsStringARB; + proc_wglChoosePixelFormatARB* wglChoosePixelFormatARB; + proc_wglCreateContextAttribsARB* wglCreateContextAttribsARB; + #endif + + proc_glGenVertexArrays* glGenVertexArrays; + proc_glBindVertexArray* glBindVertexArray; + proc_glGenBuffers* glGenBuffers; + proc_glBindBuffer* glBindBuffer; + proc_glBufferData* glBufferData; + proc_glBufferSubData* glBufferSubData; + proc_glCreateShader* glCreateShader; + proc_glShaderSource* glShaderSource; + proc_glCompileShader* glCompileShader; + proc_glCreateProgram* glCreateProgram; + proc_glAttachShader* glAttachShader; + proc_glLinkProgram* glLinkProgram; + proc_glUseProgram* glUseProgram; + proc_glGetAttribLocation* glGetAttribLocation; + proc_glVertexAttribPointer* glVertexAttribPointer; + proc_glEnableVertexAttribArray* glEnableVertexAttribArray; + proc_glGetShaderiv* glGetShaderiv; + proc_glGetShaderInfoLog* glGetShaderInfoLog; + proc_glGetProgramiv* glGetProgramiv; + proc_glGetProgramInfoLog* glGetProgramInfoLog; + proc_glGetUniformLocation* glGetUniformLocation; + proc_glUniformMatrix4fv* glUniformMatrix4fv; +}; + +global OpenGL_Extensions gl = {}; + +#endif //LUMENARIUM_EDITOR_OPENGL_H \ No newline at end of file diff --git a/src_v2/editor/lumenarium_editor.c b/src_v2/editor/lumenarium_editor.c new file mode 100644 index 0000000..350543d --- /dev/null +++ b/src_v2/editor/lumenarium_editor.c @@ -0,0 +1,334 @@ +internal void +ed_load_font_cb(File_Async_Job_Args result, u8* user_data) +{ + App_State* state = (App_State*)user_data; + UI* ui = &state->editor->ui; + + u8* f = result.data.base; + stbtt_fontinfo font; + if (!stbtt_InitFont(&font, f, stbtt_GetFontOffsetForIndex(f, 0))) + { + invalid_code_path; + } + + r32 scale = stbtt_ScaleForPixelHeight(&font, 16.0f); + s32 ascent, descent, line_gap; + stbtt_GetFontVMetrics(&font, &ascent, &descent, &line_gap); + ui->font_ascent = (r32)ascent * scale; + ui->font_descent = (r32)descent * scale; + ui->font_line_gap = (r32)line_gap * scale; + if (ui->font_line_gap == 0) ui->font_line_gap = 5; + + ui->font_texture_scale = 2; + scale *= ui->font_texture_scale; + String c = lit_str("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-=_+[]{}\\|;:'\",<.>/?`~"); + for (u64 i = 0; i < c.len; i++) + { + s32 w, h, xoff, yoff; + u32 id = (u32)c.str[i]; + u8* bp = stbtt_GetCodepointBitmap(&font, 0, scale, (char)c.str[i], &w, &h, &xoff, &yoff); + s32 x0, y0, x1, y1; + stbtt_GetCodepointBitmapBoxSubpixel(&font, (char)c.str[i], scale, scale, 0, 0, &x0, &y0, &x1, &y1); + + v2 offset = (v2){ 0, (r32)y0 / ui->font_texture_scale }; + texture_atlas_register(&state->editor->ui.atlas, bp, (u32)w, (u32)h, id, offset, TextureAtlasRegistration_PixelFormat_Alpha); + stbtt_FreeBitmap(bp, 0); + } + + Texture_Atlas_Sprite m_sprite = texture_atlas_sprite_get(&state->editor->ui.atlas, (u32)'m'); + ui->font_space_width = (r32)(m_sprite.max_x - m_sprite.min_x); + + texture_update(ui->atlas_texture, ui->atlas.pixels, 1024, 1024, 1024); +} + +internal void +ed_draw_panel(u8* user_data, BSP_Node_Id id, BSP_Node node, BSP_Area area) +{ + App_State* state = (App_State*)user_data; + UI* ui = &state->editor->ui; + scratch_get(scratch); + + UI_Layout title_layout = {}; + ui_layout_set_row_info(ui, &title_layout); + title_layout.bounds_min = (v2){ area.min.x, area.max.y - title_layout.row_height }; + title_layout.bounds_max = area.max; + title_layout.at = title_layout.bounds_min; + + UI_Layout panel_layout = {}; + ui_layout_set_row_info(ui, &panel_layout); + panel_layout.bounds_min = area.min; + panel_layout.bounds_max = (v2){ area.max.x, title_layout.bounds_max.y }; + panel_layout.at = panel_layout.bounds_min; + + ui_layout_push(ui, &panel_layout); + + String title = {}; + switch (node.user_data) + { + case 0: + { + title = lit_str("None"); + } break; + + case 1: + { + ed_sculpture_visualizer(state); + title = lit_str("Sculpture"); + } break; + + invalid_default_case; + } + ui_layout_pop(ui); + + ui_layout_push(ui, &title_layout); + UI_Widget_Desc bg = {}; + bg.style.flags = UIWidgetStyle_Bg; + bg.style.color_bg = (v4){.4f,.4f,.4f,1}; + bg.style.sprite = WHITE_SPRITE_ID; + bg.string = string_f(scratch.a, "%.*s_%u_title_bg", str_varg(title), id.value); + bg.p_min = title_layout.bounds_min; + bg.p_max = title_layout.bounds_max; + UI_Widget_Result r = ui_widget_push(ui, bg); + ui_layout_row_begin(&title_layout, 4); + { + ui_textc(ui, BLACK_V4, title); + } + ui_layout_row_end(&title_layout); + ui_widget_pop(ui, r.id); + ui_layout_pop(ui); + + scratch_release(scratch); +} + +Geometry_Buffer b; +Shader shd; +Texture tex; + +internal void +ed_init(App_State* state, Editor_Desc* desc) +{ + lumenarium_env_validate(); + + Editor* editor = allocator_alloc_struct(permanent, Editor); + zero_struct(*editor); + state->editor = editor; + editor->window_dim = desc->init_window_dim; + editor->content_scale = desc->content_scale; + editor->ui = ui_create(4096, 4096, state->input_state, permanent); + editor->ui.draw_panel_cb = ed_draw_panel; + editor->ui.draw_panel_cb_data = (u8*)state; + //bsp_split(&editor->ui.panels, editor->ui.panels.root, 700, BSPSplit_YAxis, 0, 1); + + file_async_read(lit_str("data/font.ttf"), ed_load_font_cb); + + r32 w = 1400; + r32 h = 700; + r32 z = -1; + r32 tri[] = { + 0, 0, 0, 0, 0, + w, 0, z, 1, 0, + w, h, z, 1, 1, + 0, h, z, 0, 1, + }; + u32 indices[] = { 0, 1, 2, 0, 2, 3 }; + + String shd_v = lit_str( + "#version 330 core\n" + "layout (location = 0) in vec3 pos;\n" + "layout (location = 1) in vec2 auv;\n" + "out vec2 uv;\n" + "uniform mat4 proj;\n" + "void main(void) { \n" + " gl_Position = proj * vec4(pos, 1); \n" + " uv = auv;\n" + "}\n" + ); + String shd_f = lit_str( + "#version 330 core\n" + "in vec2 uv;\n" + "out vec4 FragColor;\n" + "uniform sampler2D tex;\n" + "void main(void) { FragColor = texture(tex, uv) * vec4(1,1,1,1); }" + ); + String shd_a[] = { lit_str("pos"), lit_str("auv") }; + String shd_u[] = { lit_str("proj") }; + b = geometry_buffer_create( + tri, sizeof(tri) / sizeof(r32), + indices, 6 + ); + shd = shader_create(shd_v, shd_f, shd_a, 2, shd_u, 1); + vertex_attrib_pointer(b, shd, 3, shd.attrs[0], 5, 0); + vertex_attrib_pointer(b, shd, 2, shd.attrs[1], 5, 3); + + u32 tex_pix[] = { 0xFFFFFFFF, 0xFF00FFFF, 0xFFFFFF00, 0xFFFF00FF }; + tex = texture_create(texture_desc_default(2, 2), (u8*)tex_pix); + + ed_sculpture_visualizer_init(state); + lumenarium_env_validate(); +} + +internal u8* +ed_leds_to_texture(App_State* state, Allocator_Scratch* scratch, u32 pixels_dim) +{ + u32 at = 0; + u32* pixels = allocator_alloc_array(scratch->a, u32, pixels_dim * pixels_dim); + for (u32 a = 0; a < state->assemblies.len; a++) + { + Assembly_Pixel_Buffer leds = state->assemblies.pixel_buffers[a]; + for (u32 p = 0; p < leds.len; p++) + { + Assembly_Pixel led = leds.pixels[p]; + u32 index = at++; + pixels[index] = ( + led.r << 0 | + led.g << 8 | + led.b << 16 | + 0xFF << 24 + ); + } + } + return (u8*)pixels; +} + +internal void +ed_sculpture_updated(App_State* state, r32 scale, r32 led_size) +{ + lumenarium_env_validate(); + Editor* ed = state->editor; + if (!ed) return; + + scratch_get(scratch); + + // NOTE(PS): we need to know the total number of leds in order to give them + // texture coordinates + u32 leds_count = 0; + for (u32 a = 0; a < state->assemblies.len; a++) + { + Assembly_Pixel_Buffer pixels = state->assemblies.pixel_buffers[a]; + leds_count += pixels.len; + } + + // round up to a texture whose sides are powers of two + u32 pixels_dim = (u32)floorf(sqrtf((r32)leds_count)); + pixels_dim = round_up_to_pow2_u32(pixels_dim); + u32 pixels_count = pixels_dim * pixels_dim; + r32 texel_dim = 1 / (r32)pixels_dim; + + // NOTE(PS): Rebuild the sculpture geometry to point to the new + // sculpture. + Geo_Vertex_Buffer_Storage storage = ( + GeoVertexBufferStorage_Position | + GeoVertexBufferStorage_TexCoord + ); + + u32 verts_cap = leds_count * 4; + u32 indices_cap = leds_count * 6; + Geo_Quad_Buffer_Builder geo = geo_quad_buffer_builder_create(scratch.a, verts_cap, storage, indices_cap); + geo_vertex_buffers_validate(&geo.buffer_vertex); + + r32 r = led_size; + u32 pixels_created = 0; + for (u32 a = 0; a < state->assemblies.len; a++) + { + Assembly_Pixel_Buffer pixels = state->assemblies.pixel_buffers[a]; + for (u32 p = 0; p < pixels.len; p++) + { + v3 c = pixels.positions[p].xyz; + c = HMM_MultiplyVec3f(c, scale); + u32 pixel_count = pixels_created++; + u32 pixel_x = pixel_count % pixels_dim; + u32 pixel_y = pixel_count / pixels_dim; + + r32 texel_x_min = (r32)pixel_x / (r32)pixels_dim; + r32 texel_y_min = (r32)pixel_y / (r32)pixels_dim; + r32 texel_x_max = texel_x_min + (texel_dim / 2); + r32 texel_y_max = texel_y_min + (texel_dim / 2); + + v2 t0 = (v2){texel_x_max, texel_y_max}; + v2 t1 = (v2){texel_x_max, texel_y_max}; + v2 t2 = (v2){texel_x_max, texel_y_max}; + v2 t3 = (v2){texel_x_max, texel_y_max}; + + v3 p0 = HMM_AddVec3(c, (v3){ -r, -r, 0 }); + v3 p1 = HMM_AddVec3(c, (v3){ r, -r, 0 }); + v3 p2 = HMM_AddVec3(c, (v3){ r, r, 0 }); + v3 p3 = HMM_AddVec3(c, (v3){ -r, r, 0 }); + geo_quad_buffer_builder_push_vt(&geo, p0, p1, p2, p3, t0, t1, t2, t3); + } + } + geo_vertex_buffers_validate(&geo.buffer_vertex); + + if (ed->sculpture_geo.indices_len != 0) + { + invalid_code_path; + // TODO(PS): destroy the old geometry buffer or update it + } + ed->sculpture_geo = geometry_buffer_create( + geo.buffer_vertex.values, + geo.buffer_vertex.len * geo.buffer_vertex.stride, + geo.buffer_index.values, + geo.buffer_index.len + ); + vertex_attrib_pointer(ed->sculpture_geo, ed->sculpture_shd, 3, ed->sculpture_shd.attrs[0], 5, 0); + vertex_attrib_pointer(ed->sculpture_geo, ed->sculpture_shd, 2, ed->sculpture_shd.attrs[1], 5, 3); + + // TODO(PS): make this have enough pixels for the sculpture + // TODO(PS): map leds to pixels + + if (ed->sculpture_tex.desc.w != 0) + { + invalid_code_path; + // TODO(PS): destroy the old texture + } + + u8* pixels = ed_leds_to_texture(state, &scratch, pixels_dim); + Texture_Desc pixel_texture_desc = { + .w = pixels_dim, + .h = pixels_dim, + .s = pixels_dim, + .min_filter = GL_NEAREST, + .mag_filter = GL_NEAREST, + .fmt_internal = GL_RGBA, + .fmt_data = GL_RGBA + }; + ed->sculpture_tex = texture_create(pixel_texture_desc, pixels); + + scratch_release(scratch); + lumenarium_env_validate(); +} + +internal void +ed_frame_prepare(App_State* state) +{ + lumenarium_env_validate(); + ui_frame_prepare(&state->editor->ui, state->editor->window_dim); + lumenarium_env_validate(); +} + +internal void +ed_frame(App_State* state) +{ + lumenarium_env_validate(); + Editor* ed = state->editor; + UI* ui = &ed->ui; + + { + scratch_get(scratch); + u32 w = ed->sculpture_tex.desc.w; + u8* pixels = ed_leds_to_texture(state, &scratch, w); + texture_update(ed->sculpture_tex, pixels, w, w, w); + scratch_release(scratch); + } + + edr_render_begin(state); + ui_draw(&state->editor->ui); + edr_render(state); + lumenarium_env_validate(); +} + +internal void +ed_cleanup(App_State* state) +{ + lumenarium_env_validate(); +} + diff --git a/src_v2/editor/lumenarium_editor.h b/src_v2/editor/lumenarium_editor.h new file mode 100644 index 0000000..f275a99 --- /dev/null +++ b/src_v2/editor/lumenarium_editor.h @@ -0,0 +1,25 @@ +/* date = March 27th 2022 0:50 pm */ + +#ifndef LUMENARIUM_EDITOR_H +#define LUMENARIUM_EDITOR_H + +typedef struct Editor Editor; +struct Editor +{ + v2 content_scale; + v2 window_dim; + Editor_Renderer renderer; + UI ui; + + v3 camera_pos; + + Geometry_Buffer sculpture_geo; + Shader sculpture_shd; + Texture sculpture_tex; +}; + +// NOTE(PS): call this any time sculpture data is updated if +// you want to see the sculpture in the visualizer +internal void ed_sculpture_updated(App_State* state, r32 scale, r32 led_size); + +#endif //LUMENARIUM_EDITOR_H diff --git a/src_v2/editor/lumenarium_editor_renderer.c b/src_v2/editor/lumenarium_editor_renderer.c new file mode 100644 index 0000000..d0ebf70 --- /dev/null +++ b/src_v2/editor/lumenarium_editor_renderer.c @@ -0,0 +1,18 @@ + +internal void +edr_render_begin(App_State* state) +{ + Graphics_Frame_Desc desc = {}; + desc.clear_color = (v4){ 0.0f, 0.0f, 0.0f, 1 }; + desc.viewport_min = (v2){ 0, 0 }; + v2 wd = state->editor->window_dim; + v2 cs = state->editor->content_scale; + desc.viewport_max = HMM_MultiplyVec2(wd, cs); + frame_begin(desc); + frame_clear(); +} + +internal void +edr_render(App_State* state) +{ +} \ No newline at end of file diff --git a/src_v2/editor/lumenarium_editor_renderer.h b/src_v2/editor/lumenarium_editor_renderer.h new file mode 100644 index 0000000..4129499 --- /dev/null +++ b/src_v2/editor/lumenarium_editor_renderer.h @@ -0,0 +1,11 @@ +/* date = March 24th 2022 4:18 pm */ + +#ifndef LUMENARIUM_EDITOR_RENDERER_H +#define LUMENARIUM_EDITOR_RENDERER_H + +typedef struct Editor_Renderer Editor_Renderer; +struct Editor_Renderer +{ +}; + +#endif //LUMENARIUM_EDITOR_RENDERER_H diff --git a/src_v2/editor/lumenarium_editor_sculpture_visualizer.c b/src_v2/editor/lumenarium_editor_sculpture_visualizer.c new file mode 100644 index 0000000..686aac4 --- /dev/null +++ b/src_v2/editor/lumenarium_editor_sculpture_visualizer.c @@ -0,0 +1,153 @@ +#include "lumenarium_editor_sculpture_visualizer_shaders.h" + +u32 fbo; +Texture fbo_tex_c; +u32 fbo_rbo; +Geometry_Buffer fs_quad; +Shader fs_shd; + +internal void +ed_sculpture_visualizer_init(App_State* state) +{ + Editor* editor = state->editor; + + String vert = xplatform_shader_program_get_vert(sculpture_shd); + String frag = xplatform_shader_program_get_frag(sculpture_shd); + + String attrs[] = { lit_str("a_pos"), lit_str("a_uv") }; + String uniforms[] = { lit_str("proj") }; + editor->sculpture_shd = shader_create(vert, frag, attrs, 2, uniforms, 1); + + { + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + + v2 wds = HMM_MultiplyVec2(editor->window_dim, editor->content_scale); + s32 w = (s32)wds.x; + s32 h = (s32)wds.y; + fbo_tex_c = texture_create( + (Texture_Desc){ + .w = w, .h = h, .s = w, + .min_filter = GL_LINEAR, + .mag_filter = GL_LINEAR, + .fmt_internal = GL_RGBA, + .fmt_data = GL_RGBA, + }, + 0 + ); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fbo_tex_c.id, 0); + + glGenRenderbuffers(1, &fbo_rbo); + glBindRenderbuffer(GL_RENDERBUFFER, fbo_rbo); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, w, h); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fbo_rbo); + + u32 status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + u32 complete = GL_FRAMEBUFFER_COMPLETE; + if (status != complete) + { + #define GL_ENUM_ERROR_CASE(e, msg) case e: { printf("Error: %s - %s\n", #e, msg); } break + switch (status) { + GL_ENUM_ERROR_CASE(GL_FRAMEBUFFER_UNDEFINED, ""); + GL_ENUM_ERROR_CASE(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT, ""); + GL_ENUM_ERROR_CASE(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT, ""); + GL_ENUM_ERROR_CASE(GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER, ""); + GL_ENUM_ERROR_CASE(GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER, ""); + GL_ENUM_ERROR_CASE(GL_FRAMEBUFFER_UNSUPPORTED, ""); + GL_ENUM_ERROR_CASE(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, ""); + //GL_ENUM_ERROR_CASE(GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS, ""); + default: { + os_gl_no_error(); + } break; + } + printf("Error: unable to complete framebuffer\n"); + } + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + String vert = xplatform_shader_program_get_vert(sculpture_comp_shd); + String frag = xplatform_shader_program_get_frag(sculpture_comp_shd); + String shd_a[] = { lit_str("a_pos"), lit_str("a_uv") }; + String shd_u[] = { lit_str("proj") }; + fs_shd = shader_create(vert, frag, shd_a, 2, shd_u, 1); + + fs_quad = unit_quad_create(); + vertex_attrib_pointer(fs_quad, fs_shd, 3, fs_shd.attrs[0], 5, 0); + vertex_attrib_pointer(fs_quad, fs_shd, 2, fs_shd.attrs[1], 5, 3); + } +} + +r32 cam_theta = 0; +u32 offset = 0; + +internal void +ed_sculpture_visualizer(App_State* state) +{ + Editor* ed = state->editor; + + incenter_sculpture_visualizer_ui(state, ed); + +#define SCULPTURE_VIZ_BLOOM 0 +#if SCULPTURE_VIZ_BLOOM + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + os_gl_no_error(); + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); +#endif + + // Set the viewport to the current layout's region so that the sculpture + // never overlaps any other ui elements + UI_Layout l = *ed->ui.layout; + v2 view_dim = HMM_SubtractVec2(l.bounds_max, l.bounds_min); + v2 view_min = l.bounds_min; + v2 view_max = l.bounds_max; + v2 view_min_scaled = HMM_MultiplyVec2(view_min, ed->content_scale); + v2 view_dim_scaled = HMM_MultiplyVec2(view_dim, ed->content_scale); + glViewport( + (s32)view_min_scaled.x, + (s32)view_min_scaled.y, + (u32)view_dim_scaled.x, + (u32)view_dim_scaled.y + ); + + // TODO(PS): TEMPORARY CAMERA CODE + cam_theta += 0.005f; + r32 cam_r = 50; + v3 camera_pos = (v3){ 0, -4.9, -cam_r }; + camera_pos = (v3){sinf(cam_theta) * cam_r, -4.9f, cosf(cam_theta) * cam_r}; + r32 aspect = view_dim.x / view_dim.y; + m44 proj = HMM_Perspective(72.0, aspect, 0.01f, 500); + m44 view = HMM_LookAt(camera_pos, (v3){0,2,0}, (v3){0,1,0}); + + shader_bind(ed->sculpture_shd); + set_uniform(ed->sculpture_shd, 0, HMM_MultiplyMat4(proj, view)); + texture_bind(ed->sculpture_tex); + geometry_bind(ed->sculpture_geo); + + u32 i = 1008; + u32 j = 2868; + u32 k = ed->sculpture_geo.indices_len; + u32 h = (i * 6) + 3; + geometry_drawi(ed->sculpture_geo, k, 0); + + // reset the viewport for all other rendering +#if SCULPTURE_VIZ_BLOOM + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + v2 wds = HMM_MultiplyVec2(ed->window_dim, ed->content_scale); + glViewport(0, 0, (s32)wds.x, (s32)wds.y); + + m44 ortho = HMM_Orthographic(0, ed->window_dim.x, ed->window_dim.y, 0, 0.01f, 200.0f); + m44 scale = HMM_Scale((v3){ed->window_dim.x / 2, -ed->window_dim.y / 2, 100}); + m44 pos = HMM_Translate((v3){ed->window_dim.x / 2, ed->window_dim.y / 2, -99}); + m44 model = HMM_MultiplyMat4(pos, scale); + m44 mvp = HMM_MultiplyMat4(ortho, model); + + shader_bind(fs_shd); + set_uniform(fs_shd, 0, mvp); + texture_bind(fbo_tex_c); + geometry_bind(fs_quad); + geometry_drawi(fs_quad, 6, 0); +#endif // SCULPTURE_VIZ_BLOOM +} \ No newline at end of file diff --git a/src_v2/editor/lumenarium_editor_sculpture_visualizer_shaders.h b/src_v2/editor/lumenarium_editor_sculpture_visualizer_shaders.h new file mode 100644 index 0000000..face326 --- /dev/null +++ b/src_v2/editor/lumenarium_editor_sculpture_visualizer_shaders.h @@ -0,0 +1,135 @@ + +global XPlatform_Shader_Program_Src sculpture_shd = { + .win32_vert = lit_str( + "#version 330 core\n" + "layout (location = 0) in vec3 a_pos;\n" + "layout (location = 1) in vec2 a_uv;\n" + "out vec2 uv;\n" + "uniform mat4 proj;\n" + "void main(void) {\n" + " gl_Position = proj * vec4(a_pos, 1.0);\n" + " uv = a_uv;\n" + "}" + ), + .win32_frag = lit_str( + "#version 330 core\n" + "in vec2 uv;\n" + "out vec4 FragColor;\n" + "uniform sampler2D tex;\n" + "void main(void) {\n" + " FragColor = texture(tex, uv);\n" + "}" + ), + .osx_vert = lit_str( + "#version 330 core\n" + "layout (location = 0) in vec3 a_pos;\n" + "layout (location = 1) in vec2 a_uv;\n" + "out vec2 uv;\n" + "uniform mat4 proj;\n" + "void main(void) {\n" + " gl_Position = proj * vec4(a_pos, 1.0);\n" + " uv = a_uv;\n" + "}" + ), + .osx_frag = lit_str( + "#version 330 core\n" + "in vec2 uv;\n" + "out vec4 FragColor;\n" + "uniform sampler2D tex;\n" + "void main(void) {\n" + " FragColor = texture(tex, uv);\n" + "}" + ), + + .wasm_vert = lit_str( + "precision highp float;\n" + "attribute vec3 a_pos;\n" + "attribute vec2 a_uv;\n" + "varying vec2 uv;\n" + "uniform mat4 proj;\n" + "void main(void) {\n" + " gl_Position = proj * vec4(a_pos, 1.0);\n" + " uv = a_uv;\n" + "}" + ), + .wasm_frag = lit_str( + "precision highp float;\n" + "varying vec2 uv;\n" + "uniform sampler2D tex;\n" + "void main(void) {\n" + " //gl_FragColor = texture2D(tex, uv) * color;\n" + " gl_FragColor = vec4(uv.x,1,uv.y,1);\n" + "}" + ), +}; + + + +global XPlatform_Shader_Program_Src sculpture_comp_shd = { + .win32_vert = lit_str("" + ), + .win32_frag = lit_str( + "" + ), + + .osx_vert = lit_str( + "#version 330 core\n" + "layout (location = 0) in vec3 a_pos;\n" + "layout (location = 1) in vec2 a_uv;\n" + "out vec2 uv;\n" + "uniform mat4 proj;\n" + "void main(void) {\n" + " gl_Position = proj * vec4(a_pos, 1.0);\n" + " uv = a_uv;\n" + "}" + ), + .osx_frag = lit_str( + "#version 330 core\n" + "in vec2 uv;\n" + "out vec4 FragColor;\n" + "uniform sampler2D tex;\n" + "float normpdf(in float x, in float sigma) { return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma; }\n" + "void main(void) {\n" + " vec4 orig_p = texture(tex, uv);\n" + " vec2 tex_size = textureSize(tex, 0);\n" + " vec2 tex_offset = 1.0 / tex_size;\n" + " " + " const int m_size = 15;\n // must be odd\n" + " const int k_size = (m_size - 1) / 2;\n" + " float kernel[m_size];\n" + " float sigma = 7.0;\n" + " float z = 0;\n" + " for (int i = 0; i <= k_size; i++) {\n" + " float v = normpdf(float(i), sigma);\n" + " kernel[k_size + i] = v; kernel[k_size - i] = v;\n" + " }\n" + " for (int i = 0; i < m_size; i++) {\n" + " z += kernel[i];\n" + " }\n" + " vec3 bloom_acc = vec3(0);\n" + " for (int i = -k_size; i <= k_size; i++) {\n" + " for (int j = -k_size; j <= k_size; j++) {\n" + " vec2 uvp = uv + (vec2(float(i), float(j)) / tex_size);\n" + " bloom_acc += kernel[k_size + j] * kernel[k_size + i] * texture(tex, uvp).xyz;\n" + " }\n" + " }\n" + " vec3 bloom_color = bloom_acc / (z * z);\n" + " vec3 final_color = orig_p.xyz + bloom_color;\n" + // tone mapping + " float exposure = 1.0;\n" + " float gamma = 2.2;\n" + " vec3 result = vec3(1.0) - exp(-final_color * exposure);\n" + // also gamma correct while we're at it + " result = pow(result, vec3(1.0 / gamma));\n" + " FragColor = vec4(result, 1.0);\n" + "}" + ), + + .wasm_vert = lit_str( + "" + ), + .wasm_frag = lit_str( + "" + ), +}; + diff --git a/src_v2/editor/lumenarium_editor_ui.c b/src_v2/editor/lumenarium_editor_ui.c new file mode 100644 index 0000000..8339f8a --- /dev/null +++ b/src_v2/editor/lumenarium_editor_ui.c @@ -0,0 +1,873 @@ +#define WHITE_SPRITE_ID 511 + +#include "lumenarium_editor_ui_shaders.h" + +internal UI +ui_create(u32 widget_pool_cap, u32 verts_cap, Input_State* input, Allocator* a) +{ + UI result = {}; + zero_struct(result); + result.input = input; + + result.per_frame = bump_allocator_create_reserve(KB(4)); + + // Widgets + result.widgets.free = allocator_alloc_array(a, UI_Widget, widget_pool_cap); + result.widgets.free_cap = widget_pool_cap; + result.widgets.states_cap = 3 * widget_pool_cap; + result.widgets.states = allocator_alloc_array(a, UI_Widget_State, result.widgets.states_cap); + result.widgets.states_hash = allocator_alloc_array(a, u32, result.widgets.states_cap); + + result.panels = bsp_create(a, 32); + result.panels.root = bsp_push(&result.panels, (BSP_Node_Id){0}, (BSP_Area){(v2){},(v2){1400, 800}}, 1); + + // Per Frame Vertex Buffer + Geo_Vertex_Buffer_Storage storage = ( + GeoVertexBufferStorage_Position | + GeoVertexBufferStorage_TexCoord | + GeoVertexBufferStorage_Color + ); + result.geo = geo_quad_buffer_builder_create(a, verts_cap, storage, verts_cap * 2); + + result.per_frame_buffer = geometry_buffer_create( + result.geo.buffer_vertex.values, + result.geo.buffer_vertex.cap * result.geo.buffer_vertex.stride, + result.geo.buffer_index.values, + result.geo.buffer_index.cap + ); + + String vert = xplatform_shader_program_get_vert(ui_shader); + String frag = xplatform_shader_program_get_frag(ui_shader); + + String attrs[] = { lit_str("a_pos"), lit_str("a_uv"), lit_str("a_color") }; + String uniforms[] = { lit_str("proj") }; + result.shader = shader_create(vert, frag, attrs, 3, uniforms, 1); + + vertex_attrib_pointer(result.per_frame_buffer, result.shader, 3, result.shader.attrs[0], 9, 0); + vertex_attrib_pointer(result.per_frame_buffer, result.shader, 2, result.shader.attrs[1], 9, 3); + vertex_attrib_pointer(result.per_frame_buffer, result.shader, 4, result.shader.attrs[2], 9, 5); + + // Texture Atlas + result.atlas = texture_atlas_create(1024, 1024, 512, permanent); + result.atlas_texture = texture_create(texture_desc_default(1024, 1024), result.atlas.pixels); + + u32 white_sprite[] = { + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + }; + ui_sprite_register(&result, (u8*)white_sprite, 4, 4, WHITE_SPRITE_ID); + + ui_create_default_style_sheet(); + return result; +} + +internal void +ui_quad_push(UI* ui, v3 pmin, v3 pmax, v2 tmin, v2 tmax, v4 c) +{ + v3 p0 = pmin; + v3 p1 = (v3){pmax.x, pmin.y, pmin.z}; + v3 p2 = pmax; + v3 p3 = (v3){pmin.x, pmax.y, pmin.z}; + v2 t0 = tmin; + v2 t1 = (v2){tmax.x,tmin.y}; + v2 t2 = tmax; + v2 t3 = (v2){tmin.x,tmax.y}; + geo_quad_buffer_builder_push_vtc(&ui->geo, p0, p1, p2, p3, t0, t1, t2, t3, c); +} + +internal void +ui_sprite_register(UI* ui, u8* pixels, u32 w, u32 h, u32 id) +{ + texture_atlas_register(&ui->atlas, pixels, w, h, id, (v2){0,0}, TextureAtlasRegistration_PixelFormat_RGBA); + texture_update(ui->atlas_texture, ui->atlas.pixels, ui->atlas.width, ui->atlas.height, ui->atlas.width); +} + +internal void +ui_sprite_push_color(UI* ui, v3 pmin, v3 pmax, u32 id, v4 color) +{ + Texture_Atlas_Sprite sprite = texture_atlas_sprite_get(&ui->atlas, id); + v4 uv = texture_atlas_sprite_get_uvs(&ui->atlas, sprite); + pmin.XY = HMM_AddVec2(pmin.XY, sprite.draw_offset); + pmax.XY = HMM_AddVec2(pmax.XY, sprite.draw_offset); + ui_quad_push(ui, pmin, pmax, uv.xy, uv.zw, color); +} + +internal void +ui_sprite_push(UI* ui, v3 pmin, v3 pmax, u32 id) +{ + ui_sprite_push_color(ui, pmin, pmax, id, (v4){1,1,1,1}); +} + +typedef struct UI_Char_Draw_Cmd UI_Char_Draw_Cmd; +struct UI_Char_Draw_Cmd +{ + v4 uv; + v3 pmin; + v3 pmax; + v3 baseline_after; +}; + +internal UI_Char_Draw_Cmd +ui_sprite_char_get_draw_cmd(UI* ui, v3 at, u32 codepoint) +{ + UI_Char_Draw_Cmd result = {}; + zero_struct(result); + + Texture_Atlas_Sprite sprite = texture_atlas_sprite_get(&ui->atlas, codepoint); + result.uv = texture_atlas_sprite_get_uvs(&ui->atlas, sprite); + + v3 dim = (v3){ + (r32)(sprite.max_x - sprite.min_x) / ui->font_texture_scale, + (r32)(sprite.max_y - sprite.min_y) / ui->font_texture_scale, + 0, + }; + result.pmin = at; + result.pmin.XY = HMM_AddVec2(result.pmin.XY, sprite.draw_offset); + result.pmin.XY = v2_floor(result.pmin.XY); + result.pmax = HMM_AddVec3(result.pmin, dim); + + result.baseline_after = (v3){ result.pmax.x + 1.5f, at.y, at.z }; + + return result; +} + +internal void +ui_frame_prepare(UI* ui, v2 window_dim) +{ + bump_allocator_clear(ui->per_frame); + ui->geo.buffer_vertex.len = 0; + ui->geo.buffer_index.len = 0; + + ui->widgets.free_len = 0; + ui->widgets.active_parent = 0; + ui->widgets.root = ui_widget_pool_push(&ui->widgets, lit_str("root")); + ui->widgets.active_parent = ui->widgets.root; + + BSP_Node* panel_root = bsp_get(&ui->panels, ui->panels.root); + if (window_dim.x != 0 && window_dim.y != 0 && !HMM_EqualsVec2(window_dim, panel_root->area.max)) + { + BSP_Area area = {}; + area.min = (v2){0,0}; + area.max = window_dim; + bsp_node_area_update(&ui->panels, ui->panels.root, area); + } + + v2 half_d = HMM_MultiplyVec2f(window_dim, 0.5f); + ui->proj = HMM_Orthographic(0, window_dim.x, window_dim.y, 0, 0.01f, 100); + + if (ui->widget_next_hot.value != 0) + { + ui->widget_next_hot_frames += 1; + if (ui->widget_next_hot_frames > 1) ui_widget_next_hot_set(ui, 0); + } + if (ui->widget_hot.value != 0) + { + ui->widget_hot_frames += 1; + if (ui->widget_hot_frames > 1) ui_widget_hot_set(ui, 0); + } +} + +global bool show = false; + +internal void +ui_draw_panel(BSP* tree, BSP_Node_Id id, BSP_Node* node, u8* user_data) +{ + if (node->split.kind != BSPSplit_None) return; + UI* ui = (UI*)user_data; + BSP_Area area = node->area; + + if (ui->draw_panel_cb) ui->draw_panel_cb(ui->draw_panel_cb_data, id, *node, area); + + r32 z = -1; + v3 l0p0 = (v3){ area.min.x, area.min.y, z }; // left side + v3 l0p1 = (v3){ area.min.x + 1, area.max.y, z }; + v3 l1p0 = (v3){ area.max.x - 1, area.min.y, z }; // right side + v3 l1p1 = (v3){ area.max.x, area.max.y, z }; + v3 l2p0 = (v3){ area.min.x, area.min.y , z }; // bottom side + v3 l2p1 = (v3){ area.max.x, area.min.y + 1, z }; + v3 l3p0 = (v3){ area.min.x, area.max.y , z }; // top side + v3 l3p1 = (v3){ area.max.x, area.max.y + 1, z }; + u32 sid = WHITE_SPRITE_ID; + v4 c = WHITE_V4; + if (rect2_contains(area.min, area.max, ui->input->frame_hot->mouse_pos)) + { + c = PINK_V4; + } + + ui_sprite_push_color(ui, l0p0, l0p1, sid, c); + ui_sprite_push_color(ui, l1p0, l1p1, sid, c); + ui_sprite_push_color(ui, l2p0, l2p1, sid, c); + ui_sprite_push_color(ui, l3p0, l3p1, sid, c); +} + +internal void +ui_draw(UI* ui) +{ + bsp_walk_inorder(&ui->panels, ui->panels.root, ui_draw_panel, (u8*)ui); + + u32 widget_count = ui->widgets.free_len; + r32 range_min = -10; + r32 range_max = -1; + r32 range_step = (range_max - range_min) / (r32)(widget_count * 4); + ui_widgets_to_geometry_recursive(ui, ui->widgets.root, -10, range_step); + + geometry_buffer_update( + &ui->per_frame_buffer, + (r32*)ui->geo.buffer_vertex.values, + 0, + ui->geo.buffer_vertex.len * ui->geo.buffer_vertex.stride, + ui->geo.buffer_index.values, + 0, + ui->geo.buffer_index.len + ); + shader_bind(ui->shader); + set_uniform(ui->shader, 0, ui->proj); + texture_bind(ui->atlas_texture); + geometry_bind(ui->per_frame_buffer); + geometry_drawi(ui->per_frame_buffer, ui->geo.buffer_index.len, 0); +} + +//////////////////////////////////////////// +// Widgets + +internal UI_Widget_Id +ui_widget_id_create(String string, u32 index) +{ + assert(string.len != 0 && string.str != 0); + UI_Widget_Id result = {}; + zero_struct(result); + result.value = hash_djb2_string_to_u32(string); + result.index = index; + return result; +} + +internal UI_Widget_State* +ui_widget_pool_state_get(UI_Widget_Pool* pool, UI_Widget_Id id) +{ + u32 index = hash_table_find(pool->states_hash, pool->states_cap, id.value); + assert(index != pool->states_cap); + UI_Widget_State* result = pool->states + index; + return result; +} +internal UI_Widget_State* +ui_widget_state_get(UI* ui, UI_Widget_Id id) +{ + return ui_widget_pool_state_get(&ui->widgets, id); +} + +internal UI_Widget* +ui_widget_pool_push(UI_Widget_Pool* pool, String string) +{ + assert(pool->free_len < pool->free_cap); + UI_Widget* result = pool->free + pool->free_len++; + + result->id = ui_widget_id_create(string, pool->free_len); + result->parent = 0; + result->next = 0; + result->child_first = 0; + result->child_last = 0; + + u32 index = hash_table_find(pool->states_hash, pool->states_cap, result->id.value); + if (index == pool->states_cap) + { + index = hash_table_register(pool->states_hash, pool->states_cap, result->id.value); + } + assert(index != pool->states_cap); + UI_Widget_State* state = pool->states + index; + zero_struct(*state); + + if (pool->active_parent) + { + result->parent = pool->active_parent; + sll_push( + pool->active_parent->child_first, + pool->active_parent->child_last, + result + ); + } + pool->active_parent = result; + + return result; +} + +internal void +ui_widget_pool_pop(UI_Widget_Pool* pool) +{ + if (pool->active_parent->parent) + { + pool->active_parent = pool->active_parent->parent; + } +} + +internal bool +ui_widget_id_equals(UI_Widget_Id a, UI_Widget_Id b) +{ + return (a.value == b.value); +} + +internal bool +ui_widget_id_is_valid(UI_Widget_Id h) +{ + return h.value != 0; +} + +internal void +ui_widget_next_hot_set(UI* ui, UI_Widget* w) +{ + if (w) { + ui->widget_next_hot = w->id; + } else { + ui->widget_next_hot = (UI_Widget_Id){0}; + } + ui->widget_next_hot_frames = 0; +} + +internal void +ui_widget_hot_set(UI* ui, UI_Widget* w) +{ + if (w) { + ui->widget_hot = w->id; + } else { + ui->widget_hot = (UI_Widget_Id){0}; + } + ui->widget_hot_frames = 0; +} + +internal UI_Widget_Result +ui_widget_push(UI* ui, UI_Widget_Desc desc) +{ + UI_Widget_Result result = {}; + zero_struct(result); + v2 dim = HMM_SubtractVec2(desc.p_max, desc.p_min); + if (dim.x == 0 || dim.y == 0) return result; + + UI_Widget* w = ui_widget_pool_push(&ui->widgets, desc.string); + w->desc = desc; + result.id = w->id; + + UI_Widget_State* state = ui_widget_state_get(ui, w->id); + w->desc.fill_pct = state->scroll; + + v2 mouse_p = ui->input->frame_hot->mouse_pos; + bool mouse_over = ( + mouse_p.x >= desc.p_min.x && mouse_p.x <= desc.p_max.x && + mouse_p.y >= desc.p_min.y && mouse_p.y <= desc.p_max.y + ); + + UI_Widget_Style_Flags flags = desc.style.flags; + UI_Widget_Style_Flags mask_drag = (UIWidgetStyle_MouseDragH | UIWidgetStyle_MouseDragV); + UI_Widget_Style_Flags mask_hover = (mask_drag | UIWidgetStyle_MouseClick); + if (has_flag(flags, mask_hover)) + { + // CASES: + // Mouse Over | Mouse Clicked | Is Next Hot | Response + // f | f | t | clear next hot + // f | f | f | do nothing + // f | t | f | do nothing + // t | f | f | beome next hot + // t | t | f | become next hot + // t | t | t | become hot + + if (mouse_over) + { + if (ui_widget_id_equals(w->id, ui->widget_next_hot)) + { + if (input_key_is_down(ui->input, KeyCode_MouseLeftButton)) + { + ui_widget_hot_set(ui, w); + result.flags |= UIWidgetResult_MouseLeft_IsDown; + } + if (input_key_went_up(ui->input, KeyCode_MouseLeftButton)) + { + result.flags |= UIWidgetResult_MouseLeft_WentUp; + ui_widget_hot_set(ui, 0); + } + } + + if ((w->id.index >= ui->widget_next_hot.index) && ui->widget_hot.value == 0) + { + ui_widget_next_hot_set(ui, w); + } + } + else + { + if (ui_widget_id_equals(w->id, ui->widget_next_hot)) + { + ui_widget_next_hot_set(ui, 0); + } + } + } + + if(ui_widget_id_equals(w->id, ui->widget_hot)) + { + if (input_key_is_down(ui->input, KeyCode_MouseLeftButton)) + { + ui_widget_next_hot_set(ui, w); + ui_widget_hot_set(ui, w); + result.flags |= UIWidgetResult_MouseLeft_IsDown; + } + + if (has_flag(flags, mask_drag)) + { + v2 drag_pct_mask = { + has_flag(flags, UIWidgetStyle_MouseDragH) ? 1.0f : 0.0f, + has_flag(flags, UIWidgetStyle_MouseDragV) ? 1.0f : 0.0f + }; + v2 mp = ui->input->frame_hot->mouse_pos; + v2 drag = HMM_SubtractVec2(mp, w->desc.p_min); + drag = (v2){ clamp(0, drag.x, w->desc.p_max.x), clamp(0, drag.y, w->desc.p_max.y) }; + drag = HMM_MultiplyVec2(drag, drag_pct_mask); + v2 drag_pct = HMM_DivideVec2(drag, dim); + drag_pct = (v2){ clamp(0, drag_pct.x, 1), clamp(0, drag_pct.y, 1) }; + result.drag = drag_pct; + + state->scroll = drag_pct; + } + } + + return result; +} + +internal void +ui_widget_pop(UI* ui, UI_Widget_Id widget_id) +{ + if (!ui_widget_id_is_valid(widget_id)) return; + assert(ui_widget_id_equals(widget_id, ui->widgets.active_parent->id)); + ui_widget_pool_pop(&ui->widgets); +} + +internal r32 +ui_widgets_to_geometry_recursive(UI* ui, UI_Widget* widget, r32 z_start, r32 z_step) +{ + r32 z_at = z_start; + for (UI_Widget* child = widget->child_first; child != 0; child = child->next) + { + UI_Widget_Desc desc = child->desc; + v3 bg_min = v2_to_v3(desc.p_min, z_at); + v3 bg_max = v2_to_v3(desc.p_max, z_at); + + v4 color_fg = desc.style.color_fg; + v4 color_bg = desc.style.color_bg; + if (ui_widget_id_equals(ui->widget_next_hot, child->id)) + { + color_fg = desc.style.color_bg; + color_bg = desc.style.color_fg; + } + if (ui_widget_id_equals(ui->widget_hot, child->id)) + { + //color_fg = desc.style.color_fg; + //color_bg = desc.style.color_bg; + } + + if (has_flag(child->desc.style.flags, UIWidgetStyle_Outline)) + { + ui_sprite_push_color(ui, bg_min, bg_max, WHITE_SPRITE_ID, color_fg); + z_at += z_step; + bg_min = HMM_AddVec3(bg_min, (v3){ 1, 1, 0}); + bg_max = HMM_SubtractVec3(bg_max, (v3){ 1, 1, 0}); + } + + if (has_flag(child->desc.style.flags, UIWidgetStyle_Bg)) + { + bg_min.z = z_at; + bg_max.z = z_at; + ui_sprite_push_color(ui, bg_min, bg_max, desc.style.sprite, color_bg); + z_at += z_step; + } + + if (has_flag(child->desc.style.flags, (UIWidgetStyle_FillH | UIWidgetStyle_FillV))) + { + v3 fill_min = {}; + zero_struct(fill_min); + v3 fill_max = {}; + zero_struct(fill_max); + if (has_flag(child->desc.style.flags, UIWidgetStyle_FillH)) + { + r32 fill_x = HMM_Lerp(bg_min.x, child->desc.fill_pct.x, bg_max.x); + + if (has_flag(child->desc.style.flags, UIWidgetStyle_LineInsteadOfFill)) + { + fill_min = (v3){ fill_x, bg_min.y, z_at }; + fill_max = (v3){ fill_x + 1, bg_max.y, z_at }; + } + else + { + fill_min = bg_min; + fill_max = (v3){ fill_x, bg_max.y, z_at }; + } + } + else if (has_flag(child->desc.style.flags, UIWidgetStyle_FillV)) + { + r32 fill_y = HMM_Lerp(bg_min.y, child->desc.fill_pct.y, bg_max.y); + + if (has_flag(child->desc.style.flags, UIWidgetStyle_LineInsteadOfFill)) + { + fill_min = (v3){ bg_min.x, fill_y, z_at }; + fill_max = (v3){ bg_max.x, fill_y + 1, z_at }; + } + else + { + fill_min = bg_min; + fill_max = (v3){ bg_max.x, fill_y, z_at }; + } + } + + ui_sprite_push_color(ui, fill_min, fill_max, WHITE_SPRITE_ID, color_fg); + z_at += z_step; + } + + if (has_flag(child->desc.style.flags, UIWidgetStyle_TextWrap | UIWidgetStyle_TextClip)) + { + r32 space_width = ui->font_space_width; + r32 to_baseline = ui->font_line_gap + ui->font_ascent; + v3 line_offset = { 5, 3 + to_baseline, 0 }; + r32 baseline_x_start = desc.p_min.x + line_offset.x; + r32 baseline_y_start = desc.p_min.y + line_offset.y; + v3 baseline = { baseline_x_start, baseline_y_start, z_at }; + for (u64 i = 0; i < child->desc.string.len; i++) + { + u8 at = child->desc.string.str[i]; + UI_Char_Draw_Cmd cmd = {}; + zero_struct(cmd); + if (!char_is_space(at)) + { + cmd = ui_sprite_char_get_draw_cmd(ui, baseline, (u32)at); + } + else + { + cmd.baseline_after = baseline; + cmd.baseline_after.x += space_width; + } + + if (cmd.baseline_after.x >= desc.p_max.x - 5) + { + if (has_flag(child->desc.style.flags, UIWidgetStyle_TextClip)) break; + + baseline.x = baseline_x_start; + baseline.y += ui->font_ascent + ui->font_descent + ui->font_line_gap; + cmd = ui_sprite_char_get_draw_cmd(ui, baseline, (u32)at); + } + + if (!char_is_space(at)) + { + ui_quad_push(ui, cmd.pmin, cmd.pmax, cmd.uv.xy, cmd.uv.zw, color_fg); + } + baseline = cmd.baseline_after; + } + } + + if (child->child_first) + { + z_at = ui_widgets_to_geometry_recursive(ui, child, z_at + z_step, z_step); + } + + z_at += z_step; + } + return z_at; +} + +/////////////////////////////////////////// +// Layout Manager + +internal void +ui_layout_set_row_info(UI* ui, UI_Layout* l) +{ + l->row_height = (ui->font_ascent + ui->font_descent + ui->font_line_gap + 15); + l->row_gap = 2; + l->col_gap = 2; +} + +internal void +ui_layout_push(UI* ui, UI_Layout* layout) +{ + if (ui->layout) + { + layout->parent = ui->layout; + ui->layout = layout; + } + else + { + ui->layout = layout; + layout->parent = 0; + } +} + +internal void +ui_layout_pop(UI* ui) +{ + if (ui->layout) + { + ui->layout = ui->layout->parent; + } +} + +internal void +ui_layout_row_begin(UI_Layout* layout, u32 cols) +{ + layout->mode = UILayout_Rows; + layout->cols = cols; +} +internal void +ui_row_begin(UI* ui, u32 cols) { ui_layout_row_begin(ui->layout, cols); } + +internal void +ui_layout_row_end(UI_Layout* layout) +{ + layout->mode = UILayout_Columns; +} +internal void +ui_row_end(UI* ui) { ui_layout_row_end(ui->layout); } + +internal UI_Layout_Bounds +ui_layout_get_next(UI_Layout* layout) +{ + UI_Layout_Bounds result = {}; + zero_struct(result); + if (layout->at.x >= layout->bounds_max.x || layout->at.y >= layout->bounds_max.y || + layout->at.y + layout->row_height > layout->bounds_max.y) + { + return result; + } + + switch (layout->mode) + { + case UILayout_Columns: + { + result.min = layout->at; + result.max = (v2){ layout->bounds_max.x, layout->at.y + layout->row_height }; + layout->at = (v2){ layout->bounds_min.x, result.max.y + layout->row_gap}; + } break; + + case UILayout_Rows: + { + r32 col_width = (layout->bounds_max.x - layout->bounds_min.x) / layout->cols; + col_width -= (layout->cols - 1) * layout->col_gap; + result.min = layout->at; + result.max = (v2){ layout->at.x + col_width, layout->at.y + layout->row_height }; + layout->at = (v2){ result.max.x + layout->col_gap, layout->at.y }; + if (layout->at.x >= layout->bounds_max.x) + { + layout->at = (v2){ + layout->bounds_min.x, + layout->at.y + layout->row_height + layout->row_gap + }; + } + } break; + + invalid_default_case; + } + + if (result.min.x < layout->bounds_min.x || result.min.y < layout->bounds_min.y || + result.max.x < layout->bounds_min.x || result.max.y < layout->bounds_min.y) + { + zero_struct(result.min); + zero_struct(result.max); + } + + return result; +} + + +/////////////////////////////////////////// +// Specific Widget Implementations +// +// These all rely on a layout manager to make calling them simpler + +global UI_Style_Sheet ui_default_style_sheet = {}; + +internal void +ui_create_default_style_sheet() +{ + ui_default_style_sheet.styles[UIWidget_Text] = (UI_Widget_Style){ + (UIWidgetStyle_TextWrap), (v4){0,0,0,0}, WHITE_V4, WHITE_SPRITE_ID + }; + ui_default_style_sheet.styles[UIWidget_Button] = (UI_Widget_Style){ + (UIWidgetStyle_TextClip | UIWidgetStyle_Bg | UIWidgetStyle_Outline | UIWidgetStyle_MouseClick), BLACK_V4, WHITE_V4, WHITE_SPRITE_ID + }; + ui_default_style_sheet.styles[UIWidget_Toggle] = (UI_Widget_Style){ + (UIWidgetStyle_TextClip | UIWidgetStyle_Bg | UIWidgetStyle_MouseClick), BLACK_V4, WHITE_V4, WHITE_SPRITE_ID + }; + ui_default_style_sheet.styles[UIWidget_Menu] = ui_default_style_sheet.styles[UIWidget_Toggle]; + ui_default_style_sheet.styles[UIWidget_Dropdown] = ui_default_style_sheet.styles[UIWidget_Toggle]; + + ui_default_style_sheet.styles[UIWidget_HSlider] = (UI_Widget_Style){ + (UIWidgetStyle_TextClip | UIWidgetStyle_Bg | UIWidgetStyle_Outline | UIWidgetStyle_MouseDragH | UIWidgetStyle_FillH ), BLACK_V4, WHITE_V4, WHITE_SPRITE_ID + }; + ui_default_style_sheet.styles[UIWidget_VSlider] = (UI_Widget_Style){ + (UIWidgetStyle_TextClip | UIWidgetStyle_Bg | UIWidgetStyle_Outline | UIWidgetStyle_MouseDragV | UIWidgetStyle_FillV ), BLACK_V4, WHITE_V4, WHITE_SPRITE_ID + }; + ui_default_style_sheet.styles[UIWidget_HScroll] = (UI_Widget_Style){ + (UIWidgetStyle_TextClip | UIWidgetStyle_Bg | UIWidgetStyle_Outline | UIWidgetStyle_MouseDragH | UIWidgetStyle_FillH | UIWidgetStyle_LineInsteadOfFill ), BLACK_V4, WHITE_V4, WHITE_SPRITE_ID + }; + ui_default_style_sheet.styles[UIWidget_VScroll] = (UI_Widget_Style) { + (UIWidgetStyle_TextClip | UIWidgetStyle_Bg | UIWidgetStyle_Outline | UIWidgetStyle_MouseDragV | UIWidgetStyle_FillV | UIWidgetStyle_LineInsteadOfFill ), BLACK_V4, WHITE_V4, WHITE_SPRITE_ID + }; + + ui_default_style_sheet.styles[UIWidget_Window] = (UI_Widget_Style){ + (UIWidgetStyle_TextWrap), BLACK_V4, WHITE_V4, WHITE_SPRITE_ID + }; + +}; + +internal UI_Widget_Style +ui_get_style(UI* ui, UI_Widget_Kind kind) +{ + if (ui->style_sheet) return ui->style_sheet->styles[kind]; + return ui_default_style_sheet.styles[kind]; +} + +internal UI_Widget_Desc +ui_layout_next_widget(UI* ui, UI_Widget_Kind kind) +{ + UI_Layout_Bounds b = ui_layout_get_next(ui->layout); + UI_Widget_Desc d = {}; + zero_struct(d); + d.p_min = b.min; + d.p_max = b.max; + d.style = ui_get_style(ui, kind); + return d; +} + +internal void +ui_textc(UI* ui, v4 color, String string) +{ + UI_Widget_Desc d = ui_layout_next_widget(ui, UIWidget_Text); + d.string = string; + d.style.color_fg = color; + UI_Widget_Result r = ui_widget_push(ui, d); + ui_widget_pop(ui, r.id); +} + +internal void +ui_text(UI* ui, v4 color, String string) +{ + UI_Widget_Desc d = ui_layout_next_widget(ui, UIWidget_Text); + d.string = string_copy(string, ui->per_frame); + d.style.color_fg = color; + UI_Widget_Result r = ui_widget_push(ui, d); + ui_widget_pop(ui, r.id); +} + +internal void +ui_text_f(UI* ui, v4 color, char* fmt, ...) +{ + scratch_get(scratch); + + va_list args; + va_start(args, fmt); + String string = string_fv(scratch.a, fmt, args); + va_end(args); + + ui_text(ui, color, string); + scratch_release(scratch); +} + +internal bool +ui_button(UI* ui, String string) +{ + UI_Widget_Desc d = ui_layout_next_widget(ui, UIWidget_Button); + d.string = string; + UI_Widget_Result r = ui_widget_push(ui, d); + ui_widget_pop(ui, r.id); + return has_flag(r.flags, UIWidgetResult_MouseLeft_WentUp); +} + +internal bool +ui_toggle(UI* ui, String string, bool value) +{ + UI_Widget_Desc d = ui_layout_next_widget(ui, UIWidget_Button); + if (value) { + v4 t = d.style.color_fg; + d.style.color_fg = d.style.color_bg; + d.style.color_bg = t; + } + d.string = string; + UI_Widget_Result r = ui_widget_push(ui, d); + ui_widget_pop(ui, r.id); + bool result = value; + if (has_flag(r.flags, UIWidgetResult_MouseLeft_WentUp)) result = !result; + return result; +} + +internal UI_Layout* +ui_scroll_view_begin(UI* ui, String string, v2 bounds_min, v2 bounds_max, u32 rows) +{ + scratch_get(scratch); + + r32 scroll_bar_dim = 15; + v2 scroll_bars_area = (v2){0, 0}; + v2 scroll_area_min = bounds_min; + v2 scroll_area_max = HMM_SubtractVec2(bounds_max, scroll_bars_area); + v2 scroll_area_dim = HMM_SubtractVec2(scroll_area_max, scroll_area_min); + + v2 scroll_offset = {}; + zero_struct(scroll_offset); + r32 rows_avail = floorf(scroll_area_dim.y / ui->layout->row_height); + if (rows > rows_avail) + { + scroll_bars_area = (v2){ scroll_bar_dim, 0}; + scroll_area_min = bounds_min; + scroll_area_max = HMM_SubtractVec2(bounds_max, scroll_bars_area); + scroll_area_dim = HMM_SubtractVec2(scroll_area_max, scroll_area_min); + + UI_Widget_Desc vscroll_d = {}; + zero_struct(vscroll_d); + vscroll_d.p_min = (v2){ bounds_max.x - scroll_bar_dim, bounds_min.y }; + vscroll_d.p_max = (v2){ bounds_max.x, bounds_max.y }; + vscroll_d.style = ui_get_style(ui, UIWidget_VScroll); + vscroll_d.string = string_f(scratch.a, "%.*s_vscroll", str_varg(string)); + UI_Widget_Result r = ui_widget_push(ui, vscroll_d); + ui_widget_pop(ui, r.id); + + UI_Widget_State* vscroll_state = ui_widget_state_get(ui, r.id); + scroll_offset.y = vscroll_state->scroll.y; + } + + r32 rows_scroll_to = max(0, rows - (rows_avail - 1)); + r32 y_scroll_dist = rows_scroll_to * ui->layout->row_height; + + scroll_offset = HMM_MultiplyVec2(scroll_offset, (v2){ 0, y_scroll_dist }); + + UI_Layout* layout = allocator_alloc_struct(scratch.a, UI_Layout); + layout->mode = UILayout_Columns; + layout->bounds_min = scroll_area_min; + layout->bounds_max = scroll_area_max; + ui_layout_set_row_info(ui, layout); + layout->at = HMM_SubtractVec2(bounds_min, scroll_offset); + ui_layout_push(ui, layout); + + scratch_release(scratch); + return layout; +} + +internal void +ui_scroll_view_end(UI* ui) +{ + ui_layout_pop(ui); +} + +#if 0 +internal bool +ui_dropdown_begin(UI* ui, String string, bool state) +{ + bool result = ui_toggle(ui, string, state); + UI_Layout* layout = allocator_alloc_struct(scratch, UI_Layout); + zero_struct(*layout); + if (result) + { + ui_scroll_view_begin(ui, layout); + } + return result; +} + +internal void +ui_dropdown_end(UI* ui, bool state) +{ + if (state) + { + ui_scroll_view_end(ui); + } +} +#endif \ No newline at end of file diff --git a/src_v2/editor/lumenarium_editor_ui.h b/src_v2/editor/lumenarium_editor_ui.h new file mode 100644 index 0000000..032fd45 --- /dev/null +++ b/src_v2/editor/lumenarium_editor_ui.h @@ -0,0 +1,247 @@ +/* date = March 28th 2022 10:52 pm */ + +#ifndef LUMENARIUM_UI_H +#define LUMENARIUM_UI_H + +///////////////////////////////////////////////////////////// +// Interface + +typedef struct UI_Vertex UI_Vertex; +struct UI_Vertex +{ + v4 pos; + v2 uv; + v4 color; +}; + +#define UI_WIDGET_ID_VALID_BIT 1 << 31 + +typedef union UI_Widget_Id UI_Widget_Id; +union UI_Widget_Id +{ + // equality of widget id's only relies on the value field + // which is a hash of the widget's string + u32 value; + + // this struct tracks the index of the widget only to be able + // to override next hot in cases where an earlier element became + // next hot that is in the same location as the current one + u32 index; +}; + +typedef u32 UI_Widget_Style_Flags; +enum +{ + UIWidgetStyle_None = 0, + UIWidgetStyle_Bg = 1 << 0, + UIWidgetStyle_TextClip = 1 << 1, + UIWidgetStyle_TextWrap = 1 << 2, + UIWidgetStyle_Outline = 1 << 3, + UIWidgetStyle_MouseClick = 1 << 4, + UIWidgetStyle_MouseDragH = 1 << 5, + UIWidgetStyle_MouseDragV = 1 << 6, + UIWidgetStyle_FillH = 1 << 7, + UIWidgetStyle_FillV = 1 << 8, + UIWidgetStyle_LineInsteadOfFill = 1 << 9, +}; + +// akin to a css class, could be used to style multiple +// elements +typedef struct UI_Widget_Style UI_Widget_Style; +struct UI_Widget_Style +{ + UI_Widget_Style_Flags flags; + v4 color_bg; + v4 color_fg; + u32 sprite; +}; + +// combination of style info and per-instance data +typedef struct UI_Widget_Desc UI_Widget_Desc; +struct UI_Widget_Desc +{ + UI_Widget_Style style; + v2 fill_pct; + String string; + v2 p_min; + v2 p_max; +}; + +typedef struct UI_Widget UI_Widget; +struct UI_Widget +{ + UI_Widget_Id id; + UI_Widget_Desc desc; + + UI_Widget* parent; + UI_Widget* next; + UI_Widget* child_first; + UI_Widget* child_last; +}; + +typedef u32 UI_Widget_Result_Flags; +enum +{ + UIWidgetResult_None = 0, + UIWidgetResult_MouseLeft_IsDown = 1, + UIWidgetResult_MouseLeft_WentUp = 2, +}; + +typedef struct UI_Widget_Result UI_Widget_Result; +struct UI_Widget_Result +{ + UI_Widget_Id id; + UI_Widget_Result_Flags flags; + v2 drag; +}; + +typedef u32 UI_Widget_Kind; +enum +{ + UIWidget_Text, + + // Buttons + UIWidget_Button, + UIWidget_Toggle, + UIWidget_Menu, + UIWidget_Dropdown, + + // Sliders + UIWidget_HSlider, + UIWidget_VSlider, + UIWidget_HScroll, + UIWidget_VScroll, + + // Panels + UIWidget_Window, + + UIWidget_Count, +}; + +typedef struct UI_Style_Sheet UI_Style_Sheet; +struct UI_Style_Sheet +{ + UI_Widget_Style styles[UIWidget_Count]; +}; + +typedef struct UI_Widget_State UI_Widget_State; +struct UI_Widget_State +{ + v2 scroll; +}; + +typedef struct UI_Widget_Pool UI_Widget_Pool; +struct UI_Widget_Pool +{ + UI_Widget* free; + u32 free_cap; + u32 free_len; + + UI_Widget* root; + UI_Widget* active_parent; + + UI_Widget_State* states; + u32* states_hash; + u32 states_cap; +}; + +typedef u8 UI_Layout_Mode; +enum +{ + // each element takes up a whole row + UILayout_Columns, + + // each element takes up one column in the row. If you overflow, + // the layout manager overflows to the next row + UILayout_Rows, +}; + +typedef struct UI_Layout UI_Layout; +struct UI_Layout +{ + UI_Layout_Mode mode; + UI_Layout* parent; + + v2 bounds_min; + v2 bounds_max; + r32 row_height; + r32 row_gap; + r32 col_gap; + v2 at; + u32 cols; +}; + +typedef struct UI_Layout_Bounds UI_Layout_Bounds; +struct UI_Layout_Bounds +{ + v2 min; + v2 max; +}; + +typedef void UI_Draw_Panel_Cb(u8* user_data, BSP_Node_Id id, BSP_Node node, BSP_Area area); + +typedef struct UI UI; +struct UI +{ + Geo_Quad_Buffer_Builder geo; + + Texture_Atlas atlas; + r32 font_ascent, font_descent, font_line_gap, font_space_width; + r32 font_texture_scale; + + UI_Widget_Pool widgets; + UI_Style_Sheet* style_sheet; + + UI_Widget_Id widget_next_hot; + UI_Widget_Id widget_hot; + + UI_Layout* layout; + + BSP panels; + UI_Draw_Panel_Cb* draw_panel_cb; + u8* draw_panel_cb_data; + + // frames since these values were set + u16 widget_next_hot_frames; + u16 widget_hot_frames; + + Input_State* input; + + m44 proj; + Shader shader; + Texture atlas_texture; + Geometry_Buffer per_frame_buffer; + + Allocator* per_frame; +}; + +// Interface + +internal UI ui_create(); +internal void ui_quad_push(UI* ui, v3 pmin, v3 pmax, v2 tmin, v2 tmax, v4 c); +internal void ui_sprite_register(UI* ui, u8* pixels, u32 w, u32 h, u32 id); +internal void ui_sprite_push_color(UI* ui, v3 pmin, v3 pmax, u32 id, v4 color); +internal void ui_sprite_push(UI* ui, v3 pmin, v3 pmax, u32 id); +internal v3 ui_sprite_char_push(UI* ui, v2 at, u32 codepoint, v4 color); +internal void ui_draw(UI* ui); + +// Widgets + +internal void ui_create_default_style_sheet(); + +internal UI_Widget_Id ui_widget_id_create(String string, u32 index_in_parent); +internal bool ui_widget_id_equals(UI_Widget_Id a, UI_Widget_Id b); +internal bool ui_widget_id_is_valid(UI_Widget_Id h); + +internal void ui_widget_next_hot_set(UI* ui, UI_Widget* w); +internal void ui_widget_hot_set(UI* ui, UI_Widget* w); + +internal UI_Widget* ui_widget_pool_push(UI_Widget_Pool* pool, String string); +internal void ui_widget_pool_pop(UI_Widget_Pool* pool); + +internal UI_Widget_Result ui_widget_push(UI* ui, UI_Widget_Desc desc); +internal void ui_widget_pop(UI* ui, UI_Widget_Id widget_id); + +internal r32 ui_widgets_to_geometry_recursive(UI* ui, UI_Widget* widget, r32 z_start, r32 z_step); + +#endif //LUMENARIUM_UI_H diff --git a/src_v2/editor/lumenarium_editor_ui_shaders.h b/src_v2/editor/lumenarium_editor_ui_shaders.h new file mode 100644 index 0000000..49e4167 --- /dev/null +++ b/src_v2/editor/lumenarium_editor_ui_shaders.h @@ -0,0 +1,76 @@ +global XPlatform_Shader_Program_Src ui_shader = { + .win32_vert = lit_str( + "#version 330 core\n" + "layout (location = 0) in vec3 a_pos;\n" + "layout (location = 1) in vec2 a_uv;\n" + "layout (location = 2) in vec4 a_color;\n" + "out vec2 uv;\n" + "out vec4 color;\n" + "uniform mat4 proj;\n" + "void main(void) {\n" + " gl_Position = proj * vec4(a_pos, 1.0);\n" + " uv = a_uv;\n" + " color = a_color;\n" + "}" + ), + .win32_frag = lit_str( + "#version 330 core\n" + "in vec2 uv;\n" + "in vec4 color;\n" + "out vec4 FragColor;\n" + "uniform sampler2D tex;\n" + "void main(void) {\n" + " FragColor = texture(tex, uv) * color;\n" + "}" + ), + + .osx_vert = lit_str( + "#version 330 core\n" + "layout (location = 0) in vec3 a_pos;\n" + "layout (location = 1) in vec2 a_uv;\n" + "layout (location = 2) in vec4 a_color;\n" + "out vec2 uv;\n" + "out vec4 color;\n" + "uniform mat4 proj;\n" + "void main(void) {\n" + " gl_Position = proj * vec4(a_pos, 1.0);\n" + " uv = a_uv;\n" + " color = a_color;\n" + "}" + ), + .osx_frag = lit_str( + "#version 330 core\n" + "in vec2 uv;\n" + "in vec4 color;\n" + "out vec4 FragColor;\n" + "uniform sampler2D tex;\n" + "void main(void) {\n" + " FragColor = texture(tex, uv) * color;\n" + "}" + ), + + .wasm_vert = lit_str( + "precision highp float;\n" + "attribute vec3 a_pos;\n" + "attribute vec2 a_uv;\n" + "attribute vec4 a_color;\n" + "varying vec2 uv;\n" + "varying vec4 color;\n" + "uniform mat4 proj;\n" + "void main(void) {\n" + " gl_Position = proj * vec4(a_pos, 1.0);\n" + " uv = a_uv;\n" + " color = a_color;\n" + "}" + ), + .wasm_frag = lit_str( + "precision highp float;\n" + "varying vec2 uv;\n" + "varying vec4 color;\n" + "uniform sampler2D tex;\n" + "void main(void) {\n" + " gl_FragColor = texture2D(tex, uv) * color;\n" + "}" + ), +}; + diff --git a/src_v2/engine/lumenarium_engine.c b/src_v2/engine/lumenarium_engine.c new file mode 100644 index 0000000..cf3644e --- /dev/null +++ b/src_v2/engine/lumenarium_engine.c @@ -0,0 +1,104 @@ + +internal void +en_init(App_State* state, App_Init_Desc desc) +{ + lumenarium_env_validate(); + + state->assemblies = assembly_array_create(permanent, desc.assembly_cap); + + Output* o = &state->output; + register_output_method(o, OutputData_Invalid, 0, 0, 0); + register_output_method(o, OutputData_NetworkSACN, output_network_sacn_update, output_network_sacn_build, output_network_sacn_init()); + register_output_method(o, OutputData_ComUART, 0, output_network_sacn_build, output_com_uart_init()); + + lumenarium_env_validate(); +} + +internal void +en_frame_prepare(App_State* state) +{ + lumenarium_env_validate(); +} + +global r32 tt = 0; + +internal void +en_frame(App_State* state) +{ + lumenarium_env_validate(); + + scratch_get(scratch); + Assembly_Array assemblies = state->assemblies; + + /////////////////////////////////////// + // Output Data + Output_Methods methods = state->output.methods; + + // update each method that has an update method + for (u32 i = 0; i < OutputData_Count; i++) + { + if (methods.update_procs[i] == 0) continue; + methods.update_procs[i](methods.method_data[i]); + } + + Output_Data_Queue output_queue = {}; + output_queue.a = scratch.a; + + // build output data buffers + for (u32 i = 0; i < assemblies.len; i++) + { + Assembly_Strip_Array strips = assemblies.strip_arrays[i]; + Assembly_Pixel_Buffer* pixels = assemblies.pixel_buffers + i; + for (u32 j = 0; j < strips.len; j++) + { + Assembly_Strip* strip = strips.strips + j; + Build_Output_Data_Buffer* method_proc = methods.procs[strip->output_kind]; + u8* method_data = methods.method_data[strip->output_kind]; + if (method_proc == 0) continue; + method_proc(state, i, pixels, strip, method_data, &output_queue); + } + } + + // output the buffers + // TODO(PS): we could sort these first if switchig between output + // types is time consuming + + Sacn* sacn = (Sacn*)state->output.methods.method_data[OutputData_NetworkSACN]; + for (Output_Data* at = output_queue.first; at != 0; at = at->next) + { + // NOTE(PS): we can overload each switch case as more methods come in + // ie. OutputData_NetworkSACN and OutputData_NetworkArtNet could use + // the same case since at this point they just need to push data out + // over a socket + switch (at->kind) + { + case OutputData_NetworkSACN: + { + os_socket_send_to( + sacn->socket, + at->network.v4_addr, + at->network.port, + at->data, + 0 + ); + } break; + + case OutputData_ComUART: + { + // TODO(PS): platform com io + } break; + + invalid_code_path; + } + } + + scratch_release(scratch); + lumenarium_env_validate(); +} + +internal void +en_cleanup(App_State* state) +{ + lumenarium_env_validate(); +} + diff --git a/src_v2/engine/lumenarium_engine_assembly.c b/src_v2/engine/lumenarium_engine_assembly.c new file mode 100644 index 0000000..7d67f56 --- /dev/null +++ b/src_v2/engine/lumenarium_engine_assembly.c @@ -0,0 +1,125 @@ + +Assembly_Array +assembly_array_create(Allocator* allocator, u32 cap) +{ + Assembly_Array result = { + .cap = cap, + .names = allocator_alloc_array(allocator, String, cap), + .pixel_buffers = allocator_alloc_array(allocator, Assembly_Pixel_Buffer, cap), + .strip_arrays = allocator_alloc_array(allocator, Assembly_Strip_Array, cap), + .allocator = allocator, + }; + return result; +} + +bool +assembly_handle_is_valid(Assembly_Handle h) +{ + return ((h.value & ASSEMBLY_HANDLE_VALID_BIT) != 0); +} + +u32 +assembly_handle_to_index(Assembly_Handle h) +{ + assert(assembly_handle_is_valid(h)); + u32 index = (h.value & ASSEMBLY_HANDLE_INDEX_MASK); // mask off high bit + return index; +} + +Assembly_Handle +assembly_add(Assembly_Array* a, String name, u32 pixels_cap, u32 strips_cap) +{ + Assembly_Handle result = {}; + if (a->len < a->cap) + { + result.value = a->len++; + result.value |= ASSEMBLY_HANDLE_VALID_BIT; // high bit being set means its valid + } + else + { + // TODO(PS): find empty index + // we can use the name being zero as a signal that the slot is empty + } + + // NOTE(PS): not actually a bug, just go increase App_Init_Desc::assemblies_cap + // b/c you ran out of room + assert(assembly_handle_is_valid(result)); + + u32 index = assembly_handle_to_index(result); + + a->names[index] = name; + + Assembly_Pixel_Buffer* pixel_buffer = a->pixel_buffers + index; + zero_struct(*pixel_buffer); + pixel_buffer->cap = pixels_cap; + pixel_buffer->pixels = allocator_alloc_array(a->allocator, Assembly_Pixel, pixels_cap); + pixel_buffer->positions = allocator_alloc_array(a->allocator, v4, pixels_cap); + + Assembly_Strip_Array* strip_array = a->strip_arrays + index; + zero_struct(*strip_array); + strip_array->cap = strips_cap; + strip_array->strips = allocator_alloc_array(a->allocator, Assembly_Strip, strips_cap); + + return result; +} + +void +assembly_rem(Assembly_Array* a, Assembly_Handle h) +{ +} + +Assembly_Strip* +assembly_add_strip(Assembly_Array* a, Assembly_Handle h, u32 pixels_cap) +{ + u32 index = assembly_handle_to_index(h); + + Assembly_Strip_Array* strip_array = a->strip_arrays + index; + assert(strip_array->len < strip_array->cap); + + Assembly_Strip* result = strip_array->strips + strip_array->len++; + result->pixels_cap = pixels_cap; + result->pixels_len = 0; + result->pixels = allocator_alloc_array(a->allocator, u32, pixels_cap); + + return result; +} + +void +assembly_add_led( + Assembly_Array* a, + Assembly_Handle h, + Assembly_Strip* strip, + v4 position +){ + u32 index = assembly_handle_to_index(h); + + Assembly_Pixel_Buffer* pixel_buffer = a->pixel_buffers + index; + assert(pixel_buffer->len < pixel_buffer->cap); + + u32 pixel_index = pixel_buffer->len++; + pixel_buffer->pixels[pixel_index] = (Assembly_Pixel){}; + pixel_buffer->positions[pixel_index] = position; + + assert(strip->pixels_len < strip->pixels_cap); + strip->pixels[strip->pixels_len++] = pixel_index; +} + +void +assembly_strip_append_leds( + Assembly_Array* a, + Assembly_Handle h, + Assembly_Strip* strip, + v3 start, v3 end, + u32 led_count +){ + v3 delta_total = HMM_SubtractVec3(end, start); + v3 delta_step = HMM_MultiplyVec3f(delta_total, 1.0f / (r32)led_count); + + for (u32 i = 0; i < led_count; i++) + { + v4 pos = {0,0,0,1}; + v3 offset = HMM_MultiplyVec3f(delta_step, (r32)i); + pos.XYZ = HMM_AddVec3(start, offset); + assembly_add_led(a, h, strip, pos); + } +} \ No newline at end of file diff --git a/src_v2/engine/lumenarium_engine_assembly.h b/src_v2/engine/lumenarium_engine_assembly.h new file mode 100644 index 0000000..8dbed50 --- /dev/null +++ b/src_v2/engine/lumenarium_engine_assembly.h @@ -0,0 +1,88 @@ +/* date = March 22nd 2022 6:40 pm */ + +#ifndef LUMENARIUM_ENGINE_ASSEMBLY_H +#define LUMENARIUM_ENGINE_ASSEMBLY_H + +// Assembly_Handle is valid for any index, including zero. However, +// valid values must have the high bit set. This way, the handle declared +// via Assembly_Handle my_handle = {}; is invalid, while still allowing +// index zero to be used in the array. +// +// If memory corruption becomes an issue we can make this a bigger bit +// field that we check since Lumenarium doesn't ever really expect to have +// more than 128 sculptures in a scene - but who knows, maybe someday O.o? +#define ASSEMBLY_HANDLE_VALID_BIT (1 << 31) +#define ASSEMBLY_HANDLE_INDEX_MASK ~ASSEMBLY_HANDLE_VALID_BIT +typedef struct Assembly_Handle Assembly_Handle; +struct Assembly_Handle +{ + u32 value; +}; + +typedef union Assembly_Pixel Assembly_Pixel; +union Assembly_Pixel +{ + struct { + u8 r; + u8 g; + u8 b; + }; + u8 channels[3]; +}; + +typedef struct Assembly_Pixel_Buffer Assembly_Pixel_Buffer; +struct Assembly_Pixel_Buffer +{ + u32 cap; + u32 len; + Assembly_Pixel* pixels; + v4* positions; +}; + +typedef struct Assembly_Strip Assembly_Strip; +struct Assembly_Strip +{ + u32 pixels_cap; + u32 pixels_len; + // array of indices into the Assembly_Pixel_Buffer for the same assembly + u32* pixels; + + Output_Data_Kind output_kind; + u32 sacn_universe; +}; + +typedef struct Assembly_Strip_Array Assembly_Strip_Array; +struct Assembly_Strip_Array +{ + u32 cap; + u32 len; + Assembly_Strip* strips; +}; + +typedef struct Assembly_Array Assembly_Array; +struct Assembly_Array +{ + u32 cap; + u32 len; + + // assembly names + String* names; + + // each assembly gets its own pixel buffer + Assembly_Pixel_Buffer* pixel_buffers; + + // each assembly gets its own array of strips which + // index into that assemblies pixel_buffer + Assembly_Strip_Array* strip_arrays; + + Allocator* allocator; +}; + +Assembly_Array assembly_array_create(Allocator* allocator, u32 cap); +Assembly_Handle assembly_add(Assembly_Array* a, String name, u32 pixels_cap, u32 strips_cap); +void assembly_rem(Assembly_Array* a, Assembly_Handle h); +Assembly_Strip* assembly_add_strip(Assembly_Array* a, Assembly_Handle h, u32 pixels_cap); +void assembly_add_led(Assembly_Array* a, Assembly_Handle h, Assembly_Strip* strip, v4 position); + + +#endif //LUMENARIUM_ENGINE_ASSEMBLY_H diff --git a/src_v2/engine/lumenarium_engine_output.c b/src_v2/engine/lumenarium_engine_output.c new file mode 100644 index 0000000..d295d19 --- /dev/null +++ b/src_v2/engine/lumenarium_engine_output.c @@ -0,0 +1,26 @@ + +internal void +register_output_method(Output* output, Output_Data_Kind kind, Output_Method_Update* update, Build_Output_Data_Buffer* proc, u8* method_data) +{ + output->methods.update_procs[kind] = update; + output->methods.procs[kind] = proc; + output->methods.method_data[kind] = method_data; +} + +internal Output_Data* +output_data_queue_push(Output_Data_Queue* q, u32 size, Output_Data_Kind kind) +{ + Output_Data* d = allocator_alloc_struct(q->a, Output_Data); + d->kind = kind; + d->data.size = size; + d->data.base = allocator_alloc(q->a, size); + sll_push(q->first, q->last, d); + return d; +} + +internal void +output_data_set_network_addr(Output_Data* d, u32 send_addr, u32 port) +{ + d->network.v4_addr = send_addr; + d->network.port = port; +} diff --git a/src_v2/engine/lumenarium_engine_output.h b/src_v2/engine/lumenarium_engine_output.h new file mode 100644 index 0000000..027ce26 --- /dev/null +++ b/src_v2/engine/lumenarium_engine_output.h @@ -0,0 +1,75 @@ +/* date = March 30th 2022 9:23 am */ + +#ifndef LUMENARIUM_ENGINE_OUTPUT_H +#define LUMENARIUM_ENGINE_OUTPUT_H + +typedef u8 Output_Data_Kind; +enum +{ + OutputData_Invalid = 0, + OutputData_NetworkSACN, + OutputData_ComUART, + OutputData_Count, +}; + +typedef struct Output_Data_Network Output_Data_Network; +struct Output_Data_Network +{ + // Platform_Socket_Handle socket; + u32 v4_addr; + u32 port; +}; + +typedef struct Output_Data_Com Output_Data_Com; +struct Output_Data_Com +{ + String port; +}; + +typedef struct Output_Data Output_Data; +struct Output_Data +{ + Output_Data_Kind kind; + union + { + Output_Data_Network network; + Output_Data_Com com; + }; + Data data; + + Output_Data* next; +}; + +typedef struct Output_Data_Queue Output_Data_Queue; +struct Output_Data_Queue +{ + Output_Data* first; + Output_Data* last; + u32 len; + Allocator* a; +}; + +typedef void Output_Method_Update(u8* method_data); +typedef void Build_Output_Data_Buffer(App_State* state, u32 assembly_id, Assembly_Pixel_Buffer* pixels, Assembly_Strip* strip, u8* method_data, Output_Data_Queue* queue); + +typedef struct Output_Methods Output_Methods; +struct Output_Methods +{ + Output_Method_Update* update_procs[OutputData_Count]; + Build_Output_Data_Buffer* procs[OutputData_Count]; + u8* method_data[OutputData_Count]; +}; + +typedef struct Output Output; +struct Output +{ + Output_Methods methods; +}; + +internal void register_output_method(Output* output, Output_Data_Kind kind, Output_Method_Update* update, Build_Output_Data_Buffer* proc, u8* method_data); + +internal Output_Data* output_data_queue_push(Output_Data_Queue* q, u32 size, Output_Data_Kind kind); + +internal void output_data_set_network_addr(Output_Data* d, u32 send_addr, u32 port); + +#endif //LUMENARIUM_ENGINE_OUTPUT_H diff --git a/src_v2/engine/output/lumenarium_output_sacn.c b/src_v2/engine/output/lumenarium_output_sacn.c new file mode 100644 index 0000000..ecd28c4 --- /dev/null +++ b/src_v2/engine/output/lumenarium_output_sacn.c @@ -0,0 +1,470 @@ +#define SACN_DEFAULT_PORT 5568 + +#define SACN_STARTCODE_DMX 0 + +// a description of the address space being used +#define SACN_PREAMBLE_SIZE_ADDR 0 +#define SACN_POSTAMBLE_SIZE_ADDR 2 +#define SACN_ACN_IDENTIFIER_ADDR 4 +#define SACN_ROOT_FLAGS_AND_LEN_ADDR 16 +#define SACN_ROOT_VECTOR_ADDR 18 +#define SACN_CID_ADDR 22 +#define SACN_FRAMING_FLAGS_AND_LEN_ADDR 38 +#define SACN_FRAMING_VECTOR_ADDR 40 +#define SACN_SOURCE_NAME_ADDR 44 +#define SACN_PRIORITY_ADDR 108 +#define SACN_RESERVED_ADDR 109 +#define SACN_SEQ_NUM_ADDR 111 +#define SACN_OPTIONS_ADDR 112 +#define SACN_UNIVERSE_ADDR 113 +#define SACN_DMP_FLAGS_AND_LEN_ADDR 115 +#define SACN_DMP_VECTOR_ADDR 117 +#define SACN_DMP_ADDRESS_AND_DATA_ADDR 118 +#define SACN_FIRST_PROPERTY_ADDRESS_ADDR 119 +#define SACN_ADDRESS_INC_ADDR 121 +#define SACN_PROP_COUNT_ADDR 123 +#define SACN_START_CODE_ADDR 125 +#define SACN_PROP_VALUES_ADDR (SACN_START_CODE_ADDR + 1) + +// Common Sizes +#define SACN_BUFFER_HEADER_SIZE 126 +#define SACN_BUFFER_BODY_SIZE 512 +#define SACN_BUFFER_SIZE (SACN_BUFFER_HEADER_SIZE + SACN_BUFFER_BODY_SIZE) + +#define SACN_SOURCE_NAME_SIZE 64 +#define SACN_ACN_IDENTIFIER_SIZE 12 +#define SACN_RLP_PREAMBLE_SIZE 16 +#define SACN_RLP_POSTAMBLE_SIZE 0 + +// Data Definitions +#define SACN_ACN_IDENTIFIER lit_str("ASC-E1.17\0\0\0") +#define SACN_ROOT_VECTOR 4 +#define SACN_FRAMING_VECTOR 2 +#define SACN_DMP_VECTOR 2 +#define SACN_ADDRESS_AND_DATA_FORMAT 0xa1 +#define SACN_ADDR_INC 1 +#define SACN_DMP_FIRST_PROPERTY_ADDRESS_FORCE 0 +#define SACN_RESERVED_VALUE 0 + +#define SACN_VHD_L_FLAG 0x80 +#define SACN_VHD_V_FLAG 0x40 +#define SACN_VHD_H_FLAG 0x20 +#define SACN_VHD_D_FLAG 0x10 + +#define SACN_VHD_MAXFLAGBYTES 7 //The maximum amount of bytes used to pack the flags, len, and vector +#define SACN_VHD_MAXLEN 0x0fffff //The maximum packet length is 20 bytes long +#define SACN_VHD_MAXMINLENGTH 4095 //The highest length that will fit in the "smallest" length pack + + +internal void +sacn_vhd_pack_flags(Data_Writer* w, b8 inherit_vec, b8 inherit_head, b8 inherit_data) +{ + u8 last_byte = dw_get_u8(w) & 0x8F; + + if (!inherit_vec) { last_byte |= SACN_VHD_V_FLAG; } + if (!inherit_head) { last_byte |= SACN_VHD_H_FLAG; } + if (!inherit_data) { last_byte |= SACN_VHD_D_FLAG; } + + w->data.base[w->at] = last_byte; +} + +internal void +sacn_vhd_pack_len(Data_Writer* w, u32 len, b8 include_len) +{ + u32 len_adjusted = len; + if (include_len) + { + if (len + 1 > SACN_VHD_MAXMINLENGTH) + { + len_adjusted += 2; + } + else + { + len_adjusted += 1; + } + } + + // Mask out the length bits to keep flags intact + u8 last_byte = dw_get_u8(w) & 0x70; + + if (len_adjusted > SACN_VHD_MAXMINLENGTH) last_byte |= SACN_VHD_L_FLAG; + + u8* pack_buffer = (u8*)&len_adjusted; + if (len_adjusted <= SACN_VHD_MAXMINLENGTH) + { + last_byte |= (pack_buffer[1] & 0x0f); + dw_put_u8(w, last_byte); + dw_put_u8(w, pack_buffer[0]); + } + else + { + last_byte |= (pack_buffer[2] & 0x0f); + dw_put_u8(w, pack_buffer[1]); + dw_put_u8(w, pack_buffer[0]); + } +} + +#define CopyMemoryTo(from, to, size) CopyMemory_((u8*)(from), (u8*)(to), (size)) +internal void +CopyMemory_(u8* From, u8* To, u64 Size) +{ + for (u64 i = 0; i < Size; i++) + { + To[i] = From[i]; + } +} + +// Packs a u8 to a known big endian buffer +u8* +PackB1(u8* ptr, u8 val) +{ + *ptr = val; + return ptr + sizeof(val); +} + +//Unpacks a u8 from a known big endian buffer +u8 +UpackB1(const u8* ptr) +{ + return *ptr; +} + +//Packs a u8 to a known little endian buffer +u8* +PackL1(u8* ptr, u8 val) +{ + *ptr = val; + return ptr + sizeof(val); +} + +//Unpacks a u8 from a known little endian buffer +u8 +UpackL1(const u8* ptr) +{ + return *ptr; +} + +u8* +PackB2(u8* ptr, u16 val) +{ + ptr[1] = (u8)(val & 0xff); + ptr[0] = (u8)((val & 0xff00) >> 8); + return ptr + sizeof(val); +} + +//Unpacks a u16 from a known big endian buffer +u16 +UpackB2(const u8* ptr) +{ + return (u16)(ptr[1] | ptr[0] << 8); +} + +//Packs a u32 to a known big endian buffer +u8* +PackB4(u8* ptr, u32 val) +{ + ptr[3] = (u8) (val & 0xff); + ptr[2] = (u8)((val & 0xff00) >> 8); + ptr[1] = (u8)((val & 0xff0000) >> 16); + ptr[0] = (u8)((val & 0xff000000) >> 24); + return ptr + sizeof(val); +} + +internal void +VHD_PackFlags_(u8* Buffer, b32 InheritVec, b32 InheritHead, b32 InheritData) +{ + u8* Cursor = Buffer; + u8 NewByte = UpackB1(Cursor) & 0x8f; + + if (!InheritVec) { NewByte |= SACN_VHD_V_FLAG; } + if (!InheritHead) { NewByte |= SACN_VHD_H_FLAG; } + if (!InheritData) { NewByte |= SACN_VHD_D_FLAG; } + + PackB1(Cursor, NewByte); +} + +internal u8* +VHD_PackLength_(u8* Buffer, u32 Length, b32 IncludeLength) +{ + u8* Cursor = Buffer; + u32 AdjustedLength = Length; + if (IncludeLength) + { + if (Length + 1 > SACN_VHD_MAXMINLENGTH) + { + AdjustedLength += 2; + } + else + { + AdjustedLength += 1; + } + } + + // Mask out the length bits to keep flags intact + u8 NewByte = UpackB1(Cursor) & 0x70; + if (AdjustedLength > SACN_VHD_MAXMINLENGTH) + { + NewByte |= SACN_VHD_L_FLAG; + } + + u8 PackBuffer[4]; + PackB4(PackBuffer, AdjustedLength); + if (AdjustedLength <= SACN_VHD_MAXMINLENGTH) + { + NewByte |= (PackBuffer[2] & 0x0f); + Cursor = PackB1(Cursor, NewByte); + Cursor = PackB1(Cursor, PackBuffer[3]); + } + else + { + NewByte |= (PackBuffer[1] & 0x0f); + Cursor = PackB1(Cursor, PackBuffer[2]); + Cursor = PackB1(Cursor, PackBuffer[3]); + } + + return Cursor; +} + +internal void +InitStreamHeader (u8* Buffer, s32 BufferSize, + u16 SlotCount, + u8 StartCode, + u16 Universe, + u8 Priority, + u16 Reserved, + u8 Options, + const char* SourceName, + Sacn_Cid CID +) +{ + // TODO(pjs): Replace packing with gs_memory_cursor + + u8* Cursor = Buffer; + + // Preamble Size + Cursor = PackB2(Cursor, SACN_RLP_PREAMBLE_SIZE); + Cursor = PackB2(Cursor, SACN_RLP_POSTAMBLE_SIZE); + + CopyMemoryTo(SACN_ACN_IDENTIFIER.str, Cursor, SACN_ACN_IDENTIFIER_SIZE); + Cursor += SACN_ACN_IDENTIFIER_SIZE; + + // TODO(Peter): If you never use this anywhere else, go back and remove the parameters + VHD_PackFlags_(Cursor, false, false, false); + Cursor = VHD_PackLength_(Cursor, + SACN_BUFFER_HEADER_SIZE - SACN_RLP_PREAMBLE_SIZE + SlotCount, + false); + + // root vector + Cursor = PackB4(Cursor, SACN_ROOT_VECTOR); // 22 + + // CID Pack + for (s32 i = 0; i < SACN_CID_BYTES; i++) + { + *Cursor++ = CID.bytes[i]; + }// 38 + + VHD_PackFlags_(Cursor, false, false, false); + Cursor = VHD_PackLength_(Cursor, + SACN_BUFFER_HEADER_SIZE - SACN_FRAMING_FLAGS_AND_LEN_ADDR + SlotCount, + false); + // 40 + // framing vector + Cursor = PackB4(Cursor, SACN_FRAMING_VECTOR); + + // framing source name + // :Check + + CopyMemoryTo(SourceName, (char*)Cursor, c_str_len((char*)SourceName)); + Cursor[SACN_SOURCE_NAME_SIZE - 1] = '\0'; + Cursor += SACN_SOURCE_NAME_SIZE; // 108 + + // priority + Cursor = PackB1(Cursor, Priority); + + // reserved + Cursor = PackB2(Cursor, Reserved); // 111 + + // Sequence # is always set to 0/NONE at the beginning, but it is incremented when sending data + Cursor = PackB1(Cursor, 0); + + // Options + Cursor = PackB1(Cursor, Options); + + // Universe + Cursor = PackB2(Cursor, Universe); // 115 + + VHD_PackFlags_(Cursor, false, false, false); + Cursor = VHD_PackLength_(Cursor, + SACN_BUFFER_HEADER_SIZE - SACN_DMP_FLAGS_AND_LEN_ADDR + SlotCount, + false); // 117 + + // DMP Vector + Cursor = PackB1(Cursor, SACN_DMP_VECTOR); + + // DMP Address and data type + Cursor = PackB1(Cursor, SACN_ADDRESS_AND_DATA_FORMAT); + + // DMP first property address + Cursor = PackB1(Cursor, 0); + + // DMP Address Increment + Cursor = PackB1(Cursor, SACN_ADDR_INC); + + // Property Value Count -- Includes one byte for start code + Cursor = PackB2(Cursor, SlotCount + 1); + + Cursor = PackB1(Cursor, StartCode); + + assert(Cursor - Buffer == SACN_BUFFER_HEADER_SIZE); + +} + +internal void +sacn_fill_buffer_header(Output_Data* d, u16 universe, Sacn* sacn) +{ + assert(d && d->data.size > 0); + + // TODO(PS): these should be passed in? + u16 slot_count = SACN_BUFFER_BODY_SIZE; + u8 start_code = SACN_STARTCODE_DMX; + // universe + u8 priority = 0; + u16 reserved = 0; + u8 options = 0; + + Data_Writer w = {}; + w.data = d->data; + + dw_put_u16_b(&w, SACN_RLP_PREAMBLE_SIZE); + dw_put_u16_b(&w, SACN_RLP_POSTAMBLE_SIZE); + dw_put_str_min_len(&w, SACN_ACN_IDENTIFIER, SACN_ACN_IDENTIFIER_SIZE); + + sacn_vhd_pack_flags(&w, false, false, false); + sacn_vhd_pack_len(&w, SACN_BUFFER_HEADER_SIZE - SACN_RLP_PREAMBLE_SIZE + slot_count, false); + + dw_put_u32_b(&w, SACN_ROOT_VECTOR); + + for (u32 i = 0; i < SACN_CID_BYTES; i++) dw_put_u8(&w, sacn->cid.bytes[i]); + + sacn_vhd_pack_flags(&w, false, false, false); + sacn_vhd_pack_len(&w, SACN_BUFFER_HEADER_SIZE - SACN_FRAMING_FLAGS_AND_LEN_ADDR + slot_count, false); + + dw_put_u32_b(&w, SACN_FRAMING_VECTOR); + + dw_put_str_min_len_nullterm(&w, sacn->source_name, SACN_SOURCE_NAME_SIZE); + + dw_put_u8(&w, priority); + dw_put_u16_b(&w, reserved); // synchronization + dw_put_u8(&w, sacn->sequence_iter); + dw_put_u8(&w, options); + dw_put_u16_b(&w, universe); + + sacn_vhd_pack_flags(&w, false, false, false); + sacn_vhd_pack_len(&w, SACN_BUFFER_HEADER_SIZE - SACN_DMP_FLAGS_AND_LEN_ADDR + slot_count, false); + + dw_put_u8(&w, SACN_DMP_VECTOR); + dw_put_u8(&w, SACN_ADDRESS_AND_DATA_FORMAT); + dw_put_u16_b(&w, 0); // dmp first priority addr + dw_put_u16_b(&w, SACN_ADDR_INC); // dmp address increment + dw_put_u16_b(&w, slot_count + 1); + dw_put_u8(&w, start_code); + + assert(w.at == SACN_BUFFER_HEADER_SIZE); +} + +internal void +sacn_fill_buffer_body(Output_Data* d, Assembly_Pixel_Buffer* pixels, Assembly_Strip* strip, u32* leds_placed) +{ + u32 first = *leds_placed; + u32 to_add = min(strip->pixels_len - first, SACN_BUFFER_BODY_SIZE / 3); + u32 one_past_last = first + to_add; + for (u32 i = *leds_placed; i < one_past_last; i++) + { + u32 led_index = strip->pixels[i]; + Assembly_Pixel color = pixels->pixels[led_index]; + d->data.base[SACN_BUFFER_HEADER_SIZE + (i * 3) + 0] = color.r; + d->data.base[SACN_BUFFER_HEADER_SIZE + (i * 3) + 1] = color.g; + d->data.base[SACN_BUFFER_HEADER_SIZE + (i * 3) + 2] = color.b; + } + *leds_placed += to_add; +} + +internal Sacn_Cid +sacn_string_to_cid(String str) +{ + return (Sacn_Cid){}; +} + +//Unpacks a u32 from a known big endian buffer +inline u32 +UpackB4(const u8* ptr) +{ + return (u32)(ptr[3] | (ptr[2] << 8) | (ptr[1] << 16) | (ptr[0] << 24)); +} + +internal u32 +sacn_universe_to_send_addr(u32 universe) +{ + u8 multicast_address_buffer[4] = {}; + multicast_address_buffer[0] = 239; + multicast_address_buffer[1] = 255; + multicast_address_buffer[2] = (u8)((universe & 0xff00) >> 8); // high bit + multicast_address_buffer[3] = (u8)((universe & 0x00ff)); // low bit + + u32 v4_address = (u32)((multicast_address_buffer[3] ) | + (multicast_address_buffer[2] << 8) | + (multicast_address_buffer[1] << 16) | + (multicast_address_buffer[0] << 24)); + return v4_address; +} + +internal u8* +output_network_sacn_init() +{ + Sacn* result = allocator_alloc_struct(permanent, Sacn); + zero_struct(*result); + + result->source_name = string_f(permanent, "lumenarium::incenter"); + + String cid_str = lit_str("{67F9D986-544E-4abb-8986-D5F79382586C}"); + result->cid = sacn_string_to_cid(cid_str); + + s32 ttl = 20; + result->socket = os_socket_create(AF_INET, SOCK_DGRAM, 0); + os_socket_set_opt( + result->socket, + IPPROTO_IP, + IP_MULTICAST_TTL, + (u8*)&ttl, sizeof(ttl) + ); + + return (u8*)result; +} + +internal void +output_network_sacn_update(u8* method_data) +{ + Sacn* sacn = (Sacn*)method_data; + sacn->sequence_iter += 1; +} + +internal void +output_network_sacn_build(App_State* state, u32 assembly_id, Assembly_Pixel_Buffer* pixels, Assembly_Strip* strip, u8* method_data, Output_Data_Queue* queue) +{ + Sacn* sacn = (Sacn*)method_data; + + u16 universe = (u16)strip->sacn_universe; + u32 send_port = SACN_DEFAULT_PORT; + for (u32 leds_placed = 0; leds_placed < strip->pixels_len;) + { + u32 v4_send_addr = sacn_universe_to_send_addr(universe); + + Output_Data* d = output_data_queue_push(queue, SACN_BUFFER_SIZE, OutputData_NetworkSACN); + output_data_set_network_addr(d, v4_send_addr, send_port); + + //InitStreamHeader(d->data.base, d->data.size, SACN_BUFFER_BODY_SIZE, SACN_STARTCODE_DMX, universe, 0, 0, 0, "lumenarium::sacn", sacn->cid); + sacn_fill_buffer_header(d, universe, sacn); + sacn_fill_buffer_body(d, pixels, strip, &leds_placed); + universe += 1; + } +} diff --git a/src_v2/engine/output/lumenarium_output_sacn.h b/src_v2/engine/output/lumenarium_output_sacn.h new file mode 100644 index 0000000..09f96ae --- /dev/null +++ b/src_v2/engine/output/lumenarium_output_sacn.h @@ -0,0 +1,26 @@ +/* date = March 30th 2022 9:55 am */ + +#ifndef LUMENARIUM_OUTPUT_SACN_H +#define LUMENARIUM_OUTPUT_SACN_H + +#define SACN_CID_BYTES 16 +typedef struct Sacn_Cid Sacn_Cid; +struct Sacn_Cid +{ + u8 bytes[SACN_CID_BYTES]; +}; + +typedef struct Sacn Sacn; +struct Sacn +{ + Sacn_Cid cid; + s32 sequence_iter; + String source_name; + Socket_Handle socket; +}; + +internal u8* output_network_sacn_init(); +internal void output_network_sacn_update(u8* method_data); +internal void output_network_sacn_build(App_State* state, u32 assembly_id, Assembly_Pixel_Buffer* pixels, Assembly_Strip* strip, u8* method_data, Output_Data_Queue* queue); + +#endif //LUMENARIUM_OUTPUT_SACN_H diff --git a/src_v2/engine/output/lumenarium_output_uart.c b/src_v2/engine/output/lumenarium_output_uart.c new file mode 100644 index 0000000..cc34f65 --- /dev/null +++ b/src_v2/engine/output/lumenarium_output_uart.c @@ -0,0 +1,12 @@ + +internal u8* +output_com_uart_init() +{ + return 0; +} + +internal void +output_com_uart_build(App_State* state, u32 assembly_id, Assembly_Strip* strip, u8* method_data, Output_Data_Queue* queue) +{ + +} diff --git a/src_v2/engine/output/lumenarium_output_uart.h b/src_v2/engine/output/lumenarium_output_uart.h new file mode 100644 index 0000000..c23a6aa --- /dev/null +++ b/src_v2/engine/output/lumenarium_output_uart.h @@ -0,0 +1,9 @@ +/* date = March 30th 2022 9:57 am */ + +#ifndef LUMENARIUM_OUTPUT_UART_H +#define LUMENARIUM_OUTPUT_UART_H + +internal u8* output_com_uart_init(); +internal void output_com_uart_build(App_State* state, u32 assembly_id, Assembly_Strip* strip, u8* method_data, Output_Data_Queue* queue); + +#endif //LUMENARIUM_OUTPUT_UART_H diff --git a/src_v2/libs/HandmadeMath.h b/src_v2/libs/HandmadeMath.h new file mode 100644 index 0000000..63f883b --- /dev/null +++ b/src_v2/libs/HandmadeMath.h @@ -0,0 +1,3116 @@ +/* + HandmadeMath.h v1.2.0 + + This is a single header file with a bunch of useful functions for + basic game math operations. + + ============================================================================= + + You MUST + + #define HANDMADE_MATH_IMPLEMENTATION + + in EXACTLY one C or C++ file that includes this header, BEFORE the + include, like this: + + #define HANDMADE_MATH_IMPLEMENTATION + #include "HandmadeMath.h" + + All other files should just #include "HandmadeMath.h" without the #define. + + ============================================================================= + + For overloaded and operator overloaded versions of the base C functions, + you MUST + + #define HANDMADE_MATH_CPP_MODE + + in EXACTLY one C or C++ file that includes this header, BEFORE the + include, like this: + + #define HANDMADE_MATH_IMPLEMENTATION + #define HANDMADE_MATH_CPP_MODE + #include "HandmadeMath.h" + + All other files should just #include "HandmadeMath.h" without the #define. + + ============================================================================= + + To disable SSE intrinsics, you MUST + + #define HANDMADE_MATH_NO_SSE + + in EXACTLY one C or C++ file that includes this header, BEFORE the + include, like this: + + #define HANDMADE_MATH_IMPLEMENTATION + #define HANDMADE_MATH_CPP_MODE + #define HANDMADE_MATH_NO_SSE + #include "HandmadeMath.h" + + or + + #define HANDMADE_MATH_IMPLEMENTATION + #define HANDMADE_MATH_NO_SSE + #include "HandmadeMath.h" + + ============================================================================= + + To disable inlining functions, you MUST + + #define HANDMADE_MATH_NO_INLINE + + in EXACTLY one C or C++ file that includes this header, BEFORE the + include, like this: + + #define HANDMADE_MATH_IMPLEMENTATION + #define HANDMADE_MATH_CPP_MODE + #define HANDMADE_MATH_NO_INLINE + #include "HandmadeMath.h" + + All other files should just #include "HandmadeMath.h" without the #define. + + ============================================================================= + + To use HandmadeMath without the CRT, you MUST + + #define HMM_SINF MySinF + #define HMM_COSF MyCosF + #define HMM_TANF MyTanF + #define HMM_SQRTF MySqrtF + #define HMM_EXPF MyExpF + #define HMM_LOGF MyLogF + #define HMM_ACOSF MyACosF + #define HMM_ATANF MyATanF + #define HMM_ATAN2F MYATan2F + + Provide your own implementations of SinF, CosF, TanF, ACosF, ATanF, ATan2F, + ExpF, and LogF in EXACTLY one C or C++ file that includes this header, + BEFORE the include, like this: + + #define HMM_SINF MySinF + #define HMM_COSF MyCosF + #define HMM_TANF MyTanF + #define HMM_SQRTF MySqrtF + #define HMM_EXPF MyExpF + #define HMM_LOGF MyLogF + #define HMM_ACOSF MyACosF + #define HMM_ATANF MyATanF + #define HMM_ATAN2F MyATan2F + #define HANDMADE_MATH_IMPLEMENTATION + #define HANDMADE_MATH_CPP_MODE + #include "HandmadeMath.h" + + If you do not define all five of these, HandmadeMath.h will use the + versions of these functions that are provided by the CRT. + + ============================================================================= + + Version History: + 0.2 (*) Updated documentation + (*) Better C compliance + (*) Prefix all handmade math functions + (*) Better operator overloading + 0.2a + (*) Prefixed Macros + 0.2b + (*) Disabled warning 4201 on MSVC as it is legal is C11 + (*) Removed the f at the end of HMM_PI to get 64bit precision + 0.3 + (*) Added +=, -=, *=, /= for hmm_vec2, hmm_vec3, hmm_vec4 + 0.4 + (*) SSE Optimized HMM_SqrtF + (*) SSE Optimized HMM_RSqrtF + (*) Removed CRT + 0.5 + (*) Added scalar multiplication and division for vectors + and matrices + (*) Added matrix subtraction and += for hmm_mat4 + (*) Reconciled all headers and implementations + (*) Tidied up, and filled in a few missing operators + 0.5.1 + (*) Ensured column-major order for matrices throughout + (*) Fixed HMM_Translate producing row-major matrices + 0.5.2 + (*) Fixed SSE code in HMM_SqrtF + (*) Fixed SSE code in HMM_RSqrtF + 0.6 + (*) Added Unit testing + (*) Made HMM_Power faster + (*) Fixed possible efficiency problem with HMM_Normalize + (*) RENAMED HMM_LengthSquareRoot to HMM_LengthSquared + (*) RENAMED HMM_RSqrtF to HMM_RSquareRootF + (*) RENAMED HMM_SqrtF to HMM_SquareRootF + (*) REMOVED Inner function (user should use Dot now) + (*) REMOVED HMM_FastInverseSquareRoot function declaration + 0.7 + (*) REMOVED HMM_LengthSquared in HANDMADE_MATH_IMPLEMENTATION (should + use HMM_LengthSquaredVec3, or HANDMADE_MATH_CPP_MODE for function + overloaded version) + (*) REMOVED HMM_Length in HANDMADE_MATH_IMPLEMENTATION (should use + HMM_LengthVec3, HANDMADE_MATH_CPP_MODE for function + overloaded version) + (*) REMOVED HMM_Normalize in HANDMADE_MATH_IMPLEMENTATION (should use + HMM_NormalizeVec3, or HANDMADE_MATH_CPP_MODE for function + overloaded version) + (*) Added HMM_LengthSquaredVec2 + (*) Added HMM_LengthSquaredVec4 + (*) Addd HMM_LengthVec2 + (*) Added HMM_LengthVec4 + (*) Added HMM_NormalizeVec2 + (*) Added HMM_NormalizeVec4 + 1.0 + (*) Lots of testing! + 1.1 + (*) Quaternion support + (*) Added type hmm_quaternion + (*) Added HMM_Quaternion + (*) Added HMM_QuaternionV4 + (*) Added HMM_AddQuaternion + (*) Added HMM_SubtractQuaternion + (*) Added HMM_MultiplyQuaternion + (*) Added HMM_MultiplyQuaternionF + (*) Added HMM_DivideQuaternionF + (*) Added HMM_InverseQuaternion + (*) Added HMM_DotQuaternion + (*) Added HMM_NormalizeQuaternion + (*) Added HMM_Slerp + (*) Added HMM_QuaternionToMat4 + (*) Added HMM_QuaternionFromAxisAngle + 1.1.1 + (*) Resolved compiler warnings on gcc and g++ + 1.1.2 + (*) Fixed invalid HMMDEF's in the function definitions + 1.1.3 + (*) Fixed compile error in C mode + 1.1.4 + (*) Fixed SSE being included on platforms that don't support it + (*) Fixed divide-by-zero errors when normalizing zero vectors. + 1.1.5 + (*) Add Width and Height to HMM_Vec2 + (*) Made it so you can supply your own SqrtF + 1.2.0 + (*) Added equality functions for HMM_Vec2, HMM_Vec3, and HMM_Vec4. + (*) Added HMM_EqualsVec2, HMM_EqualsVec3, and HMM_EqualsVec4 + (*) Added C++ overloaded HMM_Equals for all three + (*) Added C++ == and != operators for all three + (*) SSE'd HMM_MultiplyMat4 (this is _WAY_ faster) + (*) SSE'd HMM_Transpose + + LICENSE + + This software is in the public domain. Where that dedication is not + recognized, you are granted a perpetual, irrevocable license to copy, + distribute, and modify this file as you see fit. + + CREDITS + + Written by Zakary Strange (zak@handmade.network && @strangezak) + + Functionality: + Matt Mascarenhas (@miblo_) + Aleph + FieryDrake (@fierydrake) + Gingerbill (@TheGingerBill) + Ben Visness (@bvisness) + Trinton Bullard (@Peliex_Dev) + + Fixes: + Jeroen van Rijn (@J_vanRijn) + Kiljacken (@Kiljacken) + Insofaras (@insofaras) + Daniel Gibson (@DanielGibson) +*/ + + +/* let's figure out if SSE is really available (unless disabled anyway) + (it isn't on non-x86/x86_64 platforms or even x86 without explicit SSE support) + => only use "#ifdef HANDMADE_MATH__USE_SSE" to check for SSE support below this block! */ +#ifndef HANDMADE_MATH_NO_SSE + +# ifdef _MSC_VER +/* MSVC supports SSE in amd64 mode or _M_IX86_FP >= 1 (2 means SSE2) */ +# if defined(_M_AMD64) || ( defined(_M_IX86_FP) && _M_IX86_FP >= 1 ) +# define HANDMADE_MATH__USE_SSE 1 +# endif +# else /* not MSVC, probably GCC, clang, icc or something that doesn't support SSE anyway */ +# ifdef __SSE__ /* they #define __SSE__ if it's supported */ +# define HANDMADE_MATH__USE_SSE 1 +# endif /* __SSE__ */ +# endif /* not _MSC_VER */ + +#endif /* #ifndef HANDMADE_MATH_NO_SSE */ + +#include // This is for types + +#ifdef HANDMADE_MATH__USE_SSE +#include +#endif + +#ifndef HANDMADE_MATH_H +#define HANDMADE_MATH_H + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu-anonymous-struct" +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef HANDMADE_MATH_STATIC +#define HMMDEF static +#else +#define HMMDEF extern +#endif + +#ifdef HANDMADE_MATH_NO_INLINE +#define HINLINE +#elif _MSC_VER && !__INTEL_COMPILER +#define HINLINE __inline +#else +#define HINLINE inline +#endif + +#if !defined(HMM_SINF) || !defined(HMM_COSF) || !defined(HMM_TANF) || \ +!defined(HMM_SQRTF) || !defined(HMM_EXPF) || !defined(HMM_LOGF) || \ +!defined(HMM_ACOSF) || !defined(HMM_ATANF)|| !defined(HMM_ATAN2F) +#include +#endif + +#ifndef HMM_SINF +#define HMM_SINF sinf +#endif + +#ifndef HMM_COSF +#define HMM_COSF cosf +#endif + +#ifndef HMM_TANF +#define HMM_TANF tanf +#endif + +#ifndef HMM_SQRTF +#define HMM_SQRTF sqrtf +#endif + +#ifndef HMM_EXPF +#define HMM_EXPF expf +#endif + +#ifndef HMM_LOGF +#define HMM_LOGF logf +#endif + +#ifndef HMM_ACOSF +#define HMM_ACOSF acosf +#endif + +#ifndef HMM_ATANF +#define HMM_ATANF atanf +#endif + +#ifndef HMM_ATAN2F +#define HMM_ATAN2F atan2f +#endif + +#define HMM_PI32 3.14159265359f +#define HMM_PI 3.14159265358979323846 + +#define HMM_MIN(a, b) (a) > (b) ? (b) : (a) +#define HMM_MAX(a, b) (a) < (b) ? (b) : (a) +#define HMM_ABS(a) ((a) > 0 ? (a) : -(a)) +#define HMM_MOD(a, m) ((a) % (m)) >= 0 ? ((a) % (m)) : (((a) % (m)) + (m)) +#define HMM_SQUARE(x) ((x) * (x)) + + typedef union hmm_vec2 + { + struct + { + float X, Y; + }; + struct + { + float x, y; + }; + struct + { + float U, V; + }; + + struct + { + float Left, Right; + }; + + struct + { + float Width, Height; + }; + + float Elements[2]; + } hmm_vec2; + + typedef union hmm_vec3 + { + struct + { + float X, Y, Z; + }; + + struct + { + float x, y, z; + }; + + struct + { + float U, V, W; + }; + + struct + { + float R, G, B; + }; + + struct + { + hmm_vec2 XY; + float Ignored0_; + }; + + struct + { + float Ignored1_; + hmm_vec2 YZ; + }; + + struct + { + hmm_vec2 UV; + float Ignored2_; + }; + + struct + { + float Ignored3_; + hmm_vec2 VW; + }; + + float Elements[3]; + } hmm_vec3; + + typedef union hmm_vec4 + { + struct + { + union + { + hmm_vec3 XYZ; + struct + { + float X, Y, Z; + }; + }; + + float W; + }; + struct + { + union + { + hmm_vec3 xyz; + struct + { + float x, y, z; + }; + }; + + float w; + }; + struct + { + union + { + hmm_vec3 RGB; + struct + { + float R, G, B; + }; + struct + { + float r, g, b; + }; + }; + + union + { + float A; + float a; + }; + }; + + struct + { + hmm_vec2 XY; + float Ignored0_; + float Ignored1_; + }; + struct + { + hmm_vec2 xy; + float Ignored0b_; + float Ignored1b_; + }; + + struct + { + float Ignored2_; + hmm_vec2 YZ; + float Ignored3_; + }; + struct + { + float Ignored2b_; + hmm_vec2 yz; + float Ignored3b_; + }; + + struct + { + float Ignored4_; + float Ignored5_; + hmm_vec2 ZW; + }; + + struct + { + float Ignored4b_; + float Ignored5b_; + hmm_vec2 zw; + }; + + float Elements[4]; + } hmm_vec4; + + typedef union hmm_mat4 + { + float Elements[4][4]; + + +#ifdef HANDMADE_MATH__USE_SSE + __m128 Rows[4]; +#endif + } hmm_mat4; + + typedef union hmm_quaternion + { + struct + { + union + { + hmm_vec3 XYZ; + struct + { + float X, Y, Z; + }; + }; + + float W; + }; + + float Elements[4]; + } hmm_quaternion; + + typedef struct + { + hmm_vec2 ValueMin; + hmm_vec2 ValueMax; + } hmm_vec2r; + + typedef struct + { + hmm_vec3 ValueMin; + hmm_vec3 ValueMax; + } hmm_vec3r; + + typedef struct + { + hmm_vec4 ValueMin; + hmm_vec4 ValueMax; + } hmm_vec4r; + + typedef int32_t hmm_bool; + + typedef hmm_vec2 hmm_v2; + typedef hmm_vec3 hmm_v3; + typedef hmm_vec4 hmm_v4; + typedef hmm_mat4 hmm_m4; + typedef hmm_vec2r hmm_v2r; + typedef hmm_vec3r hmm_v3r; + typedef hmm_vec4r hmm_v4r; + + HMMDEF float HMM_SinF(float Angle); + HMMDEF float HMM_TanF(float Angle); + HMMDEF float HMM_ATanF(float Theta); + HMMDEF float HMM_ATan2F(float Theta, float Theta2); + HMMDEF float HMM_CosF(float Angle); + HMMDEF float HMM_ACosF(float Theta); + HMMDEF float HMM_ExpF(float Float); + HMMDEF float HMM_LogF(float Float); + + HMMDEF float HMM_ToRadians(float Degrees); + HMMDEF float HMM_SquareRootF(float Float); + HMMDEF float HMM_RSquareRootF(float Float); + + HMMDEF float HMM_LengthSquaredVec2(hmm_vec2 A); + HMMDEF float HMM_LengthSquaredVec3(hmm_vec3 A); + HMMDEF float HMM_LengthSquaredVec4(hmm_vec4 A); + + HMMDEF float HMM_LengthVec2(hmm_vec2 A); + HMMDEF float HMM_LengthVec3(hmm_vec3 A); + HMMDEF float HMM_LengthVec4(hmm_vec4 A); + + HMMDEF float HMM_Power(float Base, int Exponent); + HMMDEF float HMM_PowerF(float Base, float Exponent); + HMMDEF float HMM_Lerp(float A, float Time, float B); + HMMDEF float HMM_Clamp(float Min, float Value, float Max); + + HMMDEF hmm_vec2 HMM_NormalizeVec2(hmm_vec2 A); + HMMDEF hmm_vec3 HMM_NormalizeVec3(hmm_vec3 A); + HMMDEF hmm_vec4 HMM_NormalizeVec4(hmm_vec4 A); + + HMMDEF float HMM_DotVec2(hmm_vec2 VecOne, hmm_vec2 VecTwo); + HMMDEF float HMM_DotVec3(hmm_vec3 VecOne, hmm_vec3 VecTwo); + HMMDEF float HMM_DotVec4(hmm_vec4 VecOne, hmm_vec4 VecTwo); + + HMMDEF hmm_vec3 HMM_Cross(hmm_vec3 VecOne, hmm_vec3 VecTwo); + + HMMDEF hmm_vec2 HMM_Vec2(float X, float Y); + HMMDEF hmm_vec2 HMM_Vec2i(int X, int Y); + HMMDEF hmm_vec3 HMM_Vec3(float X, float Y, float Z); + HMMDEF hmm_vec3 HMM_Vec3i(int X, int Y, int Z); + HMMDEF hmm_vec4 HMM_Vec4(float X, float Y, float Z, float W); + HMMDEF hmm_vec4 HMM_Vec4i(int X, int Y, int Z, int W); + HMMDEF hmm_vec4 HMM_Vec4v(hmm_vec3 Vector, float W); + + HMMDEF hmm_vec2 HMM_AddVec2(hmm_vec2 Left, hmm_vec2 Right); + HMMDEF hmm_vec3 HMM_AddVec3(hmm_vec3 Left, hmm_vec3 Right); + HMMDEF hmm_vec4 HMM_AddVec4(hmm_vec4 Left, hmm_vec4 Right); + + HMMDEF hmm_vec2 HMM_SubtractVec2(hmm_vec2 Left, hmm_vec2 Right); + HMMDEF hmm_vec3 HMM_SubtractVec3(hmm_vec3 Left, hmm_vec3 Right); + HMMDEF hmm_vec4 HMM_SubtractVec4(hmm_vec4 Left, hmm_vec4 Right); + + HMMDEF hmm_vec2 HMM_MultiplyVec2(hmm_vec2 Left, hmm_vec2 Right); + HMMDEF hmm_vec2 HMM_MultiplyVec2f(hmm_vec2 Left, float Right); + HMMDEF hmm_vec3 HMM_MultiplyVec3(hmm_vec3 Left, hmm_vec3 Right); + HMMDEF hmm_vec3 HMM_MultiplyVec3f(hmm_vec3 Left, float Right); + HMMDEF hmm_vec4 HMM_MultiplyVec4(hmm_vec4 Left, hmm_vec4 Right); + HMMDEF hmm_vec4 HMM_MultiplyVec4f(hmm_vec4 Left, float Right); + + HMMDEF hmm_vec2 HMM_DivideVec2(hmm_vec2 Left, hmm_vec2 Right); + HMMDEF hmm_vec2 HMM_DivideVec2f(hmm_vec2 Left, float Right); + HMMDEF hmm_vec3 HMM_DivideVec3(hmm_vec3 Left, hmm_vec3 Right); + HMMDEF hmm_vec3 HMM_DivideVec3f(hmm_vec3 Left, float Right); + HMMDEF hmm_vec4 HMM_DivideVec4(hmm_vec4 Left, hmm_vec4 Right); + HMMDEF hmm_vec4 HMM_DivideVec4f(hmm_vec4 Left, float Right); + + HMMDEF hmm_bool HMM_EqualsVec2(hmm_vec2 Left, hmm_vec2 Right); + HMMDEF hmm_bool HMM_EqualsVec3(hmm_vec3 Left, hmm_vec3 Right); + HMMDEF hmm_bool HMM_EqualsVec4(hmm_vec4 Left, hmm_vec4 Right); + + HMMDEF hmm_mat4 HMM_Mat4(void); + HMMDEF hmm_mat4 HMM_Mat4d(float Diagonal); + HMMDEF hmm_mat4 HMM_AddMat4(hmm_mat4 Left, hmm_mat4 Right); + HMMDEF hmm_mat4 HMM_SubtractMat4(hmm_mat4 Left, hmm_mat4 Right); + +#ifdef HANDMADE_MATH__USE_SSE + HMMDEF __m128 HMM_LinearCombineSSE(__m128 Left, hmm_mat4 Right); +#endif + + HMMDEF hmm_mat4 HMM_MultiplyMat4(hmm_mat4 Left, hmm_mat4 Right); + HMMDEF hmm_mat4 HMM_MultiplyMat4f(hmm_mat4 Matrix, float Scalar); + HMMDEF hmm_vec4 HMM_MultiplyMat4ByVec4(hmm_mat4 Matrix, hmm_vec4 Vector); + HMMDEF hmm_mat4 HMM_DivideMat4f(hmm_mat4 Matrix, float Scalar); + + HMMDEF hmm_mat4 HMM_Transpose(hmm_mat4 Matrix); + + HMMDEF hmm_mat4 HMM_Orthographic(float Left, float Right, float Bottom, float Top, float Near, float Far); + HMMDEF hmm_mat4 HMM_Perspective(float FOV, float AspectRatio, float Near, float Far); + + HMMDEF hmm_mat4 HMM_Translate(hmm_vec3 Translation); + HMMDEF hmm_mat4 HMM_Rotate(float Angle, hmm_vec3 Axis); + HMMDEF hmm_mat4 HMM_Scale(hmm_vec3 Scale); + + HMMDEF hmm_mat4 HMM_LookAt(hmm_vec3 Eye, hmm_vec3 Center, hmm_vec3 Up); + + HMMDEF hmm_quaternion HMM_Quaternion(float X, float Y, float Z, float W); + HMMDEF hmm_quaternion HMM_QuaternionV4(hmm_vec4 Vector); + HMMDEF hmm_quaternion HMM_AddQuaternion(hmm_quaternion Left, hmm_quaternion Right); + HMMDEF hmm_quaternion HMM_SubtractQuaternion(hmm_quaternion Left, hmm_quaternion Right); + HMMDEF hmm_quaternion HMM_MultiplyQuaternion(hmm_quaternion Left, hmm_quaternion Right); + HMMDEF hmm_quaternion HMM_MultiplyQuaternionF(hmm_quaternion Left, float Multiplicative); + HMMDEF hmm_quaternion HMM_DivideQuaternionF(hmm_quaternion Left, float Dividend); + HMMDEF hmm_quaternion HMM_InverseQuaternion(hmm_quaternion Left); + HMMDEF float HMM_DotQuaternion(hmm_quaternion Left, hmm_quaternion Right); + HMMDEF hmm_quaternion HMM_NormalizeQuaternion(hmm_quaternion Left); + HMMDEF hmm_quaternion HMM_NLerp(hmm_quaternion Left, float Time, hmm_quaternion Right); + HMMDEF hmm_quaternion HMM_Slerp(hmm_quaternion Left, float Time, hmm_quaternion Right); + HMMDEF hmm_mat4 HMM_QuaternionToMat4(hmm_quaternion Left); + HMMDEF hmm_quaternion HMM_QuaternionFromAxisAngle(hmm_vec3 Axis, float AngleOfRotation); + +#ifdef __cplusplus +} +#endif + +#ifdef HANDMADE_MATH_CPP_MODE + +HMMDEF float HMM_Length(hmm_vec2 A); +HMMDEF float HMM_Length(hmm_vec3 A); +HMMDEF float HMM_Length(hmm_vec4 A); + +HMMDEF float HMM_LengthSquared(hmm_vec2 A); +HMMDEF float HMM_LengthSquared(hmm_vec3 A); +HMMDEF float HMM_LengthSquared(hmm_vec4 A); + +HMMDEF hmm_vec2 HMM_Normalize(hmm_vec2 A); +HMMDEF hmm_vec3 HMM_Normalize(hmm_vec3 A); +HMMDEF hmm_vec4 HMM_Normalize(hmm_vec4 A); +HMMDEF hmm_quaternion HMM_Normalize(hmm_quaternion A); + +HMMDEF float HMM_Dot(hmm_vec2 VecOne, hmm_vec2 VecTwo); +HMMDEF float HMM_Dot(hmm_vec3 VecOne, hmm_vec3 VecTwo); +HMMDEF float HMM_Dot(hmm_vec4 VecOne, hmm_vec4 VecTwo); +HMMDEF float HMM_Dot(hmm_quaternion QuatOne, hmm_quaternion QuatTwo); + +HMMDEF hmm_vec2 HMM_Add(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_vec3 HMM_Add(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_vec4 HMM_Add(hmm_vec4 Left, hmm_vec4 Right); +HMMDEF hmm_mat4 HMM_Add(hmm_mat4 Left, hmm_mat4 Right); +HMMDEF hmm_quaternion HMM_Add(hmm_quaternion Left, hmm_quaternion Right); + +HMMDEF hmm_vec2 HMM_Subtract(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_vec3 HMM_Subtract(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_vec4 HMM_Subtract(hmm_vec4 Left, hmm_vec4 Right); +HMMDEF hmm_mat4 HMM_Subtract(hmm_mat4 Left, hmm_mat4 Right); +HMMDEF hmm_quaternion HMM_Subtract(hmm_quaternion Left, hmm_quaternion Right); + +HMMDEF hmm_vec2 HMM_Multiply(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_vec2 HMM_Multiply(hmm_vec2 Left, float Right); +HMMDEF hmm_vec3 HMM_Multiply(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_vec3 HMM_Multiply(hmm_vec3 Left, float Right); +HMMDEF hmm_vec4 HMM_Multiply(hmm_vec4 Left, hmm_vec4 Right); +HMMDEF hmm_vec4 HMM_Multiply(hmm_vec4 Left, float Right); +HMMDEF hmm_mat4 HMM_Multiply(hmm_mat4 Left, hmm_mat4 Right); +HMMDEF hmm_mat4 HMM_Multiply(hmm_mat4 Left, float Right); +HMMDEF hmm_vec4 HMM_Multiply(hmm_mat4 Matrix, hmm_vec4 Vector); +HMMDEF hmm_quaternion HMM_Multiply(hmm_quaternion Left, hmm_quaternion Right); +HMMDEF hmm_quaternion HMM_Multiply(hmm_quaternion Left, float Right); + +HMMDEF hmm_vec2 HMM_Divide(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_vec2 HMM_Divide(hmm_vec2 Left, float Right); +HMMDEF hmm_vec3 HMM_Divide(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_vec3 HMM_Divide(hmm_vec3 Left, float Right); +HMMDEF hmm_vec4 HMM_Divide(hmm_vec4 Left, hmm_vec4 Right); +HMMDEF hmm_vec4 HMM_Divide(hmm_vec4 Left, float Right); +HMMDEF hmm_mat4 HMM_Divide(hmm_mat4 Left, float Right); +HMMDEF hmm_quaternion HMM_Divide(hmm_quaternion Left, hmm_quaternion Right); +HMMDEF hmm_quaternion HMM_Divide(hmm_quaternion Left, float Right); + +HMMDEF hmm_bool HMM_Equals(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_bool HMM_Equals(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_bool HMM_Equals(hmm_vec4 Left, hmm_vec4 Right); + +HMMDEF hmm_vec2 operator+(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_vec3 operator+(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_vec4 operator+(hmm_vec4 Left, hmm_vec4 Right); +HMMDEF hmm_mat4 operator+(hmm_mat4 Left, hmm_mat4 Right); +HMMDEF hmm_quaternion operator+(hmm_quaternion Left, hmm_quaternion Right); + +HMMDEF hmm_vec2 operator-(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_vec3 operator-(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_vec4 operator-(hmm_vec4 Left, hmm_vec4 Right); +HMMDEF hmm_mat4 operator-(hmm_mat4 Left, hmm_mat4 Right); +HMMDEF hmm_quaternion operator-(hmm_quaternion Left, hmm_quaternion Right); + +HMMDEF hmm_vec2 operator*(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_vec3 operator*(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_vec4 operator*(hmm_vec4 Left, hmm_vec4 Right); +HMMDEF hmm_mat4 operator*(hmm_mat4 Left, hmm_mat4 Right); +HMMDEF hmm_quaternion operator*(hmm_quaternion Left, hmm_quaternion Right); + +HMMDEF hmm_vec2 operator*(hmm_vec2 Left, float Right); +HMMDEF hmm_vec3 operator*(hmm_vec3 Left, float Right); +HMMDEF hmm_vec4 operator*(hmm_vec4 Left, float Right); +HMMDEF hmm_mat4 operator*(hmm_mat4 Left, float Right); +HMMDEF hmm_quaternion operator*(hmm_quaternion Left, float Right); + +HMMDEF hmm_vec2 operator*(float Left, hmm_vec2 Right); +HMMDEF hmm_vec3 operator*(float Left, hmm_vec3 Right); +HMMDEF hmm_vec4 operator*(float Left, hmm_vec4 Right); +HMMDEF hmm_mat4 operator*(float Left, hmm_mat4 Right); +HMMDEF hmm_quaternion operator*(float Left, hmm_quaternion Right); + +HMMDEF hmm_vec4 operator*(hmm_mat4 Matrix, hmm_vec4 Vector); + +HMMDEF hmm_vec2 operator/(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_vec3 operator/(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_vec4 operator/(hmm_vec4 Left, hmm_vec4 Right); + +HMMDEF hmm_vec2 operator/(hmm_vec2 Left, float Right); +HMMDEF hmm_vec3 operator/(hmm_vec3 Left, float Right); +HMMDEF hmm_vec4 operator/(hmm_vec4 Left, float Right); +HMMDEF hmm_mat4 operator/(hmm_mat4 Left, float Right); +HMMDEF hmm_quaternion operator/(hmm_quaternion Left, float Right); + +HMMDEF hmm_vec2 &operator+=(hmm_vec2 &Left, hmm_vec2 Right); +HMMDEF hmm_vec3 &operator+=(hmm_vec3 &Left, hmm_vec3 Right); +HMMDEF hmm_vec4 &operator+=(hmm_vec4 &Left, hmm_vec4 Right); +HMMDEF hmm_mat4 &operator+=(hmm_mat4 &Left, hmm_mat4 Right); +HMMDEF hmm_quaternion &operator+=(hmm_quaternion &Left, hmm_quaternion Right); + +HMMDEF hmm_vec2 &operator-=(hmm_vec2 &Left, hmm_vec2 Right); +HMMDEF hmm_vec3 &operator-=(hmm_vec3 &Left, hmm_vec3 Right); +HMMDEF hmm_vec4 &operator-=(hmm_vec4 &Left, hmm_vec4 Right); +HMMDEF hmm_mat4 &operator-=(hmm_mat4 &Left, hmm_mat4 Right); +HMMDEF hmm_quaternion &operator-=(hmm_quaternion &Left, hmm_quaternion Right); + +HMMDEF hmm_vec2 &operator*=(hmm_vec2 &Left, hmm_vec2 Right); +HMMDEF hmm_vec3 &operator*=(hmm_vec3 &Left, hmm_vec3 Right); +HMMDEF hmm_vec4 &operator*=(hmm_vec4 &Left, hmm_vec4 Right); + +HMMDEF hmm_vec2 &operator*=(hmm_vec2 &Left, float Right); +HMMDEF hmm_vec3 &operator*=(hmm_vec3 &Left, float Right); +HMMDEF hmm_vec4 &operator*=(hmm_vec4 &Left, float Right); +HMMDEF hmm_mat4 &operator*=(hmm_mat4 &Left, float Right); +HMMDEF hmm_quaternion &operator*=(hmm_quaternion &Left, float Right); + +HMMDEF hmm_vec2 &operator/=(hmm_vec2 &Left, hmm_vec2 Right); +HMMDEF hmm_vec3 &operator/=(hmm_vec3 &Left, hmm_vec3 Right); +HMMDEF hmm_vec4 &operator/=(hmm_vec4 &Left, hmm_vec4 Right); + +HMMDEF hmm_vec2 &operator/=(hmm_vec2 &Left, float Right); +HMMDEF hmm_vec3 &operator/=(hmm_vec3 &Left, float Right); +HMMDEF hmm_vec4 &operator/=(hmm_vec4 &Left, float Right); +HMMDEF hmm_mat4 &operator/=(hmm_mat4 &Left, float Right); +HMMDEF hmm_quaternion &operator/=(hmm_quaternion &Left, float Right); + +HMMDEF hmm_bool operator==(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_bool operator==(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_bool operator==(hmm_vec4 Left, hmm_vec4 Right); + +HMMDEF hmm_bool operator!=(hmm_vec2 Left, hmm_vec2 Right); +HMMDEF hmm_bool operator!=(hmm_vec3 Left, hmm_vec3 Right); +HMMDEF hmm_bool operator!=(hmm_vec4 Left, hmm_vec4 Right); + +HMMDEF hmm_mat4 HMM_Mat4Identity(); +HMMDEF hmm_vec2 HMM_LerpV2(hmm_vec2 A, float T, hmm_vec2 B); +HMMDEF hmm_vec3 HMM_LerpV3(hmm_vec3 A, float T, hmm_vec3 B); +HMMDEF hmm_vec4 HMM_LerpV4(hmm_vec4 A, float T, hmm_vec4 B); +HMMDEF hmm_vec4 HMM_AverageVec3(hmm_vec4* Arr, unsigned int Len); +HMMDEF hmm_vec4 HMM_AverageVec4(hmm_vec4* Arr, unsigned int Len); +HMMDEF bool HMM_SameSide(hmm_vec3 P1, hmm_vec3 P2, hmm_vec3 A, hmm_vec3 B); +HMMDEF bool HMM_PointInTriangle(hmm_vec3 P, hmm_vec3 T0, hmm_vec3 T1, hmm_vec3 T2); + +#endif /* HANDMADE_MATH_CPP */ + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif /* HANDMADE_MATH_H */ + +#ifdef HANDMADE_MATH_IMPLEMENTATION + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-braces" +#endif + +HINLINE float +HMM_SinF(float Angle) +{ + float Result = 0.0f; + + Result = HMM_SINF(Angle); + return (Result); +} + +HINLINE float +HMM_CosF(float Angle) +{ + float Result = 0.0f; + + Result = HMM_COSF(Angle); + return (Result); +} + +HINLINE float +HMM_TanF(float Radians) +{ + float Result = 0.0f; + + Result = HMM_TANF(Radians); + return (Result); +} + +HINLINE float +HMM_ACosF(float Radians) +{ + float Result = 0.0f; + + Result = HMM_ACOSF(Radians); + return (Result); +} + +HINLINE float +HMM_ATanF(float Radians) +{ + float Result = 0.0f; + + Result = HMM_ATANF(Radians); + return (Result); +} + +HINLINE float +HMM_Atan2F(float Left, float Right) +{ + float Result = 0.0f; + + Result = HMM_ATAN2F(Left, Right); + return (Result); +} + +HINLINE float +HMM_ExpF(float Float) +{ + float Result = 0.0f; + + Result = HMM_EXPF(Float); + return (Result); +} + +HINLINE float +HMM_LogF(float Float) +{ + float Result = 0.0f; + + Result = HMM_LOGF(Float); + return (Result); +} + +HINLINE float +HMM_ToRadians(float Degrees) +{ + float Result = 0.0f; + + Result = Degrees * (HMM_PI32 / 180.0f); + return (Result); +} + +HINLINE float +HMM_SquareRootF(float Value) +{ + float Result = 0.0f; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 In = _mm_set_ss(Value); + __m128 Out = _mm_sqrt_ss(In); + Result = _mm_cvtss_f32(Out); +#else + Result = HMM_SQRTF(Value); +#endif + + return(Result); +} + +HINLINE float +HMM_RSquareRootF(float Value) +{ + float Result = 0.0f; + +#ifdef HANDMADE_MATH__USE_SSE + __m128 In = _mm_set_ss(Value); + __m128 Out = _mm_rsqrt_ss(In); + Result = _mm_cvtss_f32(Out); +#else + Result = 1.0f/HMM_SquareRootF(Value); +#endif + + return(Result); +} + +HINLINE float +HMM_LengthSquaredVec2(hmm_vec2 A) +{ + float Result = 0.0f; + + Result = HMM_DotVec2(A, A); + + return(Result); +} + +HINLINE float +HMM_LengthSquaredVec3(hmm_vec3 A) +{ + float Result = 0.0f; + + Result = HMM_DotVec3(A, A); + + return (Result); +} + +HINLINE float +HMM_LengthSquaredVec4(hmm_vec4 A) +{ + float Result = 0.0f; + + Result = HMM_DotVec4(A, A); + + return(Result); +} + +HINLINE float +HMM_LengthVec2(hmm_vec2 A) +{ + float Result = 0.0f; + + Result = HMM_SquareRootF(HMM_LengthSquaredVec2(A)); + + return(Result); +} + +HINLINE float +HMM_LengthVec3(hmm_vec3 A) +{ + float Result = 0.0f; + + Result = HMM_SquareRootF(HMM_LengthSquaredVec3(A)); + + return (Result); +} + +HINLINE float +HMM_LengthVec4(hmm_vec4 A) +{ + float Result = 0.0f; + + Result = HMM_SquareRootF(HMM_LengthSquaredVec4(A)); + + return(Result); +} + +HINLINE float +HMM_Power(float Base, int Exponent) +{ + float Result = 1.0f; + float Mul = Exponent < 0 ? 1.f / Base : Base; + int X = Exponent < 0 ? -Exponent : Exponent; + while (X) + { + if (X & 1) + { + Result *= Mul; + } + + Mul *= Mul; + X >>= 1; + } + + return (Result); +} + +HINLINE float +HMM_PowerF(float Base, float Exponent) +{ + return HMM_EXPF(Exponent * HMM_LOGF(Base)); +} + +HINLINE float +HMM_Lerp(float A, float Time, float B) +{ + float Result = 0; + + Result = (1.0f - Time) * A + Time * B; + return (Result); +} + +HINLINE float +HMM_Clamp(float Min, float Value, float Max) +{ + float Result = Value; + + if(Result < Min) + { + Result = Min; + } + else if(Result > Max) + { + Result = Max; + } + + return (Result); +} + +HINLINE hmm_vec2 +HMM_NormalizeVec2(hmm_vec2 A) +{ + hmm_vec2 Result = {0}; + + float VectorLength = HMM_LengthVec2(A); + + /* NOTE(kiljacken): We need a zero check to not divide-by-zero */ + if (VectorLength != 0.0f) + { + Result.X = A.X * (1.0f / VectorLength); + Result.Y = A.Y * (1.0f / VectorLength); + } + + return (Result); +} + +HINLINE hmm_vec3 +HMM_NormalizeVec3(hmm_vec3 A) +{ + hmm_vec3 Result = {0}; + + float VectorLength = HMM_LengthVec3(A); + + /* NOTE(kiljacken): We need a zero check to not divide-by-zero */ + if (VectorLength != 0.0f) + { + Result.X = A.X * (1.0f / VectorLength); + Result.Y = A.Y * (1.0f / VectorLength); + Result.Z = A.Z * (1.0f / VectorLength); + } + + return (Result); +} + +HINLINE hmm_vec4 +HMM_NormalizeVec4(hmm_vec4 A) +{ + hmm_vec4 Result = {0}; + + float VectorLength = HMM_LengthVec4(A); + + /* NOTE(kiljacken): We need a zero check to not divide-by-zero */ + if (VectorLength != 0.0f) + { + Result.X = A.X * (1.0f / VectorLength); + Result.Y = A.Y * (1.0f / VectorLength); + Result.Z = A.Z * (1.0f / VectorLength); + Result.W = A.W * (1.0f / VectorLength); + } + + return (Result); +} + +HINLINE float +HMM_DotVec2(hmm_vec2 VecOne, hmm_vec2 VecTwo) +{ + float Result = 0.0f; + + Result = (VecOne.X * VecTwo.X) + (VecOne.Y * VecTwo.Y); + + return (Result); +} + +HINLINE float +HMM_DotVec3(hmm_vec3 VecOne, hmm_vec3 VecTwo) +{ + float Result = 0.0f; + + Result = (VecOne.X * VecTwo.X) + (VecOne.Y * VecTwo.Y) + (VecOne.Z * VecTwo.Z); + + return (Result); +} + +HINLINE float +HMM_DotVec4(hmm_vec4 VecOne, hmm_vec4 VecTwo) +{ + float Result = 0.0f; + + Result = (VecOne.X * VecTwo.X) + (VecOne.Y * VecTwo.Y) + (VecOne.Z * VecTwo.Z) + (VecOne.W * VecTwo.W); + + return (Result); +} + +HINLINE hmm_vec3 +HMM_Cross(hmm_vec3 VecOne, hmm_vec3 VecTwo) +{ + hmm_vec3 Result = {0}; + + Result.X = (VecOne.Y * VecTwo.Z) - (VecOne.Z * VecTwo.Y); + Result.Y = (VecOne.Z * VecTwo.X) - (VecOne.X * VecTwo.Z); + Result.Z = (VecOne.X * VecTwo.Y) - (VecOne.Y * VecTwo.X); + + return (Result); +} + +HINLINE hmm_vec2 +HMM_Vec2(float X, float Y) +{ + hmm_vec2 Result = {0}; + + Result.X = X; + Result.Y = Y; + + return (Result); +} + +HINLINE hmm_vec2 +HMM_Vec2i(int X, int Y) +{ + hmm_vec2 Result = {0}; + + Result.X = (float)X; + Result.Y = (float)Y; + + return (Result); +} + +HINLINE hmm_vec3 +HMM_Vec3(float X, float Y, float Z) +{ + hmm_vec3 Result = {0}; + + Result.X = X; + Result.Y = Y; + Result.Z = Z; + + return (Result); +} + +HINLINE hmm_vec3 +HMM_Vec3i(int X, int Y, int Z) +{ + hmm_vec3 Result = {0}; + + Result.X = (float)X; + Result.Y = (float)Y; + Result.Z = (float)Z; + + return (Result); +} + +HINLINE hmm_vec4 +HMM_Vec4(float X, float Y, float Z, float W) +{ + hmm_vec4 Result = {0}; + + Result.X = X; + Result.Y = Y; + Result.Z = Z; + Result.W = W; + + return (Result); +} + +HINLINE hmm_vec4 +HMM_Vec4i(int X, int Y, int Z, int W) +{ + hmm_vec4 Result = {0}; + + Result.X = (float)X; + Result.Y = (float)Y; + Result.Z = (float)Z; + Result.W = (float)W; + + return (Result); +} + +HINLINE hmm_vec4 +HMM_Vec4v(hmm_vec3 Vector, float W) +{ + hmm_vec4 Result = {0}; + + Result.XYZ = Vector; + Result.W = W; + + return (Result); +} + +HINLINE hmm_vec2 +HMM_AddVec2(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result.X = Left.X + Right.X; + Result.Y = Left.Y + Right.Y; + + return (Result); +} + +HINLINE hmm_vec3 +HMM_AddVec3(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result.X = Left.X + Right.X; + Result.Y = Left.Y + Right.Y; + Result.Z = Left.Z + Right.Z; + + return (Result); +} + +HINLINE hmm_vec4 +HMM_AddVec4(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result.X = Left.X + Right.X; + Result.Y = Left.Y + Right.Y; + Result.Z = Left.Z + Right.Z; + Result.W = Left.W + Right.W; + + return (Result); +} + +HINLINE hmm_vec2 +HMM_SubtractVec2(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result.X = Left.X - Right.X; + Result.Y = Left.Y - Right.Y; + + return (Result); +} + +HINLINE hmm_vec3 +HMM_SubtractVec3(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result.X = Left.X - Right.X; + Result.Y = Left.Y - Right.Y; + Result.Z = Left.Z - Right.Z; + + return (Result); +} + +HINLINE hmm_vec4 +HMM_SubtractVec4(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result.X = Left.X - Right.X; + Result.Y = Left.Y - Right.Y; + Result.Z = Left.Z - Right.Z; + Result.W = Left.W - Right.W; + + return (Result); +} + +HINLINE hmm_vec2 +HMM_MultiplyVec2(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result.X = Left.X * Right.X; + Result.Y = Left.Y * Right.Y; + + return (Result); +} + +HINLINE hmm_vec2 +HMM_MultiplyVec2f(hmm_vec2 Left, float Right) +{ + hmm_vec2 Result = {0}; + + Result.X = Left.X * Right; + Result.Y = Left.Y * Right; + + return (Result); +} + +HINLINE hmm_vec3 +HMM_MultiplyVec3(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result.X = Left.X * Right.X; + Result.Y = Left.Y * Right.Y; + Result.Z = Left.Z * Right.Z; + + return (Result); +} + +HINLINE hmm_vec3 +HMM_MultiplyVec3f(hmm_vec3 Left, float Right) +{ + hmm_vec3 Result = {0}; + + Result.X = Left.X * Right; + Result.Y = Left.Y * Right; + Result.Z = Left.Z * Right; + + return (Result); +} + +HINLINE hmm_vec4 +HMM_MultiplyVec4(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result.X = Left.X * Right.X; + Result.Y = Left.Y * Right.Y; + Result.Z = Left.Z * Right.Z; + Result.W = Left.W * Right.W; + + return (Result); +} + +HINLINE hmm_vec4 +HMM_MultiplyVec4f(hmm_vec4 Left, float Right) +{ + hmm_vec4 Result = {0}; + + Result.X = Left.X * Right; + Result.Y = Left.Y * Right; + Result.Z = Left.Z * Right; + Result.W = Left.W * Right; + + return (Result); +} + +HINLINE hmm_vec2 +HMM_DivideVec2(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result.X = Left.X / Right.X; + Result.Y = Left.Y / Right.Y; + + return (Result); +} + +HINLINE hmm_vec2 +HMM_DivideVec2f(hmm_vec2 Left, float Right) +{ + hmm_vec2 Result = {0}; + + Result.X = Left.X / Right; + Result.Y = Left.Y / Right; + + return (Result); +} + +HINLINE hmm_vec3 +HMM_DivideVec3(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result.X = Left.X / Right.X; + Result.Y = Left.Y / Right.Y; + Result.Z = Left.Z / Right.Z; + + return (Result); +} + +HINLINE hmm_vec3 +HMM_DivideVec3f(hmm_vec3 Left, float Right) +{ + hmm_vec3 Result = {0}; + + Result.X = Left.X / Right; + Result.Y = Left.Y / Right; + Result.Z = Left.Z / Right; + + return (Result); +} + +HINLINE hmm_vec4 +HMM_DivideVec4(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result.X = Left.X / Right.X; + Result.Y = Left.Y / Right.Y; + Result.Z = Left.Z / Right.Z; + Result.W = Left.W / Right.W; + + return (Result); +} + +HINLINE hmm_vec4 +HMM_DivideVec4f(hmm_vec4 Left, float Right) +{ + hmm_vec4 Result = {0}; + + Result.X = Left.X / Right; + Result.Y = Left.Y / Right; + Result.Z = Left.Z / Right; + Result.W = Left.W / Right; + + return (Result); +} + +HINLINE hmm_bool +HMM_EqualsVec2(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_bool Result = 0; + + Result = (Left.X == Right.X && Left.Y == Right.Y); + + return (Result); +} + +HINLINE hmm_bool +HMM_EqualsVec3(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_bool Result = 0; + + Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z); + + return (Result); +} + +HINLINE hmm_bool +HMM_EqualsVec4(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_bool Result = 0; + + Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z && Left.W == Right.W); + + return (Result); +} + +HINLINE hmm_mat4 +HMM_Mat4(void) +{ + hmm_mat4 Result = {0}; + + return (Result); +} + +HINLINE hmm_mat4 +HMM_Mat4d(float Diagonal) +{ + hmm_mat4 Result = HMM_Mat4(); + + Result.Elements[0][0] = Diagonal; + Result.Elements[1][1] = Diagonal; + Result.Elements[2][2] = Diagonal; + Result.Elements[3][3] = Diagonal; + + return (Result); +} + +HINLINE hmm_mat4 +HMM_AddMat4(hmm_mat4 Left, hmm_mat4 Right) +{ + hmm_mat4 Result = HMM_Mat4(); + + int Columns; + for(Columns = 0; Columns < 4; ++Columns) + { + int Rows; + for(Rows = 0; Rows < 4; ++Rows) + { + Result.Elements[Columns][Rows] = Left.Elements[Columns][Rows] + Right.Elements[Columns][Rows]; + } + } + + return (Result); +} + +HINLINE hmm_mat4 +HMM_SubtractMat4(hmm_mat4 Left, hmm_mat4 Right) +{ + hmm_mat4 Result = HMM_Mat4(); + + int Columns; + for(Columns = 0; Columns < 4; ++Columns) + { + int Rows; + for(Rows = 0; Rows < 4; ++Rows) + { + Result.Elements[Columns][Rows] = Left.Elements[Columns][Rows] - Right.Elements[Columns][Rows]; + } + } + + return (Result); +} + +#ifdef HANDMADE_MATH__USE_SSE +HINLINE __m128 +HMM_LinearCombineSSE(__m128 Left, hmm_mat4 Right) +{ + __m128 Result = {}; + Result = _mm_mul_ps(_mm_shuffle_ps(Left, Left, 0x00), Right.Rows[0]); + Result = _mm_add_ps(Result, _mm_mul_ps(_mm_shuffle_ps(Left, Left, 0x55), Right.Rows[1])); + Result = _mm_add_ps(Result, _mm_mul_ps(_mm_shuffle_ps(Left, Left, 0xaa), Right.Rows[2])); + Result = _mm_add_ps(Result, _mm_mul_ps(_mm_shuffle_ps(Left, Left, 0xff), Right.Rows[3])); + + return(Result); +} +#endif + +HINLINE hmm_mat4 +HMM_MultiplyMat4(hmm_mat4 Left, hmm_mat4 Right) +{ + hmm_mat4 Result = HMM_Mat4(); + +#ifdef HANDMADE_MATH__USE_SSE + + hmm_mat4 TransposedLeft = HMM_Transpose(Left); + hmm_mat4 TransposedRight = HMM_Transpose(Right); + + Result.Rows[0] = HMM_LinearCombineSSE(TransposedLeft.Rows[0], TransposedRight); + Result.Rows[1] = HMM_LinearCombineSSE(TransposedLeft.Rows[1], TransposedRight); + Result.Rows[2] = HMM_LinearCombineSSE(TransposedLeft.Rows[2], TransposedRight); + Result.Rows[3] = HMM_LinearCombineSSE(TransposedLeft.Rows[3], TransposedRight); + + Result = HMM_Transpose(Result); + +#else + int Columns; + for(Columns = 0; Columns < 4; ++Columns) + { + int Rows; + for(Rows = 0; Rows < 4; ++Rows) + { + float Sum = 0; + int CurrentMatrice; + for(CurrentMatrice = 0; CurrentMatrice < 4; ++CurrentMatrice) + { + Sum += Left.Elements[CurrentMatrice][Rows] * Right.Elements[Columns][CurrentMatrice]; + } + + Result.Elements[Columns][Rows] = Sum; + } + } +#endif + return (Result); +} + +HINLINE hmm_mat4 +HMM_MultiplyMat4f(hmm_mat4 Matrix, float Scalar) +{ + hmm_mat4 Result = HMM_Mat4(); + + int Columns; + for(Columns = 0; Columns < 4; ++Columns) + { + int Rows; + for(Rows = 0; Rows < 4; ++Rows) + { + Result.Elements[Columns][Rows] = Matrix.Elements[Columns][Rows] * Scalar; + } + } + + return (Result); +} + +HINLINE hmm_vec4 +HMM_MultiplyMat4ByVec4(hmm_mat4 Matrix, hmm_vec4 Vector) +{ + hmm_vec4 Result = {0}; + + int Columns, Rows; + for(Rows = 0; Rows < 4; ++Rows) + { + float Sum = 0; + for(Columns = 0; Columns < 4; ++Columns) + { + Sum += Matrix.Elements[Columns][Rows] * Vector.Elements[Columns]; + } + + Result.Elements[Rows] = Sum; + } + + return (Result); +} + +HINLINE hmm_mat4 +HMM_DivideMat4f(hmm_mat4 Matrix, float Scalar) +{ + hmm_mat4 Result = HMM_Mat4(); + + int Columns; + for(Columns = 0; Columns < 4; ++Columns) + { + int Rows; + for(Rows = 0; Rows < 4; ++Rows) + { + Result.Elements[Columns][Rows] = Matrix.Elements[Columns][Rows] / Scalar; + } + } + + return (Result); +} + +HINLINE hmm_mat4 +HMM_Transpose(hmm_mat4 Matrix) +{ + hmm_mat4 Result = HMM_Mat4(); + +#ifdef HANDMADE_MATH__USE_SSE + Result = Matrix; + + _MM_TRANSPOSE4_PS(Result.Rows[0], Result.Rows[1], Result.Rows[2], Result.Rows[3]); +#else + int Columns; + for(Columns = 0; Columns < 4; ++Columns) + { + int Rows; + for(Rows = 0; Rows < 4; ++Rows) + { + Result.Elements[Rows][Columns] = Matrix.Elements[Columns][Rows]; + } + } +#endif + + return (Result); +} + +HINLINE hmm_mat4 +HMM_Orthographic(float Left, float Right, float Bottom, float Top, float Near, float Far) +{ + hmm_mat4 Result = HMM_Mat4d(1.0f); + + Result.Elements[0][0] = 2.0f / (Right - Left); + Result.Elements[1][1] = 2.0f / (Top - Bottom); + Result.Elements[2][2] = 2.0f / (Near - Far); + + Result.Elements[3][0] = (Left + Right) / (Left - Right); + Result.Elements[3][1] = (Bottom + Top) / (Bottom - Top); + Result.Elements[3][2] = (Far + Near) / (Near - Far); + + return (Result); +} + +HINLINE hmm_mat4 +HMM_Perspective(float FOV, float AspectRatio, float Near, float Far) +{ + hmm_mat4 Result = HMM_Mat4d(1.0f); + + float TanThetaOver2 = HMM_TanF(FOV * (HMM_PI32 / 360.0f)); + + Result.Elements[0][0] = 1.0f / TanThetaOver2; + Result.Elements[1][1] = AspectRatio / TanThetaOver2; + Result.Elements[2][3] = -1.0f; + Result.Elements[2][2] = (Near + Far) / (Near - Far); + Result.Elements[3][2] = (2.0f * Near * Far) / (Near - Far); + Result.Elements[3][3] = 0.0f; + + return (Result); +} + +HINLINE hmm_mat4 +HMM_Translate(hmm_vec3 Translation) +{ + hmm_mat4 Result = HMM_Mat4d(1.0f); + + Result.Elements[3][0] = Translation.X; + Result.Elements[3][1] = Translation.Y; + Result.Elements[3][2] = Translation.Z; + + return (Result); +} + +HINLINE hmm_mat4 +HMM_Rotate(float Angle, hmm_vec3 Axis) +{ + hmm_mat4 Result = HMM_Mat4d(1.0f); + + Axis = HMM_NormalizeVec3(Axis); + + float SinTheta = HMM_SinF(HMM_ToRadians(Angle)); + float CosTheta = HMM_CosF(HMM_ToRadians(Angle)); + float CosValue = 1.0f - CosTheta; + + Result.Elements[0][0] = (Axis.X * Axis.X * CosValue) + CosTheta; + Result.Elements[0][1] = (Axis.X * Axis.Y * CosValue) + (Axis.Z * SinTheta); + Result.Elements[0][2] = (Axis.X * Axis.Z * CosValue) - (Axis.Y * SinTheta); + + Result.Elements[1][0] = (Axis.Y * Axis.X * CosValue) - (Axis.Z * SinTheta); + Result.Elements[1][1] = (Axis.Y * Axis.Y * CosValue) + CosTheta; + Result.Elements[1][2] = (Axis.Y * Axis.Z * CosValue) + (Axis.X * SinTheta); + + Result.Elements[2][0] = (Axis.Z * Axis.X * CosValue) + (Axis.Y * SinTheta); + Result.Elements[2][1] = (Axis.Z * Axis.Y * CosValue) - (Axis.X * SinTheta); + Result.Elements[2][2] = (Axis.Z * Axis.Z * CosValue) + CosTheta; + + return (Result); +} + +HINLINE hmm_mat4 +HMM_Scale(hmm_vec3 Scale) +{ + hmm_mat4 Result = HMM_Mat4d(1.0f); + + Result.Elements[0][0] = Scale.X; + Result.Elements[1][1] = Scale.Y; + Result.Elements[2][2] = Scale.Z; + + return (Result); +} + +HINLINE hmm_mat4 +HMM_LookAt(hmm_vec3 Eye, hmm_vec3 Center, hmm_vec3 Up) +{ + hmm_mat4 Result = {0}; + + hmm_vec3 F = HMM_NormalizeVec3(HMM_SubtractVec3(Center, Eye)); + hmm_vec3 S = HMM_NormalizeVec3(HMM_Cross(F, Up)); + hmm_vec3 U = HMM_Cross(S, F); + + Result.Elements[0][0] = S.X; + Result.Elements[0][1] = U.X; + Result.Elements[0][2] = -F.X; + + Result.Elements[1][0] = S.Y; + Result.Elements[1][1] = U.Y; + Result.Elements[1][2] = -F.Y; + + Result.Elements[2][0] = S.Z; + Result.Elements[2][1] = U.Z; + Result.Elements[2][2] = -F.Z; + + Result.Elements[3][0] = -HMM_DotVec3(S, Eye); + Result.Elements[3][1] = -HMM_DotVec3(U, Eye); + Result.Elements[3][2] = HMM_DotVec3(F, Eye); + Result.Elements[3][3] = 1.0f; + + return (Result); +} + + +HINLINE hmm_quaternion +HMM_Quaternion(float X, float Y, float Z, float W) +{ + hmm_quaternion Result = {0}; + + Result.X = X; + Result.Y = Y; + Result.Z = Z; + Result.W = W; + + return(Result); +} + +HINLINE hmm_quaternion +HMM_QuaternionV4(hmm_vec4 Vector) +{ + hmm_quaternion Result = {0}; + + Result.X = Vector.X; + Result.Y = Vector.Y; + Result.Z = Vector.Z; + Result.W = Vector.W; + + return(Result); +} + +HINLINE hmm_quaternion +HMM_AddQuaternion(hmm_quaternion Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result.X = Left.X + Right.X; + Result.Y = Left.Y + Right.Y; + Result.Z = Left.Z + Right.Z; + Result.W = Left.W + Right.W; + + return(Result); +} + +HINLINE hmm_quaternion +HMM_SubtractQuaternion(hmm_quaternion Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result.X = Left.X - Right.X; + Result.Y = Left.Y - Right.Y; + Result.Z = Left.Z - Right.Z; + Result.W = Left.W - Right.W; + + return(Result); +} + +HINLINE hmm_quaternion +HMM_MultiplyQuaternion(hmm_quaternion Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result.X = (Left.X * Right.W) + (Left.Y * Right.Z) - (Left.Z * Right.Y) + (Left.W * Right.X); + Result.Y = (-Left.X * Right.Z) + (Left.Y * Right.W) + (Left.Z * Right.X) + (Left.W * Right.Y); + Result.Z = (Left.X * Right.Y) - (Left.Y * Right.X) + (Left.Z * Right.W) + (Left.W * Right.Z); + Result.W = (-Left.X * Right.X) - (Left.Y * Right.Y) - (Left.Z * Right.Z) + (Left.W * Right.W); + + return(Result); +} + +HINLINE hmm_quaternion +HMM_MultiplyQuaternionF(hmm_quaternion Left, float Multiplicative) +{ + hmm_quaternion Result = {0}; + + Result.X = Left.X * Multiplicative; + Result.Y = Left.Y * Multiplicative; + Result.Z = Left.Z * Multiplicative; + Result.W = Left.W * Multiplicative; + + return(Result); +} + +HINLINE hmm_quaternion +HMM_DivideQuaternionF(hmm_quaternion Left, float Dividend) +{ + hmm_quaternion Result = {0}; + + Result.X = Left.X / Dividend; + Result.Y = Left.Y / Dividend; + Result.Z = Left.Z / Dividend; + Result.W = Left.W / Dividend; + + return(Result); +} + +HINLINE hmm_quaternion +HMM_InverseQuaternion(hmm_quaternion Left) +{ + hmm_quaternion Conjugate = {0}; + hmm_quaternion Result = {0}; + float Norm = 0; + float NormSquared = 0; + + Conjugate.X = -Left.X; + Conjugate.Y = -Left.Y; + Conjugate.Z = -Left.Z; + Conjugate.W = Left.W; + + Norm = HMM_SquareRootF(HMM_DotQuaternion(Left, Left)); + NormSquared = Norm * Norm; + + Result.X = Conjugate.X / NormSquared; + Result.Y = Conjugate.Y / NormSquared; + Result.Z = Conjugate.Z / NormSquared; + Result.W = Conjugate.W / NormSquared; + + return(Result); +} + +HINLINE float +HMM_DotQuaternion(hmm_quaternion Left, hmm_quaternion Right) +{ + float Result = 0.0f; + + Result = (Left.X * Right.X) + (Left.Y * Right.Y) + (Left.Z * Right.Z) + (Left.W * Right.W); + + return(Result); +} + +HINLINE hmm_quaternion +HMM_NormalizeQuaternion(hmm_quaternion Left) +{ + hmm_quaternion Result; + + float Length = HMM_SquareRootF(HMM_DotQuaternion(Left, Left)); + Result = HMM_DivideQuaternionF(Left, Length); + + return(Result); +} + +HINLINE hmm_quaternion +HMM_NLerp(hmm_quaternion Left, float Time, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result.X = HMM_Lerp(Left.X, Time, Right.X); + Result.Y = HMM_Lerp(Left.Y, Time, Right.Y); + Result.Z = HMM_Lerp(Left.Z, Time, Right.Z); + Result.W = HMM_Lerp(Left.W, Time, Right.W); + + Result = HMM_NormalizeQuaternion(Result); + + return(Result); +} + +HINLINE hmm_quaternion +HMM_Slerp(hmm_quaternion Left, float Time, hmm_quaternion Right) +{ + hmm_quaternion Result; + hmm_quaternion QuaternionLeft; + hmm_quaternion QuaternionRight; + + float Cos_Theta = HMM_DotQuaternion(Left, Right); + float Angle = HMM_ACosF(Cos_Theta); + + float S1 = HMM_SinF((1.0f - Time) * Angle); + float S2 = HMM_SinF(Time * Angle); + float Is = 1.0f / HMM_SinF(Angle); + + QuaternionLeft = HMM_MultiplyQuaternionF(Left, S1); + QuaternionRight = HMM_MultiplyQuaternionF(Right, S2); + + Result = HMM_AddQuaternion(QuaternionLeft, QuaternionRight); + Result = HMM_MultiplyQuaternionF(Result, Is); + + return(Result); +} + +HINLINE hmm_mat4 +HMM_QuaternionToMat4(hmm_quaternion Left) +{ + hmm_mat4 Result; + Result = HMM_Mat4d(1); + + hmm_quaternion NormalizedQuaternion = HMM_NormalizeQuaternion(Left); + + float XX, YY, ZZ, + XY, XZ, YZ, + WX, WY, WZ; + + XX = NormalizedQuaternion.X * NormalizedQuaternion.X; + YY = NormalizedQuaternion.Y * NormalizedQuaternion.Y; + ZZ = NormalizedQuaternion.Z * NormalizedQuaternion.Z; + XY = NormalizedQuaternion.X * NormalizedQuaternion.Y; + XZ = NormalizedQuaternion.X * NormalizedQuaternion.Z; + YZ = NormalizedQuaternion.Y * NormalizedQuaternion.Z; + WX = NormalizedQuaternion.W * NormalizedQuaternion.X; + WY = NormalizedQuaternion.W * NormalizedQuaternion.Y; + WZ = NormalizedQuaternion.W * NormalizedQuaternion.Z; + + Result.Elements[0][0] = 1.0f - 2.0f * (YY + ZZ); + Result.Elements[0][1] = 2.0f * (XY + WZ); + Result.Elements[0][2] = 2.0f * (XZ - WY); + + Result.Elements[1][0] = 2.0f * (XY - WZ); + Result.Elements[1][1] = 1.0f - 2.0f * (XX + ZZ); + Result.Elements[1][2] = 2.0f * (YZ + WX); + + Result.Elements[2][0] = 2.0f * (XZ + WY); + Result.Elements[2][1] = 2.0f * (YZ - WX); + Result.Elements[2][2] = 1.0f - 2.0f * (XX + YY); + + return(Result); +} + +HINLINE hmm_quaternion +HMM_QuaternionFromAxisAngle(hmm_vec3 Axis, float AngleOfRotation) +{ + hmm_quaternion Result = {0}; + float AxisNorm = 0; + float SineOfRotation = 0; + hmm_vec3 RotatedVector; + + AxisNorm = HMM_SquareRootF(HMM_DotVec3(Axis, Axis)); + SineOfRotation = HMM_SinF(AngleOfRotation / 2.0f); + RotatedVector = HMM_MultiplyVec3f(Axis, SineOfRotation); + + Result.W = HMM_CosF(AngleOfRotation / 2.0f); + Result.XYZ = HMM_DivideVec3f(RotatedVector, AxisNorm); + + return(Result); +} + +// Extensions + +HINLINE hmm_mat4 +HMM_Mat4Identity() +{ + hmm_mat4 Result = {}; + + Result.Elements[0][0] = 1; + Result.Elements[0][1] = 0; + Result.Elements[0][2] = 0; + Result.Elements[0][3] = 0; + + Result.Elements[1][0] = 0; + Result.Elements[1][1] = 1; + Result.Elements[1][2] = 0; + Result.Elements[1][3] = 0; + + Result.Elements[2][0] = 0; + Result.Elements[2][1] = 0; + Result.Elements[2][2] = 1; + Result.Elements[2][3] = 0; + + Result.Elements[3][0] = 0; + Result.Elements[3][1] = 0; + Result.Elements[3][2] = 0; + Result.Elements[3][3] = 1; + + return Result; +} + +#define HMMToV2(v) (v2){ (v).X, (v).Y } +#define HMMToV3(v) (v3){ (v).X, (v).Y, (v).Z } +#define HMMToV4(v) (v4){ (v).X, (v).Y, (v).Z, (v).W } + +#define ToHMMV2(v) (hmm_vec2){ (v).x, (v).y } +#define ToHMMV3(v) (hmm_vec3){ (v).x, (v).y, (v).z } +#define ToHMMV4(v) (hmm_vec4){ (v).x, (v).y, (v).z, (v).w } + +HINLINE hmm_vec2 +HMM_LerpV2(hmm_vec2 A, float T, hmm_vec2 B) +{ + hmm_vec2 Result = {}; + Result.X = HMM_Lerp(A.X, T, B.X); + Result.Y = HMM_Lerp(A.Y, T, B.Y); + return Result; +} +HINLINE hmm_vec3 +HMM_LerpV3(hmm_vec3 A, float T, hmm_vec3 B) +{ + hmm_vec3 Result = {}; + Result.X = HMM_Lerp(A.X, T, B.X); + Result.Y = HMM_Lerp(A.Y, T, B.Y); + Result.Z = HMM_Lerp(A.Z, T, B.Z); + return Result; +} +HINLINE hmm_vec4 +HMM_LerpV4(hmm_vec4 A, float T, hmm_vec4 B) +{ + hmm_vec4 Result = {}; + Result.X = HMM_Lerp(A.X, T, B.X); + Result.Y = HMM_Lerp(A.Y, T, B.Y); + Result.Z = HMM_Lerp(A.Z, T, B.Z); + Result.W = HMM_Lerp(A.W, T, B.W); + return Result; +} + +// Range + +static bool +HMM_V2RContains(hmm_v2r Range, hmm_v2 P) +{ + return (Range.ValueMin.x <= P.x && + Range.ValueMin.y <= P.y && + Range.ValueMax.x >= P.x && + Range.ValueMax.y >= P.y); +} + +static hmm_v2 +HMM_V2RSize(hmm_v2r Range) +{ + hmm_v2 Result = {}; + Result.x = Range.ValueMax.x - Range.ValueMin.x; + Result.y = Range.ValueMax.y - Range.ValueMin.y; + return Result; +} + +#define HMM_V2RWidth(r) HMM_V2RSize(r).x +#define HMM_V2RHeight(r) HMM_V2RSize(r).y + +static hmm_v2r +HMM_V2ROffset(hmm_v2r Range, hmm_v2 Offset) +{ + hmm_v2r Result = {}; + Result.ValueMin = HMM_AddVec2(Range.ValueMin, Offset); + Result.ValueMax = HMM_AddVec2(Range.ValueMax, Offset); + return Result; +} + +// Geometry + +static hmm_vec3 +HMM_AverageVec3(hmm_vec3* Arr, int Len) +{ + hmm_vec3 Total = {}; + for (int i = 0; i < Len; i++) + { + Total = HMM_AddVec3(Total, Arr[i]); + } + + hmm_vec3 Result = {}; + Result.x = Total.x / Len; + Result.y = Total.y / Len; + Result.z = Total.z / Len; + + return Result; +} + +static hmm_vec4 +HMM_AverageVec4(hmm_vec4* Arr, int Len) +{ + hmm_vec4 Total = {}; + for (int i = 0; i < Len; i++) + { + Total = HMM_AddVec4(Total, Arr[i]); + } + + hmm_vec4 Result = {}; + Result.x = Total.x / Len; + Result.y = Total.y / Len; + Result.z = Total.z / Len; + Result.w = Total.w / Len; + return Result; +} + +// Point In Triangle From: https://blackpawn.com/texts/pointinpoly/default.html +static bool +HMM_SameSide(hmm_vec3 P1, hmm_vec3 P2, hmm_vec3 A, hmm_vec3 B) +{ + hmm_vec3 BA = HMM_SubtractVec3(B, A); + hmm_vec3 P1A = HMM_SubtractVec3(P1, A); + hmm_vec3 P2A = HMM_SubtractVec3(P2, A); + hmm_vec3 CP1 = HMM_Cross(BA, P1A); + hmm_vec3 CP2 = HMM_Cross(BA, P2A); + return (HMM_DotVec3(CP1, CP2) >= 0); +} + +static bool +HMM_PointInTriangle(hmm_vec3 P, hmm_vec3 T0, hmm_vec3 T1, hmm_vec3 T2) +{ + return (HMM_SameSide(P, T0, T1, T2) && + HMM_SameSide(P, T1, T0, T2) && + HMM_SameSide(P, T2, T0, T1)); +} + +#ifdef HANDMADE_MATH_CPP_MODE + +HINLINE float +HMM_Length(hmm_vec2 A) +{ + float Result = 0.0f; + + Result = HMM_LengthVec2(A); + + return(Result); +} + +HINLINE float +HMM_Length(hmm_vec3 A) +{ + float Result = 0.0f; + + Result = HMM_LengthVec3(A); + + return(Result); +} + +HINLINE float +HMM_Length(hmm_vec4 A) +{ + float Result = 0.0f; + + Result = HMM_LengthVec4(A); + + return(Result); +} + +HINLINE float +HMM_LengthSquared(hmm_vec2 A) +{ + float Result = 0.0f; + + Result = HMM_LengthSquaredVec2(A); + + return(Result); +} + +HINLINE float +HMM_LengthSquared(hmm_vec3 A) +{ + float Result = 0.0f; + + Result = HMM_LengthSquaredVec3(A); + + return(Result); +} + +HINLINE float +HMM_LengthSquared(hmm_vec4 A) +{ + float Result = 0.0f; + + Result = HMM_LengthSquaredVec4(A); + + return(Result); +} + +HINLINE hmm_vec2 +HMM_Normalize(hmm_vec2 A) +{ + hmm_vec2 Result = {0}; + + Result = HMM_NormalizeVec2(A); + + return(Result); +} + +HINLINE hmm_vec3 +HMM_Normalize(hmm_vec3 A) +{ + hmm_vec3 Result = {0}; + + Result = HMM_NormalizeVec3(A); + + return(Result); +} + +HINLINE hmm_vec4 +HMM_Normalize(hmm_vec4 A) +{ + hmm_vec4 Result = {0}; + + Result = HMM_NormalizeVec4(A); + + return(Result); +} + +HINLINE hmm_quaternion +HMM_Normalize(hmm_quaternion A) +{ + hmm_quaternion Result = {0}; + + Result = HMM_NormalizeQuaternion(A); + + return(Result); +} + +HINLINE float +HMM_Dot(hmm_vec2 VecOne, hmm_vec2 VecTwo) +{ + float Result = 0; + + Result = HMM_DotVec2(VecOne, VecTwo); + + return(Result); +} + +HINLINE float +HMM_Dot(hmm_vec3 VecOne, hmm_vec3 VecTwo) +{ + float Result = 0; + + Result = HMM_DotVec3(VecOne, VecTwo); + + return(Result); +} + +HINLINE float +HMM_Dot(hmm_vec4 VecOne, hmm_vec4 VecTwo) +{ + float Result = 0; + + Result = HMM_DotVec4(VecOne, VecTwo); + + return(Result); +} + +HINLINE float +HMM_Dot(hmm_quaternion QuatOne, hmm_quaternion QuatTwo) +{ + float Result = 0; + + Result = HMM_DotQuaternion(QuatOne, QuatTwo); + + return(Result); +} + +HINLINE hmm_vec2 +HMM_Add(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_AddVec2(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +HMM_Add(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_AddVec3(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +HMM_Add(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_AddVec4(Left, Right); + return (Result); +} + +HINLINE hmm_mat4 +HMM_Add(hmm_mat4 Left, hmm_mat4 Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_AddMat4(Left, Right); + return (Result); +} + +HINLINE hmm_quaternion +HMM_Add(hmm_quaternion Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_AddQuaternion(Left, Right); + return(Result); +} + +HINLINE hmm_vec2 +HMM_Subtract(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_SubtractVec2(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +HMM_Subtract(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_SubtractVec3(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +HMM_Subtract(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_SubtractVec4(Left, Right); + return (Result); +} + +HINLINE hmm_mat4 +HMM_Subtract(hmm_mat4 Left, hmm_mat4 Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_SubtractMat4(Left, Right); + return (Result); +} + +HINLINE hmm_quaternion +HMM_Subtract(hmm_quaternion Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_SubtractQuaternion(Left, Right); + return (Result); +} + +HINLINE hmm_vec2 +HMM_Multiply(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_MultiplyVec2(Left, Right); + return (Result); +} + +HINLINE hmm_vec2 +HMM_Multiply(hmm_vec2 Left, float Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_MultiplyVec2f(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +HMM_Multiply(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_MultiplyVec3(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +HMM_Multiply(hmm_vec3 Left, float Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_MultiplyVec3f(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +HMM_Multiply(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_MultiplyVec4(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +HMM_Multiply(hmm_vec4 Left, float Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_MultiplyVec4f(Left, Right); + return (Result); +} + +HINLINE hmm_mat4 +HMM_Multiply(hmm_mat4 Left, hmm_mat4 Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_MultiplyMat4(Left, Right); + return (Result); +} + +HINLINE hmm_mat4 +HMM_Multiply(hmm_mat4 Left, float Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_MultiplyMat4f(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +HMM_Multiply(hmm_mat4 Matrix, hmm_vec4 Vector) +{ + hmm_vec4 Result = {0}; + + Result = HMM_MultiplyMat4ByVec4(Matrix, Vector); + return (Result); +} + +HINLINE hmm_quaternion +HMM_Multiply(hmm_quaternion Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_MultiplyQuaternion(Left, Right); + return (Result); +} + +HINLINE hmm_quaternion +HMM_Multiply(hmm_quaternion Left, float Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_MultiplyQuaternionF(Left, Right); + return (Result); +} + +HINLINE hmm_quaternion +HMM_Multiply(float Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_MultiplyQuaternionF(Right, Left); + return (Result); +} + +HINLINE hmm_vec2 +HMM_Divide(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_DivideVec2(Left, Right); + return (Result); +} + +HINLINE hmm_vec2 +HMM_Divide(hmm_vec2 Left, float Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_DivideVec2f(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +HMM_Divide(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_DivideVec3(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +HMM_Divide(hmm_vec3 Left, float Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_DivideVec3f(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +HMM_Divide(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_DivideVec4(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +HMM_Divide(hmm_vec4 Left, float Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_DivideVec4f(Left, Right); + return (Result); +} + +HINLINE hmm_mat4 +HMM_Divide(hmm_mat4 Left, float Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_DivideMat4f(Left, Right); + return (Result); +} + +HINLINE hmm_quaternion +HMM_Divide(hmm_quaternion Left, float Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_DivideQuaternionF(Left, Right); + return (Result); +} + +HINLINE hmm_bool +HMM_Equals(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_bool Result = 0; + + Result = HMM_EqualsVec2(Left, Right); + return (Result); +} + +HINLINE hmm_bool +HMM_Equals(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_bool Result = 0; + + Result = HMM_EqualsVec3(Left, Right); + return (Result); +} + +HINLINE hmm_bool +HMM_Equals(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_bool Result = 0; + + Result = HMM_EqualsVec4(Left, Right); + return (Result); +} + +HINLINE hmm_vec2 +operator+(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_Add(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +operator+(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_Add(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +operator+(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_Add(Left, Right); + return (Result); +} + +HINLINE hmm_mat4 +operator+(hmm_mat4 Left, hmm_mat4 Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_Add(Left, Right); + return (Result); +} + +HINLINE hmm_quaternion +operator+(hmm_quaternion Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_Add(Left, Right); + return (Result); +} + +HINLINE hmm_vec2 +operator-(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_Subtract(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +operator-(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_Subtract(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +operator-(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_Subtract(Left, Right); + return (Result); +} + +HINLINE hmm_mat4 +operator-(hmm_mat4 Left, hmm_mat4 Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_Subtract(Left, Right); + return (Result); +} + +HINLINE hmm_quaternion +operator-(hmm_quaternion Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_Subtract(Left, Right); + return (Result); +} + +HINLINE hmm_vec2 +operator*(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_Multiply(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +operator*(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_Multiply(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +operator*(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = HMM_Multiply(Left, Right); + + return (Result); +} + +HINLINE hmm_vec2 +operator*(hmm_vec2 Left, float Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_Multiply(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +operator*(hmm_vec3 Left, float Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_Multiply(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +operator*(hmm_vec4 Left, float Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_Multiply(Left, Right); + return (Result); +} + +HINLINE hmm_mat4 +operator*(hmm_mat4 Left, float Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_Multiply(Left, Right); + return (Result); +} + +HINLINE hmm_vec2 +operator*(float Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_Multiply(Right, Left); + return (Result); +} + +HINLINE hmm_vec3 +operator*(float Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_Multiply(Right, Left); + return (Result); +} + +HINLINE hmm_vec4 +operator*(float Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_Multiply(Right, Left); + return (Result); +} + +HINLINE hmm_mat4 +operator*(float Left, hmm_mat4 Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_Multiply(Right, Left); + return (Result); +} + +HINLINE hmm_mat4 +operator*(hmm_mat4 Left, hmm_mat4 Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_Multiply(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +operator*(hmm_mat4 Matrix, hmm_vec4 Vector) +{ + hmm_vec4 Result = {0}; + + Result = HMM_Multiply(Matrix, Vector); + return (Result); +} + +HINLINE hmm_quaternion +operator*(hmm_quaternion Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_Multiply(Left, Right); + return (Result); +} + +HINLINE hmm_quaternion +operator*(hmm_quaternion Left, float Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_Multiply(Left, Right); + return (Result); +} + +HINLINE hmm_quaternion +operator*(float Left, hmm_quaternion Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_Multiply(Right, Left); + return (Result); +} + +HINLINE hmm_vec2 +operator/(hmm_vec2 Left, hmm_vec2 Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_Divide(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +operator/(hmm_vec3 Left, hmm_vec3 Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_Divide(Left, Right); + + return (Result); +} + +HINLINE hmm_vec4 +operator/(hmm_vec4 Left, hmm_vec4 Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_Divide(Left, Right); + return (Result); +} + +HINLINE hmm_vec2 +operator/(hmm_vec2 Left, float Right) +{ + hmm_vec2 Result = {0}; + + Result = HMM_Divide(Left, Right); + return (Result); +} + +HINLINE hmm_vec3 +operator/(hmm_vec3 Left, float Right) +{ + hmm_vec3 Result = {0}; + + Result = HMM_Divide(Left, Right); + return (Result); +} + +HINLINE hmm_vec4 +operator/(hmm_vec4 Left, float Right) +{ + hmm_vec4 Result = {0}; + + Result = HMM_Divide(Left, Right); + return (Result); +} + +HINLINE hmm_mat4 +operator/(hmm_mat4 Left, float Right) +{ + hmm_mat4 Result = {0}; + + Result = HMM_Divide(Left, Right); + return (Result); +} + +HINLINE hmm_quaternion +operator/(hmm_quaternion Left, float Right) +{ + hmm_quaternion Result = {0}; + + Result = HMM_Divide(Left, Right); + return (Result); +} + +HINLINE hmm_vec2 & +operator+=(hmm_vec2 &Left, hmm_vec2 Right) +{ + return (Left = Left + Right); +} + +HINLINE hmm_vec3 & +operator+=(hmm_vec3 &Left, hmm_vec3 Right) +{ + return (Left = Left + Right); +} + +HINLINE hmm_vec4 & +operator+=(hmm_vec4 &Left, hmm_vec4 Right) +{ + return (Left = Left + Right); +} + +HINLINE hmm_mat4 & +operator+=(hmm_mat4 &Left, hmm_mat4 Right) +{ + return (Left = Left + Right); +} + +HINLINE hmm_quaternion & +operator+=(hmm_quaternion &Left, hmm_quaternion Right) +{ + return (Left = Left + Right); +} + +HINLINE hmm_vec2 & +operator-=(hmm_vec2 &Left, hmm_vec2 Right) +{ + return (Left = Left - Right); +} + +HINLINE hmm_vec3 & +operator-=(hmm_vec3 &Left, hmm_vec3 Right) +{ + return (Left = Left - Right); +} + +HINLINE hmm_vec4 & +operator-=(hmm_vec4 &Left, hmm_vec4 Right) +{ + return (Left = Left - Right); +} + +HINLINE hmm_mat4 & +operator-=(hmm_mat4 &Left, hmm_mat4 Right) +{ + return (Left = Left - Right); +} + +HINLINE hmm_quaternion & +operator-=(hmm_quaternion &Left, hmm_quaternion Right) +{ + return (Left = Left - Right); +} + +HINLINE hmm_vec2 & +operator/=(hmm_vec2 &Left, hmm_vec2 Right) +{ + return (Left = Left / Right); +} + +HINLINE hmm_vec3 & +operator/=(hmm_vec3 &Left, hmm_vec3 Right) +{ + return (Left = Left / Right); +} + +HINLINE hmm_vec4 & +operator/=(hmm_vec4 &Left, hmm_vec4 Right) +{ + return (Left = Left / Right); +} + +HINLINE hmm_vec2 & +operator/=(hmm_vec2 &Left, float Right) +{ + return (Left = Left / Right); +} + +HINLINE hmm_vec3 & +operator/=(hmm_vec3 &Left, float Right) +{ + return (Left = Left / Right); +} + +HINLINE hmm_vec4 & +operator/=(hmm_vec4 &Left, float Right) +{ + return (Left = Left / Right); +} + +HINLINE hmm_mat4 & +operator/=(hmm_mat4 &Left, float Right) +{ + return (Left = Left / Right); +} + +HINLINE hmm_quaternion & +operator/=(hmm_quaternion &Left, float Right) +{ + return (Left = Left / Right); +} + +HINLINE hmm_vec2 & +operator*=(hmm_vec2 &Left, hmm_vec2 Right) +{ + return (Left = Left * Right); +} + +HINLINE hmm_vec3 & +operator*=(hmm_vec3 &Left, hmm_vec3 Right) +{ + return (Left = Left * Right); +} + +HINLINE hmm_vec4 & +operator*=(hmm_vec4 &Left, hmm_vec4 Right) +{ + return (Left = Left * Right); +} + +HINLINE hmm_vec2 & +operator*=(hmm_vec2 &Left, float Right) +{ + return (Left = Left * Right); +} + +HINLINE hmm_vec3 & +operator*=(hmm_vec3 &Left, float Right) +{ + return (Left = Left * Right); +} + +HINLINE hmm_vec4 & +operator*=(hmm_vec4 &Left, float Right) +{ + return (Left = Left * Right); +} + +HINLINE hmm_mat4 & +operator*=(hmm_mat4 &Left, float Right) +{ + return (Left = Left * Right); +} + +HINLINE hmm_quaternion & +operator*=(hmm_quaternion &Left, float Right) +{ + return (Left = Left * Right); +} + +HINLINE hmm_bool +operator==(hmm_vec2 Left, hmm_vec2 Right) +{ + return HMM_EqualsVec2(Left, Right); +} + +HINLINE hmm_bool +operator==(hmm_vec3 Left, hmm_vec3 Right) +{ + return HMM_EqualsVec3(Left, Right); +} + +HINLINE hmm_bool +operator==(hmm_vec4 Left, hmm_vec4 Right) +{ + return HMM_EqualsVec4(Left, Right); +} + + +HINLINE hmm_bool +operator!=(hmm_vec2 Left, hmm_vec2 Right) +{ + return !HMM_EqualsVec2(Left, Right); +} + +HINLINE hmm_bool +operator!=(hmm_vec3 Left, hmm_vec3 Right) +{ + return !HMM_EqualsVec3(Left, Right); +} + +HINLINE hmm_bool +operator!=(hmm_vec4 Left, hmm_vec4 Right) +{ + return !HMM_EqualsVec4(Left, Right); +} + +#endif /* HANDMADE_MATH_CPP_MODE */ + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#endif /* HANDMADE_MATH_IMPLEMENTATION */ diff --git a/src_v2/libs/glfw_osx/include/GLFW/glfw3.h b/src_v2/libs/glfw_osx/include/GLFW/glfw3.h new file mode 100644 index 0000000..d074de1 --- /dev/null +++ b/src_v2/libs/glfw_osx/include/GLFW/glfw3.h @@ -0,0 +1,5913 @@ +/************************************************************************* + * GLFW 3.3 - www.glfw.org + * A library for OpenGL, window and input + *------------------------------------------------------------------------ + * Copyright (c) 2002-2006 Marcus Geelnard + * Copyright (c) 2006-2019 Camilla Löwy + * + * 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_h_ +#define _glfw3_h_ + +#ifdef __cplusplus +extern "C" { +#endif + + +/************************************************************************* + * Doxygen documentation + *************************************************************************/ + +/*! @file glfw3.h + * @brief The header of the GLFW 3 API. + * + * This is the header file of the GLFW 3 API. It defines all its types and + * declares all its functions. + * + * For more information about how to use this file, see @ref build_include. + */ +/*! @defgroup context Context reference + * @brief Functions and types related to OpenGL and OpenGL ES contexts. + * + * This is the reference documentation for OpenGL and OpenGL ES context related + * functions. For more task-oriented information, see the @ref context_guide. + */ +/*! @defgroup vulkan Vulkan support reference + * @brief Functions and types related to Vulkan. + * + * This is the reference documentation for Vulkan related functions and types. + * For more task-oriented information, see the @ref vulkan_guide. + */ +/*! @defgroup init Initialization, version and error reference + * @brief Functions and types related to initialization and error handling. + * + * This is the reference documentation for initialization and termination of + * the library, version management and error handling. For more task-oriented + * information, see the @ref intro_guide. + */ +/*! @defgroup input Input reference + * @brief Functions and types related to input handling. + * + * This is the reference documentation for input related functions and types. + * For more task-oriented information, see the @ref input_guide. + */ +/*! @defgroup monitor Monitor reference + * @brief Functions and types related to monitors. + * + * This is the reference documentation for monitor related functions and types. + * For more task-oriented information, see the @ref monitor_guide. + */ +/*! @defgroup window Window reference + * @brief Functions and types related to windows. + * + * This is the reference documentation for window related functions and types, + * including creation, deletion and event polling. For more task-oriented + * information, see the @ref window_guide. + */ + + +/************************************************************************* + * Compiler- and platform-specific preprocessor work + *************************************************************************/ + +/* If we are we on Windows, we want a single define for it. + */ +#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)) + #define _WIN32 +#endif /* _WIN32 */ + +/* Include because most Windows GLU headers need wchar_t and + * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h. + * Include it unconditionally to avoid surprising side-effects. + */ +#include + +/* Include because it is needed by Vulkan and related functions. + * Include it unconditionally to avoid surprising side-effects. + */ +#include + +#if defined(GLFW_INCLUDE_VULKAN) + #include +#endif /* Vulkan header */ + +/* The Vulkan header may have indirectly included windows.h (because of + * VK_USE_PLATFORM_WIN32_KHR) so we offer our replacement symbols after it. + */ + +/* It is customary to use APIENTRY for OpenGL function pointer declarations on + * all platforms. Additionally, the Windows OpenGL header needs APIENTRY. + */ +#if !defined(APIENTRY) + #if defined(_WIN32) + #define APIENTRY __stdcall + #else + #define APIENTRY + #endif + #define GLFW_APIENTRY_DEFINED +#endif /* APIENTRY */ + +/* Some Windows OpenGL headers need this. + */ +#if !defined(WINGDIAPI) && defined(_WIN32) + #define WINGDIAPI __declspec(dllimport) + #define GLFW_WINGDIAPI_DEFINED +#endif /* WINGDIAPI */ + +/* Some Windows GLU headers need this. + */ +#if !defined(CALLBACK) && defined(_WIN32) + #define CALLBACK __stdcall + #define GLFW_CALLBACK_DEFINED +#endif /* CALLBACK */ + +/* Include the chosen OpenGL or OpenGL ES headers. + */ +#if defined(GLFW_INCLUDE_ES1) + + #include + #if defined(GLFW_INCLUDE_GLEXT) + #include + #endif + +#elif defined(GLFW_INCLUDE_ES2) + + #include + #if defined(GLFW_INCLUDE_GLEXT) + #include + #endif + +#elif defined(GLFW_INCLUDE_ES3) + + #include + #if defined(GLFW_INCLUDE_GLEXT) + #include + #endif + +#elif defined(GLFW_INCLUDE_ES31) + + #include + #if defined(GLFW_INCLUDE_GLEXT) + #include + #endif + +#elif defined(GLFW_INCLUDE_ES32) + + #include + #if defined(GLFW_INCLUDE_GLEXT) + #include + #endif + +#elif defined(GLFW_INCLUDE_GLCOREARB) + + #if defined(__APPLE__) + + #include + #if defined(GLFW_INCLUDE_GLEXT) + #include + #endif /*GLFW_INCLUDE_GLEXT*/ + + #else /*__APPLE__*/ + + #include + #if defined(GLFW_INCLUDE_GLEXT) + #include + #endif + + #endif /*__APPLE__*/ + +#elif defined(GLFW_INCLUDE_GLU) + + #if defined(__APPLE__) + + #if defined(GLFW_INCLUDE_GLU) + #include + #endif + + #else /*__APPLE__*/ + + #if defined(GLFW_INCLUDE_GLU) + #include + #endif + + #endif /*__APPLE__*/ + +#elif !defined(GLFW_INCLUDE_NONE) && \ + !defined(__gl_h_) && \ + !defined(__gles1_gl_h_) && \ + !defined(__gles2_gl2_h_) && \ + !defined(__gles2_gl3_h_) && \ + !defined(__gles2_gl31_h_) && \ + !defined(__gles2_gl32_h_) && \ + !defined(__gl_glcorearb_h_) && \ + !defined(__gl2_h_) /*legacy*/ && \ + !defined(__gl3_h_) /*legacy*/ && \ + !defined(__gl31_h_) /*legacy*/ && \ + !defined(__gl32_h_) /*legacy*/ && \ + !defined(__glcorearb_h_) /*legacy*/ && \ + !defined(__GL_H__) /*non-standard*/ && \ + !defined(__gltypes_h_) /*non-standard*/ && \ + !defined(__glee_h_) /*non-standard*/ + + #if defined(__APPLE__) + + #if !defined(GLFW_INCLUDE_GLEXT) + #define GL_GLEXT_LEGACY + #endif + #include + + #else /*__APPLE__*/ + + #include + #if defined(GLFW_INCLUDE_GLEXT) + #include + #endif + + #endif /*__APPLE__*/ + +#endif /* OpenGL and OpenGL ES headers */ + +#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL) + /* GLFW_DLL must be defined by applications that are linking against the DLL + * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW + * configuration header when compiling the DLL version of the library. + */ + #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined" +#endif + +/* GLFWAPI is used to declare public API functions for export + * from the DLL / shared library / dynamic library. + */ +#if defined(_WIN32) && defined(_GLFW_BUILD_DLL) + /* We are building GLFW as a Win32 DLL */ + #define GLFWAPI __declspec(dllexport) +#elif defined(_WIN32) && defined(GLFW_DLL) + /* We are calling GLFW as a Win32 DLL */ + #define GLFWAPI __declspec(dllimport) +#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL) + /* We are building GLFW as a shared / dynamic library */ + #define GLFWAPI __attribute__((visibility("default"))) +#else + /* We are building or calling GLFW as a static library */ + #define GLFWAPI +#endif + + +/************************************************************************* + * GLFW API tokens + *************************************************************************/ + +/*! @name GLFW version macros + * @{ */ +/*! @brief The major version number of the GLFW header. + * + * The major version number of the GLFW header. This is incremented when the + * API is changed in non-compatible ways. + * @ingroup init + */ +#define GLFW_VERSION_MAJOR 3 +/*! @brief The minor version number of the GLFW header. + * + * The minor version number of the GLFW header. This is incremented when + * features are added to the API but it remains backward-compatible. + * @ingroup init + */ +#define GLFW_VERSION_MINOR 3 +/*! @brief The revision number of the GLFW header. + * + * The revision number of the GLFW header. This is incremented when a bug fix + * release is made that does not contain any API changes. + * @ingroup init + */ +#define GLFW_VERSION_REVISION 7 +/*! @} */ + +/*! @brief One. + * + * This is only semantic sugar for the number 1. You can instead use `1` or + * `true` or `_True` or `GL_TRUE` or `VK_TRUE` or anything else that is equal + * to one. + * + * @ingroup init + */ +#define GLFW_TRUE 1 +/*! @brief Zero. + * + * This is only semantic sugar for the number 0. You can instead use `0` or + * `false` or `_False` or `GL_FALSE` or `VK_FALSE` or anything else that is + * equal to zero. + * + * @ingroup init + */ +#define GLFW_FALSE 0 + +/*! @name Key and button actions + * @{ */ +/*! @brief The key or mouse button was released. + * + * The key or mouse button was released. + * + * @ingroup input + */ +#define GLFW_RELEASE 0 +/*! @brief The key or mouse button was pressed. + * + * The key or mouse button was pressed. + * + * @ingroup input + */ +#define GLFW_PRESS 1 +/*! @brief The key was held down until it repeated. + * + * The key was held down until it repeated. + * + * @ingroup input + */ +#define GLFW_REPEAT 2 +/*! @} */ + +/*! @defgroup hat_state Joystick hat states + * @brief Joystick hat states. + * + * See [joystick hat input](@ref joystick_hat) for how these are used. + * + * @ingroup input + * @{ */ +#define GLFW_HAT_CENTERED 0 +#define GLFW_HAT_UP 1 +#define GLFW_HAT_RIGHT 2 +#define GLFW_HAT_DOWN 4 +#define GLFW_HAT_LEFT 8 +#define GLFW_HAT_RIGHT_UP (GLFW_HAT_RIGHT | GLFW_HAT_UP) +#define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN) +#define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP) +#define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN) +/*! @} */ + +/*! @defgroup keys Keyboard keys + * @brief Keyboard key IDs. + * + * See [key input](@ref input_key) for how these are used. + * + * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60), + * but re-arranged to map to 7-bit ASCII for printable keys (function keys are + * put in the 256+ range). + * + * The naming of the key codes follow these rules: + * - The US keyboard layout is used + * - Names of printable alpha-numeric characters are used (e.g. "A", "R", + * "3", etc.) + * - For non-alphanumeric characters, Unicode:ish names are used (e.g. + * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not + * correspond to the Unicode standard (usually for brevity) + * - Keys that lack a clear US mapping are named "WORLD_x" + * - For non-printable keys, custom names are used (e.g. "F4", + * "BACKSPACE", etc.) + * + * @ingroup input + * @{ + */ + +/* The unknown key */ +#define GLFW_KEY_UNKNOWN -1 + +/* Printable keys */ +#define GLFW_KEY_SPACE 32 +#define GLFW_KEY_APOSTROPHE 39 /* ' */ +#define GLFW_KEY_COMMA 44 /* , */ +#define GLFW_KEY_MINUS 45 /* - */ +#define GLFW_KEY_PERIOD 46 /* . */ +#define GLFW_KEY_SLASH 47 /* / */ +#define GLFW_KEY_0 48 +#define GLFW_KEY_1 49 +#define GLFW_KEY_2 50 +#define GLFW_KEY_3 51 +#define GLFW_KEY_4 52 +#define GLFW_KEY_5 53 +#define GLFW_KEY_6 54 +#define GLFW_KEY_7 55 +#define GLFW_KEY_8 56 +#define GLFW_KEY_9 57 +#define GLFW_KEY_SEMICOLON 59 /* ; */ +#define GLFW_KEY_EQUAL 61 /* = */ +#define GLFW_KEY_A 65 +#define GLFW_KEY_B 66 +#define GLFW_KEY_C 67 +#define GLFW_KEY_D 68 +#define GLFW_KEY_E 69 +#define GLFW_KEY_F 70 +#define GLFW_KEY_G 71 +#define GLFW_KEY_H 72 +#define GLFW_KEY_I 73 +#define GLFW_KEY_J 74 +#define GLFW_KEY_K 75 +#define GLFW_KEY_L 76 +#define GLFW_KEY_M 77 +#define GLFW_KEY_N 78 +#define GLFW_KEY_O 79 +#define GLFW_KEY_P 80 +#define GLFW_KEY_Q 81 +#define GLFW_KEY_R 82 +#define GLFW_KEY_S 83 +#define GLFW_KEY_T 84 +#define GLFW_KEY_U 85 +#define GLFW_KEY_V 86 +#define GLFW_KEY_W 87 +#define GLFW_KEY_X 88 +#define GLFW_KEY_Y 89 +#define GLFW_KEY_Z 90 +#define GLFW_KEY_LEFT_BRACKET 91 /* [ */ +#define GLFW_KEY_BACKSLASH 92 /* \ */ +#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */ +#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */ +#define GLFW_KEY_WORLD_1 161 /* non-US #1 */ +#define GLFW_KEY_WORLD_2 162 /* non-US #2 */ + +/* Function keys */ +#define GLFW_KEY_ESCAPE 256 +#define GLFW_KEY_ENTER 257 +#define GLFW_KEY_TAB 258 +#define GLFW_KEY_BACKSPACE 259 +#define GLFW_KEY_INSERT 260 +#define GLFW_KEY_DELETE 261 +#define GLFW_KEY_RIGHT 262 +#define GLFW_KEY_LEFT 263 +#define GLFW_KEY_DOWN 264 +#define GLFW_KEY_UP 265 +#define GLFW_KEY_PAGE_UP 266 +#define GLFW_KEY_PAGE_DOWN 267 +#define GLFW_KEY_HOME 268 +#define GLFW_KEY_END 269 +#define GLFW_KEY_CAPS_LOCK 280 +#define GLFW_KEY_SCROLL_LOCK 281 +#define GLFW_KEY_NUM_LOCK 282 +#define GLFW_KEY_PRINT_SCREEN 283 +#define GLFW_KEY_PAUSE 284 +#define GLFW_KEY_F1 290 +#define GLFW_KEY_F2 291 +#define GLFW_KEY_F3 292 +#define GLFW_KEY_F4 293 +#define GLFW_KEY_F5 294 +#define GLFW_KEY_F6 295 +#define GLFW_KEY_F7 296 +#define GLFW_KEY_F8 297 +#define GLFW_KEY_F9 298 +#define GLFW_KEY_F10 299 +#define GLFW_KEY_F11 300 +#define GLFW_KEY_F12 301 +#define GLFW_KEY_F13 302 +#define GLFW_KEY_F14 303 +#define GLFW_KEY_F15 304 +#define GLFW_KEY_F16 305 +#define GLFW_KEY_F17 306 +#define GLFW_KEY_F18 307 +#define GLFW_KEY_F19 308 +#define GLFW_KEY_F20 309 +#define GLFW_KEY_F21 310 +#define GLFW_KEY_F22 311 +#define GLFW_KEY_F23 312 +#define GLFW_KEY_F24 313 +#define GLFW_KEY_F25 314 +#define GLFW_KEY_KP_0 320 +#define GLFW_KEY_KP_1 321 +#define GLFW_KEY_KP_2 322 +#define GLFW_KEY_KP_3 323 +#define GLFW_KEY_KP_4 324 +#define GLFW_KEY_KP_5 325 +#define GLFW_KEY_KP_6 326 +#define GLFW_KEY_KP_7 327 +#define GLFW_KEY_KP_8 328 +#define GLFW_KEY_KP_9 329 +#define GLFW_KEY_KP_DECIMAL 330 +#define GLFW_KEY_KP_DIVIDE 331 +#define GLFW_KEY_KP_MULTIPLY 332 +#define GLFW_KEY_KP_SUBTRACT 333 +#define GLFW_KEY_KP_ADD 334 +#define GLFW_KEY_KP_ENTER 335 +#define GLFW_KEY_KP_EQUAL 336 +#define GLFW_KEY_LEFT_SHIFT 340 +#define GLFW_KEY_LEFT_CONTROL 341 +#define GLFW_KEY_LEFT_ALT 342 +#define GLFW_KEY_LEFT_SUPER 343 +#define GLFW_KEY_RIGHT_SHIFT 344 +#define GLFW_KEY_RIGHT_CONTROL 345 +#define GLFW_KEY_RIGHT_ALT 346 +#define GLFW_KEY_RIGHT_SUPER 347 +#define GLFW_KEY_MENU 348 + +#define GLFW_KEY_LAST GLFW_KEY_MENU + +/*! @} */ + +/*! @defgroup mods Modifier key flags + * @brief Modifier key flags. + * + * See [key input](@ref input_key) for how these are used. + * + * @ingroup input + * @{ */ + +/*! @brief If this bit is set one or more Shift keys were held down. + * + * If this bit is set one or more Shift keys were held down. + */ +#define GLFW_MOD_SHIFT 0x0001 +/*! @brief If this bit is set one or more Control keys were held down. + * + * If this bit is set one or more Control keys were held down. + */ +#define GLFW_MOD_CONTROL 0x0002 +/*! @brief If this bit is set one or more Alt keys were held down. + * + * If this bit is set one or more Alt keys were held down. + */ +#define GLFW_MOD_ALT 0x0004 +/*! @brief If this bit is set one or more Super keys were held down. + * + * If this bit is set one or more Super keys were held down. + */ +#define GLFW_MOD_SUPER 0x0008 +/*! @brief If this bit is set the Caps Lock key is enabled. + * + * If this bit is set the Caps Lock key is enabled and the @ref + * GLFW_LOCK_KEY_MODS input mode is set. + */ +#define GLFW_MOD_CAPS_LOCK 0x0010 +/*! @brief If this bit is set the Num Lock key is enabled. + * + * If this bit is set the Num Lock key is enabled and the @ref + * GLFW_LOCK_KEY_MODS input mode is set. + */ +#define GLFW_MOD_NUM_LOCK 0x0020 + +/*! @} */ + +/*! @defgroup buttons Mouse buttons + * @brief Mouse button IDs. + * + * See [mouse button input](@ref input_mouse_button) for how these are used. + * + * @ingroup input + * @{ */ +#define GLFW_MOUSE_BUTTON_1 0 +#define GLFW_MOUSE_BUTTON_2 1 +#define GLFW_MOUSE_BUTTON_3 2 +#define GLFW_MOUSE_BUTTON_4 3 +#define GLFW_MOUSE_BUTTON_5 4 +#define GLFW_MOUSE_BUTTON_6 5 +#define GLFW_MOUSE_BUTTON_7 6 +#define GLFW_MOUSE_BUTTON_8 7 +#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8 +#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1 +#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2 +#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3 +/*! @} */ + +/*! @defgroup joysticks Joysticks + * @brief Joystick IDs. + * + * See [joystick input](@ref joystick) for how these are used. + * + * @ingroup input + * @{ */ +#define GLFW_JOYSTICK_1 0 +#define GLFW_JOYSTICK_2 1 +#define GLFW_JOYSTICK_3 2 +#define GLFW_JOYSTICK_4 3 +#define GLFW_JOYSTICK_5 4 +#define GLFW_JOYSTICK_6 5 +#define GLFW_JOYSTICK_7 6 +#define GLFW_JOYSTICK_8 7 +#define GLFW_JOYSTICK_9 8 +#define GLFW_JOYSTICK_10 9 +#define GLFW_JOYSTICK_11 10 +#define GLFW_JOYSTICK_12 11 +#define GLFW_JOYSTICK_13 12 +#define GLFW_JOYSTICK_14 13 +#define GLFW_JOYSTICK_15 14 +#define GLFW_JOYSTICK_16 15 +#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16 +/*! @} */ + +/*! @defgroup gamepad_buttons Gamepad buttons + * @brief Gamepad buttons. + * + * See @ref gamepad for how these are used. + * + * @ingroup input + * @{ */ +#define GLFW_GAMEPAD_BUTTON_A 0 +#define GLFW_GAMEPAD_BUTTON_B 1 +#define GLFW_GAMEPAD_BUTTON_X 2 +#define GLFW_GAMEPAD_BUTTON_Y 3 +#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4 +#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5 +#define GLFW_GAMEPAD_BUTTON_BACK 6 +#define GLFW_GAMEPAD_BUTTON_START 7 +#define GLFW_GAMEPAD_BUTTON_GUIDE 8 +#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9 +#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10 +#define GLFW_GAMEPAD_BUTTON_DPAD_UP 11 +#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12 +#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13 +#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14 +#define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT + +#define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A +#define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B +#define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X +#define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y +/*! @} */ + +/*! @defgroup gamepad_axes Gamepad axes + * @brief Gamepad axes. + * + * See @ref gamepad for how these are used. + * + * @ingroup input + * @{ */ +#define GLFW_GAMEPAD_AXIS_LEFT_X 0 +#define GLFW_GAMEPAD_AXIS_LEFT_Y 1 +#define GLFW_GAMEPAD_AXIS_RIGHT_X 2 +#define GLFW_GAMEPAD_AXIS_RIGHT_Y 3 +#define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4 +#define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5 +#define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER +/*! @} */ + +/*! @defgroup errors Error codes + * @brief Error codes. + * + * See [error handling](@ref error_handling) for how these are used. + * + * @ingroup init + * @{ */ +/*! @brief No error has occurred. + * + * No error has occurred. + * + * @analysis Yay. + */ +#define GLFW_NO_ERROR 0 +/*! @brief GLFW has not been initialized. + * + * This occurs if a GLFW function was called that must not be called unless the + * library is [initialized](@ref intro_init). + * + * @analysis Application programmer error. Initialize GLFW before calling any + * function that requires initialization. + */ +#define GLFW_NOT_INITIALIZED 0x00010001 +/*! @brief No context is current for this thread. + * + * This occurs if a GLFW function was called that needs and operates on the + * current OpenGL or OpenGL ES context but no context is current on the calling + * thread. One such function is @ref glfwSwapInterval. + * + * @analysis Application programmer error. Ensure a context is current before + * calling functions that require a current context. + */ +#define GLFW_NO_CURRENT_CONTEXT 0x00010002 +/*! @brief One of the arguments to the function was an invalid enum value. + * + * One of the arguments to the function was an invalid enum value, for example + * requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib. + * + * @analysis Application programmer error. Fix the offending call. + */ +#define GLFW_INVALID_ENUM 0x00010003 +/*! @brief One of the arguments to the function was an invalid value. + * + * One of the arguments to the function was an invalid value, for example + * requesting a non-existent OpenGL or OpenGL ES version like 2.7. + * + * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead + * result in a @ref GLFW_VERSION_UNAVAILABLE error. + * + * @analysis Application programmer error. Fix the offending call. + */ +#define GLFW_INVALID_VALUE 0x00010004 +/*! @brief A memory allocation failed. + * + * A memory allocation failed. + * + * @analysis A bug in GLFW or the underlying operating system. Report the bug + * to our [issue tracker](https://github.com/glfw/glfw/issues). + */ +#define GLFW_OUT_OF_MEMORY 0x00010005 +/*! @brief GLFW could not find support for the requested API on the system. + * + * GLFW could not find support for the requested API on the system. + * + * @analysis The installed graphics driver does not support the requested + * API, or does not support it via the chosen context creation backend. + * Below are a few examples. + * + * @par + * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only + * supports OpenGL ES via EGL, while Nvidia and Intel only support it via + * a WGL or GLX extension. macOS does not provide OpenGL ES at all. The Mesa + * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary + * driver. Older graphics drivers do not support Vulkan. + */ +#define GLFW_API_UNAVAILABLE 0x00010006 +/*! @brief The requested OpenGL or OpenGL ES version is not available. + * + * The requested OpenGL or OpenGL ES version (including any requested context + * or framebuffer hints) is not available on this machine. + * + * @analysis The machine does not support your requirements. If your + * application is sufficiently flexible, downgrade your requirements and try + * again. Otherwise, inform the user that their machine does not match your + * requirements. + * + * @par + * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0 + * comes out before the 4.x series gets that far, also fail with this error and + * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions + * will exist. + */ +#define GLFW_VERSION_UNAVAILABLE 0x00010007 +/*! @brief A platform-specific error occurred that does not match any of the + * more specific categories. + * + * A platform-specific error occurred that does not match any of the more + * specific categories. + * + * @analysis A bug or configuration error in GLFW, the underlying operating + * system or its drivers, or a lack of required resources. Report the issue to + * our [issue tracker](https://github.com/glfw/glfw/issues). + */ +#define GLFW_PLATFORM_ERROR 0x00010008 +/*! @brief The requested format is not supported or available. + * + * If emitted during window creation, the requested pixel format is not + * supported. + * + * If emitted when querying the clipboard, the contents of the clipboard could + * not be converted to the requested format. + * + * @analysis If emitted during window creation, one or more + * [hard constraints](@ref window_hints_hard) did not match any of the + * available pixel formats. If your application is sufficiently flexible, + * downgrade your requirements and try again. Otherwise, inform the user that + * their machine does not match your requirements. + * + * @par + * If emitted when querying the clipboard, ignore the error or report it to + * the user, as appropriate. + */ +#define GLFW_FORMAT_UNAVAILABLE 0x00010009 +/*! @brief The specified window does not have an OpenGL or OpenGL ES context. + * + * A window that does not have an OpenGL or OpenGL ES context was passed to + * a function that requires it to have one. + * + * @analysis Application programmer error. Fix the offending call. + */ +#define GLFW_NO_WINDOW_CONTEXT 0x0001000A +/*! @} */ + +/*! @addtogroup window + * @{ */ +/*! @brief Input focus window hint and attribute + * + * Input focus [window hint](@ref GLFW_FOCUSED_hint) or + * [window attribute](@ref GLFW_FOCUSED_attrib). + */ +#define GLFW_FOCUSED 0x00020001 +/*! @brief Window iconification window attribute + * + * Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib). + */ +#define GLFW_ICONIFIED 0x00020002 +/*! @brief Window resize-ability window hint and attribute + * + * Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and + * [window attribute](@ref GLFW_RESIZABLE_attrib). + */ +#define GLFW_RESIZABLE 0x00020003 +/*! @brief Window visibility window hint and attribute + * + * Window visibility [window hint](@ref GLFW_VISIBLE_hint) and + * [window attribute](@ref GLFW_VISIBLE_attrib). + */ +#define GLFW_VISIBLE 0x00020004 +/*! @brief Window decoration window hint and attribute + * + * Window decoration [window hint](@ref GLFW_DECORATED_hint) and + * [window attribute](@ref GLFW_DECORATED_attrib). + */ +#define GLFW_DECORATED 0x00020005 +/*! @brief Window auto-iconification window hint and attribute + * + * Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and + * [window attribute](@ref GLFW_AUTO_ICONIFY_attrib). + */ +#define GLFW_AUTO_ICONIFY 0x00020006 +/*! @brief Window decoration window hint and attribute + * + * Window decoration [window hint](@ref GLFW_FLOATING_hint) and + * [window attribute](@ref GLFW_FLOATING_attrib). + */ +#define GLFW_FLOATING 0x00020007 +/*! @brief Window maximization window hint and attribute + * + * Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and + * [window attribute](@ref GLFW_MAXIMIZED_attrib). + */ +#define GLFW_MAXIMIZED 0x00020008 +/*! @brief Cursor centering window hint + * + * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint). + */ +#define GLFW_CENTER_CURSOR 0x00020009 +/*! @brief Window framebuffer transparency hint and attribute + * + * Window framebuffer transparency + * [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and + * [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib). + */ +#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A +/*! @brief Mouse cursor hover window attribute. + * + * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib). + */ +#define GLFW_HOVERED 0x0002000B +/*! @brief Input focus on calling show window hint and attribute + * + * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or + * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib). + */ +#define GLFW_FOCUS_ON_SHOW 0x0002000C + +/*! @brief Framebuffer bit depth hint. + * + * Framebuffer bit depth [hint](@ref GLFW_RED_BITS). + */ +#define GLFW_RED_BITS 0x00021001 +/*! @brief Framebuffer bit depth hint. + * + * Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS). + */ +#define GLFW_GREEN_BITS 0x00021002 +/*! @brief Framebuffer bit depth hint. + * + * Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS). + */ +#define GLFW_BLUE_BITS 0x00021003 +/*! @brief Framebuffer bit depth hint. + * + * Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS). + */ +#define GLFW_ALPHA_BITS 0x00021004 +/*! @brief Framebuffer bit depth hint. + * + * Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS). + */ +#define GLFW_DEPTH_BITS 0x00021005 +/*! @brief Framebuffer bit depth hint. + * + * Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS). + */ +#define GLFW_STENCIL_BITS 0x00021006 +/*! @brief Framebuffer bit depth hint. + * + * Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS). + */ +#define GLFW_ACCUM_RED_BITS 0x00021007 +/*! @brief Framebuffer bit depth hint. + * + * Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS). + */ +#define GLFW_ACCUM_GREEN_BITS 0x00021008 +/*! @brief Framebuffer bit depth hint. + * + * Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS). + */ +#define GLFW_ACCUM_BLUE_BITS 0x00021009 +/*! @brief Framebuffer bit depth hint. + * + * Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS). + */ +#define GLFW_ACCUM_ALPHA_BITS 0x0002100A +/*! @brief Framebuffer auxiliary buffer hint. + * + * Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS). + */ +#define GLFW_AUX_BUFFERS 0x0002100B +/*! @brief OpenGL stereoscopic rendering hint. + * + * OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO). + */ +#define GLFW_STEREO 0x0002100C +/*! @brief Framebuffer MSAA samples hint. + * + * Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES). + */ +#define GLFW_SAMPLES 0x0002100D +/*! @brief Framebuffer sRGB hint. + * + * Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE). + */ +#define GLFW_SRGB_CAPABLE 0x0002100E +/*! @brief Monitor refresh rate hint. + * + * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE). + */ +#define GLFW_REFRESH_RATE 0x0002100F +/*! @brief Framebuffer double buffering hint. + * + * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER). + */ +#define GLFW_DOUBLEBUFFER 0x00021010 + +/*! @brief Context client API hint and attribute. + * + * Context client API [hint](@ref GLFW_CLIENT_API_hint) and + * [attribute](@ref GLFW_CLIENT_API_attrib). + */ +#define GLFW_CLIENT_API 0x00022001 +/*! @brief Context client API major version hint and attribute. + * + * Context client API major version [hint](@ref GLFW_CONTEXT_VERSION_MAJOR_hint) + * and [attribute](@ref GLFW_CONTEXT_VERSION_MAJOR_attrib). + */ +#define GLFW_CONTEXT_VERSION_MAJOR 0x00022002 +/*! @brief Context client API minor version hint and attribute. + * + * Context client API minor version [hint](@ref GLFW_CONTEXT_VERSION_MINOR_hint) + * and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib). + */ +#define GLFW_CONTEXT_VERSION_MINOR 0x00022003 +/*! @brief Context client API revision number attribute. + * + * Context client API revision number + * [attribute](@ref GLFW_CONTEXT_REVISION_attrib). + */ +#define GLFW_CONTEXT_REVISION 0x00022004 +/*! @brief Context robustness hint and attribute. + * + * Context client API revision number [hint](@ref GLFW_CONTEXT_ROBUSTNESS_hint) + * and [attribute](@ref GLFW_CONTEXT_ROBUSTNESS_attrib). + */ +#define GLFW_CONTEXT_ROBUSTNESS 0x00022005 +/*! @brief OpenGL forward-compatibility hint and attribute. + * + * OpenGL forward-compatibility [hint](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) + * and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib). + */ +#define GLFW_OPENGL_FORWARD_COMPAT 0x00022006 +/*! @brief Debug mode context hint and attribute. + * + * Debug mode context [hint](@ref GLFW_OPENGL_DEBUG_CONTEXT_hint) and + * [attribute](@ref GLFW_OPENGL_DEBUG_CONTEXT_attrib). + */ +#define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007 +/*! @brief OpenGL profile hint and attribute. + * + * OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and + * [attribute](@ref GLFW_OPENGL_PROFILE_attrib). + */ +#define GLFW_OPENGL_PROFILE 0x00022008 +/*! @brief Context flush-on-release hint and attribute. + * + * Context flush-on-release [hint](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) and + * [attribute](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib). + */ +#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009 +/*! @brief Context error suppression hint and attribute. + * + * Context error suppression [hint](@ref GLFW_CONTEXT_NO_ERROR_hint) and + * [attribute](@ref GLFW_CONTEXT_NO_ERROR_attrib). + */ +#define GLFW_CONTEXT_NO_ERROR 0x0002200A +/*! @brief Context creation API hint and attribute. + * + * Context creation API [hint](@ref GLFW_CONTEXT_CREATION_API_hint) and + * [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib). + */ +#define GLFW_CONTEXT_CREATION_API 0x0002200B +/*! @brief Window content area scaling window + * [window hint](@ref GLFW_SCALE_TO_MONITOR). + */ +#define GLFW_SCALE_TO_MONITOR 0x0002200C +/*! @brief macOS specific + * [window hint](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint). + */ +#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001 +/*! @brief macOS specific + * [window hint](@ref GLFW_COCOA_FRAME_NAME_hint). + */ +#define GLFW_COCOA_FRAME_NAME 0x00023002 +/*! @brief macOS specific + * [window hint](@ref GLFW_COCOA_GRAPHICS_SWITCHING_hint). + */ +#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003 +/*! @brief X11 specific + * [window hint](@ref GLFW_X11_CLASS_NAME_hint). + */ +#define GLFW_X11_CLASS_NAME 0x00024001 +/*! @brief X11 specific + * [window hint](@ref GLFW_X11_CLASS_NAME_hint). + */ +#define GLFW_X11_INSTANCE_NAME 0x00024002 +/*! @} */ + +#define GLFW_NO_API 0 +#define GLFW_OPENGL_API 0x00030001 +#define GLFW_OPENGL_ES_API 0x00030002 + +#define GLFW_NO_ROBUSTNESS 0 +#define GLFW_NO_RESET_NOTIFICATION 0x00031001 +#define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002 + +#define GLFW_OPENGL_ANY_PROFILE 0 +#define GLFW_OPENGL_CORE_PROFILE 0x00032001 +#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002 + +#define GLFW_CURSOR 0x00033001 +#define GLFW_STICKY_KEYS 0x00033002 +#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003 +#define GLFW_LOCK_KEY_MODS 0x00033004 +#define GLFW_RAW_MOUSE_MOTION 0x00033005 + +#define GLFW_CURSOR_NORMAL 0x00034001 +#define GLFW_CURSOR_HIDDEN 0x00034002 +#define GLFW_CURSOR_DISABLED 0x00034003 + +#define GLFW_ANY_RELEASE_BEHAVIOR 0 +#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001 +#define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002 + +#define GLFW_NATIVE_CONTEXT_API 0x00036001 +#define GLFW_EGL_CONTEXT_API 0x00036002 +#define GLFW_OSMESA_CONTEXT_API 0x00036003 + +/*! @defgroup shapes Standard cursor shapes + * @brief Standard system cursor shapes. + * + * See [standard cursor creation](@ref cursor_standard) for how these are used. + * + * @ingroup input + * @{ */ + +/*! @brief The regular arrow cursor shape. + * + * The regular arrow cursor. + */ +#define GLFW_ARROW_CURSOR 0x00036001 +/*! @brief The text input I-beam cursor shape. + * + * The text input I-beam cursor shape. + */ +#define GLFW_IBEAM_CURSOR 0x00036002 +/*! @brief The crosshair shape. + * + * The crosshair shape. + */ +#define GLFW_CROSSHAIR_CURSOR 0x00036003 +/*! @brief The hand shape. + * + * The hand shape. + */ +#define GLFW_HAND_CURSOR 0x00036004 +/*! @brief The horizontal resize arrow shape. + * + * The horizontal resize arrow shape. + */ +#define GLFW_HRESIZE_CURSOR 0x00036005 +/*! @brief The vertical resize arrow shape. + * + * The vertical resize arrow shape. + */ +#define GLFW_VRESIZE_CURSOR 0x00036006 +/*! @} */ + +#define GLFW_CONNECTED 0x00040001 +#define GLFW_DISCONNECTED 0x00040002 + +/*! @addtogroup init + * @{ */ +/*! @brief Joystick hat buttons init hint. + * + * Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS). + */ +#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001 +/*! @brief macOS specific init hint. + * + * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint). + */ +#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001 +/*! @brief macOS specific init hint. + * + * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint). + */ +#define GLFW_COCOA_MENUBAR 0x00051002 +/*! @} */ + +#define GLFW_DONT_CARE -1 + + +/************************************************************************* + * GLFW API types + *************************************************************************/ + +/*! @brief Client API function pointer type. + * + * Generic function pointer used for returning client API function pointers + * without forcing a cast from a regular pointer. + * + * @sa @ref context_glext + * @sa @ref glfwGetProcAddress + * + * @since Added in version 3.0. + * + * @ingroup context + */ +typedef void (*GLFWglproc)(void); + +/*! @brief Vulkan API function pointer type. + * + * Generic function pointer used for returning Vulkan API function pointers + * without forcing a cast from a regular pointer. + * + * @sa @ref vulkan_proc + * @sa @ref glfwGetInstanceProcAddress + * + * @since Added in version 3.2. + * + * @ingroup vulkan + */ +typedef void (*GLFWvkproc)(void); + +/*! @brief Opaque monitor object. + * + * Opaque monitor object. + * + * @see @ref monitor_object + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +typedef struct GLFWmonitor GLFWmonitor; + +/*! @brief Opaque window object. + * + * Opaque window object. + * + * @see @ref window_object + * + * @since Added in version 3.0. + * + * @ingroup window + */ +typedef struct GLFWwindow GLFWwindow; + +/*! @brief Opaque cursor object. + * + * Opaque cursor object. + * + * @see @ref cursor_object + * + * @since Added in version 3.1. + * + * @ingroup input + */ +typedef struct GLFWcursor GLFWcursor; + +/*! @brief The function pointer type for error callbacks. + * + * This is the function pointer type for error callbacks. An error callback + * function has the following signature: + * @code + * void callback_name(int error_code, const char* description) + * @endcode + * + * @param[in] error_code An [error code](@ref errors). Future releases may add + * more error codes. + * @param[in] description A UTF-8 encoded string describing the error. + * + * @pointer_lifetime The error description string is valid until the callback + * function returns. + * + * @sa @ref error_handling + * @sa @ref glfwSetErrorCallback + * + * @since Added in version 3.0. + * + * @ingroup init + */ +typedef void (* GLFWerrorfun)(int error_code, const char* description); + +/*! @brief The function pointer type for window position callbacks. + * + * This is the function pointer type for window position callbacks. A window + * position callback function has the following signature: + * @code + * void callback_name(GLFWwindow* window, int xpos, int ypos) + * @endcode + * + * @param[in] window The window that was moved. + * @param[in] xpos The new x-coordinate, in screen coordinates, of the + * upper-left corner of the content area of the window. + * @param[in] ypos The new y-coordinate, in screen coordinates, of the + * upper-left corner of the content area of the window. + * + * @sa @ref window_pos + * @sa @ref glfwSetWindowPosCallback + * + * @since Added in version 3.0. + * + * @ingroup window + */ +typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos); + +/*! @brief The function pointer type for window size callbacks. + * + * This is the function pointer type for window size callbacks. A window size + * callback function has the following signature: + * @code + * void callback_name(GLFWwindow* window, int width, int height) + * @endcode + * + * @param[in] window The window that was resized. + * @param[in] width The new width, in screen coordinates, of the window. + * @param[in] height The new height, in screen coordinates, of the window. + * + * @sa @ref window_size + * @sa @ref glfwSetWindowSizeCallback + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter. + * + * @ingroup window + */ +typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height); + +/*! @brief The function pointer type for window close callbacks. + * + * This is the function pointer type for window close callbacks. A window + * close callback function has the following signature: + * @code + * void function_name(GLFWwindow* window) + * @endcode + * + * @param[in] window The window that the user attempted to close. + * + * @sa @ref window_close + * @sa @ref glfwSetWindowCloseCallback + * + * @since Added in version 2.5. + * @glfw3 Added window handle parameter. + * + * @ingroup window + */ +typedef void (* GLFWwindowclosefun)(GLFWwindow* window); + +/*! @brief The function pointer type for window content refresh callbacks. + * + * This is the function pointer type for window content refresh callbacks. + * A window content refresh callback function has the following signature: + * @code + * void function_name(GLFWwindow* window); + * @endcode + * + * @param[in] window The window whose content needs to be refreshed. + * + * @sa @ref window_refresh + * @sa @ref glfwSetWindowRefreshCallback + * + * @since Added in version 2.5. + * @glfw3 Added window handle parameter. + * + * @ingroup window + */ +typedef void (* GLFWwindowrefreshfun)(GLFWwindow* window); + +/*! @brief The function pointer type for window focus callbacks. + * + * This is the function pointer type for window focus callbacks. A window + * focus callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int focused) + * @endcode + * + * @param[in] window The window that gained or lost input focus. + * @param[in] focused `GLFW_TRUE` if the window was given input focus, or + * `GLFW_FALSE` if it lost it. + * + * @sa @ref window_focus + * @sa @ref glfwSetWindowFocusCallback + * + * @since Added in version 3.0. + * + * @ingroup window + */ +typedef void (* GLFWwindowfocusfun)(GLFWwindow* window, int focused); + +/*! @brief The function pointer type for window iconify callbacks. + * + * This is the function pointer type for window iconify callbacks. A window + * iconify callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int iconified) + * @endcode + * + * @param[in] window The window that was iconified or restored. + * @param[in] iconified `GLFW_TRUE` if the window was iconified, or + * `GLFW_FALSE` if it was restored. + * + * @sa @ref window_iconify + * @sa @ref glfwSetWindowIconifyCallback + * + * @since Added in version 3.0. + * + * @ingroup window + */ +typedef void (* GLFWwindowiconifyfun)(GLFWwindow* window, int iconified); + +/*! @brief The function pointer type for window maximize callbacks. + * + * This is the function pointer type for window maximize callbacks. A window + * maximize callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int maximized) + * @endcode + * + * @param[in] window The window that was maximized or restored. + * @param[in] maximized `GLFW_TRUE` if the window was maximized, or + * `GLFW_FALSE` if it was restored. + * + * @sa @ref window_maximize + * @sa glfwSetWindowMaximizeCallback + * + * @since Added in version 3.3. + * + * @ingroup window + */ +typedef void (* GLFWwindowmaximizefun)(GLFWwindow* window, int maximized); + +/*! @brief The function pointer type for framebuffer size callbacks. + * + * This is the function pointer type for framebuffer size callbacks. + * A framebuffer size callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int width, int height) + * @endcode + * + * @param[in] window The window whose framebuffer was resized. + * @param[in] width The new width, in pixels, of the framebuffer. + * @param[in] height The new height, in pixels, of the framebuffer. + * + * @sa @ref window_fbsize + * @sa @ref glfwSetFramebufferSizeCallback + * + * @since Added in version 3.0. + * + * @ingroup window + */ +typedef void (* GLFWframebuffersizefun)(GLFWwindow* window, int width, int height); + +/*! @brief The function pointer type for window content scale callbacks. + * + * This is the function pointer type for window content scale callbacks. + * A window content scale callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, float xscale, float yscale) + * @endcode + * + * @param[in] window The window whose content scale changed. + * @param[in] xscale The new x-axis content scale of the window. + * @param[in] yscale The new y-axis content scale of the window. + * + * @sa @ref window_scale + * @sa @ref glfwSetWindowContentScaleCallback + * + * @since Added in version 3.3. + * + * @ingroup window + */ +typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, float yscale); + +/*! @brief The function pointer type for mouse button callbacks. + * + * This is the function pointer type for mouse button callback functions. + * A mouse button callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int button, int action, int mods) + * @endcode + * + * @param[in] window The window that received the event. + * @param[in] button The [mouse button](@ref buttons) that was pressed or + * released. + * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. Future releases + * may add more actions. + * @param[in] mods Bit field describing which [modifier keys](@ref mods) were + * held down. + * + * @sa @ref input_mouse_button + * @sa @ref glfwSetMouseButtonCallback + * + * @since Added in version 1.0. + * @glfw3 Added window handle and modifier mask parameters. + * + * @ingroup input + */ +typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods); + +/*! @brief The function pointer type for cursor position callbacks. + * + * This is the function pointer type for cursor position callbacks. A cursor + * position callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, double xpos, double ypos); + * @endcode + * + * @param[in] window The window that received the event. + * @param[in] xpos The new cursor x-coordinate, relative to the left edge of + * the content area. + * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the + * content area. + * + * @sa @ref cursor_pos + * @sa @ref glfwSetCursorPosCallback + * + * @since Added in version 3.0. Replaces `GLFWmouseposfun`. + * + * @ingroup input + */ +typedef void (* GLFWcursorposfun)(GLFWwindow* window, double xpos, double ypos); + +/*! @brief The function pointer type for cursor enter/leave callbacks. + * + * This is the function pointer type for cursor enter/leave callbacks. + * A cursor enter/leave callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int entered) + * @endcode + * + * @param[in] window The window that received the event. + * @param[in] entered `GLFW_TRUE` if the cursor entered the window's content + * area, or `GLFW_FALSE` if it left it. + * + * @sa @ref cursor_enter + * @sa @ref glfwSetCursorEnterCallback + * + * @since Added in version 3.0. + * + * @ingroup input + */ +typedef void (* GLFWcursorenterfun)(GLFWwindow* window, int entered); + +/*! @brief The function pointer type for scroll callbacks. + * + * This is the function pointer type for scroll callbacks. A scroll callback + * function has the following signature: + * @code + * void function_name(GLFWwindow* window, double xoffset, double yoffset) + * @endcode + * + * @param[in] window The window that received the event. + * @param[in] xoffset The scroll offset along the x-axis. + * @param[in] yoffset The scroll offset along the y-axis. + * + * @sa @ref scrolling + * @sa @ref glfwSetScrollCallback + * + * @since Added in version 3.0. Replaces `GLFWmousewheelfun`. + * + * @ingroup input + */ +typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset); + +/*! @brief The function pointer type for keyboard key callbacks. + * + * This is the function pointer type for keyboard key callbacks. A keyboard + * key callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods) + * @endcode + * + * @param[in] window The window that received the event. + * @param[in] key The [keyboard key](@ref keys) that was pressed or released. + * @param[in] scancode The system-specific scancode of the key. + * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future + * releases may add more actions. + * @param[in] mods Bit field describing which [modifier keys](@ref mods) were + * held down. + * + * @sa @ref input_key + * @sa @ref glfwSetKeyCallback + * + * @since Added in version 1.0. + * @glfw3 Added window handle, scancode and modifier mask parameters. + * + * @ingroup input + */ +typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int action, int mods); + +/*! @brief The function pointer type for Unicode character callbacks. + * + * This is the function pointer type for Unicode character callbacks. + * A Unicode character callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, unsigned int codepoint) + * @endcode + * + * @param[in] window The window that received the event. + * @param[in] codepoint The Unicode code point of the character. + * + * @sa @ref input_char + * @sa @ref glfwSetCharCallback + * + * @since Added in version 2.4. + * @glfw3 Added window handle parameter. + * + * @ingroup input + */ +typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint); + +/*! @brief The function pointer type for Unicode character with modifiers + * callbacks. + * + * This is the function pointer type for Unicode character with modifiers + * callbacks. It is called for each input character, regardless of what + * modifier keys are held down. A Unicode character with modifiers callback + * function has the following signature: + * @code + * void function_name(GLFWwindow* window, unsigned int codepoint, int mods) + * @endcode + * + * @param[in] window The window that received the event. + * @param[in] codepoint The Unicode code point of the character. + * @param[in] mods Bit field describing which [modifier keys](@ref mods) were + * held down. + * + * @sa @ref input_char + * @sa @ref glfwSetCharModsCallback + * + * @deprecated Scheduled for removal in version 4.0. + * + * @since Added in version 3.1. + * + * @ingroup input + */ +typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods); + +/*! @brief The function pointer type for path drop callbacks. + * + * This is the function pointer type for path drop callbacks. A path drop + * callback function has the following signature: + * @code + * void function_name(GLFWwindow* window, int path_count, const char* paths[]) + * @endcode + * + * @param[in] window The window that received the event. + * @param[in] path_count The number of dropped paths. + * @param[in] paths The UTF-8 encoded file and/or directory path names. + * + * @pointer_lifetime The path array and its strings are valid until the + * callback function returns. + * + * @sa @ref path_drop + * @sa @ref glfwSetDropCallback + * + * @since Added in version 3.1. + * + * @ingroup input + */ +typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]); + +/*! @brief The function pointer type for monitor configuration callbacks. + * + * This is the function pointer type for monitor configuration callbacks. + * A monitor callback function has the following signature: + * @code + * void function_name(GLFWmonitor* monitor, int event) + * @endcode + * + * @param[in] monitor The monitor that was connected or disconnected. + * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future + * releases may add more events. + * + * @sa @ref monitor_event + * @sa @ref glfwSetMonitorCallback + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +typedef void (* GLFWmonitorfun)(GLFWmonitor* monitor, int event); + +/*! @brief The function pointer type for joystick configuration callbacks. + * + * This is the function pointer type for joystick configuration callbacks. + * A joystick configuration callback function has the following signature: + * @code + * void function_name(int jid, int event) + * @endcode + * + * @param[in] jid The joystick that was connected or disconnected. + * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future + * releases may add more events. + * + * @sa @ref joystick_event + * @sa @ref glfwSetJoystickCallback + * + * @since Added in version 3.2. + * + * @ingroup input + */ +typedef void (* GLFWjoystickfun)(int jid, int event); + +/*! @brief Video mode type. + * + * This describes a single video mode. + * + * @sa @ref monitor_modes + * @sa @ref glfwGetVideoMode + * @sa @ref glfwGetVideoModes + * + * @since Added in version 1.0. + * @glfw3 Added refresh rate member. + * + * @ingroup monitor + */ +typedef struct GLFWvidmode +{ + /*! The width, in screen coordinates, of the video mode. + */ + int width; + /*! The height, in screen coordinates, of the video mode. + */ + int height; + /*! The bit depth of the red channel of the video mode. + */ + int redBits; + /*! The bit depth of the green channel of the video mode. + */ + int greenBits; + /*! The bit depth of the blue channel of the video mode. + */ + int blueBits; + /*! The refresh rate, in Hz, of the video mode. + */ + int refreshRate; +} GLFWvidmode; + +/*! @brief Gamma ramp. + * + * This describes the gamma ramp for a monitor. + * + * @sa @ref monitor_gamma + * @sa @ref glfwGetGammaRamp + * @sa @ref glfwSetGammaRamp + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +typedef struct GLFWgammaramp +{ + /*! An array of value describing the response of the red channel. + */ + unsigned short* red; + /*! An array of value describing the response of the green channel. + */ + unsigned short* green; + /*! An array of value describing the response of the blue channel. + */ + unsigned short* blue; + /*! The number of elements in each array. + */ + unsigned int size; +} GLFWgammaramp; + +/*! @brief Image data. + * + * This describes a single 2D image. See the documentation for each related + * function what the expected pixel format is. + * + * @sa @ref cursor_custom + * @sa @ref window_icon + * + * @since Added in version 2.1. + * @glfw3 Removed format and bytes-per-pixel members. + * + * @ingroup window + */ +typedef struct GLFWimage +{ + /*! The width, in pixels, of this image. + */ + int width; + /*! The height, in pixels, of this image. + */ + int height; + /*! The pixel data of this image, arranged left-to-right, top-to-bottom. + */ + unsigned char* pixels; +} GLFWimage; + +/*! @brief Gamepad input state + * + * This describes the input state of a gamepad. + * + * @sa @ref gamepad + * @sa @ref glfwGetGamepadState + * + * @since Added in version 3.3. + * + * @ingroup input + */ +typedef struct GLFWgamepadstate +{ + /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS` + * or `GLFW_RELEASE`. + */ + unsigned char buttons[15]; + /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0 + * to 1.0 inclusive. + */ + float axes[6]; +} GLFWgamepadstate; + + +/************************************************************************* + * GLFW API functions + *************************************************************************/ + +/*! @brief Initializes the GLFW library. + * + * This function initializes the GLFW library. Before most GLFW functions can + * be used, GLFW must be initialized, and before an application terminates GLFW + * should be terminated in order to free any resources allocated during or + * after initialization. + * + * If this function fails, it calls @ref glfwTerminate before returning. If it + * succeeds, you should call @ref glfwTerminate before the application exits. + * + * Additional calls to this function after successful initialization but before + * termination will return `GLFW_TRUE` immediately. + * + * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_PLATFORM_ERROR. + * + * @remark @macos This function will change the current directory of the + * application to the `Contents/Resources` subdirectory of the application's + * bundle, if present. This can be disabled with the @ref + * GLFW_COCOA_CHDIR_RESOURCES init hint. + * + * @remark @x11 This function will set the `LC_CTYPE` category of the + * application locale according to the current environment if that category is + * still "C". This is because the "C" locale breaks Unicode text input. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref intro_init + * @sa @ref glfwTerminate + * + * @since Added in version 1.0. + * + * @ingroup init + */ +GLFWAPI int glfwInit(void); + +/*! @brief Terminates the GLFW library. + * + * This function destroys all remaining windows and cursors, restores any + * modified gamma ramps and frees any other allocated resources. Once this + * function is called, you must again call @ref glfwInit successfully before + * you will be able to use most GLFW functions. + * + * If GLFW has been successfully initialized, this function should be called + * before the application exits. If initialization fails, there is no need to + * call this function, as it is called by @ref glfwInit before it returns + * failure. + * + * This function has no effect if GLFW is not initialized. + * + * @errors Possible errors include @ref GLFW_PLATFORM_ERROR. + * + * @remark This function may be called before @ref glfwInit. + * + * @warning The contexts of any remaining windows must not be current on any + * other thread when this function is called. + * + * @reentrancy This function must not be called from a callback. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref intro_init + * @sa @ref glfwInit + * + * @since Added in version 1.0. + * + * @ingroup init + */ +GLFWAPI void glfwTerminate(void); + +/*! @brief Sets the specified init hint to the desired value. + * + * This function sets hints for the next initialization of GLFW. + * + * The values you set hints to are never reset by GLFW, but they only take + * effect during initialization. Once GLFW has been initialized, any values + * you set will be ignored until the library is terminated and initialized + * again. + * + * Some hints are platform specific. These may be set on any platform but they + * will only affect their specific platform. Other platforms will ignore them. + * Setting these hints requires no platform specific headers or functions. + * + * @param[in] hint The [init hint](@ref init_hints) to set. + * @param[in] value The new value of the init hint. + * + * @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref + * GLFW_INVALID_VALUE. + * + * @remarks This function may be called before @ref glfwInit. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa init_hints + * @sa glfwInit + * + * @since Added in version 3.3. + * + * @ingroup init + */ +GLFWAPI void glfwInitHint(int hint, int value); + +/*! @brief Retrieves the version of the GLFW library. + * + * This function retrieves the major, minor and revision numbers of the GLFW + * library. It is intended for when you are using GLFW as a shared library and + * want to ensure that you are using the minimum required version. + * + * Any or all of the version arguments may be `NULL`. + * + * @param[out] major Where to store the major version number, or `NULL`. + * @param[out] minor Where to store the minor version number, or `NULL`. + * @param[out] rev Where to store the revision number, or `NULL`. + * + * @errors None. + * + * @remark This function may be called before @ref glfwInit. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref intro_version + * @sa @ref glfwGetVersionString + * + * @since Added in version 1.0. + * + * @ingroup init + */ +GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev); + +/*! @brief Returns a string describing the compile-time configuration. + * + * This function returns the compile-time generated + * [version string](@ref intro_version_string) of the GLFW library binary. It + * describes the version, platform, compiler and any platform-specific + * compile-time options. It should not be confused with the OpenGL or OpenGL + * ES version string, queried with `glGetString`. + * + * __Do not use the version string__ to parse the GLFW library version. The + * @ref glfwGetVersion function provides the version of the running library + * binary in numerical format. + * + * @return The ASCII encoded GLFW version string. + * + * @errors None. + * + * @remark This function may be called before @ref glfwInit. + * + * @pointer_lifetime The returned string is static and compile-time generated. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref intro_version + * @sa @ref glfwGetVersion + * + * @since Added in version 3.0. + * + * @ingroup init + */ +GLFWAPI const char* glfwGetVersionString(void); + +/*! @brief Returns and clears the last error for the calling thread. + * + * This function returns and clears the [error code](@ref errors) of the last + * error that occurred on the calling thread, and optionally a UTF-8 encoded + * human-readable description of it. If no error has occurred since the last + * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is + * set to `NULL`. + * + * @param[in] description Where to store the error description pointer, or `NULL`. + * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR + * (zero). + * + * @errors None. + * + * @pointer_lifetime The returned string is allocated and freed by GLFW. You + * should not free it yourself. It is guaranteed to be valid only until the + * next error occurs or the library is terminated. + * + * @remark This function may be called before @ref glfwInit. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref error_handling + * @sa @ref glfwSetErrorCallback + * + * @since Added in version 3.3. + * + * @ingroup init + */ +GLFWAPI int glfwGetError(const char** description); + +/*! @brief Sets the error callback. + * + * This function sets the error callback, which is called with an error code + * and a human-readable description each time a GLFW error occurs. + * + * The error code is set before the callback is called. Calling @ref + * glfwGetError from the error callback will return the same value as the error + * code argument. + * + * The error callback is called on the thread where the error occurred. If you + * are using GLFW from multiple threads, your error callback needs to be + * written accordingly. + * + * Because the description string may have been generated specifically for that + * error, it is not guaranteed to be valid after the callback has returned. If + * you wish to use it after the callback returns, you need to make a copy. + * + * Once set, the error callback remains set even after the library has been + * terminated. + * + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set. + * + * @callback_signature + * @code + * void callback_name(int error_code, const char* description) + * @endcode + * For more information about the callback parameters, see the + * [callback pointer type](@ref GLFWerrorfun). + * + * @errors None. + * + * @remark This function may be called before @ref glfwInit. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref error_handling + * @sa @ref glfwGetError + * + * @since Added in version 3.0. + * + * @ingroup init + */ +GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback); + +/*! @brief Returns the currently connected monitors. + * + * This function returns an array of handles for all currently connected + * monitors. The primary monitor is always first in the returned array. If no + * monitors were found, this function returns `NULL`. + * + * @param[out] count Where to store the number of monitors in the returned + * array. This is set to zero if an error occurred. + * @return An array of monitor handles, or `NULL` if no monitors were found or + * if an [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @pointer_lifetime The returned array is allocated and freed by GLFW. You + * should not free it yourself. It is guaranteed to be valid only until the + * monitor configuration changes or the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_monitors + * @sa @ref monitor_event + * @sa @ref glfwGetPrimaryMonitor + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +GLFWAPI GLFWmonitor** glfwGetMonitors(int* count); + +/*! @brief Returns the primary monitor. + * + * This function returns the primary monitor. This is usually the monitor + * where elements like the task bar or global menu bar are located. + * + * @return The primary monitor, or `NULL` if no monitors were found or if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @remark The primary monitor is always first in the array returned by @ref + * glfwGetMonitors. + * + * @sa @ref monitor_monitors + * @sa @ref glfwGetMonitors + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void); + +/*! @brief Returns the position of the monitor's viewport on the virtual screen. + * + * This function returns the position, in screen coordinates, of the upper-left + * corner of the specified monitor. + * + * Any or all of the position arguments may be `NULL`. If an error occurs, all + * non-`NULL` position arguments will be set to zero. + * + * @param[in] monitor The monitor to query. + * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`. + * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_properties + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); + +/*! @brief Retrieves the work area of the monitor. + * + * This function returns the position, in screen coordinates, of the upper-left + * corner of the work area of the specified monitor along with the work area + * size in screen coordinates. The work area is defined as the area of the + * monitor not occluded by the operating system task bar where present. If no + * task bar exists then the work area is the monitor resolution in screen + * coordinates. + * + * Any or all of the position and size arguments may be `NULL`. If an error + * occurs, all non-`NULL` position and size arguments will be set to zero. + * + * @param[in] monitor The monitor to query. + * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`. + * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`. + * @param[out] width Where to store the monitor width, or `NULL`. + * @param[out] height Where to store the monitor height, or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_workarea + * + * @since Added in version 3.3. + * + * @ingroup monitor + */ +GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); + +/*! @brief Returns the physical size of the monitor. + * + * This function returns the size, in millimetres, of the display area of the + * specified monitor. + * + * Some systems do not provide accurate monitor size information, either + * because the monitor + * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data) + * data is incorrect or because the driver does not report it accurately. + * + * Any or all of the size arguments may be `NULL`. If an error occurs, all + * non-`NULL` size arguments will be set to zero. + * + * @param[in] monitor The monitor to query. + * @param[out] widthMM Where to store the width, in millimetres, of the + * monitor's display area, or `NULL`. + * @param[out] heightMM Where to store the height, in millimetres, of the + * monitor's display area, or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @remark @win32 On Windows 8 and earlier the physical size is calculated from + * the current resolution and system DPI instead of querying the monitor EDID data. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_properties + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM); + +/*! @brief Retrieves the content scale for the specified monitor. + * + * This function retrieves the content scale for the specified monitor. The + * content scale is the ratio between the current DPI and the platform's + * default DPI. This is especially important for text and any UI elements. If + * the pixel dimensions of your UI scaled by this look appropriate on your + * machine then it should appear at a reasonable size on other machines + * regardless of their DPI and scaling settings. This relies on the system DPI + * and scaling settings being somewhat correct. + * + * The content scale may depend on both the monitor resolution and pixel + * density and on user settings. It may be very different from the raw DPI + * calculated from the physical size and current resolution. + * + * @param[in] monitor The monitor to query. + * @param[out] xscale Where to store the x-axis content scale, or `NULL`. + * @param[out] yscale Where to store the y-axis content scale, or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_scale + * @sa @ref glfwGetWindowContentScale + * + * @since Added in version 3.3. + * + * @ingroup monitor + */ +GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale); + +/*! @brief Returns the name of the specified monitor. + * + * This function returns a human-readable name, encoded as UTF-8, of the + * specified monitor. The name typically reflects the make and model of the + * monitor and is not guaranteed to be unique among the connected monitors. + * + * @param[in] monitor The monitor to query. + * @return The UTF-8 encoded name of the monitor, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @pointer_lifetime The returned string is allocated and freed by GLFW. You + * should not free it yourself. It is valid until the specified monitor is + * disconnected or the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_properties + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor); + +/*! @brief Sets the user pointer of the specified monitor. + * + * This function sets the user-defined pointer of the specified monitor. The + * current value is retained until the monitor is disconnected. The initial + * value is `NULL`. + * + * This function may be called from the monitor callback, even for a monitor + * that is being disconnected. + * + * @param[in] monitor The monitor whose pointer to set. + * @param[in] pointer The new value. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @sa @ref monitor_userptr + * @sa @ref glfwGetMonitorUserPointer + * + * @since Added in version 3.3. + * + * @ingroup monitor + */ +GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer); + +/*! @brief Returns the user pointer of the specified monitor. + * + * This function returns the current value of the user-defined pointer of the + * specified monitor. The initial value is `NULL`. + * + * This function may be called from the monitor callback, even for a monitor + * that is being disconnected. + * + * @param[in] monitor The monitor whose pointer to return. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @sa @ref monitor_userptr + * @sa @ref glfwSetMonitorUserPointer + * + * @since Added in version 3.3. + * + * @ingroup monitor + */ +GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor); + +/*! @brief Sets the monitor configuration callback. + * + * This function sets the monitor configuration callback, or removes the + * currently set callback. This is called when a monitor is connected to or + * disconnected from the system. + * + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWmonitor* monitor, int event) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWmonitorfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_event + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback); + +/*! @brief Returns the available video modes for the specified monitor. + * + * This function returns an array of all video modes supported by the specified + * monitor. The returned array is sorted in ascending order, first by color + * bit depth (the sum of all channel depths), then by resolution area (the + * product of width and height), then resolution width and finally by refresh + * rate. + * + * @param[in] monitor The monitor to query. + * @param[out] count Where to store the number of video modes in the returned + * array. This is set to zero if an error occurred. + * @return An array of video modes, 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 array is allocated and freed by GLFW. You + * should not free it yourself. It is valid until the specified monitor is + * disconnected, this function is called again for that monitor or the library + * is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_modes + * @sa @ref glfwGetVideoMode + * + * @since Added in version 1.0. + * @glfw3 Changed to return an array of modes for a specific monitor. + * + * @ingroup monitor + */ +GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); + +/*! @brief Returns the current mode of the specified monitor. + * + * This function returns the current video mode of the specified monitor. If + * you have created a full screen window for that monitor, the return value + * will depend on whether that window is iconified. + * + * @param[in] monitor The monitor to query. + * @return The current mode of the monitor, 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 array is allocated and freed by GLFW. You + * should not free it yourself. It is valid until the specified monitor is + * disconnected or the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_modes + * @sa @ref glfwGetVideoModes + * + * @since Added in version 3.0. Replaces `glfwGetDesktopMode`. + * + * @ingroup monitor + */ +GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); + +/*! @brief Generates a gamma ramp and sets it for the specified monitor. + * + * This function generates an appropriately sized gamma ramp from the specified + * exponent and then calls @ref glfwSetGammaRamp with it. The value must be + * a finite number greater than zero. + * + * The software controlled gamma ramp is applied _in addition_ to the hardware + * gamma correction, which today is usually an approximation of sRGB gamma. + * This means that setting a perfectly linear ramp, or gamma 1.0, will produce + * the default (usually sRGB-like) behavior. + * + * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref + * GLFW_SRGB_CAPABLE hint. + * + * @param[in] monitor The monitor whose gamma ramp to set. + * @param[in] gamma The desired exponent. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR. + * + * @remark @wayland Gamma handling is a privileged protocol, this function + * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_gamma + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); + +/*! @brief Returns the current gamma ramp for the specified monitor. + * + * This function returns the current gamma ramp of the specified monitor. + * + * @param[in] monitor The monitor to query. + * @return The current gamma ramp, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @wayland Gamma handling is a privileged protocol, this function + * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while + * returning `NULL`. + * + * @pointer_lifetime The returned structure and its arrays are allocated and + * freed by GLFW. You should not free them yourself. They are valid until the + * specified monitor is disconnected, this function is called again for that + * monitor or the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_gamma + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); + +/*! @brief Sets the current gamma ramp for the specified monitor. + * + * This function sets the current gamma ramp for the specified monitor. The + * original gamma ramp for that monitor is saved by GLFW the first time this + * function is called and is restored by @ref glfwTerminate. + * + * The software controlled gamma ramp is applied _in addition_ to the hardware + * gamma correction, which today is usually an approximation of sRGB gamma. + * This means that setting a perfectly linear ramp, or gamma 1.0, will produce + * the default (usually sRGB-like) behavior. + * + * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref + * GLFW_SRGB_CAPABLE hint. + * + * @param[in] monitor The monitor whose gamma ramp to set. + * @param[in] ramp The gamma ramp to use. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark The size of the specified gamma ramp should match the size of the + * current ramp for that monitor. + * + * @remark @win32 The gamma ramp size must be 256. + * + * @remark @wayland Gamma handling is a privileged protocol, this function + * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR. + * + * @pointer_lifetime The specified gamma ramp is copied before this function + * returns. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref monitor_gamma + * + * @since Added in version 3.0. + * + * @ingroup monitor + */ +GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp); + +/*! @brief Resets all window hints to their default values. + * + * This function resets all window hints to their + * [default values](@ref window_hints_values). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_hints + * @sa @ref glfwWindowHint + * @sa @ref glfwWindowHintString + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI void glfwDefaultWindowHints(void); + +/*! @brief Sets the specified window hint to the desired value. + * + * This function sets hints for the next call to @ref glfwCreateWindow. The + * hints, once set, retain their values until changed by a call to this + * function or @ref glfwDefaultWindowHints, or until the library is terminated. + * + * Only integer value hints can be set with this function. String value hints + * are set with @ref glfwWindowHintString. + * + * This function does not check whether the specified hint values are valid. + * If you set hints to invalid values this will instead be reported by the next + * call to @ref glfwCreateWindow. + * + * Some hints are platform specific. These may be set on any platform but they + * will only affect their specific platform. Other platforms will ignore them. + * Setting these hints requires no platform specific headers or functions. + * + * @param[in] hint The [window hint](@ref window_hints) to set. + * @param[in] value The new value of the window hint. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_ENUM. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_hints + * @sa @ref glfwWindowHintString + * @sa @ref glfwDefaultWindowHints + * + * @since Added in version 3.0. Replaces `glfwOpenWindowHint`. + * + * @ingroup window + */ +GLFWAPI void glfwWindowHint(int hint, int value); + +/*! @brief Sets the specified window hint to the desired value. + * + * This function sets hints for the next call to @ref glfwCreateWindow. The + * hints, once set, retain their values until changed by a call to this + * function or @ref glfwDefaultWindowHints, or until the library is terminated. + * + * Only string type hints can be set with this function. Integer value hints + * are set with @ref glfwWindowHint. + * + * This function does not check whether the specified hint values are valid. + * If you set hints to invalid values this will instead be reported by the next + * call to @ref glfwCreateWindow. + * + * Some hints are platform specific. These may be set on any platform but they + * will only affect their specific platform. Other platforms will ignore them. + * Setting these hints requires no platform specific headers or functions. + * + * @param[in] hint The [window hint](@ref window_hints) to set. + * @param[in] value The new value of the window hint. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_ENUM. + * + * @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 window_hints + * @sa @ref glfwWindowHint + * @sa @ref glfwDefaultWindowHints + * + * @since Added in version 3.3. + * + * @ingroup window + */ +GLFWAPI void glfwWindowHintString(int hint, const char* value); + +/*! @brief Creates a window and its associated context. + * + * This function creates a window and its associated OpenGL or OpenGL ES + * context. Most of the options controlling how the window and its context + * should be created are specified with [window hints](@ref window_hints). + * + * Successful creation does not change which context is current. Before you + * can use the newly created context, you need to + * [make it current](@ref context_current). For information about the `share` + * parameter, see @ref context_sharing. + * + * The created window, framebuffer and context may differ from what you + * requested, as not all parameters and hints are + * [hard constraints](@ref window_hints_hard). This includes the size of the + * window, especially for full screen windows. To query the actual attributes + * of the created window, framebuffer and context, see @ref + * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize. + * + * To create a full screen window, you need to specify the monitor the window + * will cover. If no monitor is specified, the window will be windowed mode. + * Unless you have a way for the user to choose a specific monitor, it is + * recommended that you pick the primary monitor. For more information on how + * to query connected monitors, see @ref monitor_monitors. + * + * For full screen windows, the specified size becomes the resolution of the + * window's _desired video mode_. As long as a full screen window is not + * iconified, the supported video mode most closely matching the desired video + * mode is set for the specified monitor. For more information about full + * screen windows, including the creation of so called _windowed full screen_ + * or _borderless full screen_ windows, see @ref window_windowed_full_screen. + * + * Once you have created the window, you can switch it between windowed and + * full screen mode with @ref glfwSetWindowMonitor. This will not affect its + * OpenGL or OpenGL ES context. + * + * By default, newly created windows use the placement recommended by the + * window system. To create the window at a specific position, make it + * initially invisible using the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window + * hint, set its [position](@ref window_pos) and then [show](@ref window_hide) + * it. + * + * As long as at least one full screen window is not iconified, the screensaver + * is prohibited from starting. + * + * Window systems put limits on window sizes. Very large or very small window + * dimensions may be overridden by the window system on creation. Check the + * actual [size](@ref window_size) after creation. + * + * The [swap interval](@ref buffer_swap) is not set during window creation and + * the initial value may vary depending on driver settings and defaults. + * + * @param[in] width The desired width, in screen coordinates, of the window. + * This must be greater than zero. + * @param[in] height The desired height, in screen coordinates, of the window. + * This must be greater than zero. + * @param[in] title The initial, UTF-8 encoded window title. + * @param[in] monitor The monitor to use for full screen mode, or `NULL` for + * windowed mode. + * @param[in] share The window whose context to share resources with, or `NULL` + * to not share resources. + * @return The handle of the created window, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref + * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @win32 Window creation will fail if the Microsoft GDI software + * OpenGL implementation is the only one available. + * + * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it + * will be set as the initial icon for the window. If no such icon is present, + * the `IDI_APPLICATION` icon will be used instead. To set a different icon, + * see @ref glfwSetWindowIcon. + * + * @remark @win32 The context to share resources with must not be current on + * any other thread. + * + * @remark @macos The OS only supports forward-compatible core profile contexts + * for OpenGL versions 3.2 and later. Before creating an OpenGL context of + * version 3.2 or later you must set the + * [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and + * [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly. + * OpenGL 3.0 and 3.1 contexts are not supported at all on macOS. + * + * @remark @macos The GLFW window has no icon, as it is not a document + * window, but the dock icon will be the same as the application bundle's icon. + * For more information on bundles, see the + * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) + * in the Mac Developer Library. + * + * @remark @macos The first time a window is created the menu bar is created. + * If GLFW finds a `MainMenu.nib` it is loaded and assumed to contain a menu + * bar. Otherwise a minimal menu bar is created manually with common commands + * like Hide, Quit and About. The About entry opens a minimal about dialog + * with information from the application's bundle. Menu bar creation can be + * disabled entirely with the @ref GLFW_COCOA_MENUBAR init hint. + * + * @remark @macos On OS X 10.10 and later the window frame will not be rendered + * at full resolution on Retina displays unless the + * [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint) + * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the + * application bundle's `Info.plist`. For more information, see + * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html) + * in the Mac Developer Library. The GLFW test and example programs use + * a custom `Info.plist` template for this, which can be found as + * `CMake/MacOSXBundleInfo.plist.in` in the source tree. + * + * @remark @macos When activating frame autosaving with + * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified + * window size and position may be overridden by previously saved values. + * + * @remark @x11 Some window managers will not respect the placement of + * initially hidden windows. + * + * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for + * a window to reach its requested state. This means you may not be able to + * query the final size, position or other attributes directly after window + * creation. + * + * @remark @x11 The class part of the `WM_CLASS` window property will by + * default be set to the window title passed to this function. The instance + * part will use the contents of the `RESOURCE_NAME` environment variable, if + * present and not empty, or fall back to the window title. Set the + * [GLFW_X11_CLASS_NAME](@ref GLFW_X11_CLASS_NAME_hint) and + * [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to + * override this. + * + * @remark @wayland Compositors should implement the xdg-decoration protocol + * for GLFW to decorate the window properly. If this protocol isn't + * supported, or if the compositor prefers client-side decorations, a very + * simple fallback frame will be drawn using the wp_viewporter protocol. A + * compositor can still emit close, maximize or fullscreen events, using for + * instance a keybind mechanism. If neither of these protocols is supported, + * the window won't be decorated. + * + * @remark @wayland A full screen window will not attempt to change the mode, + * no matter what the requested size or refresh rate. + * + * @remark @wayland Screensaver inhibition requires the idle-inhibit protocol + * to be implemented in the user's compositor. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_creation + * @sa @ref glfwDestroyWindow + * + * @since Added in version 3.0. Replaces `glfwOpenWindow`. + * + * @ingroup window + */ +GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share); + +/*! @brief Destroys the specified window and its context. + * + * This function destroys the specified window and its context. On calling + * this function, no further callbacks will be called for that window. + * + * If the context of the specified window is current on the main thread, it is + * detached before being destroyed. + * + * @param[in] window The window to destroy. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @note The context of the specified window must not be current on any other + * thread when this function is called. + * + * @reentrancy This function must not be called from a callback. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_creation + * @sa @ref glfwCreateWindow + * + * @since Added in version 3.0. Replaces `glfwCloseWindow`. + * + * @ingroup window + */ +GLFWAPI void glfwDestroyWindow(GLFWwindow* window); + +/*! @brief Checks the close flag of the specified window. + * + * This function returns the value of the close flag of the specified window. + * + * @param[in] window The window to query. + * @return The value of the close flag. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @sa @ref window_close + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI int glfwWindowShouldClose(GLFWwindow* window); + +/*! @brief Sets the close flag of the specified window. + * + * This function sets the value of the close flag of the specified window. + * This can be used to override the user's attempt to close the window, or + * to signal that it should be closed. + * + * @param[in] window The window whose flag to change. + * @param[in] value The new value. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @sa @ref window_close + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value); + +/*! @brief Sets the title of the specified window. + * + * This function sets the window title, encoded as UTF-8, of the specified + * window. + * + * @param[in] window The window whose title to change. + * @param[in] title The UTF-8 encoded window title. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @macos The window title will not be updated until the next time you + * process events. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_title + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); + +/*! @brief Sets the icon for the specified window. + * + * This function sets the icon of the specified window. If passed an array of + * candidate images, those of or closest to the sizes desired by the system are + * selected. If no images are specified, the window reverts to its default + * icon. + * + * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight + * bits per channel with the red channel first. They are arranged canonically + * as packed sequential rows, starting from the top-left corner. + * + * The desired image sizes varies depending on platform and system settings. + * The selected images will be rescaled as needed. Good sizes include 16x16, + * 32x32 and 48x48. + * + * @param[in] window The window whose icon to set. + * @param[in] count The number of images in the specified array, or zero to + * revert to the default window icon. + * @param[in] images The images to create the icon from. This is ignored if + * count is zero. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @pointer_lifetime The specified image data is copied before this function + * returns. + * + * @remark @macos The GLFW window has no icon, as it is not a document + * window, so this function does nothing. The dock icon will be the same as + * the application bundle's icon. For more information on bundles, see the + * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) + * in the Mac Developer Library. + * + * @remark @wayland There is no existing protocol to change an icon, the + * window will thus inherit the one defined in the application's desktop file. + * This function always emits @ref GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_icon + * + * @since Added in version 3.2. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images); + +/*! @brief Retrieves the position of the content area of the specified window. + * + * This function retrieves the position, in screen coordinates, of the + * upper-left corner of the content area of the specified window. + * + * Any or all of the position arguments may be `NULL`. If an error occurs, all + * non-`NULL` position arguments will be set to zero. + * + * @param[in] window The window to query. + * @param[out] xpos Where to store the x-coordinate of the upper-left corner of + * the content area, or `NULL`. + * @param[out] ypos Where to store the y-coordinate of the upper-left corner of + * the content area, or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @wayland There is no way for an application to retrieve the global + * position of its windows, this function will always emit @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_pos + * @sa @ref glfwSetWindowPos + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); + +/*! @brief Sets the position of the content area of the specified window. + * + * This function sets the position, in screen coordinates, of the upper-left + * corner of the content area of the specified windowed mode window. If the + * window is a full screen window, this function does nothing. + * + * __Do not use this function__ to move an already visible window unless you + * have very good reasons for doing so, as it will confuse and annoy the user. + * + * The window manager may put limits on what positions are allowed. GLFW + * cannot and should not override these limits. + * + * @param[in] window The window to query. + * @param[in] xpos The x-coordinate of the upper-left corner of the content area. + * @param[in] ypos The y-coordinate of the upper-left corner of the content area. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @wayland There is no way for an application to set the global + * position of its windows, this function will always emit @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_pos + * @sa @ref glfwGetWindowPos + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); + +/*! @brief Retrieves the size of the content area of the specified window. + * + * This function retrieves the size, in screen coordinates, of the content area + * of the specified window. If you wish to retrieve the size of the + * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize. + * + * Any or all of the size arguments may be `NULL`. If an error occurs, all + * non-`NULL` size arguments will be set to zero. + * + * @param[in] window The window whose size to retrieve. + * @param[out] width Where to store the width, in screen coordinates, of the + * content area, or `NULL`. + * @param[out] height Where to store the height, in screen coordinates, of the + * content area, or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_size + * @sa @ref glfwSetWindowSize + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter. + * + * @ingroup window + */ +GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); + +/*! @brief Sets the size limits of the specified window. + * + * This function sets the size limits of the content area of the specified + * window. If the window is full screen, the size limits only take effect + * once it is made windowed. If the window is not resizable, this function + * does nothing. + * + * The size limits are applied immediately to a windowed mode window and may + * cause it to be resized. + * + * The maximum dimensions must be greater than or equal to the minimum + * dimensions and all must be greater than or equal to zero. + * + * @param[in] window The window to set limits for. + * @param[in] minwidth The minimum width, in screen coordinates, of the content + * area, or `GLFW_DONT_CARE`. + * @param[in] minheight The minimum height, in screen coordinates, of the + * content area, or `GLFW_DONT_CARE`. + * @param[in] maxwidth The maximum width, in screen coordinates, of the content + * area, or `GLFW_DONT_CARE`. + * @param[in] maxheight The maximum height, in screen coordinates, of the + * content area, or `GLFW_DONT_CARE`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR. + * + * @remark If you set size limits and an aspect ratio that conflict, the + * results are undefined. + * + * @remark @wayland The size limits will not be applied until the window is + * actually resized, either by the user or by the compositor. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_sizelimits + * @sa @ref glfwSetWindowAspectRatio + * + * @since Added in version 3.2. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); + +/*! @brief Sets the aspect ratio of the specified window. + * + * This function sets the required aspect ratio of the content area of the + * specified window. If the window is full screen, the aspect ratio only takes + * effect once it is made windowed. If the window is not resizable, this + * function does nothing. + * + * The aspect ratio is specified as a numerator and a denominator and both + * values must be greater than zero. For example, the common 16:9 aspect ratio + * is specified as 16 and 9, respectively. + * + * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect + * ratio limit is disabled. + * + * The aspect ratio is applied immediately to a windowed mode window and may + * cause it to be resized. + * + * @param[in] window The window to set limits for. + * @param[in] numer The numerator of the desired aspect ratio, or + * `GLFW_DONT_CARE`. + * @param[in] denom The denominator of the desired aspect ratio, or + * `GLFW_DONT_CARE`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR. + * + * @remark If you set size limits and an aspect ratio that conflict, the + * results are undefined. + * + * @remark @wayland The aspect ratio will not be applied until the window is + * actually resized, either by the user or by the compositor. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_sizelimits + * @sa @ref glfwSetWindowSizeLimits + * + * @since Added in version 3.2. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom); + +/*! @brief Sets the size of the content area of the specified window. + * + * This function sets the size, in screen coordinates, of the content area of + * the specified window. + * + * For full screen windows, this function updates the resolution of its desired + * video mode and switches to the video mode closest to it, without affecting + * the window's context. As the context is unaffected, the bit depths of the + * framebuffer remain unchanged. + * + * If you wish to update the refresh rate of the desired video mode in addition + * to its resolution, see @ref glfwSetWindowMonitor. + * + * The window manager may put limits on what sizes are allowed. GLFW cannot + * and should not override these limits. + * + * @param[in] window The window to resize. + * @param[in] width The desired width, in screen coordinates, of the window + * content area. + * @param[in] height The desired height, in screen coordinates, of the window + * content area. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @wayland A full screen window will not attempt to change the mode, + * no matter what the requested size. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_size + * @sa @ref glfwGetWindowSize + * @sa @ref glfwSetWindowMonitor + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height); + +/*! @brief Retrieves the size of the framebuffer of the specified window. + * + * This function retrieves the size, in pixels, of the framebuffer of the + * specified window. If you wish to retrieve the size of the window in screen + * coordinates, see @ref glfwGetWindowSize. + * + * Any or all of the size arguments may be `NULL`. If an error occurs, all + * non-`NULL` size arguments will be set to zero. + * + * @param[in] window The window whose framebuffer to query. + * @param[out] width Where to store the width, in pixels, of the framebuffer, + * or `NULL`. + * @param[out] height Where to store the height, in pixels, of the framebuffer, + * or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_fbsize + * @sa @ref glfwSetFramebufferSizeCallback + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height); + +/*! @brief Retrieves the size of the frame of the window. + * + * This function retrieves the size, in screen coordinates, of each edge of the + * frame of the specified window. This size includes the title bar, if the + * window has one. The size of the frame may vary depending on the + * [window-related hints](@ref window_hints_wnd) used to create it. + * + * Because this function retrieves the size of each window frame edge and not + * the offset along a particular coordinate axis, the retrieved values will + * always be zero or positive. + * + * Any or all of the size arguments may be `NULL`. If an error occurs, all + * non-`NULL` size arguments will be set to zero. + * + * @param[in] window The window whose frame size to query. + * @param[out] left Where to store the size, in screen coordinates, of the left + * edge of the window frame, or `NULL`. + * @param[out] top Where to store the size, in screen coordinates, of the top + * edge of the window frame, or `NULL`. + * @param[out] right Where to store the size, in screen coordinates, of the + * right edge of the window frame, or `NULL`. + * @param[out] bottom Where to store the size, in screen coordinates, of the + * bottom edge of the window frame, or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_size + * + * @since Added in version 3.1. + * + * @ingroup window + */ +GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom); + +/*! @brief Retrieves the content scale for the specified window. + * + * This function retrieves the content scale for the specified window. The + * content scale is the ratio between the current DPI and the platform's + * default DPI. This is especially important for text and any UI elements. If + * the pixel dimensions of your UI scaled by this look appropriate on your + * machine then it should appear at a reasonable size on other machines + * regardless of their DPI and scaling settings. This relies on the system DPI + * and scaling settings being somewhat correct. + * + * On systems where each monitors can have its own content scale, the window + * content scale will depend on which monitor the system considers the window + * to be on. + * + * @param[in] window The window to query. + * @param[out] xscale Where to store the x-axis content scale, or `NULL`. + * @param[out] yscale Where to store the y-axis content scale, or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_scale + * @sa @ref glfwSetWindowContentScaleCallback + * @sa @ref glfwGetMonitorContentScale + * + * @since Added in version 3.3. + * + * @ingroup window + */ +GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale); + +/*! @brief Returns the opacity of the whole window. + * + * This function returns the opacity of the window, including any decorations. + * + * The opacity (or alpha) value is a positive finite number between zero and + * one, where zero is fully transparent and one is fully opaque. If the system + * does not support whole window transparency, this function always returns one. + * + * The initial opacity value for newly created windows is one. + * + * @param[in] window The window to query. + * @return The opacity value of the specified window. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_transparency + * @sa @ref glfwSetWindowOpacity + * + * @since Added in version 3.3. + * + * @ingroup window + */ +GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window); + +/*! @brief Sets the opacity of the whole window. + * + * This function sets the opacity of the window, including any decorations. + * + * The opacity (or alpha) value is a positive finite number between zero and + * one, where zero is fully transparent and one is fully opaque. + * + * The initial opacity value for newly created windows is one. + * + * A window created with framebuffer transparency may not use whole window + * transparency. The results of doing this are undefined. + * + * @param[in] window The window to set the opacity for. + * @param[in] opacity The desired opacity of the specified window. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_transparency + * @sa @ref glfwGetWindowOpacity + * + * @since Added in version 3.3. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity); + +/*! @brief Iconifies the specified window. + * + * This function iconifies (minimizes) the specified window if it was + * previously restored. If the window is already iconified, this function does + * nothing. + * + * If the specified window is a full screen window, the original monitor + * resolution is restored until the window is restored. + * + * @param[in] window The window to iconify. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @wayland There is no concept of iconification in wl_shell, this + * function will emit @ref GLFW_PLATFORM_ERROR when using this deprecated + * protocol. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_iconify + * @sa @ref glfwRestoreWindow + * @sa @ref glfwMaximizeWindow + * + * @since Added in version 2.1. + * @glfw3 Added window handle parameter. + * + * @ingroup window + */ +GLFWAPI void glfwIconifyWindow(GLFWwindow* window); + +/*! @brief Restores the specified window. + * + * This function restores the specified window if it was previously iconified + * (minimized) or maximized. If the window is already restored, this function + * does nothing. + * + * If the specified window is a full screen window, the resolution chosen for + * the window is restored on the selected monitor. + * + * @param[in] window The window to restore. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_iconify + * @sa @ref glfwIconifyWindow + * @sa @ref glfwMaximizeWindow + * + * @since Added in version 2.1. + * @glfw3 Added window handle parameter. + * + * @ingroup window + */ +GLFWAPI void glfwRestoreWindow(GLFWwindow* window); + +/*! @brief Maximizes the specified window. + * + * This function maximizes the specified window if it was previously not + * maximized. If the window is already maximized, this function does nothing. + * + * If the specified window is a full screen window, this function does nothing. + * + * @param[in] window The window to maximize. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @par Thread Safety + * This function may only be called from the main thread. + * + * @sa @ref window_iconify + * @sa @ref glfwIconifyWindow + * @sa @ref glfwRestoreWindow + * + * @since Added in GLFW 3.2. + * + * @ingroup window + */ +GLFWAPI void glfwMaximizeWindow(GLFWwindow* window); + +/*! @brief Makes the specified window visible. + * + * This function makes the specified window visible if it was previously + * hidden. If the window is already visible or is in full screen mode, this + * function does nothing. + * + * By default, windowed mode windows are focused when shown + * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint + * to change this behavior for all newly created windows, or change the + * behavior for an existing window with @ref glfwSetWindowAttrib. + * + * @param[in] window The window to make visible. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @wayland Because Wayland wants every frame of the desktop to be + * complete, this function does not immediately make the window visible. + * Instead it will become visible the next time the window framebuffer is + * updated after this call. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_hide + * @sa @ref glfwHideWindow + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI void glfwShowWindow(GLFWwindow* window); + +/*! @brief Hides the specified window. + * + * This function hides the specified window if it was previously visible. If + * the window is already hidden or is in full screen mode, this function does + * nothing. + * + * @param[in] window The window to hide. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_hide + * @sa @ref glfwShowWindow + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI void glfwHideWindow(GLFWwindow* window); + +/*! @brief Brings the specified window to front and sets input focus. + * + * This function brings the specified window to front and sets input focus. + * The window should already be visible and not iconified. + * + * By default, both windowed and full screen mode windows are focused when + * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to + * disable this behavior. + * + * Also by default, windowed mode windows are focused when shown + * with @ref glfwShowWindow. Set the + * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior. + * + * __Do not use this function__ to steal focus from other applications unless + * you are certain that is what the user wants. Focus stealing can be + * extremely disruptive. + * + * For a less disruptive way of getting the user's attention, see + * [attention requests](@ref window_attention). + * + * @param[in] window The window to give input focus. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @wayland It is not possible for an application to bring its windows + * to front, this function will always emit @ref GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_focus + * @sa @ref window_attention + * + * @since Added in version 3.2. + * + * @ingroup window + */ +GLFWAPI void glfwFocusWindow(GLFWwindow* window); + +/*! @brief Requests user attention to the specified window. + * + * This function requests user attention to the specified window. On + * platforms where this is not supported, attention is requested to the + * application as a whole. + * + * Once the user has given attention, usually by focusing the window or + * application, the system will end the request automatically. + * + * @param[in] window The window to request attention to. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @macos Attention is requested to the application as a whole, not the + * specific window. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_attention + * + * @since Added in version 3.3. + * + * @ingroup window + */ +GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window); + +/*! @brief Returns the monitor that the window uses for full screen mode. + * + * This function returns the handle of the monitor that the specified window is + * in full screen on. + * + * @param[in] window The window to query. + * @return The monitor, or `NULL` if the window is in windowed mode or an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_monitor + * @sa @ref glfwSetWindowMonitor + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); + +/*! @brief Sets the mode, monitor, video mode and placement of a window. + * + * This function sets the monitor that the window uses for full screen mode or, + * if the monitor is `NULL`, makes it windowed mode. + * + * When setting a monitor, this function updates the width, height and refresh + * rate of the desired video mode and switches to the video mode closest to it. + * The window position is ignored when setting a monitor. + * + * When the monitor is `NULL`, the position, width and height are used to + * place the window content area. The refresh rate is ignored when no monitor + * is specified. + * + * If you only wish to update the resolution of a full screen window or the + * size of a windowed mode window, see @ref glfwSetWindowSize. + * + * When a window transitions from full screen to windowed mode, this function + * restores any previous window settings such as whether it is decorated, + * floating, resizable, has size or aspect ratio limits, etc. + * + * @param[in] window The window whose monitor, size or video mode to set. + * @param[in] monitor The desired monitor, or `NULL` to set windowed mode. + * @param[in] xpos The desired x-coordinate of the upper-left corner of the + * content area. + * @param[in] ypos The desired y-coordinate of the upper-left corner of the + * content area. + * @param[in] width The desired with, in screen coordinates, of the content + * area or video mode. + * @param[in] height The desired height, in screen coordinates, of the content + * area or video mode. + * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode, + * or `GLFW_DONT_CARE`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise + * affected by any resizing or mode switching, although you may need to update + * your viewport if the framebuffer size has changed. + * + * @remark @wayland The desired window position is ignored, as there is no way + * for an application to set this property. + * + * @remark @wayland Setting the window to full screen will not attempt to + * change the mode, no matter what the requested size or refresh rate. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_monitor + * @sa @ref window_full_screen + * @sa @ref glfwGetWindowMonitor + * @sa @ref glfwSetWindowSize + * + * @since Added in version 3.2. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); + +/*! @brief Returns an attribute of the specified window. + * + * This function returns the value of an attribute of the specified window or + * its OpenGL or OpenGL ES context. + * + * @param[in] window The window to query. + * @param[in] attrib The [window attribute](@ref window_attribs) whose value to + * return. + * @return The value of the attribute, or zero if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * + * @remark Framebuffer related hints are not window attributes. See @ref + * window_attribs_fb for more information. + * + * @remark Zero is a valid value for many window and context related + * attributes so you cannot use a return value of zero as an indication of + * errors. However, this function should not fail as long as it is passed + * valid arguments and the library has been [initialized](@ref intro_init). + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_attribs + * @sa @ref glfwSetWindowAttrib + * + * @since Added in version 3.0. Replaces `glfwGetWindowParam` and + * `glfwGetGLVersion`. + * + * @ingroup window + */ +GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); + +/*! @brief Sets an attribute of the specified window. + * + * This function sets the value of an attribute of the specified window. + * + * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib), + * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib), + * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib), + * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and + * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib). + * + * Some of these attributes are ignored for full screen windows. The new + * value will take effect if the window is later made windowed. + * + * Some of these attributes are ignored for windowed mode windows. The new + * value will take effect if the window is later made full screen. + * + * @param[in] window The window to set the attribute for. + * @param[in] attrib A supported window attribute. + * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR. + * + * @remark Calling @ref glfwGetWindowAttrib will always return the latest + * value, even if that value is ignored by the current mode of the window. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_attribs + * @sa @ref glfwGetWindowAttrib + * + * @since Added in version 3.3. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value); + +/*! @brief Sets the user pointer of the specified window. + * + * This function sets the user-defined pointer of the specified window. The + * current value is retained until the window is destroyed. The initial value + * is `NULL`. + * + * @param[in] window The window whose pointer to set. + * @param[in] pointer The new value. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @sa @ref window_userptr + * @sa @ref glfwGetWindowUserPointer + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer); + +/*! @brief Returns the user pointer of the specified window. + * + * This function returns the current value of the user-defined pointer of the + * specified window. The initial value is `NULL`. + * + * @param[in] window The window whose pointer to return. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @sa @ref window_userptr + * @sa @ref glfwSetWindowUserPointer + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); + +/*! @brief Sets the position callback for the specified window. + * + * This function sets the position callback of the specified window, which is + * called when the window is moved. The callback is provided with the + * position, in screen coordinates, of the upper-left corner of the content + * area of the window. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int xpos, int ypos) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowposfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @remark @wayland This callback will never be called, as there is no way for + * an application to know its global position. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_pos + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback); + +/*! @brief Sets the size callback for the specified window. + * + * This function sets the size callback of the specified window, which is + * called when the window is resized. The callback is provided with the size, + * in screen coordinates, of the content area of the window. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int width, int height) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowsizefun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_size + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter and return value. + * + * @ingroup window + */ +GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback); + +/*! @brief Sets the close callback for the specified window. + * + * This function sets the close callback of the specified window, which is + * called when the user attempts to close the window, for example by clicking + * the close widget in the title bar. + * + * The close flag is set before this callback is called, but you can modify it + * at any time with @ref glfwSetWindowShouldClose. + * + * The close callback is not triggered by @ref glfwDestroyWindow. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowclosefun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @remark @macos Selecting Quit from the application menu will trigger the + * close callback for all windows. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_close + * + * @since Added in version 2.5. + * @glfw3 Added window handle parameter and return value. + * + * @ingroup window + */ +GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback); + +/*! @brief Sets the refresh callback for the specified window. + * + * This function sets the refresh callback of the specified window, which is + * called when the content area of the window needs to be redrawn, for example + * if the window has been exposed after having been covered by another window. + * + * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where + * the window contents are saved off-screen, this callback may be called only + * very infrequently or never at all. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window); + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowrefreshfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_refresh + * + * @since Added in version 2.5. + * @glfw3 Added window handle parameter and return value. + * + * @ingroup window + */ +GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback); + +/*! @brief Sets the focus callback for the specified window. + * + * This function sets the focus callback of the specified window, which is + * called when the window gains or loses input focus. + * + * After the focus callback is called for a window that lost input focus, + * synthetic key and mouse button release events will be generated for all such + * that had been pressed. For more information, see @ref glfwSetKeyCallback + * and @ref glfwSetMouseButtonCallback. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int focused) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowfocusfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_focus + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback); + +/*! @brief Sets the iconify callback for the specified window. + * + * This function sets the iconification callback of the specified window, which + * is called when the window is iconified or restored. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int iconified) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowiconifyfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @remark @wayland The wl_shell protocol has no concept of iconification, + * this callback will never be called when using this deprecated protocol. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_iconify + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback); + +/*! @brief Sets the maximize callback for the specified window. + * + * This function sets the maximization callback of the specified window, which + * is called when the window is maximized or restored. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int maximized) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowmaximizefun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_maximize + * + * @since Added in version 3.3. + * + * @ingroup window + */ +GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback); + +/*! @brief Sets the framebuffer resize callback for the specified window. + * + * This function sets the framebuffer resize callback of the specified window, + * which is called when the framebuffer of the specified window is resized. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int width, int height) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWframebuffersizefun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_fbsize + * + * @since Added in version 3.0. + * + * @ingroup window + */ +GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback); + +/*! @brief Sets the window content scale callback for the specified window. + * + * This function sets the window content scale callback of the specified window, + * which is called when the content scale of the specified window changes. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, float xscale, float yscale) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWwindowcontentscalefun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_scale + * @sa @ref glfwGetWindowContentScale + * + * @since Added in version 3.3. + * + * @ingroup window + */ +GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback); + +/*! @brief Processes all pending events. + * + * This function processes only those events that are already in the event + * queue and then returns immediately. Processing events will cause the window + * and input callbacks associated with those events to be called. + * + * On some platforms, a window move, resize or menu operation will cause event + * processing to block. This is due to how event processing is designed on + * those platforms. You can use the + * [window refresh callback](@ref window_refresh) to redraw the contents of + * your window when necessary during such operations. + * + * Do not assume that callbacks you set will _only_ be called in response to + * event processing functions like this one. While it is necessary to poll for + * events, window systems that require GLFW to register callbacks of its own + * can pass events to GLFW in response to many window system function calls. + * GLFW will pass those events on to the application callbacks before + * returning. + * + * Event processing is not required for joystick input to work. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @reentrancy This function must not be called from a callback. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref events + * @sa @ref glfwWaitEvents + * @sa @ref glfwWaitEventsTimeout + * + * @since Added in version 1.0. + * + * @ingroup window + */ +GLFWAPI void glfwPollEvents(void); + +/*! @brief Waits until events are queued and processes them. + * + * This function puts the calling thread to sleep until at least one event is + * available in the event queue. Once one or more events are available, + * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue + * are processed and the function then returns immediately. Processing events + * will cause the window and input callbacks associated with those events to be + * called. + * + * Since not all events are associated with callbacks, this function may return + * without a callback having been called even if you are monitoring all + * callbacks. + * + * On some platforms, a window move, resize or menu operation will cause event + * processing to block. This is due to how event processing is designed on + * those platforms. You can use the + * [window refresh callback](@ref window_refresh) to redraw the contents of + * your window when necessary during such operations. + * + * Do not assume that callbacks you set will _only_ be called in response to + * event processing functions like this one. While it is necessary to poll for + * events, window systems that require GLFW to register callbacks of its own + * can pass events to GLFW in response to many window system function calls. + * GLFW will pass those events on to the application callbacks before + * returning. + * + * Event processing is not required for joystick input to work. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @reentrancy This function must not be called from a callback. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref events + * @sa @ref glfwPollEvents + * @sa @ref glfwWaitEventsTimeout + * + * @since Added in version 2.5. + * + * @ingroup window + */ +GLFWAPI void glfwWaitEvents(void); + +/*! @brief Waits with timeout until events are queued and processes them. + * + * This function puts the calling thread to sleep until at least one event is + * available in the event queue, or until the specified timeout is reached. If + * one or more events are available, it behaves exactly like @ref + * glfwPollEvents, i.e. the events in the queue are processed and the function + * then returns immediately. Processing events will cause the window and input + * callbacks associated with those events to be called. + * + * The timeout value must be a positive finite number. + * + * Since not all events are associated with callbacks, this function may return + * without a callback having been called even if you are monitoring all + * callbacks. + * + * On some platforms, a window move, resize or menu operation will cause event + * processing to block. This is due to how event processing is designed on + * those platforms. You can use the + * [window refresh callback](@ref window_refresh) to redraw the contents of + * your window when necessary during such operations. + * + * Do not assume that callbacks you set will _only_ be called in response to + * event processing functions like this one. While it is necessary to poll for + * events, window systems that require GLFW to register callbacks of its own + * can pass events to GLFW in response to many window system function calls. + * GLFW will pass those events on to the application callbacks before + * returning. + * + * Event processing is not required for joystick input to work. + * + * @param[in] timeout The maximum amount of time, in seconds, to wait. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR. + * + * @reentrancy This function must not be called from a callback. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref events + * @sa @ref glfwPollEvents + * @sa @ref glfwWaitEvents + * + * @since Added in version 3.2. + * + * @ingroup window + */ +GLFWAPI void glfwWaitEventsTimeout(double timeout); + +/*! @brief Posts an empty event to the event queue. + * + * This function posts an empty event from the current thread to the event + * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref events + * @sa @ref glfwWaitEvents + * @sa @ref glfwWaitEventsTimeout + * + * @since Added in version 3.1. + * + * @ingroup window + */ +GLFWAPI void glfwPostEmptyEvent(void); + +/*! @brief Returns the value of an input option for the specified window. + * + * This function returns the value of an input option for the specified window. + * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS, + * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or + * @ref GLFW_RAW_MOUSE_MOTION. + * + * @param[in] window The window to query. + * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`, + * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or + * `GLFW_RAW_MOUSE_MOTION`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_ENUM. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref glfwSetInputMode + * + * @since Added in version 3.0. + * + * @ingroup input + */ +GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); + +/*! @brief Sets an input option for the specified window. + * + * This function sets an input mode option for the specified window. The mode + * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS, + * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or + * @ref GLFW_RAW_MOUSE_MOTION. + * + * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor + * modes: + * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally. + * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the + * content area of the window but does not restrict the cursor from leaving. + * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual + * and unlimited cursor movement. This is useful for implementing for + * example 3D camera controls. + * + * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to + * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are + * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS` + * the next time it is called even if the key had been released before the + * call. This is useful when you are only interested in whether keys have been + * pressed but not when or in which order. + * + * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either + * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it. + * If sticky mouse buttons are enabled, a mouse button press will ensure that + * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even + * if the mouse button had been released before the call. This is useful when + * you are only interested in whether mouse buttons have been pressed but not + * when or in which order. + * + * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to + * enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled, + * callbacks that receive modifier bits will also have the @ref + * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on, + * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on. + * + * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE` + * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is + * disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported, + * attempting to set this will emit @ref GLFW_PLATFORM_ERROR. Call @ref + * glfwRawMouseMotionSupported to check for support. + * + * @param[in] window The window whose input mode to set. + * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`, + * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or + * `GLFW_RAW_MOUSE_MOTION`. + * @param[in] value The new value of the specified input mode. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref glfwGetInputMode + * + * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`. + * + * @ingroup input + */ +GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value); + +/*! @brief Returns whether raw mouse motion is supported. + * + * This function returns whether raw mouse motion is supported on the current + * system. This status does not change after GLFW has been initialized so you + * only need to check this once. If you attempt to enable raw motion on + * a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted. + * + * Raw mouse motion is closer to the actual motion of the mouse across + * a surface. It is not affected by the scaling and acceleration applied to + * the motion of the desktop cursor. That processing is suitable for a cursor + * while raw motion is better for controlling for example a 3D camera. Because + * of this, raw mouse motion is only provided when the cursor is disabled. + * + * @return `GLFW_TRUE` if raw mouse motion is supported on the current machine, + * or `GLFW_FALSE` otherwise. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref raw_mouse_motion + * @sa @ref glfwSetInputMode + * + * @since Added in version 3.3. + * + * @ingroup input + */ +GLFWAPI int glfwRawMouseMotionSupported(void); + +/*! @brief Returns the layout-specific name of the specified printable key. + * + * This function returns the name of the specified printable key, encoded as + * UTF-8. This is typically the character that key would produce without any + * modifier keys, intended for displaying key bindings to the user. For dead + * keys, it is typically the diacritic it would add to a character. + * + * __Do not use this function__ for [text input](@ref input_char). You will + * break text input for many languages even if it happens to work for yours. + * + * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key, + * otherwise the scancode is ignored. If you specify a non-printable key, or + * `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this + * function returns `NULL` but does not emit an error. + * + * This behavior allows you to always pass in the arguments in the + * [key callback](@ref input_key) without modification. + * + * The printable keys are: + * - `GLFW_KEY_APOSTROPHE` + * - `GLFW_KEY_COMMA` + * - `GLFW_KEY_MINUS` + * - `GLFW_KEY_PERIOD` + * - `GLFW_KEY_SLASH` + * - `GLFW_KEY_SEMICOLON` + * - `GLFW_KEY_EQUAL` + * - `GLFW_KEY_LEFT_BRACKET` + * - `GLFW_KEY_RIGHT_BRACKET` + * - `GLFW_KEY_BACKSLASH` + * - `GLFW_KEY_WORLD_1` + * - `GLFW_KEY_WORLD_2` + * - `GLFW_KEY_0` to `GLFW_KEY_9` + * - `GLFW_KEY_A` to `GLFW_KEY_Z` + * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9` + * - `GLFW_KEY_KP_DECIMAL` + * - `GLFW_KEY_KP_DIVIDE` + * - `GLFW_KEY_KP_MULTIPLY` + * - `GLFW_KEY_KP_SUBTRACT` + * - `GLFW_KEY_KP_ADD` + * - `GLFW_KEY_KP_EQUAL` + * + * Names for printable keys depend on keyboard layout, while names for + * non-printable keys are the same across layouts but depend on the application + * language and should be localized along with other user interface text. + * + * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`. + * @param[in] scancode The scancode of the key to query. + * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark The contents of the returned string may change when a keyboard + * layout change event is received. + * + * @pointer_lifetime The returned string is allocated and freed by GLFW. You + * should not free it yourself. It is valid until the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref input_key_name + * + * @since Added in version 3.2. + * + * @ingroup input + */ +GLFWAPI const char* glfwGetKeyName(int key, int scancode); + +/*! @brief Returns the platform-specific scancode of the specified key. + * + * This function returns the platform-specific scancode of the specified key. + * + * If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this + * method will return `-1`. + * + * @param[in] key Any [named key](@ref keys). + * @return The platform-specific scancode for the key, or `-1` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref input_key + * + * @since Added in version 3.3. + * + * @ingroup input + */ +GLFWAPI int glfwGetKeyScancode(int key); + +/*! @brief Returns the last reported state of a keyboard key for the specified + * window. + * + * This function returns the last state reported for the specified key to the + * specified window. The returned state is one of `GLFW_PRESS` or + * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to + * the key callback. + * + * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns + * `GLFW_PRESS` the first time you call it for a key that was pressed, even if + * that key has already been released. + * + * The key functions deal with physical keys, with [key tokens](@ref keys) + * named after their use on the standard US keyboard layout. If you want to + * input text, use the Unicode character callback instead. + * + * The [modifier key bit masks](@ref mods) are not key tokens and cannot be + * used with this function. + * + * __Do not use this function__ to implement [text input](@ref input_char). + * + * @param[in] window The desired window. + * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is + * not a valid key for this function. + * @return One of `GLFW_PRESS` or `GLFW_RELEASE`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_ENUM. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref input_key + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter. + * + * @ingroup input + */ +GLFWAPI int glfwGetKey(GLFWwindow* window, int key); + +/*! @brief Returns the last reported state of a mouse button for the specified + * window. + * + * This function returns the last state reported for the specified mouse button + * to the specified window. The returned state is one of `GLFW_PRESS` or + * `GLFW_RELEASE`. + * + * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function + * returns `GLFW_PRESS` the first time you call it for a mouse button that was + * pressed, even if that mouse button has already been released. + * + * @param[in] window The desired window. + * @param[in] button The desired [mouse button](@ref buttons). + * @return One of `GLFW_PRESS` or `GLFW_RELEASE`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_ENUM. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref input_mouse_button + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter. + * + * @ingroup input + */ +GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button); + +/*! @brief Retrieves the position of the cursor relative to the content area of + * the window. + * + * This function returns the position of the cursor, in screen coordinates, + * relative to the upper-left corner of the content area of the specified + * window. + * + * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor + * position is unbounded and limited only by the minimum and maximum values of + * a `double`. + * + * The coordinate can be converted to their integer equivalents with the + * `floor` function. Casting directly to an integer type works for positive + * coordinates, but fails for negative ones. + * + * Any or all of the position arguments may be `NULL`. If an error occurs, all + * non-`NULL` position arguments will be set to zero. + * + * @param[in] window The desired window. + * @param[out] xpos Where to store the cursor x-coordinate, relative to the + * left edge of the content area, or `NULL`. + * @param[out] ypos Where to store the cursor y-coordinate, relative to the to + * top edge of the content area, or `NULL`. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref cursor_pos + * @sa @ref glfwSetCursorPos + * + * @since Added in version 3.0. Replaces `glfwGetMousePos`. + * + * @ingroup input + */ +GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); + +/*! @brief Sets the position of the cursor, relative to the content area of the + * window. + * + * This function sets the position, in screen coordinates, of the cursor + * relative to the upper-left corner of the content area of the specified + * window. The window must have input focus. If the window does not have + * input focus when this function is called, it fails silently. + * + * __Do not use this function__ to implement things like camera controls. GLFW + * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the + * cursor, transparently re-centers it and provides unconstrained cursor + * motion. See @ref glfwSetInputMode for more information. + * + * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is + * unconstrained and limited only by the minimum and maximum values of + * a `double`. + * + * @param[in] window The desired window. + * @param[in] xpos The desired x-coordinate, relative to the left edge of the + * content area. + * @param[in] ypos The desired y-coordinate, relative to the top edge of the + * content area. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @wayland This function will only work when the cursor mode is + * `GLFW_CURSOR_DISABLED`, otherwise it will do nothing. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref cursor_pos + * @sa @ref glfwGetCursorPos + * + * @since Added in version 3.0. Replaces `glfwSetMousePos`. + * + * @ingroup input + */ +GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos); + +/*! @brief Creates a custom cursor. + * + * Creates a new custom cursor image that can be set for a window with @ref + * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor. + * Any remaining cursors are destroyed by @ref glfwTerminate. + * + * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight + * bits per channel with the red channel first. They are arranged canonically + * as packed sequential rows, starting from the top-left corner. + * + * The cursor hotspot is specified in pixels, relative to the upper-left corner + * of the cursor image. Like all other coordinate systems in GLFW, the X-axis + * points to the right and the Y-axis points down. + * + * @param[in] image The desired cursor image. + * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot. + * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot. + * @return The handle of the created cursor, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @pointer_lifetime The specified image data is copied before this function + * returns. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref cursor_object + * @sa @ref glfwDestroyCursor + * @sa @ref glfwCreateStandardCursor + * + * @since Added in version 3.1. + * + * @ingroup input + */ +GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot); + +/*! @brief Creates a cursor with a standard shape. + * + * Returns a cursor with a [standard shape](@ref shapes), that can be set for + * a window with @ref glfwSetCursor. + * + * @param[in] shape One of the [standard shapes](@ref shapes). + * @return A new cursor ready to use or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref cursor_object + * @sa @ref glfwCreateCursor + * + * @since Added in version 3.1. + * + * @ingroup input + */ +GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape); + +/*! @brief Destroys a cursor. + * + * This function destroys a cursor previously created with @ref + * glfwCreateCursor. Any remaining cursors will be destroyed by @ref + * glfwTerminate. + * + * If the specified cursor is current for any window, that window will be + * reverted to the default cursor. This does not affect the cursor mode. + * + * @param[in] cursor The cursor object to destroy. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @reentrancy This function must not be called from a callback. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref cursor_object + * @sa @ref glfwCreateCursor + * + * @since Added in version 3.1. + * + * @ingroup input + */ +GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor); + +/*! @brief Sets the cursor for the window. + * + * This function sets the cursor image to be used when the cursor is over the + * content area of the specified window. The set cursor will only be visible + * when the [cursor mode](@ref cursor_mode) of the window is + * `GLFW_CURSOR_NORMAL`. + * + * On some platforms, the set cursor may not be visible unless the window also + * has input focus. + * + * @param[in] window The window to set the cursor for. + * @param[in] cursor The cursor to set, or `NULL` to switch back to the default + * arrow cursor. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref cursor_object + * + * @since Added in version 3.1. + * + * @ingroup input + */ +GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); + +/*! @brief Sets the key callback. + * + * This function sets the key callback of the specified window, which is called + * when a key is pressed, repeated or released. + * + * The key functions deal with physical keys, with layout independent + * [key tokens](@ref keys) named after their values in the standard US keyboard + * layout. If you want to input text, use the + * [character callback](@ref glfwSetCharCallback) instead. + * + * When a window loses input focus, it will generate synthetic key release + * events for all pressed keys. You can tell these events from user-generated + * events by the fact that the synthetic ones are generated after the focus + * loss event has been processed, i.e. after the + * [window focus callback](@ref glfwSetWindowFocusCallback) has been called. + * + * The scancode of a key is specific to that platform or sometimes even to that + * machine. Scancodes are intended to allow users to bind keys that don't have + * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their + * state is not saved and so it cannot be queried with @ref glfwGetKey. + * + * Sometimes GLFW needs to generate synthetic key events, in which case the + * scancode may be zero. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new key callback, or `NULL` to remove the currently + * set callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWkeyfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref input_key + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter and return value. + * + * @ingroup input + */ +GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback); + +/*! @brief Sets the Unicode character callback. + * + * This function sets the character callback of the specified window, which is + * called when a Unicode character is input. + * + * The character callback is intended for Unicode text input. As it deals with + * characters, it is keyboard layout dependent, whereas the + * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1 + * to physical keys, as a key may produce zero, one or more characters. If you + * want to know whether a specific physical key was pressed or released, see + * the key callback instead. + * + * The character callback behaves as system text input normally does and will + * not be called if modifier keys are held down that would prevent normal text + * input on that platform, for example a Super (Command) key on macOS or Alt key + * on Windows. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, unsigned int codepoint) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWcharfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref input_char + * + * @since Added in version 2.4. + * @glfw3 Added window handle parameter and return value. + * + * @ingroup input + */ +GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback); + +/*! @brief Sets the Unicode character with modifiers callback. + * + * This function sets the character with modifiers callback of the specified + * window, which is called when a Unicode character is input regardless of what + * modifier keys are used. + * + * The character with modifiers callback is intended for implementing custom + * Unicode character input. For regular Unicode text input, see the + * [character callback](@ref glfwSetCharCallback). Like the character + * callback, the character with modifiers callback deals with characters and is + * keyboard layout dependent. Characters do not map 1:1 to physical keys, as + * a key may produce zero, one or more characters. If you want to know whether + * a specific physical key was pressed or released, see the + * [key callback](@ref glfwSetKeyCallback) instead. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or an + * [error](@ref error_handling) occurred. + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, unsigned int codepoint, int mods) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWcharmodsfun). + * + * @deprecated Scheduled for removal in version 4.0. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref input_char + * + * @since Added in version 3.1. + * + * @ingroup input + */ +GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback); + +/*! @brief Sets the mouse button callback. + * + * This function sets the mouse button callback of the specified window, which + * is called when a mouse button is pressed or released. + * + * When a window loses input focus, it will generate synthetic mouse button + * release events for all pressed mouse buttons. You can tell these events + * from user-generated events by the fact that the synthetic ones are generated + * after the focus loss event has been processed, i.e. after the + * [window focus callback](@ref glfwSetWindowFocusCallback) has been called. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int button, int action, int mods) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWmousebuttonfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref input_mouse_button + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter and return value. + * + * @ingroup input + */ +GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback); + +/*! @brief Sets the cursor position callback. + * + * This function sets the cursor position callback of the specified window, + * which is called when the cursor is moved. The callback is provided with the + * position, in screen coordinates, relative to the upper-left corner of the + * content area of the window. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, double xpos, double ypos); + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWcursorposfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref cursor_pos + * + * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`. + * + * @ingroup input + */ +GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback); + +/*! @brief Sets the cursor enter/leave callback. + * + * This function sets the cursor boundary crossing callback of the specified + * window, which is called when the cursor enters or leaves the content area of + * the window. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int entered) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWcursorenterfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref cursor_enter + * + * @since Added in version 3.0. + * + * @ingroup input + */ +GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback); + +/*! @brief Sets the scroll callback. + * + * This function sets the scroll callback of the specified window, which is + * called when a scrolling device is used, such as a mouse wheel or scrolling + * area of a touchpad. + * + * The scroll callback receives all scrolling input, like that from a mouse + * wheel or a touchpad scrolling area. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new scroll callback, or `NULL` to remove the + * currently set callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, double xoffset, double yoffset) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWscrollfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref scrolling + * + * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`. + * + * @ingroup input + */ +GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback); + +/*! @brief Sets the path drop callback. + * + * This function sets the path drop callback of the specified window, which is + * called when one or more dragged paths are dropped on the window. + * + * Because the path array and its strings may have been generated specifically + * for that event, they are not guaranteed to be valid after the callback has + * returned. If you wish to use them after the callback returns, you need to + * make a deep copy. + * + * @param[in] window The window whose callback to set. + * @param[in] callback The new file drop callback, or `NULL` to remove the + * currently set callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(GLFWwindow* window, int path_count, const char* paths[]) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWdropfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @remark @wayland File drop is currently unimplemented. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref path_drop + * + * @since Added in version 3.1. + * + * @ingroup input + */ +GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback); + +/*! @brief Returns whether the specified joystick is present. + * + * This function returns whether the specified joystick is present. + * + * There is no need to call this function before other functions that accept + * a joystick ID, as they all check for presence before performing any other + * work. + * + * @param[in] jid The [joystick](@ref joysticks) to query. + * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref joystick + * + * @since Added in version 3.0. Replaces `glfwGetJoystickParam`. + * + * @ingroup input + */ +GLFWAPI int glfwJoystickPresent(int jid); + +/*! @brief Returns the values of all axes of the specified joystick. + * + * This function returns the values of all axes of the specified joystick. + * Each element in the array is a value between -1.0 and 1.0. + * + * If the specified joystick is not present this function will return `NULL` + * but will not generate an error. This can be used instead of first calling + * @ref glfwJoystickPresent. + * + * @param[in] jid The [joystick](@ref joysticks) to query. + * @param[out] count Where to store the number of axis values in the returned + * array. This is set to zero if the joystick is not present or an error + * occurred. + * @return An array of axis values, or `NULL` if the joystick is not present or + * an [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * + * @pointer_lifetime The returned array is allocated and freed by GLFW. You + * should not free it yourself. It is valid until the specified joystick is + * disconnected or the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref joystick_axis + * + * @since Added in version 3.0. Replaces `glfwGetJoystickPos`. + * + * @ingroup input + */ +GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count); + +/*! @brief Returns the state of all buttons of the specified joystick. + * + * This function returns the state of all buttons of the specified joystick. + * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`. + * + * For backward compatibility with earlier versions that did not have @ref + * glfwGetJoystickHats, the button array also includes all hats, each + * represented as four buttons. The hats are in the same order as returned by + * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and + * _left_. To disable these extra buttons, set the @ref + * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization. + * + * If the specified joystick is not present this function will return `NULL` + * but will not generate an error. This can be used instead of first calling + * @ref glfwJoystickPresent. + * + * @param[in] jid The [joystick](@ref joysticks) to query. + * @param[out] count Where to store the number of button states in the returned + * array. This is set to zero if the joystick is not present or an error + * occurred. + * @return An array of button states, or `NULL` if the joystick is not present + * or an [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * + * @pointer_lifetime The returned array is allocated and freed by GLFW. You + * should not free it yourself. It is valid until the specified joystick is + * disconnected or the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref joystick_button + * + * @since Added in version 2.2. + * @glfw3 Changed to return a dynamic array. + * + * @ingroup input + */ +GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count); + +/*! @brief Returns the state of all hats of the specified joystick. + * + * This function returns the state of all hats of the specified joystick. + * Each element in the array is one of the following values: + * + * Name | Value + * ---- | ----- + * `GLFW_HAT_CENTERED` | 0 + * `GLFW_HAT_UP` | 1 + * `GLFW_HAT_RIGHT` | 2 + * `GLFW_HAT_DOWN` | 4 + * `GLFW_HAT_LEFT` | 8 + * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP` + * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN` + * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP` + * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN` + * + * The diagonal directions are bitwise combinations of the primary (up, right, + * down and left) directions and you can test for these individually by ANDing + * it with the corresponding direction. + * + * @code + * if (hats[2] & GLFW_HAT_RIGHT) + * { + * // State of hat 2 could be right-up, right or right-down + * } + * @endcode + * + * If the specified joystick is not present this function will return `NULL` + * but will not generate an error. This can be used instead of first calling + * @ref glfwJoystickPresent. + * + * @param[in] jid The [joystick](@ref joysticks) to query. + * @param[out] count Where to store the number of hat states in the returned + * array. This is set to zero if the joystick is not present or an error + * occurred. + * @return An array of hat states, or `NULL` if the joystick is not present + * or an [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * + * @pointer_lifetime The returned array is allocated and freed by GLFW. You + * should not free it yourself. It is valid until the specified joystick is + * disconnected, this function is called again for that joystick or the library + * is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref joystick_hat + * + * @since Added in version 3.3. + * + * @ingroup input + */ +GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count); + +/*! @brief Returns the name of the specified joystick. + * + * This function returns the name, encoded as UTF-8, of the specified joystick. + * The returned string is allocated and freed by GLFW. You should not free it + * yourself. + * + * If the specified joystick is not present this function will return `NULL` + * but will not generate an error. This can be used instead of first calling + * @ref glfwJoystickPresent. + * + * @param[in] jid The [joystick](@ref joysticks) to query. + * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick + * is not present or an [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM 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 specified joystick is + * disconnected or the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref joystick_name + * + * @since Added in version 3.0. + * + * @ingroup input + */ +GLFWAPI const char* glfwGetJoystickName(int jid); + +/*! @brief Returns the SDL compatible GUID of the specified joystick. + * + * This function returns the SDL compatible GUID, as a UTF-8 encoded + * hexadecimal string, of the specified joystick. The returned string is + * allocated and freed by GLFW. You should not free it yourself. + * + * The GUID is what connects a joystick to a gamepad mapping. A connected + * joystick will always have a GUID even if there is no gamepad mapping + * assigned to it. + * + * If the specified joystick is not present this function will return `NULL` + * but will not generate an error. This can be used instead of first calling + * @ref glfwJoystickPresent. + * + * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to + * uniquely identify the make and model of a joystick but does not identify + * a specific unit, e.g. all wired Xbox 360 controllers will have the same + * GUID on that platform. The GUID for a unit may vary between platforms + * depending on what hardware information the platform specific APIs provide. + * + * @param[in] jid The [joystick](@ref joysticks) to query. + * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick + * is not present or an [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_INVALID_ENUM 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 specified joystick is + * disconnected or the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref gamepad + * + * @since Added in version 3.3. + * + * @ingroup input + */ +GLFWAPI const char* glfwGetJoystickGUID(int jid); + +/*! @brief Sets the user pointer of the specified joystick. + * + * This function sets the user-defined pointer of the specified joystick. The + * current value is retained until the joystick is disconnected. The initial + * value is `NULL`. + * + * This function may be called from the joystick callback, even for a joystick + * that is being disconnected. + * + * @param[in] jid The joystick whose pointer to set. + * @param[in] pointer The new value. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @sa @ref joystick_userptr + * @sa @ref glfwGetJoystickUserPointer + * + * @since Added in version 3.3. + * + * @ingroup input + */ +GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer); + +/*! @brief Returns the user pointer of the specified joystick. + * + * This function returns the current value of the user-defined pointer of the + * specified joystick. The initial value is `NULL`. + * + * This function may be called from the joystick callback, even for a joystick + * that is being disconnected. + * + * @param[in] jid The joystick whose pointer to return. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @sa @ref joystick_userptr + * @sa @ref glfwSetJoystickUserPointer + * + * @since Added in version 3.3. + * + * @ingroup input + */ +GLFWAPI void* glfwGetJoystickUserPointer(int jid); + +/*! @brief Returns whether the specified joystick has a gamepad mapping. + * + * This function returns whether the specified joystick is both present and has + * a gamepad mapping. + * + * If the specified joystick is present but does not have a gamepad mapping + * this function will return `GLFW_FALSE` but will not generate an error. Call + * @ref glfwJoystickPresent to check if a joystick is present regardless of + * whether it has a mapping. + * + * @param[in] jid The [joystick](@ref joysticks) to query. + * @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping, + * or `GLFW_FALSE` otherwise. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_ENUM. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref gamepad + * @sa @ref glfwGetGamepadState + * + * @since Added in version 3.3. + * + * @ingroup input + */ +GLFWAPI int glfwJoystickIsGamepad(int jid); + +/*! @brief Sets the joystick configuration callback. + * + * This function sets the joystick configuration callback, or removes the + * currently set callback. This is called when a joystick is connected to or + * disconnected from the system. + * + * For joystick connection and disconnection events to be delivered on all + * platforms, you need to call one of the [event processing](@ref events) + * functions. Joystick disconnection may also be detected and the callback + * called by joystick functions. The function will then return whatever it + * returns if the joystick is not present. + * + * @param[in] callback The new callback, or `NULL` to remove the currently set + * callback. + * @return The previously set callback, or `NULL` if no callback was set or the + * library had not been [initialized](@ref intro_init). + * + * @callback_signature + * @code + * void function_name(int jid, int event) + * @endcode + * For more information about the callback parameters, see the + * [function pointer type](@ref GLFWjoystickfun). + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref joystick_event + * + * @since Added in version 3.2. + * + * @ingroup input + */ +GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback); + +/*! @brief Adds the specified SDL_GameControllerDB gamepad mappings. + * + * This function parses the specified ASCII encoded string and updates the + * internal list with any gamepad mappings it finds. This string may + * contain either a single gamepad mapping or many mappings separated by + * newlines. The parser supports the full format of the `gamecontrollerdb.txt` + * source file including empty lines and comments. + * + * See @ref gamepad_mapping for a description of the format. + * + * If there is already a gamepad mapping for a given GUID in the internal list, + * it will be replaced by the one passed to this function. If the library is + * terminated and re-initialized the internal list will revert to the built-in + * default. + * + * @param[in] string The string containing the gamepad mappings. + * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_VALUE. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref gamepad + * @sa @ref glfwJoystickIsGamepad + * @sa @ref glfwGetGamepadName + * + * @since Added in version 3.3. + * + * @ingroup input + */ +GLFWAPI int glfwUpdateGamepadMappings(const char* string); + +/*! @brief Returns the human-readable gamepad name for the specified joystick. + * + * This function returns the human-readable name of the gamepad from the + * gamepad mapping assigned to the specified joystick. + * + * If the specified joystick is not present or does not have a gamepad mapping + * this function will return `NULL` but will not generate an error. Call + * @ref glfwJoystickPresent to check whether it is present regardless of + * whether it has a mapping. + * + * @param[in] jid The [joystick](@ref joysticks) to query. + * @return The UTF-8 encoded name of the gamepad, or `NULL` if the + * joystick is not present, does not have a mapping or an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM. + * + * @pointer_lifetime The returned string is allocated and freed by GLFW. You + * should not free it yourself. It is valid until the specified joystick is + * disconnected, the gamepad mappings are updated or the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref gamepad + * @sa @ref glfwJoystickIsGamepad + * + * @since Added in version 3.3. + * + * @ingroup input + */ +GLFWAPI const char* glfwGetGamepadName(int jid); + +/*! @brief Retrieves the state of the specified joystick remapped as a gamepad. + * + * This function retrieves the state of the specified joystick remapped to + * an Xbox-like gamepad. + * + * If the specified joystick is not present or does not have a gamepad mapping + * this function will return `GLFW_FALSE` but will not generate an error. Call + * @ref glfwJoystickPresent to check whether it is present regardless of + * whether it has a mapping. + * + * The Guide button may not be available for input as it is often hooked by the + * system or the Steam client. + * + * Not all devices have all the buttons or axes provided by @ref + * GLFWgamepadstate. Unavailable buttons and axes will always report + * `GLFW_RELEASE` and 0.0 respectively. + * + * @param[in] jid The [joystick](@ref joysticks) to query. + * @param[out] state The gamepad input state of the joystick. + * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is + * connected, it has no gamepad mapping or an [error](@ref error_handling) + * occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_ENUM. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref gamepad + * @sa @ref glfwUpdateGamepadMappings + * @sa @ref glfwJoystickIsGamepad + * + * @since Added in version 3.3. + * + * @ingroup input + */ +GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state); + +/*! @brief Sets the clipboard to the specified string. + * + * This function sets the system clipboard to the specified, UTF-8 encoded + * string. + * + * @param[in] window Deprecated. Any valid window or `NULL`. + * @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 @ref glfwGetClipboardString + * + * @since Added in version 3.0. + * + * @ingroup input + */ +GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); + +/*! @brief Returns the contents of the clipboard as a string. + * + * This function returns the contents of the system clipboard, if it contains + * or is convertible to a UTF-8 encoded string. If the clipboard is empty or + * if its contents cannot be converted, `NULL` is returned and a @ref + * GLFW_FORMAT_UNAVAILABLE error is generated. + * + * @param[in] window Deprecated. Any valid window or `NULL`. + * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL` + * if an [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. + * + * @pointer_lifetime The returned string is allocated and freed by GLFW. You + * should not free it yourself. It is valid until the next call to @ref + * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library + * is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref clipboard + * @sa @ref glfwSetClipboardString + * + * @since Added in version 3.0. + * + * @ingroup input + */ +GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window); + +/*! @brief Returns the GLFW time. + * + * This function returns the current GLFW time, in seconds. Unless the time + * has been set using @ref glfwSetTime it measures time elapsed since GLFW was + * initialized. + * + * This function and @ref glfwSetTime are helper functions on top of @ref + * glfwGetTimerFrequency and @ref glfwGetTimerValue. + * + * The resolution of the timer is system dependent, but is usually on the order + * of a few micro- or nanoseconds. It uses the highest-resolution monotonic + * time source on each supported platform. + * + * @return The current time, in seconds, or zero 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. Reading and + * writing of the internal base time is not atomic, so it needs to be + * externally synchronized with calls to @ref glfwSetTime. + * + * @sa @ref time + * + * @since Added in version 1.0. + * + * @ingroup input + */ +GLFWAPI double glfwGetTime(void); + +/*! @brief Sets the GLFW time. + * + * This function sets the current GLFW time, in seconds. The value must be + * a positive finite number less than or equal to 18446744073.0, which is + * approximately 584.5 years. + * + * This function and @ref glfwGetTime are helper functions on top of @ref + * glfwGetTimerFrequency and @ref glfwGetTimerValue. + * + * @param[in] time The new value, in seconds. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_INVALID_VALUE. + * + * @remark The upper limit of GLFW time is calculated as + * floor((264 - 1) / 109) and is due to implementations + * storing nanoseconds in 64 bits. The limit may be increased in the future. + * + * @thread_safety This function may be called from any thread. Reading and + * writing of the internal base time is not atomic, so it needs to be + * externally synchronized with calls to @ref glfwGetTime. + * + * @sa @ref time + * + * @since Added in version 2.2. + * + * @ingroup input + */ +GLFWAPI void glfwSetTime(double time); + +/*! @brief Returns the current value of the raw timer. + * + * This function returns the current value of the raw timer, measured in + * 1 / frequency seconds. To get the frequency, call @ref + * glfwGetTimerFrequency. + * + * @return The value of the timer, or zero 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. + * + * @sa @ref time + * @sa @ref glfwGetTimerFrequency + * + * @since Added in version 3.2. + * + * @ingroup input + */ +GLFWAPI uint64_t glfwGetTimerValue(void); + +/*! @brief Returns the frequency, in Hz, of the raw timer. + * + * This function returns the frequency, in Hz, of the raw timer. + * + * @return The frequency of the timer, in Hz, or zero 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. + * + * @sa @ref time + * @sa @ref glfwGetTimerValue + * + * @since Added in version 3.2. + * + * @ingroup input + */ +GLFWAPI uint64_t glfwGetTimerFrequency(void); + +/*! @brief Makes the context of the specified window current for the calling + * thread. + * + * This function makes the OpenGL or OpenGL ES context of the specified window + * current on the calling thread. A context must only be made current on + * a single thread at a time and each thread can have only a single current + * context at a time. + * + * When moving a context between threads, you must make it non-current on the + * old thread before making it current on the new one. + * + * By default, making a context non-current implicitly forces a pipeline flush. + * On machines that support `GL_KHR_context_flush_control`, you can control + * whether a context performs this flush by setting the + * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) + * hint. + * + * The specified window must have an OpenGL or OpenGL ES context. Specifying + * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT + * error. + * + * @param[in] window The window whose context to make current, or `NULL` to + * detach the current context. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref context_current + * @sa @ref glfwGetCurrentContext + * + * @since Added in version 3.0. + * + * @ingroup context + */ +GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window); + +/*! @brief Returns the window whose context is current on the calling thread. + * + * This function returns the window whose OpenGL or OpenGL ES context is + * current on the calling thread. + * + * @return The window whose context is current, or `NULL` if no window's + * context is current. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref context_current + * @sa @ref glfwMakeContextCurrent + * + * @since Added in version 3.0. + * + * @ingroup context + */ +GLFWAPI GLFWwindow* glfwGetCurrentContext(void); + +/*! @brief Swaps the front and back buffers of the specified window. + * + * This function swaps the front and back buffers of the specified window when + * rendering with OpenGL or OpenGL ES. If the swap interval is greater than + * zero, the GPU driver waits the specified number of screen updates before + * swapping the buffers. + * + * The specified window must have an OpenGL or OpenGL ES context. Specifying + * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT + * error. + * + * This function does not apply to Vulkan. If you are rendering with Vulkan, + * see `vkQueuePresentKHR` instead. + * + * @param[in] window The window whose buffers to swap. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR. + * + * @remark __EGL:__ The context of the specified window must be current on the + * calling thread. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref buffer_swap + * @sa @ref glfwSwapInterval + * + * @since Added in version 1.0. + * @glfw3 Added window handle parameter. + * + * @ingroup window + */ +GLFWAPI void glfwSwapBuffers(GLFWwindow* window); + +/*! @brief Sets the swap interval for the current context. + * + * This function sets the swap interval for the current OpenGL or OpenGL ES + * context, i.e. the number of screen updates to wait from the time @ref + * glfwSwapBuffers was called before swapping the buffers and returning. This + * is sometimes called _vertical synchronization_, _vertical retrace + * synchronization_ or just _vsync_. + * + * A context that supports either of the `WGL_EXT_swap_control_tear` and + * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap + * intervals, which allows the driver to swap immediately even if a frame + * arrives a little bit late. You can check for these extensions with @ref + * glfwExtensionSupported. + * + * A context must be current on the calling thread. Calling this function + * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error. + * + * This function does not apply to Vulkan. If you are rendering with Vulkan, + * see the present mode of your swapchain instead. + * + * @param[in] interval The minimum number of screen updates to wait for + * until the buffers are swapped by @ref glfwSwapBuffers. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR. + * + * @remark This function is not called during context creation, leaving the + * swap interval set to whatever is the default on that platform. This is done + * because some swap interval extensions used by GLFW do not allow the swap + * interval to be reset to zero once it has been set to a non-zero value. + * + * @remark Some GPU drivers do not honor the requested swap interval, either + * because of a user setting that overrides the application's request or due to + * bugs in the driver. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref buffer_swap + * @sa @ref glfwSwapBuffers + * + * @since Added in version 1.0. + * + * @ingroup context + */ +GLFWAPI void glfwSwapInterval(int interval); + +/*! @brief Returns whether the specified extension is available. + * + * This function returns whether the specified + * [API extension](@ref context_glext) is supported by the current OpenGL or + * OpenGL ES context. It searches both for client API extension and context + * creation API extensions. + * + * A context must be current on the calling thread. Calling this function + * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error. + * + * As this functions retrieves and searches one or more extension strings each + * call, it is recommended that you cache its results if it is going to be used + * frequently. The extension strings will not change during the lifetime of + * a context, so there is no danger in doing this. + * + * This function does not apply to Vulkan. If you are using Vulkan, see @ref + * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties` + * and `vkEnumerateDeviceExtensionProperties` instead. + * + * @param[in] extension The ASCII encoded name of the extension. + * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE` + * otherwise. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref context_glext + * @sa @ref glfwGetProcAddress + * + * @since Added in version 1.0. + * + * @ingroup context + */ +GLFWAPI int glfwExtensionSupported(const char* extension); + +/*! @brief Returns the address of the specified function for the current + * context. + * + * This function returns the address of the specified OpenGL or OpenGL ES + * [core or extension function](@ref context_glext), if it is supported + * by the current context. + * + * A context must be current on the calling thread. Calling this function + * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error. + * + * This function does not apply to Vulkan. If you are rendering with Vulkan, + * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and + * `vkGetDeviceProcAddr` instead. + * + * @param[in] procname The ASCII encoded name of the function. + * @return The address of the function, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR. + * + * @remark The address of a given function is not guaranteed to be the same + * between contexts. + * + * @remark This function may return a non-`NULL` address despite the + * associated version or extension not being available. Always check the + * context version or extension string first. + * + * @pointer_lifetime The returned function pointer is valid until the context + * is destroyed or the library is terminated. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref context_glext + * @sa @ref glfwExtensionSupported + * + * @since Added in version 1.0. + * + * @ingroup context + */ +GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname); + +/*! @brief Returns whether the Vulkan loader and an ICD have been found. + * + * This function returns whether the Vulkan loader and any minimally functional + * ICD have been found. + * + * The availability of a Vulkan loader and even an ICD does not by itself guarantee that + * surface creation or even instance creation is possible. Call @ref + * glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan + * surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to + * check whether a queue family of a physical device supports image presentation. + * + * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE` + * otherwise. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref vulkan_support + * + * @since Added in version 3.2. + * + * @ingroup vulkan + */ +GLFWAPI int glfwVulkanSupported(void); + +/*! @brief Returns the Vulkan instance extensions required by GLFW. + * + * This function returns an array of names of Vulkan instance extensions required + * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the + * list will always contain `VK_KHR_surface`, so if you don't require any + * additional extensions you can pass this list directly to the + * `VkInstanceCreateInfo` struct. + * + * If Vulkan is not available on the machine, this function returns `NULL` and + * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported + * to check whether Vulkan is at least minimally available. + * + * If Vulkan is available but no set of extensions allowing window surface + * creation was found, this function returns `NULL`. You may still use Vulkan + * for off-screen rendering and compute work. + * + * @param[out] count Where to store the number of extensions in the returned + * array. This is set to zero if an error occurred. + * @return An array of ASCII encoded extension names, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_API_UNAVAILABLE. + * + * @remark Additional extensions may be required by future versions of GLFW. + * You should check if any extensions you wish to enable are already in the + * returned array, as it is an error to specify an extension more than once in + * the `VkInstanceCreateInfo` struct. + * + * @pointer_lifetime The returned array is allocated and freed by GLFW. You + * should not free it yourself. It is guaranteed to be valid only until the + * library is terminated. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref vulkan_ext + * @sa @ref glfwCreateWindowSurface + * + * @since Added in version 3.2. + * + * @ingroup vulkan + */ +GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count); + +#if defined(VK_VERSION_1_0) + +/*! @brief Returns the address of the specified Vulkan instance function. + * + * This function returns the address of the specified Vulkan core or extension + * function for the specified instance. If instance is set to `NULL` it can + * return any function exported from the Vulkan loader, including at least the + * following functions: + * + * - `vkEnumerateInstanceExtensionProperties` + * - `vkEnumerateInstanceLayerProperties` + * - `vkCreateInstance` + * - `vkGetInstanceProcAddr` + * + * If Vulkan is not available on the machine, this function returns `NULL` and + * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported + * to check whether Vulkan is at least minimally available. + * + * This function is equivalent to calling `vkGetInstanceProcAddr` with + * a platform-specific query of the Vulkan loader as a fallback. + * + * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve + * functions related to instance creation. + * @param[in] procname The ASCII encoded name of the function. + * @return The address of the function, or `NULL` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_API_UNAVAILABLE. + * + * @pointer_lifetime The returned function pointer is valid until the library + * is terminated. + * + * @thread_safety This function may be called from any thread. + * + * @sa @ref vulkan_proc + * + * @since Added in version 3.2. + * + * @ingroup vulkan + */ +GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname); + +/*! @brief Returns whether the specified queue family can present images. + * + * This function returns whether the specified queue family of the specified + * physical device supports presentation to the platform GLFW was built for. + * + * If Vulkan or the required window surface creation instance extensions are + * not available on the machine, or if the specified instance was not created + * with the required extensions, this function returns `GLFW_FALSE` and + * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported + * to check whether Vulkan is at least minimally available and @ref + * glfwGetRequiredInstanceExtensions to check what instance extensions are + * required. + * + * @param[in] instance The instance that the physical device belongs to. + * @param[in] device The physical device that the queue family belongs to. + * @param[in] queuefamily The index of the queue family to query. + * @return `GLFW_TRUE` if the queue family supports presentation, or + * `GLFW_FALSE` otherwise. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. + * + * @remark @macos This function currently always returns `GLFW_TRUE`, as the + * `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide + * a `vkGetPhysicalDevice*PresentationSupport` type function. + * + * @thread_safety This function may be called from any thread. For + * synchronization details of Vulkan objects, see the Vulkan specification. + * + * @sa @ref vulkan_present + * + * @since Added in version 3.2. + * + * @ingroup vulkan + */ +GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); + +/*! @brief Creates a Vulkan surface for the specified window. + * + * This function creates a Vulkan surface for the specified window. + * + * If the Vulkan loader or at least one minimally functional ICD were not found, + * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref + * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether + * Vulkan is at least minimally available. + * + * If the required window surface creation instance extensions are not + * available or if the specified instance was not created with these extensions + * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and + * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref + * glfwGetRequiredInstanceExtensions to check what instance extensions are + * required. + * + * The window surface cannot be shared with another API so the window must + * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib) + * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error + * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`. + * + * The window surface must be destroyed before the specified Vulkan instance. + * It is the responsibility of the caller to destroy the window surface. GLFW + * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the + * surface. + * + * @param[in] instance The Vulkan instance to create the surface in. + * @param[in] window The window to create the surface for. + * @param[in] allocator The allocator to use, or `NULL` to use the default + * allocator. + * @param[out] surface Where to store the handle of the surface. This is set + * to `VK_NULL_HANDLE` if an error occurred. + * @return `VK_SUCCESS` if successful, or a Vulkan error code if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE + * + * @remark If an error occurs before the creation call is made, GLFW returns + * the Vulkan error code most appropriate for the error. Appropriate use of + * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should + * eliminate almost all occurrences of these errors. + * + * @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the + * `VK_MVK_macos_surface` extension as a fallback. The name of the selected + * extension, if any, is included in the array returned by @ref + * glfwGetRequiredInstanceExtensions. + * + * @remark @macos This function creates and sets a `CAMetalLayer` instance for + * the window content view, which is required for MoltenVK to function. + * + * @thread_safety This function may be called from any thread. For + * synchronization details of Vulkan objects, see the Vulkan specification. + * + * @sa @ref vulkan_surface + * @sa @ref glfwGetRequiredInstanceExtensions + * + * @since Added in version 3.2. + * + * @ingroup vulkan + */ +GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); + +#endif /*VK_VERSION_1_0*/ + + +/************************************************************************* + * Global definition cleanup + *************************************************************************/ + +/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */ + +#ifdef GLFW_WINGDIAPI_DEFINED + #undef WINGDIAPI + #undef GLFW_WINGDIAPI_DEFINED +#endif + +#ifdef GLFW_CALLBACK_DEFINED + #undef CALLBACK + #undef GLFW_CALLBACK_DEFINED +#endif + +/* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally + * defined by some gl.h variants (OpenBSD) so define it after if needed. + */ +#ifndef GLAPIENTRY + #define GLAPIENTRY APIENTRY +#endif + +/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _glfw3_h_ */ + diff --git a/src_v2/libs/glfw_osx/include/GLFW/glfw3native.h b/src_v2/libs/glfw_osx/include/GLFW/glfw3native.h new file mode 100644 index 0000000..fe74c73 --- /dev/null +++ b/src_v2/libs/glfw_osx/include/GLFW/glfw3native.h @@ -0,0 +1,594 @@ +/************************************************************************* + * GLFW 3.3 - www.glfw.org + * A library for OpenGL, window and input + *------------------------------------------------------------------------ + * Copyright (c) 2002-2006 Marcus Geelnard + * Copyright (c) 2006-2018 Camilla Löwy + * + * 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. + */ + + +/************************************************************************* + * System headers and types + *************************************************************************/ + +#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 +#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL) + #if defined(__OBJC__) + #import + #else + #include + typedef void* id; + #endif +#elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX) + #include + #include +#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND) + #include +#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) + #include +#endif +#if defined(GLFW_EXPOSE_NATIVE_EGL) + #include +#endif +#if defined(GLFW_EXPOSE_NATIVE_OSMESA) + #include +#endif + + +/************************************************************************* + * 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. + * + * @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_ */ + diff --git a/src_v2/libs/glfw_osx/lib-arm64/libglfw.3.dylib b/src_v2/libs/glfw_osx/lib-arm64/libglfw.3.dylib new file mode 100755 index 0000000..5fbb9fb Binary files /dev/null and b/src_v2/libs/glfw_osx/lib-arm64/libglfw.3.dylib differ diff --git a/src_v2/libs/glfw_osx/lib-arm64/libglfw3.a b/src_v2/libs/glfw_osx/lib-arm64/libglfw3.a new file mode 100644 index 0000000..ae5433c Binary files /dev/null and b/src_v2/libs/glfw_osx/lib-arm64/libglfw3.a differ diff --git a/src_v2/libs/glfw_osx/lib-universal/libglfw.3.dylib b/src_v2/libs/glfw_osx/lib-universal/libglfw.3.dylib new file mode 100755 index 0000000..4d12877 Binary files /dev/null and b/src_v2/libs/glfw_osx/lib-universal/libglfw.3.dylib differ diff --git a/src_v2/libs/glfw_osx/lib-universal/libglfw3.a b/src_v2/libs/glfw_osx/lib-universal/libglfw3.a new file mode 100644 index 0000000..afc2148 Binary files /dev/null and b/src_v2/libs/glfw_osx/lib-universal/libglfw3.a differ diff --git a/src_v2/libs/glfw_osx/lib-x86_64/libglfw.3.dylib b/src_v2/libs/glfw_osx/lib-x86_64/libglfw.3.dylib new file mode 100755 index 0000000..392b8b4 Binary files /dev/null and b/src_v2/libs/glfw_osx/lib-x86_64/libglfw.3.dylib differ diff --git a/src_v2/libs/glfw_osx/lib-x86_64/libglfw3.a b/src_v2/libs/glfw_osx/lib-x86_64/libglfw3.a new file mode 100644 index 0000000..0c113d7 Binary files /dev/null and b/src_v2/libs/glfw_osx/lib-x86_64/libglfw3.a differ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftconfig.h b/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftconfig.h new file mode 100644 index 0000000..f539e9a --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftconfig.h @@ -0,0 +1,562 @@ +/***************************************************************************/ +/* */ +/* ftconfig.h */ +/* */ +/* ANSI-specific configuration file (specification only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This header file contains a number of macro definitions that are used */ + /* by the rest of the engine. Most of the macros here are automatically */ + /* determined at compile time, and you should not need to change it to */ + /* port FreeType, except to compile the library with a non-ANSI */ + /* compiler. */ + /* */ + /* Note however that if some specific modifications are needed, we */ + /* advise you to place a modified copy in your build directory. */ + /* */ + /* The build directory is usually `builds/', and contains */ + /* system-specific files that are always included first when building */ + /* the library. */ + /* */ + /* This ANSI version should stay in `include/config/'. */ + /* */ + /*************************************************************************/ + +#ifndef FTCONFIG_H_ +#define FTCONFIG_H_ + +#include +#include FT_CONFIG_OPTIONS_H +#include FT_CONFIG_STANDARD_LIBRARY_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* PLATFORM-SPECIFIC CONFIGURATION MACROS */ + /* */ + /* These macros can be toggled to suit a specific system. The current */ + /* ones are defaults used to compile FreeType in an ANSI C environment */ + /* (16bit compilers are also supported). Copy this file to your own */ + /* `builds/' directory, and edit it to port the engine. */ + /* */ + /*************************************************************************/ + + + /* There are systems (like the Texas Instruments 'C54x) where a `char' */ + /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */ + /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */ + /* is probably unexpected. */ + /* */ + /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */ + /* `char' type. */ + +#ifndef FT_CHAR_BIT +#define FT_CHAR_BIT CHAR_BIT +#endif + + + /* The size of an `int' type. */ +#if FT_UINT_MAX == 0xFFFFUL +#define FT_SIZEOF_INT ( 16 / FT_CHAR_BIT ) +#elif FT_UINT_MAX == 0xFFFFFFFFUL +#define FT_SIZEOF_INT ( 32 / FT_CHAR_BIT ) +#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL +#define FT_SIZEOF_INT ( 64 / FT_CHAR_BIT ) +#else +#error "Unsupported size of `int' type!" +#endif + + /* The size of a `long' type. A five-byte `long' (as used e.g. on the */ + /* DM642) is recognized but avoided. */ +#if FT_ULONG_MAX == 0xFFFFFFFFUL +#define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT ) +#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL +#define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT ) +#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL +#define FT_SIZEOF_LONG ( 64 / FT_CHAR_BIT ) +#else +#error "Unsupported size of `long' type!" +#endif + + + /* FT_UNUSED is a macro used to indicate that a given parameter is not */ + /* used -- this is only used to get rid of unpleasant compiler warnings */ +#ifndef FT_UNUSED +#define FT_UNUSED( arg ) ( (arg) = (arg) ) +#endif + + + /*************************************************************************/ + /* */ + /* AUTOMATIC CONFIGURATION MACROS */ + /* */ + /* These macros are computed from the ones defined above. Don't touch */ + /* their definition, unless you know precisely what you are doing. No */ + /* porter should need to mess with them. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Mac support */ + /* */ + /* This is the only necessary change, so it is defined here instead */ + /* providing a new configuration file. */ + /* */ +#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) ) + /* no Carbon frameworks for 64bit 10.4.x */ + /* AvailabilityMacros.h is available since Mac OS X 10.2, */ + /* so guess the system version by maximum errno before inclusion */ +#include +#ifdef ECANCELED /* defined since 10.2 */ +#include "AvailabilityMacros.h" +#endif +#if defined( __LP64__ ) && \ + ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 ) +#undef FT_MACINTOSH +#endif + +#elif defined( __SC__ ) || defined( __MRC__ ) + /* Classic MacOS compilers */ +#include "ConditionalMacros.h" +#if TARGET_OS_MAC +#define FT_MACINTOSH 1 +#endif + +#endif + + + /* Fix compiler warning with sgi compiler */ +#if defined( __sgi ) && !defined( __GNUC__ ) +#if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 ) +#pragma set woff 3505 +#endif +#endif + + + /*************************************************************************/ + /* */ + /*
*/ + /* basic_types */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* */ + /* FT_Int16 */ + /* */ + /* */ + /* A typedef for a 16bit signed integer type. */ + /* */ + typedef signed short FT_Int16; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_UInt16 */ + /* */ + /* */ + /* A typedef for a 16bit unsigned integer type. */ + /* */ + typedef unsigned short FT_UInt16; + + /* */ + + + /* this #if 0 ... #endif clause is for documentation purposes */ +#if 0 + + /*************************************************************************/ + /* */ + /* */ + /* FT_Int32 */ + /* */ + /* */ + /* A typedef for a 32bit signed integer type. The size depends on */ + /* the configuration. */ + /* */ + typedef signed XXX FT_Int32; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_UInt32 */ + /* */ + /* A typedef for a 32bit unsigned integer type. The size depends on */ + /* the configuration. */ + /* */ + typedef unsigned XXX FT_UInt32; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_Int64 */ + /* */ + /* A typedef for a 64bit signed integer type. The size depends on */ + /* the configuration. Only defined if there is real 64bit support; */ + /* otherwise, it gets emulated with a structure (if necessary). */ + /* */ + typedef signed XXX FT_Int64; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_UInt64 */ + /* */ + /* A typedef for a 64bit unsigned integer type. The size depends on */ + /* the configuration. Only defined if there is real 64bit support; */ + /* otherwise, it gets emulated with a structure (if necessary). */ + /* */ + typedef unsigned XXX FT_UInt64; + + /* */ + +#endif + +#if FT_SIZEOF_INT == ( 32 / FT_CHAR_BIT ) + + typedef signed int FT_Int32; + typedef unsigned int FT_UInt32; + +#elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT ) + + typedef signed long FT_Int32; + typedef unsigned long FT_UInt32; + +#else +#error "no 32bit type found -- please check your configuration files" +#endif + + + /* look up an integer type that is at least 32 bits */ +#if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT ) + + typedef int FT_Fast; + typedef unsigned int FT_UFast; + +#elif FT_SIZEOF_LONG >= ( 32 / FT_CHAR_BIT ) + + typedef long FT_Fast; + typedef unsigned long FT_UFast; + +#endif + + + /* determine whether we have a 64-bit int type for platforms without */ + /* Autoconf */ +#if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT ) + + /* FT_LONG64 must be defined if a 64-bit type is available */ +#define FT_LONG64 +#define FT_INT64 long +#define FT_UINT64 unsigned long + + /*************************************************************************/ + /* */ + /* A 64-bit data type may create compilation problems if you compile */ + /* in strict ANSI mode. To avoid them, we disable other 64-bit data */ + /* types if __STDC__ is defined. You can however ignore this rule */ + /* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */ + /* */ +#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 ) + +#if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L + +#define FT_LONG64 +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ + + /* this compiler provides the __int64 type */ +#define FT_LONG64 +#define FT_INT64 __int64 +#define FT_UINT64 unsigned __int64 + +#elif defined( __BORLANDC__ ) /* Borland C++ */ + + /* XXXX: We should probably check the value of __BORLANDC__ in order */ + /* to test the compiler version. */ + + /* this compiler provides the __int64 type */ +#define FT_LONG64 +#define FT_INT64 __int64 +#define FT_UINT64 unsigned __int64 + +#elif defined( __WATCOMC__ ) /* Watcom C++ */ + + /* Watcom doesn't provide 64-bit data types */ + +#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */ + +#define FT_LONG64 +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#elif defined( __GNUC__ ) + + /* GCC provides the `long long' type */ +#define FT_LONG64 +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#endif /* __STDC_VERSION__ >= 199901L */ + +#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */ + +#ifdef FT_LONG64 + typedef FT_INT64 FT_Int64; + typedef FT_UINT64 FT_UInt64; +#endif + + +#ifdef _WIN64 + /* only 64bit Windows uses the LLP64 data model, i.e., */ + /* 32bit integers, 64bit pointers */ +#define FT_UINT_TO_POINTER( x ) (void*)(unsigned __int64)(x) +#else +#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x) +#endif + + + /*************************************************************************/ + /* */ + /* miscellaneous */ + /* */ + /*************************************************************************/ + + +#define FT_BEGIN_STMNT do { +#define FT_END_STMNT } while ( 0 ) +#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT + + + /* typeof condition taken from gnulib's `intprops.h' header file */ +#if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \ + ( defined( __IBMC__ ) && __IBMC__ >= 1210 && \ + defined( __IBM__TYPEOF__ ) ) || \ + ( defined( __SUNPRO_C ) && __SUNPRO_C >= 0x5110 && !__STDC__ ) ) +#define FT_TYPEOF( type ) ( __typeof__ ( type ) ) +#else +#define FT_TYPEOF( type ) /* empty */ +#endif + + + /* Use FT_LOCAL and FT_LOCAL_DEF to declare and define, respectively, */ + /* a function that gets used only within the scope of a module. */ + /* Normally, both the header and source code files for such a */ + /* function are within a single module directory. */ + /* */ + /* Intra-module arrays should be tagged with FT_LOCAL_ARRAY and */ + /* FT_LOCAL_ARRAY_DEF. */ + /* */ +#ifdef FT_MAKE_OPTION_SINGLE_OBJECT + +#define FT_LOCAL( x ) static x +#define FT_LOCAL_DEF( x ) static x + +#else + +#ifdef __cplusplus +#define FT_LOCAL( x ) extern "C" x +#define FT_LOCAL_DEF( x ) extern "C" x +#else +#define FT_LOCAL( x ) extern x +#define FT_LOCAL_DEF( x ) x +#endif + +#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */ + +#define FT_LOCAL_ARRAY( x ) extern const x +#define FT_LOCAL_ARRAY_DEF( x ) const x + + + /* Use FT_BASE and FT_BASE_DEF to declare and define, respectively, */ + /* functions that are used in more than a single module. In the */ + /* current setup this implies that the declaration is in a header */ + /* file in the `include/freetype/internal' directory, and the */ + /* function body is in a file in `src/base'. */ + /* */ +#ifndef FT_BASE + +#ifdef __cplusplus +#define FT_BASE( x ) extern "C" x +#else +#define FT_BASE( x ) extern x +#endif + +#endif /* !FT_BASE */ + + +#ifndef FT_BASE_DEF + +#ifdef __cplusplus +#define FT_BASE_DEF( x ) x +#else +#define FT_BASE_DEF( x ) x +#endif + +#endif /* !FT_BASE_DEF */ + + + /* When compiling FreeType as a DLL, some systems/compilers need a */ + /* special attribute in front OR after the return type of function */ + /* declarations. */ + /* */ + /* Two macros are used within the FreeType source code to define */ + /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */ + /* */ + /* FT_EXPORT( return_type ) */ + /* */ + /* is used in a function declaration, as in */ + /* */ + /* FT_EXPORT( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ); */ + /* */ + /* */ + /* FT_EXPORT_DEF( return_type ) */ + /* */ + /* is used in a function definition, as in */ + /* */ + /* FT_EXPORT_DEF( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ) */ + /* { */ + /* ... some code ... */ + /* return FT_Err_Ok; */ + /* } */ + /* */ + /* You can provide your own implementation of FT_EXPORT and */ + /* FT_EXPORT_DEF here if you want. */ + /* */ + /* To export a variable, use FT_EXPORT_VAR. */ + /* */ +#ifndef FT_EXPORT + +#ifdef __cplusplus +#define FT_EXPORT( x ) extern "C" x +#else +#define FT_EXPORT( x ) extern x +#endif + +#ifdef _MSC_VER +#undef FT_EXPORT +#ifdef _DLL +#define FT_EXPORT( x ) __declspec( dllexport ) x +#else +#define FT_EXPORT( x ) __declspec( dllimport ) x +#endif +#endif + +#endif /* !FT_EXPORT */ + + +#ifndef FT_EXPORT_DEF + +#ifdef __cplusplus +#define FT_EXPORT_DEF( x ) extern "C" x +#else +#define FT_EXPORT_DEF( x ) extern x +#endif + +#endif /* !FT_EXPORT_DEF */ + + +#ifndef FT_EXPORT_VAR + +#ifdef __cplusplus +#define FT_EXPORT_VAR( x ) extern "C" x +#else +#define FT_EXPORT_VAR( x ) extern x +#endif + +#endif /* !FT_EXPORT_VAR */ + + + /* The following macros are needed to compile the library with a */ + /* C++ compiler and with 16bit compilers. */ + /* */ + + /* This is special. Within C++, you must specify `extern "C"' for */ + /* functions which are used via function pointers, and you also */ + /* must do that for structures which contain function pointers to */ + /* assure C linkage -- it's not possible to have (local) anonymous */ + /* functions which are accessed by (global) function pointers. */ + /* */ + /* */ + /* FT_CALLBACK_DEF is used to _define_ a callback function, */ + /* located in the same source code file as the structure that uses */ + /* it. */ + /* */ + /* FT_BASE_CALLBACK and FT_BASE_CALLBACK_DEF are used to declare */ + /* and define a callback function, respectively, in a similar way */ + /* as FT_BASE and FT_BASE_DEF work. */ + /* */ + /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */ + /* contains pointers to callback functions. */ + /* */ + /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */ + /* that contains pointers to callback functions. */ + /* */ + /* */ + /* Some 16bit compilers have to redefine these macros to insert */ + /* the infamous `_cdecl' or `__fastcall' declarations. */ + /* */ +#ifndef FT_CALLBACK_DEF +#ifdef __cplusplus +#define FT_CALLBACK_DEF( x ) extern "C" x +#else +#define FT_CALLBACK_DEF( x ) static x +#endif +#endif /* FT_CALLBACK_DEF */ + +#ifndef FT_BASE_CALLBACK +#ifdef __cplusplus +#define FT_BASE_CALLBACK( x ) extern "C" x +#define FT_BASE_CALLBACK_DEF( x ) extern "C" x +#else +#define FT_BASE_CALLBACK( x ) extern x +#define FT_BASE_CALLBACK_DEF( x ) x +#endif +#endif /* FT_BASE_CALLBACK */ + +#ifndef FT_CALLBACK_TABLE +#ifdef __cplusplus +#define FT_CALLBACK_TABLE extern "C" +#define FT_CALLBACK_TABLE_DEF extern "C" +#else +#define FT_CALLBACK_TABLE extern +#define FT_CALLBACK_TABLE_DEF /* nothing */ +#endif +#endif /* FT_CALLBACK_TABLE */ + + +FT_END_HEADER + + +#endif /* FTCONFIG_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftheader.h b/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftheader.h new file mode 100644 index 0000000..702f77c --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftheader.h @@ -0,0 +1,804 @@ +/***************************************************************************/ +/* */ +/* ftheader.h */ +/* */ +/* Build macros of the FreeType 2 library. */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#ifndef FTHEADER_H_ +#define FTHEADER_H_ + + + /*@***********************************************************************/ + /* */ + /* */ + /* FT_BEGIN_HEADER */ + /* */ + /* */ + /* This macro is used in association with @FT_END_HEADER in header */ + /* files to ensure that the declarations within are properly */ + /* encapsulated in an `extern "C" { .. }' block when included from a */ + /* C++ compiler. */ + /* */ +#ifdef __cplusplus +#define FT_BEGIN_HEADER extern "C" { +#else +#define FT_BEGIN_HEADER /* nothing */ +#endif + + + /*@***********************************************************************/ + /* */ + /* */ + /* FT_END_HEADER */ + /* */ + /* */ + /* This macro is used in association with @FT_BEGIN_HEADER in header */ + /* files to ensure that the declarations within are properly */ + /* encapsulated in an `extern "C" { .. }' block when included from a */ + /* C++ compiler. */ + /* */ +#ifdef __cplusplus +#define FT_END_HEADER } +#else +#define FT_END_HEADER /* nothing */ +#endif + + + /*************************************************************************/ + /* */ + /* Aliases for the FreeType 2 public and configuration files. */ + /* */ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /*
*/ + /* header_file_macros */ + /* */ + /* */ + /* Header File Macros */ + /* */ + /* <Abstract> */ + /* Macro definitions used to #include specific header files. */ + /* */ + /* <Description> */ + /* The following macros are defined to the name of specific */ + /* FreeType~2 header files. They can be used directly in #include */ + /* statements as in: */ + /* */ + /* { */ + /* #include FT_FREETYPE_H */ + /* #include FT_MULTIPLE_MASTERS_H */ + /* #include FT_GLYPH_H */ + /* } */ + /* */ + /* There are several reasons why we are now using macros to name */ + /* public header files. The first one is that such macros are not */ + /* limited to the infamous 8.3~naming rule required by DOS (and */ + /* `FT_MULTIPLE_MASTERS_H' is a lot more meaningful than `ftmm.h'). */ + /* */ + /* The second reason is that it allows for more flexibility in the */ + /* way FreeType~2 is installed on a given system. */ + /* */ + /*************************************************************************/ + + + /* configuration files */ + + /************************************************************************* + * + * @macro: + * FT_CONFIG_CONFIG_H + * + * @description: + * A macro used in #include statements to name the file containing + * FreeType~2 configuration data. + * + */ +#ifndef FT_CONFIG_CONFIG_H +#define FT_CONFIG_CONFIG_H <freetype/config/ftconfig.h> +#endif + + + /************************************************************************* + * + * @macro: + * FT_CONFIG_STANDARD_LIBRARY_H + * + * @description: + * A macro used in #include statements to name the file containing + * FreeType~2 interface to the standard C library functions. + * + */ +#ifndef FT_CONFIG_STANDARD_LIBRARY_H +#define FT_CONFIG_STANDARD_LIBRARY_H <freetype/config/ftstdlib.h> +#endif + + + /************************************************************************* + * + * @macro: + * FT_CONFIG_OPTIONS_H + * + * @description: + * A macro used in #include statements to name the file containing + * FreeType~2 project-specific configuration options. + * + */ +#ifndef FT_CONFIG_OPTIONS_H +#define FT_CONFIG_OPTIONS_H <freetype/config/ftoption.h> +#endif + + + /************************************************************************* + * + * @macro: + * FT_CONFIG_MODULES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list of FreeType~2 modules that are statically linked to new library + * instances in @FT_Init_FreeType. + * + */ +#ifndef FT_CONFIG_MODULES_H +#define FT_CONFIG_MODULES_H <freetype/config/ftmodule.h> +#endif + + /* */ + + /* public headers */ + + /************************************************************************* + * + * @macro: + * FT_FREETYPE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * base FreeType~2 API. + * + */ +#define FT_FREETYPE_H <freetype/freetype.h> + + + /************************************************************************* + * + * @macro: + * FT_ERRORS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list of FreeType~2 error codes (and messages). + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_ERRORS_H <freetype/fterrors.h> + + + /************************************************************************* + * + * @macro: + * FT_MODULE_ERRORS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list of FreeType~2 module error offsets (and messages). + * + */ +#define FT_MODULE_ERRORS_H <freetype/ftmoderr.h> + + + /************************************************************************* + * + * @macro: + * FT_SYSTEM_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 interface to low-level operations (i.e., memory management + * and stream i/o). + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_SYSTEM_H <freetype/ftsystem.h> + + + /************************************************************************* + * + * @macro: + * FT_IMAGE_H + * + * @description: + * A macro used in #include statements to name the file containing type + * definitions related to glyph images (i.e., bitmaps, outlines, + * scan-converter parameters). + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_IMAGE_H <freetype/ftimage.h> + + + /************************************************************************* + * + * @macro: + * FT_TYPES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * basic data types defined by FreeType~2. + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_TYPES_H <freetype/fttypes.h> + + + /************************************************************************* + * + * @macro: + * FT_LIST_H + * + * @description: + * A macro used in #include statements to name the file containing the + * list management API of FreeType~2. + * + * (Most applications will never need to include this file.) + * + */ +#define FT_LIST_H <freetype/ftlist.h> + + + /************************************************************************* + * + * @macro: + * FT_OUTLINE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * scalable outline management API of FreeType~2. + * + */ +#define FT_OUTLINE_H <freetype/ftoutln.h> + + + /************************************************************************* + * + * @macro: + * FT_SIZES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API which manages multiple @FT_Size objects per face. + * + */ +#define FT_SIZES_H <freetype/ftsizes.h> + + + /************************************************************************* + * + * @macro: + * FT_MODULE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * module management API of FreeType~2. + * + */ +#define FT_MODULE_H <freetype/ftmodapi.h> + + + /************************************************************************* + * + * @macro: + * FT_RENDER_H + * + * @description: + * A macro used in #include statements to name the file containing the + * renderer module management API of FreeType~2. + * + */ +#define FT_RENDER_H <freetype/ftrender.h> + + + /************************************************************************* + * + * @macro: + * FT_DRIVER_H + * + * @description: + * A macro used in #include statements to name the file containing + * structures and macros related to the driver modules. + * + */ +#define FT_DRIVER_H <freetype/ftdriver.h> + + + /************************************************************************* + * + * @macro: + * FT_AUTOHINTER_H + * + * @description: + * A macro used in #include statements to name the file containing + * structures and macros related to the auto-hinting module. + * + * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * + */ +#define FT_AUTOHINTER_H FT_DRIVER_H + + + /************************************************************************* + * + * @macro: + * FT_CFF_DRIVER_H + * + * @description: + * A macro used in #include statements to name the file containing + * structures and macros related to the CFF driver module. + * + * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * + */ +#define FT_CFF_DRIVER_H FT_DRIVER_H + + + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_DRIVER_H + * + * @description: + * A macro used in #include statements to name the file containing + * structures and macros related to the TrueType driver module. + * + * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * + */ +#define FT_TRUETYPE_DRIVER_H FT_DRIVER_H + + + /************************************************************************* + * + * @macro: + * FT_PCF_DRIVER_H + * + * @description: + * A macro used in #include statements to name the file containing + * structures and macros related to the PCF driver module. + * + * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * + */ +#define FT_PCF_DRIVER_H FT_DRIVER_H + + + /************************************************************************* + * + * @macro: + * FT_TYPE1_TABLES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * types and API specific to the Type~1 format. + * + */ +#define FT_TYPE1_TABLES_H <freetype/t1tables.h> + + + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_IDS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * enumeration values which identify name strings, languages, encodings, + * etc. This file really contains a _large_ set of constant macro + * definitions, taken from the TrueType and OpenType specifications. + * + */ +#define FT_TRUETYPE_IDS_H <freetype/ttnameid.h> + + + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_TABLES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * types and API specific to the TrueType (as well as OpenType) format. + * + */ +#define FT_TRUETYPE_TABLES_H <freetype/tttables.h> + + + /************************************************************************* + * + * @macro: + * FT_TRUETYPE_TAGS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of TrueType four-byte `tags' which identify blocks in + * SFNT-based font formats (i.e., TrueType and OpenType). + * + */ +#define FT_TRUETYPE_TAGS_H <freetype/tttags.h> + + + /************************************************************************* + * + * @macro: + * FT_BDF_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which accesses BDF-specific strings from a + * face. + * + */ +#define FT_BDF_H <freetype/ftbdf.h> + + + /************************************************************************* + * + * @macro: + * FT_CID_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which access CID font information from a + * face. + * + */ +#define FT_CID_H <freetype/ftcid.h> + + + /************************************************************************* + * + * @macro: + * FT_GZIP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which supports gzip-compressed files. + * + */ +#define FT_GZIP_H <freetype/ftgzip.h> + + + /************************************************************************* + * + * @macro: + * FT_LZW_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which supports LZW-compressed files. + * + */ +#define FT_LZW_H <freetype/ftlzw.h> + + + /************************************************************************* + * + * @macro: + * FT_BZIP2_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which supports bzip2-compressed files. + * + */ +#define FT_BZIP2_H <freetype/ftbzip2.h> + + + /************************************************************************* + * + * @macro: + * FT_WINFONTS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * definitions of an API which supports Windows FNT files. + * + */ +#define FT_WINFONTS_H <freetype/ftwinfnt.h> + + + /************************************************************************* + * + * @macro: + * FT_GLYPH_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional glyph management component. + * + */ +#define FT_GLYPH_H <freetype/ftglyph.h> + + + /************************************************************************* + * + * @macro: + * FT_BITMAP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional bitmap conversion component. + * + */ +#define FT_BITMAP_H <freetype/ftbitmap.h> + + + /************************************************************************* + * + * @macro: + * FT_BBOX_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional exact bounding box computation routines. + * + */ +#define FT_BBOX_H <freetype/ftbbox.h> + + + /************************************************************************* + * + * @macro: + * FT_CACHE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * API of the optional FreeType~2 cache sub-system. + * + */ +#define FT_CACHE_H <freetype/ftcache.h> + + + /************************************************************************* + * + * @macro: + * FT_MAC_H + * + * @description: + * A macro used in #include statements to name the file containing the + * Macintosh-specific FreeType~2 API. The latter is used to access + * fonts embedded in resource forks. + * + * This header file must be explicitly included by client applications + * compiled on the Mac (note that the base API still works though). + * + */ +#define FT_MAC_H <freetype/ftmac.h> + + + /************************************************************************* + * + * @macro: + * FT_MULTIPLE_MASTERS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional multiple-masters management API of FreeType~2. + * + */ +#define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h> + + + /************************************************************************* + * + * @macro: + * FT_SFNT_NAMES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional FreeType~2 API which accesses embedded `name' strings in + * SFNT-based font formats (i.e., TrueType and OpenType). + * + */ +#define FT_SFNT_NAMES_H <freetype/ftsnames.h> + + + /************************************************************************* + * + * @macro: + * FT_OPENTYPE_VALIDATE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional FreeType~2 API which validates OpenType tables (BASE, GDEF, + * GPOS, GSUB, JSTF). + * + */ +#define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h> + + + /************************************************************************* + * + * @macro: + * FT_GX_VALIDATE_H + * + * @description: + * A macro used in #include statements to name the file containing the + * optional FreeType~2 API which validates TrueTypeGX/AAT tables (feat, + * mort, morx, bsln, just, kern, opbd, trak, prop). + * + */ +#define FT_GX_VALIDATE_H <freetype/ftgxval.h> + + + /************************************************************************* + * + * @macro: + * FT_PFR_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which accesses PFR-specific data. + * + */ +#define FT_PFR_H <freetype/ftpfr.h> + + + /************************************************************************* + * + * @macro: + * FT_STROKER_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which provides functions to stroke outline paths. + */ +#define FT_STROKER_H <freetype/ftstroke.h> + + + /************************************************************************* + * + * @macro: + * FT_SYNTHESIS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which performs artificial obliquing and emboldening. + */ +#define FT_SYNTHESIS_H <freetype/ftsynth.h> + + + /************************************************************************* + * + * @macro: + * FT_FONT_FORMATS_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which provides functions specific to font formats. + */ +#define FT_FONT_FORMATS_H <freetype/ftfntfmt.h> + + /* deprecated */ +#define FT_XFREE86_H FT_FONT_FORMATS_H + + + /************************************************************************* + * + * @macro: + * FT_TRIGONOMETRY_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which performs trigonometric computations (e.g., + * cosines and arc tangents). + */ +#define FT_TRIGONOMETRY_H <freetype/fttrigon.h> + + + /************************************************************************* + * + * @macro: + * FT_LCD_FILTER_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which performs color filtering for subpixel rendering. + */ +#define FT_LCD_FILTER_H <freetype/ftlcdfil.h> + + + /************************************************************************* + * + * @macro: + * FT_INCREMENTAL_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which performs incremental glyph loading. + */ +#define FT_INCREMENTAL_H <freetype/ftincrem.h> + + + /************************************************************************* + * + * @macro: + * FT_GASP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which returns entries from the TrueType GASP table. + */ +#define FT_GASP_H <freetype/ftgasp.h> + + + /************************************************************************* + * + * @macro: + * FT_ADVANCES_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType~2 API which returns individual and ranged glyph advances. + */ +#define FT_ADVANCES_H <freetype/ftadvanc.h> + + + /* */ + + /* These header files don't need to be included by the user. */ +#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h> +#define FT_PARAMETER_TAGS_H <freetype/ftparams.h> + + /* Deprecated macros. */ +#define FT_UNPATENTED_HINTING_H <freetype/ftparams.h> +#define FT_TRUETYPE_UNPATENTED_H <freetype/ftparams.h> + + /* FT_CACHE_H is the only header file needed for the cache subsystem. */ +#define FT_CACHE_IMAGE_H FT_CACHE_H +#define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H +#define FT_CACHE_CHARMAP_H FT_CACHE_H + + /* The internals of the cache sub-system are no longer exposed. We */ + /* default to FT_CACHE_H at the moment just in case, but we know of */ + /* no rogue client that uses them. */ + /* */ +#define FT_CACHE_MANAGER_H FT_CACHE_H +#define FT_CACHE_INTERNAL_MRU_H FT_CACHE_H +#define FT_CACHE_INTERNAL_MANAGER_H FT_CACHE_H +#define FT_CACHE_INTERNAL_CACHE_H FT_CACHE_H +#define FT_CACHE_INTERNAL_GLYPH_H FT_CACHE_H +#define FT_CACHE_INTERNAL_IMAGE_H FT_CACHE_H +#define FT_CACHE_INTERNAL_SBITS_H FT_CACHE_H + + + /* + * Include internal headers definitions from <internal/...> + * only when building the library. + */ +#ifdef FT2_BUILD_LIBRARY +#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h> +#include FT_INTERNAL_INTERNAL_H +#endif /* FT2_BUILD_LIBRARY */ + + +#endif /* FTHEADER_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftmodule.h b/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftmodule.h new file mode 100644 index 0000000..76d271a --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftmodule.h @@ -0,0 +1,32 @@ +/* + * This file registers the FreeType modules compiled into the library. + * + * If you use GNU make, this file IS NOT USED! Instead, it is created in + * the objects directory (normally `<topdir>/objs/') based on information + * from `<topdir>/modules.cfg'. + * + * Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile + * FreeType without GNU make. + * + */ + +FT_USE_MODULE( FT_Module_Class, autofit_module_class ) +FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class ) +FT_USE_MODULE( FT_Module_Class, psaux_module_class ) +FT_USE_MODULE( FT_Module_Class, psnames_module_class ) +FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class ) +FT_USE_MODULE( FT_Module_Class, sfnt_module_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class ) +FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) + +/* EOF */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftoption.h b/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftoption.h new file mode 100644 index 0000000..a5cb7ff --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftoption.h @@ -0,0 +1,973 @@ +/***************************************************************************/ +/* */ +/* ftoption.h */ +/* */ +/* User-selectable configuration macros (specification only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTOPTION_H_ +#define FTOPTION_H_ + + +#include <ft2build.h> + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* USER-SELECTABLE CONFIGURATION MACROS */ + /* */ + /* This file contains the default configuration macro definitions for */ + /* a standard build of the FreeType library. There are three ways to */ + /* use this file to build project-specific versions of the library: */ + /* */ + /* - You can modify this file by hand, but this is not recommended in */ + /* cases where you would like to build several versions of the */ + /* library from a single source directory. */ + /* */ + /* - You can put a copy of this file in your build directory, more */ + /* precisely in `$BUILD/freetype/config/ftoption.h', where `$BUILD' */ + /* is the name of a directory that is included _before_ the FreeType */ + /* include path during compilation. */ + /* */ + /* The default FreeType Makefiles and Jamfiles use the build */ + /* directory `builds/<system>' by default, but you can easily change */ + /* that for your own projects. */ + /* */ + /* - Copy the file <ft2build.h> to `$BUILD/ft2build.h' and modify it */ + /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */ + /* locate this file during the build. For example, */ + /* */ + /* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */ + /* #include <freetype/config/ftheader.h> */ + /* */ + /* will use `$BUILD/myftoptions.h' instead of this file for macro */ + /* definitions. */ + /* */ + /* Note also that you can similarly pre-define the macro */ + /* FT_CONFIG_MODULES_H used to locate the file listing of the modules */ + /* that are statically linked to the library at compile time. By */ + /* default, this file is <freetype/config/ftmodule.h>. */ + /* */ + /* We highly recommend using the third method whenever possible. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*#***********************************************************************/ + /* */ + /* If you enable this configuration option, FreeType recognizes an */ + /* environment variable called `FREETYPE_PROPERTIES', which can be used */ + /* to control the various font drivers and modules. The controllable */ + /* properties are listed in the section @properties. */ + /* */ + /* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */ + /* multiple lines for better readability). */ + /* */ + /* { */ + /* <optional whitespace> */ + /* <module-name1> ':' */ + /* <property-name1> '=' <property-value1> */ + /* <whitespace> */ + /* <module-name2> ':' */ + /* <property-name2> '=' <property-value2> */ + /* ... */ + /* } */ + /* */ + /* Example: */ + /* */ + /* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */ + /* cff:no-stem-darkening=1 \ */ + /* autofitter:warping=1 */ + /* */ +#define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + + + /*************************************************************************/ + /* */ + /* Uncomment the line below if you want to activate LCD rendering */ + /* technology similar to ClearType in this build of the library. This */ + /* technology triples the resolution in the direction color subpixels. */ + /* To mitigate color fringes inherent to this technology, you also need */ + /* to explicitly set up LCD filtering. */ + /* */ + /* Note that this feature is covered by several Microsoft patents */ + /* and should not be activated in any default build of the library. */ + /* When this macro is not defined, FreeType offers alternative LCD */ + /* rendering technology that produces excellent output without LCD */ + /* filtering. */ + /* */ +/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ + + + /*************************************************************************/ + /* */ + /* Many compilers provide a non-ANSI 64-bit data type that can be used */ + /* by FreeType to speed up some computations. However, this will create */ + /* some problems when compiling the library in strict ANSI mode. */ + /* */ + /* For this reason, the use of 64-bit integers is normally disabled when */ + /* the __STDC__ macro is defined. You can however disable this by */ + /* defining the macro FT_CONFIG_OPTION_FORCE_INT64 here. */ + /* */ + /* For most compilers, this will only create compilation warnings when */ + /* building the library. */ + /* */ + /* ObNote: The compiler-specific 64-bit integers are detected in the */ + /* file `ftconfig.h' either statically or through the */ + /* `configure' script on supported platforms. */ + /* */ +#undef FT_CONFIG_OPTION_FORCE_INT64 + + + /*************************************************************************/ + /* */ + /* If this macro is defined, do not try to use an assembler version of */ + /* performance-critical functions (e.g. FT_MulFix). You should only do */ + /* that to verify that the assembler function works properly, or to */ + /* execute benchmark tests of the various implementations. */ +/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */ + + + /*************************************************************************/ + /* */ + /* If this macro is defined, try to use an inlined assembler version of */ + /* the `FT_MulFix' function, which is a `hotspot' when loading and */ + /* hinting glyphs, and which should be executed as fast as possible. */ + /* */ + /* Note that if your compiler or CPU is not supported, this will default */ + /* to the standard and portable implementation found in `ftcalc.c'. */ + /* */ +#define FT_CONFIG_OPTION_INLINE_MULFIX + + + /*************************************************************************/ + /* */ + /* LZW-compressed file support. */ + /* */ + /* FreeType now handles font files that have been compressed with the */ + /* `compress' program. This is mostly used to parse many of the PCF */ + /* files that come with various X11 distributions. The implementation */ + /* uses NetBSD's `zopen' to partially uncompress the file on the fly */ + /* (see src/lzw/ftgzip.c). */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ +#define FT_CONFIG_OPTION_USE_LZW + + + /*************************************************************************/ + /* */ + /* Gzip-compressed file support. */ + /* */ + /* FreeType now handles font files that have been compressed with the */ + /* `gzip' program. This is mostly used to parse many of the PCF files */ + /* that come with XFree86. The implementation uses `zlib' to */ + /* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */ + /* */ + /* Define this macro if you want to enable this `feature'. See also */ + /* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */ + /* */ +#define FT_CONFIG_OPTION_USE_ZLIB + + + /*************************************************************************/ + /* */ + /* ZLib library selection */ + /* */ + /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */ + /* It allows FreeType's `ftgzip' component to link to the system's */ + /* installation of the ZLib library. This is useful on systems like */ + /* Unix or VMS where it generally is already available. */ + /* */ + /* If you let it undefined, the component will use its own copy */ + /* of the zlib sources instead. These have been modified to be */ + /* included directly within the component and *not* export external */ + /* function names. This allows you to link any program with FreeType */ + /* _and_ ZLib without linking conflicts. */ + /* */ + /* Do not #undef this macro here since the build system might define */ + /* it for certain configurations only. */ + /* */ + /* If you use a build system like cmake or the `configure' script, */ + /* options set by those programs have precendence, overwriting the */ + /* value here with the configured one. */ + /* */ +/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */ + + + /*************************************************************************/ + /* */ + /* Bzip2-compressed file support. */ + /* */ + /* FreeType now handles font files that have been compressed with the */ + /* `bzip2' program. This is mostly used to parse many of the PCF */ + /* files that come with XFree86. The implementation uses `libbz2' to */ + /* partially uncompress the file on the fly (see src/bzip2/ftbzip2.c). */ + /* Contrary to gzip, bzip2 currently is not included and need to use */ + /* the system available bzip2 implementation. */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ + /* If you use a build system like cmake or the `configure' script, */ + /* options set by those programs have precendence, overwriting the */ + /* value here with the configured one. */ + /* */ +/* #define FT_CONFIG_OPTION_USE_BZIP2 */ + + + /*************************************************************************/ + /* */ + /* Define to disable the use of file stream functions and types, FILE, */ + /* fopen() etc. Enables the use of smaller system libraries on embedded */ + /* systems that have multiple system libraries, some with or without */ + /* file stream support, in the cases where file stream support is not */ + /* necessary such as memory loading of font files. */ + /* */ +/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */ + + + /*************************************************************************/ + /* */ + /* PNG bitmap support. */ + /* */ + /* FreeType now handles loading color bitmap glyphs in the PNG format. */ + /* This requires help from the external libpng library. Uncompressed */ + /* color bitmaps do not need any external libraries and will be */ + /* supported regardless of this configuration. */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ + /* If you use a build system like cmake or the `configure' script, */ + /* options set by those programs have precendence, overwriting the */ + /* value here with the configured one. */ + /* */ +/* #define FT_CONFIG_OPTION_USE_PNG */ + + + /*************************************************************************/ + /* */ + /* HarfBuzz support. */ + /* */ + /* FreeType uses the HarfBuzz library to improve auto-hinting of */ + /* OpenType fonts. If available, many glyphs not directly addressable */ + /* by a font's character map will be hinted also. */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ + /* If you use a build system like cmake or the `configure' script, */ + /* options set by those programs have precendence, overwriting the */ + /* value here with the configured one. */ + /* */ +/* #define FT_CONFIG_OPTION_USE_HARFBUZZ */ + + + /*************************************************************************/ + /* */ + /* Glyph Postscript Names handling */ + /* */ + /* By default, FreeType 2 is compiled with the `psnames' module. This */ + /* module is in charge of converting a glyph name string into a */ + /* Unicode value, or return a Macintosh standard glyph name for the */ + /* use with the TrueType `post' table. */ + /* */ + /* Undefine this macro if you do not want `psnames' compiled in your */ + /* build of FreeType. This has the following effects: */ + /* */ + /* - The TrueType driver will provide its own set of glyph names, */ + /* if you build it to support postscript names in the TrueType */ + /* `post' table, but will not synthesize a missing Unicode charmap. */ + /* */ + /* - The Type 1 driver will not be able to synthesize a Unicode */ + /* charmap out of the glyphs found in the fonts. */ + /* */ + /* You would normally undefine this configuration macro when building */ + /* a version of FreeType that doesn't contain a Type 1 or CFF driver. */ + /* */ +#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES + + + /*************************************************************************/ + /* */ + /* Postscript Names to Unicode Values support */ + /* */ + /* By default, FreeType 2 is built with the `PSNames' module compiled */ + /* in. Among other things, the module is used to convert a glyph name */ + /* into a Unicode value. This is especially useful in order to */ + /* synthesize on the fly a Unicode charmap from the CFF/Type 1 driver */ + /* through a big table named the `Adobe Glyph List' (AGL). */ + /* */ + /* Undefine this macro if you do not want the Adobe Glyph List */ + /* compiled in your `PSNames' module. The Type 1 driver will not be */ + /* able to synthesize a Unicode charmap out of the glyphs found in the */ + /* fonts. */ + /* */ +#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST + + + /*************************************************************************/ + /* */ + /* Support for Mac fonts */ + /* */ + /* Define this macro if you want support for outline fonts in Mac */ + /* format (mac dfont, mac resource, macbinary containing a mac */ + /* resource) on non-Mac platforms. */ + /* */ + /* Note that the `FOND' resource isn't checked. */ + /* */ +#define FT_CONFIG_OPTION_MAC_FONTS + + + /*************************************************************************/ + /* */ + /* Guessing methods to access embedded resource forks */ + /* */ + /* Enable extra Mac fonts support on non-Mac platforms (e.g. */ + /* GNU/Linux). */ + /* */ + /* Resource forks which include fonts data are stored sometimes in */ + /* locations which users or developers don't expected. In some cases, */ + /* resource forks start with some offset from the head of a file. In */ + /* other cases, the actual resource fork is stored in file different */ + /* from what the user specifies. If this option is activated, */ + /* FreeType tries to guess whether such offsets or different file */ + /* names must be used. */ + /* */ + /* Note that normal, direct access of resource forks is controlled via */ + /* the FT_CONFIG_OPTION_MAC_FONTS option. */ + /* */ +#ifdef FT_CONFIG_OPTION_MAC_FONTS +#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK +#endif + + + /*************************************************************************/ + /* */ + /* Allow the use of FT_Incremental_Interface to load typefaces that */ + /* contain no glyph data, but supply it via a callback function. */ + /* This is required by clients supporting document formats which */ + /* supply font data incrementally as the document is parsed, such */ + /* as the Ghostscript interpreter for the PostScript language. */ + /* */ +#define FT_CONFIG_OPTION_INCREMENTAL + + + /*************************************************************************/ + /* */ + /* The size in bytes of the render pool used by the scan-line converter */ + /* to do all of its work. */ + /* */ +#define FT_RENDER_POOL_SIZE 16384L + + + /*************************************************************************/ + /* */ + /* FT_MAX_MODULES */ + /* */ + /* The maximum number of modules that can be registered in a single */ + /* FreeType library object. 32 is the default. */ + /* */ +#define FT_MAX_MODULES 32 + + + /*************************************************************************/ + /* */ + /* Debug level */ + /* */ + /* FreeType can be compiled in debug or trace mode. In debug mode, */ + /* errors are reported through the `ftdebug' component. In trace */ + /* mode, additional messages are sent to the standard output during */ + /* execution. */ + /* */ + /* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */ + /* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */ + /* */ + /* Don't define any of these macros to compile in `release' mode! */ + /* */ + /* Do not #undef these macros here since the build system might define */ + /* them for certain configurations only. */ + /* */ +/* #define FT_DEBUG_LEVEL_ERROR */ +/* #define FT_DEBUG_LEVEL_TRACE */ + + + /*************************************************************************/ + /* */ + /* Autofitter debugging */ + /* */ + /* If FT_DEBUG_AUTOFIT is defined, FreeType provides some means to */ + /* control the autofitter behaviour for debugging purposes with global */ + /* boolean variables (consequently, you should *never* enable this */ + /* while compiling in `release' mode): */ + /* */ + /* _af_debug_disable_horz_hints */ + /* _af_debug_disable_vert_hints */ + /* _af_debug_disable_blue_hints */ + /* */ + /* Additionally, the following functions provide dumps of various */ + /* internal autofit structures to stdout (using `printf'): */ + /* */ + /* af_glyph_hints_dump_points */ + /* af_glyph_hints_dump_segments */ + /* af_glyph_hints_dump_edges */ + /* af_glyph_hints_get_num_segments */ + /* af_glyph_hints_get_segment_offset */ + /* */ + /* As an argument, they use another global variable: */ + /* */ + /* _af_debug_hints */ + /* */ + /* Please have a look at the `ftgrid' demo program to see how those */ + /* variables and macros should be used. */ + /* */ + /* Do not #undef these macros here since the build system might define */ + /* them for certain configurations only. */ + /* */ +/* #define FT_DEBUG_AUTOFIT */ + + + /*************************************************************************/ + /* */ + /* Memory Debugging */ + /* */ + /* FreeType now comes with an integrated memory debugger that is */ + /* capable of detecting simple errors like memory leaks or double */ + /* deletes. To compile it within your build of the library, you */ + /* should define FT_DEBUG_MEMORY here. */ + /* */ + /* Note that the memory debugger is only activated at runtime when */ + /* when the _environment_ variable `FT2_DEBUG_MEMORY' is defined also! */ + /* */ + /* Do not #undef this macro here since the build system might define */ + /* it for certain configurations only. */ + /* */ +/* #define FT_DEBUG_MEMORY */ + + + /*************************************************************************/ + /* */ + /* Module errors */ + /* */ + /* If this macro is set (which is _not_ the default), the higher byte */ + /* of an error code gives the module in which the error has occurred, */ + /* while the lower byte is the real error code. */ + /* */ + /* Setting this macro makes sense for debugging purposes only, since */ + /* it would break source compatibility of certain programs that use */ + /* FreeType 2. */ + /* */ + /* More details can be found in the files ftmoderr.h and fterrors.h. */ + /* */ +#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS + + + /*************************************************************************/ + /* */ + /* Position Independent Code */ + /* */ + /* If this macro is set (which is _not_ the default), FreeType2 will */ + /* avoid creating constants that require address fixups. Instead the */ + /* constants will be moved into a struct and additional intialization */ + /* code will be used. */ + /* */ + /* Setting this macro is needed for systems that prohibit address */ + /* fixups, such as BREW. [Note that standard compilers like gcc or */ + /* clang handle PIC generation automatically; you don't have to set */ + /* FT_CONFIG_OPTION_PIC, which is only necessary for very special */ + /* compilers.] */ + /* */ + /* Note that FT_CONFIG_OPTION_PIC support is not available for all */ + /* modules (see `modules.cfg' for a complete list). For building with */ + /* FT_CONFIG_OPTION_PIC support, do the following. */ + /* */ + /* 0. Clone the repository. */ + /* 1. Define FT_CONFIG_OPTION_PIC. */ + /* 2. Remove all subdirectories in `src' that don't have */ + /* FT_CONFIG_OPTION_PIC support. */ + /* 3. Comment out the corresponding modules in `modules.cfg'. */ + /* 4. Compile. */ + /* */ +/* #define FT_CONFIG_OPTION_PIC */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** S F N T D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */ + /* embedded bitmaps in all formats using the SFNT module (namely */ + /* TrueType & OpenType). */ + /* */ +#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */ + /* load and enumerate the glyph Postscript names in a TrueType or */ + /* OpenType file. */ + /* */ + /* Note that when you do not compile the `PSNames' module by undefining */ + /* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */ + /* contain additional code used to read the PS Names table from a font. */ + /* */ + /* (By default, the module uses `PSNames' to extract glyph names.) */ + /* */ +#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */ + /* access the internal name table in a SFNT-based format like TrueType */ + /* or OpenType. The name table contains various strings used to */ + /* describe the font, like family name, copyright, version, etc. It */ + /* does not contain any glyph name though. */ + /* */ + /* Accessing SFNT names is done through the functions declared in */ + /* `ftsnames.h'. */ + /* */ +#define TT_CONFIG_OPTION_SFNT_NAMES + + + /*************************************************************************/ + /* */ + /* TrueType CMap support */ + /* */ + /* Here you can fine-tune which TrueType CMap table format shall be */ + /* supported. */ +#define TT_CONFIG_CMAP_FORMAT_0 +#define TT_CONFIG_CMAP_FORMAT_2 +#define TT_CONFIG_CMAP_FORMAT_4 +#define TT_CONFIG_CMAP_FORMAT_6 +#define TT_CONFIG_CMAP_FORMAT_8 +#define TT_CONFIG_CMAP_FORMAT_10 +#define TT_CONFIG_CMAP_FORMAT_12 +#define TT_CONFIG_CMAP_FORMAT_13 +#define TT_CONFIG_CMAP_FORMAT_14 + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */ + /* a bytecode interpreter in the TrueType driver. */ + /* */ + /* By undefining this, you will only compile the code necessary to load */ + /* TrueType glyphs without hinting. */ + /* */ + /* Do not #undef this macro here, since the build system might */ + /* define it for certain configurations only. */ + /* */ +#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile */ + /* subpixel hinting support into the TrueType driver. This modifies the */ + /* TrueType hinting mechanism when anything but FT_RENDER_MODE_MONO is */ + /* requested. */ + /* */ + /* In particular, it modifies the bytecode interpreter to interpret (or */ + /* not) instructions in a certain way so that all TrueType fonts look */ + /* like they do in a Windows ClearType (DirectWrite) environment. See */ + /* [1] for a technical overview on what this means. See `ttinterp.h' */ + /* for more details on the LEAN option. */ + /* */ + /* There are three possible values. */ + /* */ + /* Value 1: */ + /* This value is associated with the `Infinality' moniker, */ + /* contributed by an individual nicknamed Infinality with the goal of */ + /* making TrueType fonts render better than on Windows. A high */ + /* amount of configurability and flexibility, down to rules for */ + /* single glyphs in fonts, but also very slow. Its experimental and */ + /* slow nature and the original developer losing interest meant that */ + /* this option was never enabled in default builds. */ + /* */ + /* The corresponding interpreter version is v38. */ + /* */ + /* Value 2: */ + /* The new default mode for the TrueType driver. The Infinality code */ + /* base was stripped to the bare minimum and all configurability */ + /* removed in the name of speed and simplicity. The configurability */ + /* was mainly aimed at legacy fonts like Arial, Times New Roman, or */ + /* Courier. Legacy fonts are fonts that modify vertical stems to */ + /* achieve clean black-and-white bitmaps. The new mode focuses on */ + /* applying a minimal set of rules to all fonts indiscriminately so */ + /* that modern and web fonts render well while legacy fonts render */ + /* okay. */ + /* */ + /* The corresponding interpreter version is v40. */ + /* */ + /* Value 3: */ + /* Compile both, making both v38 and v40 available (the latter is the */ + /* default). */ + /* */ + /* By undefining these, you get rendering behavior like on Windows */ + /* without ClearType, i.e., Windows XP without ClearType enabled and */ + /* Win9x (interpreter version v35). Or not, depending on how much */ + /* hinting blood and testing tears the font designer put into a given */ + /* font. If you define one or both subpixel hinting options, you can */ + /* switch between between v35 and the ones you define (using */ + /* `FT_Property_Set'). */ + /* */ + /* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */ + /* defined. */ + /* */ + /* [1] https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */ + /* */ +/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 1 */ +#define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2 +/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 ) */ + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */ + /* TrueType glyph loader to use Apple's definition of how to handle */ + /* component offsets in composite glyphs. */ + /* */ + /* Apple and MS disagree on the default behavior of component offsets */ + /* in composites. Apple says that they should be scaled by the scaling */ + /* factors in the transformation matrix (roughly, it's more complex) */ + /* while MS says they should not. OpenType defines two bits in the */ + /* composite flags array which can be used to disambiguate, but old */ + /* fonts will not have them. */ + /* */ + /* https://www.microsoft.com/typography/otspec/glyf.htm */ + /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html */ + /* */ +#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_GX_VAR_SUPPORT if you want to include */ + /* support for Apple's distortable font technology (fvar, gvar, cvar, */ + /* and avar tables). This has many similarities to Type 1 Multiple */ + /* Masters support. */ + /* */ +#define TT_CONFIG_OPTION_GX_VAR_SUPPORT + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_BDF if you want to include support for */ + /* an embedded `BDF ' table within SFNT-based bitmap formats. */ + /* */ +#define TT_CONFIG_OPTION_BDF + + + /*************************************************************************/ + /* */ + /* Option TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES controls the maximum */ + /* number of bytecode instructions executed for a single run of the */ + /* bytecode interpreter, needed to prevent infinite loops. You don't */ + /* want to change this except for very special situations (e.g., making */ + /* a library fuzzer spend less time to handle broken fonts). */ + /* */ + /* It is not expected that this value is ever modified by a configuring */ + /* script; instead, it gets surrounded with #ifndef ... #endif so that */ + /* the value can be set as a preprocessor option on the compiler's */ + /* command line. */ + /* */ +#ifndef TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES +#define TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES 1000000L +#endif + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* T1_MAX_DICT_DEPTH is the maximum depth of nest dictionaries and */ + /* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */ + /* required. */ + /* */ +#define T1_MAX_DICT_DEPTH 5 + + + /*************************************************************************/ + /* */ + /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ + /* calls during glyph loading. */ + /* */ +#define T1_MAX_SUBRS_CALLS 16 + + + /*************************************************************************/ + /* */ + /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ + /* minimum of 16 is required. */ + /* */ + /* The Chinese font MingTiEG-Medium (CNS 11643 character set) needs 256. */ + /* */ +#define T1_MAX_CHARSTRINGS_OPERANDS 256 + + + /*************************************************************************/ + /* */ + /* Define this configuration macro if you want to prevent the */ + /* compilation of `t1afm', which is in charge of reading Type 1 AFM */ + /* files into an existing face. Note that if set, the T1 driver will be */ + /* unable to produce kerning distances. */ + /* */ +#undef T1_CONFIG_OPTION_NO_AFM + + + /*************************************************************************/ + /* */ + /* Define this configuration macro if you want to prevent the */ + /* compilation of the Multiple Masters font support in the Type 1 */ + /* driver. */ + /* */ +#undef T1_CONFIG_OPTION_NO_MM_SUPPORT + + + /*************************************************************************/ + /* */ + /* T1_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe Type 1 */ + /* engine gets compiled into FreeType. If defined, it is possible to */ + /* switch between the two engines using the `hinting-engine' property of */ + /* the type1 driver module. */ + /* */ +/* #define T1_CONFIG_OPTION_OLD_ENGINE */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** C F F D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Using CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} it is */ + /* possible to set up the default values of the four control points that */ + /* define the stem darkening behaviour of the (new) CFF engine. For */ + /* more details please read the documentation of the */ + /* `darkening-parameters' property (file `ftdriver.h'), which allows the */ + /* control at run-time. */ + /* */ + /* Do *not* undefine these macros! */ + /* */ +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 1000 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 275 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 1667 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 275 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 2333 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0 + + + /*************************************************************************/ + /* */ + /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF */ + /* engine gets compiled into FreeType. If defined, it is possible to */ + /* switch between the two engines using the `hinting-engine' property of */ + /* the cff driver module. */ + /* */ +/* #define CFF_CONFIG_OPTION_OLD_ENGINE */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** P C F D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* There are many PCF fonts just called `Fixed' which look completely */ + /* different, and which have nothing to do with each other. When */ + /* selecting `Fixed' in KDE or Gnome one gets results that appear rather */ + /* random, the style changes often if one changes the size and one */ + /* cannot select some fonts at all. This option makes the PCF module */ + /* prepend the foundry name (plus a space) to the family name. */ + /* */ + /* We also check whether we have `wide' characters; all put together, we */ + /* get family names like `Sony Fixed' or `Misc Fixed Wide'. */ + /* */ + /* If this option is activated, it can be controlled with the */ + /* `no-long-family-names' property of the pcf driver module. */ + /* */ +/* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Compile autofit module with CJK (Chinese, Japanese, Korean) script */ + /* support. */ + /* */ +#define AF_CONFIG_OPTION_CJK + + /*************************************************************************/ + /* */ + /* Compile autofit module with fallback Indic script support, covering */ + /* some scripts that the `latin' submodule of the autofit module doesn't */ + /* (yet) handle. */ + /* */ +#define AF_CONFIG_OPTION_INDIC + + /*************************************************************************/ + /* */ + /* Compile autofit module with warp hinting. The idea of the warping */ + /* code is to slightly scale and shift a glyph within a single dimension */ + /* so that as much of its segments are aligned (more or less) on the */ + /* grid. To find out the optimal scaling and shifting value, various */ + /* parameter combinations are tried and scored. */ + /* */ + /* This experimental option is active only if the rendering mode is */ + /* FT_RENDER_MODE_LIGHT; you can switch warping on and off with the */ + /* `warping' property of the auto-hinter (see file `ftdriver.h' for more */ + /* information; by default it is switched off). */ + /* */ +#define AF_CONFIG_OPTION_USE_WARPER + + /*************************************************************************/ + /* */ + /* Use TrueType-like size metrics for `light' auto-hinting. */ + /* */ + /* It is strongly recommended to avoid this option, which exists only to */ + /* help some legacy applications retain its appearance and behaviour */ + /* with respect to auto-hinted TrueType fonts. */ + /* */ + /* The very reason this option exists at all are GNU/Linux distributions */ + /* like Fedora that did not un-patch the following change (which was */ + /* present in FreeType between versions 2.4.6 and 2.7.1, inclusive). */ + /* */ + /* 2011-07-16 Steven Chu <steven.f.chu@gmail.com> */ + /* */ + /* [truetype] Fix metrics on size request for scalable fonts. */ + /* */ + /* This problematic commit is now reverted (more or less). */ + /* */ +/* #define AF_CONFIG_OPTION_TT_SIZE_METRICS */ + + /* */ + + + /* + * This macro is obsolete. Support has been removed in FreeType + * version 2.5. + */ +/* #define FT_CONFIG_OPTION_OLD_INTERNALS */ + + + /* + * This macro is defined if native TrueType hinting is requested by the + * definitions above. + */ +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#define TT_USE_BYTECODE_INTERPRETER + +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING +#if TT_CONFIG_OPTION_SUBPIXEL_HINTING & 1 +#define TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY +#endif + +#if TT_CONFIG_OPTION_SUBPIXEL_HINTING & 2 +#define TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL +#endif +#endif +#endif + + + /* + * Check CFF darkening parameters. The checks are the same as in function + * `cff_property_set' in file `cffdrivr.c'. + */ +#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500 +#error "Invalid CFF darkening parameters!" +#endif + +FT_END_HEADER + + +#endif /* FTOPTION_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftstdlib.h b/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftstdlib.h new file mode 100644 index 0000000..42f9a06 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/config/ftstdlib.h @@ -0,0 +1,175 @@ +/***************************************************************************/ +/* */ +/* ftstdlib.h */ +/* */ +/* ANSI-specific library and header configuration file (specification */ +/* only). */ +/* */ +/* Copyright 2002-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file is used to group all #includes to the ANSI C library that */ + /* FreeType normally requires. It also defines macros to rename the */ + /* standard functions within the FreeType source code. */ + /* */ + /* Load a file which defines FTSTDLIB_H_ before this one to override it. */ + /* */ + /*************************************************************************/ + + +#ifndef FTSTDLIB_H_ +#define FTSTDLIB_H_ + + +#include <stddef.h> + +#define ft_ptrdiff_t ptrdiff_t + + + /**********************************************************************/ + /* */ + /* integer limits */ + /* */ + /* UINT_MAX and ULONG_MAX are used to automatically compute the size */ + /* of `int' and `long' in bytes at compile-time. So far, this works */ + /* for all platforms the library has been tested on. */ + /* */ + /* Note that on the extremely rare platforms that do not provide */ + /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */ + /* old Crays where `int' is 36 bits), we do not make any guarantee */ + /* about the correct behaviour of FT2 with all fonts. */ + /* */ + /* In these case, `ftconfig.h' will refuse to compile anyway with a */ + /* message like `couldn't find 32-bit type' or something similar. */ + /* */ + /**********************************************************************/ + + +#include <limits.h> + +#define FT_CHAR_BIT CHAR_BIT +#define FT_USHORT_MAX USHRT_MAX +#define FT_INT_MAX INT_MAX +#define FT_INT_MIN INT_MIN +#define FT_UINT_MAX UINT_MAX +#define FT_LONG_MIN LONG_MIN +#define FT_LONG_MAX LONG_MAX +#define FT_ULONG_MAX ULONG_MAX + + + /**********************************************************************/ + /* */ + /* character and string processing */ + /* */ + /**********************************************************************/ + + +#include <string.h> + +#define ft_memchr memchr +#define ft_memcmp memcmp +#define ft_memcpy memcpy +#define ft_memmove memmove +#define ft_memset memset +#define ft_strcat strcat +#define ft_strcmp strcmp +#define ft_strcpy strcpy +#define ft_strlen strlen +#define ft_strncmp strncmp +#define ft_strncpy strncpy +#define ft_strrchr strrchr +#define ft_strstr strstr + + + /**********************************************************************/ + /* */ + /* file handling */ + /* */ + /**********************************************************************/ + + +#include <stdio.h> + +#define FT_FILE FILE +#define ft_fclose fclose +#define ft_fopen fopen +#define ft_fread fread +#define ft_fseek fseek +#define ft_ftell ftell +#define ft_sprintf sprintf + + + /**********************************************************************/ + /* */ + /* sorting */ + /* */ + /**********************************************************************/ + + +#include <stdlib.h> + +#define ft_qsort qsort + + + /**********************************************************************/ + /* */ + /* memory allocation */ + /* */ + /**********************************************************************/ + + +#define ft_scalloc calloc +#define ft_sfree free +#define ft_smalloc malloc +#define ft_srealloc realloc + + + /**********************************************************************/ + /* */ + /* miscellaneous */ + /* */ + /**********************************************************************/ + + +#define ft_strtol strtol +#define ft_getenv getenv + + + /**********************************************************************/ + /* */ + /* execution control */ + /* */ + /**********************************************************************/ + + +#include <setjmp.h> + +#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ + /* jmp_buf is defined as a macro */ + /* on certain platforms */ + +#define ft_longjmp longjmp +#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */ + + + /* the following is only used for debugging purposes, i.e., if */ + /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */ + +#include <stdarg.h> + + +#endif /* FTSTDLIB_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/freetype.h b/src_v2/libs/sloth/freetype/freetype2/freetype/freetype.h new file mode 100644 index 0000000..eda95e2 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/freetype.h @@ -0,0 +1,4652 @@ +/***************************************************************************/ +/* */ +/* freetype.h */ +/* */ +/* FreeType high-level API and common types (specification only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FREETYPE_H_ +#define FREETYPE_H_ + + +#ifndef FT_FREETYPE_H +#error "`ft2build.h' hasn't been included yet!" +#error "Please always use macros to include FreeType header files." +#error "Example:" +#error " #include <ft2build.h>" +#error " #include FT_FREETYPE_H" +#endif + + +#include <ft2build.h> +#include FT_CONFIG_CONFIG_H +#include FT_TYPES_H +#include FT_ERRORS_H + + +FT_BEGIN_HEADER + + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* header_inclusion */ + /* */ + /* <Title> */ + /* FreeType's header inclusion scheme */ + /* */ + /* <Abstract> */ + /* How client applications should include FreeType header files. */ + /* */ + /* <Description> */ + /* To be as flexible as possible (and for historical reasons), */ + /* FreeType uses a very special inclusion scheme to load header */ + /* files, for example */ + /* */ + /* { */ + /* #include <ft2build.h> */ + /* */ + /* #include FT_FREETYPE_H */ + /* #include FT_OUTLINE_H */ + /* } */ + /* */ + /* A compiler and its preprocessor only needs an include path to find */ + /* the file `ft2build.h'; the exact locations and names of the other */ + /* FreeType header files are hidden by preprocessor macro names, */ + /* loaded by `ft2build.h'. The API documentation always gives the */ + /* header macro name needed for a particular function. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* user_allocation */ + /* */ + /* <Title> */ + /* User allocation */ + /* */ + /* <Abstract> */ + /* How client applications should allocate FreeType data structures. */ + /* */ + /* <Description> */ + /* FreeType assumes that structures allocated by the user and passed */ + /* as arguments are zeroed out except for the actual data. In other */ + /* words, it is recommended to use `calloc' (or variants of it) */ + /* instead of `malloc' for allocation. */ + /* */ + /*************************************************************************/ + + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* B A S I C T Y P E S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* base_interface */ + /* */ + /* <Title> */ + /* Base Interface */ + /* */ + /* <Abstract> */ + /* The FreeType~2 base font interface. */ + /* */ + /* <Description> */ + /* This section describes the most important public high-level API */ + /* functions of FreeType~2. */ + /* */ + /* <Order> */ + /* FT_Library */ + /* FT_Face */ + /* FT_Size */ + /* FT_GlyphSlot */ + /* FT_CharMap */ + /* FT_Encoding */ + /* FT_ENC_TAG */ + /* */ + /* FT_FaceRec */ + /* */ + /* FT_FACE_FLAG_SCALABLE */ + /* FT_FACE_FLAG_FIXED_SIZES */ + /* FT_FACE_FLAG_FIXED_WIDTH */ + /* FT_FACE_FLAG_HORIZONTAL */ + /* FT_FACE_FLAG_VERTICAL */ + /* FT_FACE_FLAG_COLOR */ + /* FT_FACE_FLAG_SFNT */ + /* FT_FACE_FLAG_CID_KEYED */ + /* FT_FACE_FLAG_TRICKY */ + /* FT_FACE_FLAG_KERNING */ + /* FT_FACE_FLAG_MULTIPLE_MASTERS */ + /* FT_FACE_FLAG_VARIATION */ + /* FT_FACE_FLAG_GLYPH_NAMES */ + /* FT_FACE_FLAG_EXTERNAL_STREAM */ + /* FT_FACE_FLAG_HINTER */ + /* */ + /* FT_HAS_HORIZONTAL */ + /* FT_HAS_VERTICAL */ + /* FT_HAS_KERNING */ + /* FT_HAS_FIXED_SIZES */ + /* FT_HAS_GLYPH_NAMES */ + /* FT_HAS_COLOR */ + /* FT_HAS_MULTIPLE_MASTERS */ + /* */ + /* FT_IS_SFNT */ + /* FT_IS_SCALABLE */ + /* FT_IS_FIXED_WIDTH */ + /* FT_IS_CID_KEYED */ + /* FT_IS_TRICKY */ + /* FT_IS_NAMED_INSTANCE */ + /* FT_IS_VARIATION */ + /* */ + /* FT_STYLE_FLAG_BOLD */ + /* FT_STYLE_FLAG_ITALIC */ + /* */ + /* FT_SizeRec */ + /* FT_Size_Metrics */ + /* */ + /* FT_GlyphSlotRec */ + /* FT_Glyph_Metrics */ + /* FT_SubGlyph */ + /* */ + /* FT_Bitmap_Size */ + /* */ + /* FT_Init_FreeType */ + /* FT_Done_FreeType */ + /* */ + /* FT_New_Face */ + /* FT_Done_Face */ + /* FT_Reference_Face */ + /* FT_New_Memory_Face */ + /* FT_Face_Properties */ + /* FT_Open_Face */ + /* FT_Open_Args */ + /* FT_Parameter */ + /* FT_Attach_File */ + /* FT_Attach_Stream */ + /* */ + /* FT_Set_Char_Size */ + /* FT_Set_Pixel_Sizes */ + /* FT_Request_Size */ + /* FT_Select_Size */ + /* FT_Size_Request_Type */ + /* FT_Size_RequestRec */ + /* FT_Size_Request */ + /* FT_Set_Transform */ + /* FT_Load_Glyph */ + /* FT_Get_Char_Index */ + /* FT_Get_First_Char */ + /* FT_Get_Next_Char */ + /* FT_Get_Name_Index */ + /* FT_Load_Char */ + /* */ + /* FT_OPEN_MEMORY */ + /* FT_OPEN_STREAM */ + /* FT_OPEN_PATHNAME */ + /* FT_OPEN_DRIVER */ + /* FT_OPEN_PARAMS */ + /* */ + /* FT_LOAD_DEFAULT */ + /* FT_LOAD_RENDER */ + /* FT_LOAD_MONOCHROME */ + /* FT_LOAD_LINEAR_DESIGN */ + /* FT_LOAD_NO_SCALE */ + /* FT_LOAD_NO_HINTING */ + /* FT_LOAD_NO_BITMAP */ + /* FT_LOAD_NO_AUTOHINT */ + /* FT_LOAD_COLOR */ + /* */ + /* FT_LOAD_VERTICAL_LAYOUT */ + /* FT_LOAD_IGNORE_TRANSFORM */ + /* FT_LOAD_FORCE_AUTOHINT */ + /* FT_LOAD_NO_RECURSE */ + /* FT_LOAD_PEDANTIC */ + /* */ + /* FT_LOAD_TARGET_NORMAL */ + /* FT_LOAD_TARGET_LIGHT */ + /* FT_LOAD_TARGET_MONO */ + /* FT_LOAD_TARGET_LCD */ + /* FT_LOAD_TARGET_LCD_V */ + /* */ + /* FT_LOAD_TARGET_MODE */ + /* */ + /* FT_Render_Glyph */ + /* FT_Render_Mode */ + /* FT_Get_Kerning */ + /* FT_Kerning_Mode */ + /* FT_Get_Track_Kerning */ + /* FT_Get_Glyph_Name */ + /* FT_Get_Postscript_Name */ + /* */ + /* FT_CharMapRec */ + /* FT_Select_Charmap */ + /* FT_Set_Charmap */ + /* FT_Get_Charmap_Index */ + /* */ + /* FT_Get_FSType_Flags */ + /* FT_Get_SubGlyph_Info */ + /* */ + /* FT_Face_Internal */ + /* FT_Size_Internal */ + /* FT_Slot_Internal */ + /* */ + /* FT_FACE_FLAG_XXX */ + /* FT_STYLE_FLAG_XXX */ + /* FT_OPEN_XXX */ + /* FT_LOAD_XXX */ + /* FT_LOAD_TARGET_XXX */ + /* FT_SUBGLYPH_FLAG_XXX */ + /* FT_FSTYPE_XXX */ + /* */ + /* FT_HAS_FAST_GLYPHS */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Glyph_Metrics */ + /* */ + /* <Description> */ + /* A structure to model the metrics of a single glyph. The values */ + /* are expressed in 26.6 fractional pixel format; if the flag */ + /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */ + /* are expressed in font units instead. */ + /* */ + /* <Fields> */ + /* width :: */ + /* The glyph's width. */ + /* */ + /* height :: */ + /* The glyph's height. */ + /* */ + /* horiBearingX :: */ + /* Left side bearing for horizontal layout. */ + /* */ + /* horiBearingY :: */ + /* Top side bearing for horizontal layout. */ + /* */ + /* horiAdvance :: */ + /* Advance width for horizontal layout. */ + /* */ + /* vertBearingX :: */ + /* Left side bearing for vertical layout. */ + /* */ + /* vertBearingY :: */ + /* Top side bearing for vertical layout. Larger positive values */ + /* mean further below the vertical glyph origin. */ + /* */ + /* vertAdvance :: */ + /* Advance height for vertical layout. Positive values mean the */ + /* glyph has a positive advance downward. */ + /* */ + /* <Note> */ + /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */ + /* dimensions of the hinted glyph (in case hinting is applicable). */ + /* */ + /* Stroking a glyph with an outside border does not increase */ + /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */ + /* values to account for the added width and height. */ + /* */ + /* FreeType doesn't use the `VORG' table data for CFF fonts because */ + /* it doesn't have an interface to quickly retrieve the glyph height. */ + /* The y~coordinate of the vertical origin can be simply computed as */ + /* `vertBearingY + height' after loading a glyph. */ + /* */ + typedef struct FT_Glyph_Metrics_ + { + FT_Pos width; + FT_Pos height; + + FT_Pos horiBearingX; + FT_Pos horiBearingY; + FT_Pos horiAdvance; + + FT_Pos vertBearingX; + FT_Pos vertBearingY; + FT_Pos vertAdvance; + + } FT_Glyph_Metrics; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Bitmap_Size */ + /* */ + /* <Description> */ + /* This structure models the metrics of a bitmap strike (i.e., a set */ + /* of glyphs for a given point size and resolution) in a bitmap font. */ + /* It is used for the `available_sizes' field of @FT_Face. */ + /* */ + /* <Fields> */ + /* height :: The vertical distance, in pixels, between two */ + /* consecutive baselines. It is always positive. */ + /* */ + /* width :: The average width, in pixels, of all glyphs in the */ + /* strike. */ + /* */ + /* size :: The nominal size of the strike in 26.6 fractional */ + /* points. This field is not very useful. */ + /* */ + /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */ + /* pixels. */ + /* */ + /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */ + /* pixels. */ + /* */ + /* <Note> */ + /* Windows FNT: */ + /* The nominal size given in a FNT font is not reliable. If the */ + /* driver finds it incorrect, it sets `size' to some calculated */ + /* values, and `x_ppem' and `y_ppem' to the pixel width and height */ + /* given in the font, respectively. */ + /* */ + /* TrueType embedded bitmaps: */ + /* `size', `width', and `height' values are not contained in the */ + /* bitmap strike itself. They are computed from the global font */ + /* parameters. */ + /* */ + typedef struct FT_Bitmap_Size_ + { + FT_Short height; + FT_Short width; + + FT_Pos size; + + FT_Pos x_ppem; + FT_Pos y_ppem; + + } FT_Bitmap_Size; + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* O B J E C T C L A S S E S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Library */ + /* */ + /* <Description> */ + /* A handle to a FreeType library instance. Each `library' is */ + /* completely independent from the others; it is the `root' of a set */ + /* of objects like fonts, faces, sizes, etc. */ + /* */ + /* It also embeds a memory manager (see @FT_Memory), as well as a */ + /* scan-line converter object (see @FT_Raster). */ + /* */ + /* In multi-threaded applications it is easiest to use one */ + /* `FT_Library' object per thread. In case this is too cumbersome, */ + /* a single `FT_Library' object across threads is possible also */ + /* (since FreeType version 2.5.6), as long as a mutex lock is used */ + /* around @FT_New_Face and @FT_Done_Face. */ + /* */ + /* <Note> */ + /* Library objects are normally created by @FT_Init_FreeType, and */ + /* destroyed with @FT_Done_FreeType. If you need reference-counting */ + /* (cf. @FT_Reference_Library), use @FT_New_Library and */ + /* @FT_Done_Library. */ + /* */ + typedef struct FT_LibraryRec_ *FT_Library; + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* module_management */ + /* */ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Module */ + /* */ + /* <Description> */ + /* A handle to a given FreeType module object. A module can be a */ + /* font driver, a renderer, or anything else that provides services */ + /* to the former. */ + /* */ + typedef struct FT_ModuleRec_* FT_Module; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Driver */ + /* */ + /* <Description> */ + /* A handle to a given FreeType font driver object. A font driver */ + /* is a module capable of creating faces from font files. */ + /* */ + typedef struct FT_DriverRec_* FT_Driver; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Renderer */ + /* */ + /* <Description> */ + /* A handle to a given FreeType renderer. A renderer is a module in */ + /* charge of converting a glyph's outline image to a bitmap. It */ + /* supports a single glyph image format, and one or more target */ + /* surface depths. */ + /* */ + typedef struct FT_RendererRec_* FT_Renderer; + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* base_interface */ + /* */ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Face */ + /* */ + /* <Description> */ + /* A handle to a typographic face object. A face object models a */ + /* given typeface, in a given style. */ + /* */ + /* <Note> */ + /* A face object also owns a single @FT_GlyphSlot object, as well */ + /* as one or more @FT_Size objects. */ + /* */ + /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */ + /* a given filepath or a custom input stream. */ + /* */ + /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */ + /* */ + /* An `FT_Face' object can only be safely used from one thread at a */ + /* time. Similarly, creation and destruction of `FT_Face' with the */ + /* same @FT_Library object can only be done from one thread at a */ + /* time. On the other hand, functions like @FT_Load_Glyph and its */ + /* siblings are thread-safe and do not need the lock to be held as */ + /* long as the same `FT_Face' object is not used from multiple */ + /* threads at the same time. */ + /* */ + /* <Also> */ + /* See @FT_FaceRec for the publicly accessible fields of a given face */ + /* object. */ + /* */ + typedef struct FT_FaceRec_* FT_Face; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Size */ + /* */ + /* <Description> */ + /* A handle to an object that models a face scaled to a given */ + /* character size. */ + /* */ + /* <Note> */ + /* An @FT_Face has one _active_ @FT_Size object that is used by */ + /* functions like @FT_Load_Glyph to determine the scaling */ + /* transformation that in turn is used to load and hint glyphs and */ + /* metrics. */ + /* */ + /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */ + /* @FT_Request_Size or even @FT_Select_Size to change the content */ + /* (i.e., the scaling values) of the active @FT_Size. */ + /* */ + /* You can use @FT_New_Size to create additional size objects for a */ + /* given @FT_Face, but they won't be used by other functions until */ + /* you activate it through @FT_Activate_Size. Only one size can be */ + /* activated at any given time per face. */ + /* */ + /* <Also> */ + /* See @FT_SizeRec for the publicly accessible fields of a given size */ + /* object. */ + /* */ + typedef struct FT_SizeRec_* FT_Size; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_GlyphSlot */ + /* */ + /* <Description> */ + /* A handle to a given `glyph slot'. A slot is a container that can */ + /* hold any of the glyphs contained in its parent face. */ + /* */ + /* In other words, each time you call @FT_Load_Glyph or */ + /* @FT_Load_Char, the slot's content is erased by the new glyph data, */ + /* i.e., the glyph's metrics, its image (bitmap or outline), and */ + /* other control information. */ + /* */ + /* <Also> */ + /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */ + /* */ + typedef struct FT_GlyphSlotRec_* FT_GlyphSlot; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_CharMap */ + /* */ + /* <Description> */ + /* A handle to a character map (usually abbreviated to `charmap'). A */ + /* charmap is used to translate character codes in a given encoding */ + /* into glyph indexes for its parent's face. Some font formats may */ + /* provide several charmaps per font. */ + /* */ + /* Each face object owns zero or more charmaps, but only one of them */ + /* can be `active', providing the data used by @FT_Get_Char_Index or */ + /* @FT_Load_Char. */ + /* */ + /* The list of available charmaps in a face is available through the */ + /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */ + /* */ + /* The currently active charmap is available as `face->charmap'. */ + /* You should call @FT_Set_Charmap to change it. */ + /* */ + /* <Note> */ + /* When a new face is created (either through @FT_New_Face or */ + /* @FT_Open_Face), the library looks for a Unicode charmap within */ + /* the list and automatically activates it. If there is no Unicode */ + /* charmap, FreeType doesn't set an `active' charmap. */ + /* */ + /* <Also> */ + /* See @FT_CharMapRec for the publicly accessible fields of a given */ + /* character map. */ + /* */ + typedef struct FT_CharMapRec_* FT_CharMap; + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_ENC_TAG */ + /* */ + /* <Description> */ + /* This macro converts four-letter tags into an unsigned long. It is */ + /* used to define `encoding' identifiers (see @FT_Encoding). */ + /* */ + /* <Note> */ + /* Since many 16-bit compilers don't like 32-bit enumerations, you */ + /* should redefine this macro in case of problems to something like */ + /* this: */ + /* */ + /* { */ + /* #define FT_ENC_TAG( value, a, b, c, d ) value */ + /* } */ + /* */ + /* to get a simple enumeration without assigning special numbers. */ + /* */ + +#ifndef FT_ENC_TAG +#define FT_ENC_TAG( value, a, b, c, d ) \ + value = ( ( (FT_UInt32)(a) << 24 ) | \ + ( (FT_UInt32)(b) << 16 ) | \ + ( (FT_UInt32)(c) << 8 ) | \ + (FT_UInt32)(d) ) + +#endif /* FT_ENC_TAG */ + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Encoding */ + /* */ + /* <Description> */ + /* An enumeration to specify character sets supported by charmaps. */ + /* Used in the @FT_Select_Charmap API function. */ + /* */ + /* <Note> */ + /* Despite the name, this enumeration lists specific character */ + /* repertories (i.e., charsets), and not text encoding methods (e.g., */ + /* UTF-8, UTF-16, etc.). */ + /* */ + /* Other encodings might be defined in the future. */ + /* */ + /* <Values> */ + /* FT_ENCODING_NONE :: */ + /* The encoding value~0 is reserved. */ + /* */ + /* FT_ENCODING_UNICODE :: */ + /* The Unicode character set. This value covers all versions of */ + /* the Unicode repertoire, including ASCII and Latin-1. Most fonts */ + /* include a Unicode charmap, but not all of them. */ + /* */ + /* For example, if you want to access Unicode value U+1F028 (and */ + /* the font contains it), use value 0x1F028 as the input value for */ + /* @FT_Get_Char_Index. */ + /* */ + /* FT_ENCODING_MS_SYMBOL :: */ + /* Microsoft Symbol encoding, used to encode mathematical symbols */ + /* and wingdings. For more information, see */ + /* `https://www.microsoft.com/typography/otspec/recom.htm', */ + /* `http://www.kostis.net/charsets/symbol.htm', and */ + /* `http://www.kostis.net/charsets/wingding.htm'. */ + /* */ + /* This encoding uses character codes from the PUA (Private Unicode */ + /* Area) in the range U+F020-U+F0FF. */ + /* */ + /* FT_ENCODING_SJIS :: */ + /* Shift JIS encoding for Japanese. More info at */ + /* `https://en.wikipedia.org/wiki/Shift_JIS'. See note on */ + /* multi-byte encodings below. */ + /* */ + /* FT_ENCODING_PRC :: */ + /* Corresponds to encoding systems mainly for Simplified Chinese as */ + /* used in People's Republic of China (PRC). The encoding layout */ + /* is based on GB~2312 and its supersets GBK and GB~18030. */ + /* */ + /* FT_ENCODING_BIG5 :: */ + /* Corresponds to an encoding system for Traditional Chinese as */ + /* used in Taiwan and Hong Kong. */ + /* */ + /* FT_ENCODING_WANSUNG :: */ + /* Corresponds to the Korean encoding system known as Extended */ + /* Wansung (MS Windows code page 949). */ + /* For more information see */ + /* `https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. */ + /* */ + /* FT_ENCODING_JOHAB :: */ + /* The Korean standard character set (KS~C 5601-1992), which */ + /* corresponds to MS Windows code page 1361. This character set */ + /* includes all possible Hangul character combinations. */ + /* */ + /* FT_ENCODING_ADOBE_LATIN_1 :: */ + /* Corresponds to a Latin-1 encoding as defined in a Type~1 */ + /* PostScript font. It is limited to 256 character codes. */ + /* */ + /* FT_ENCODING_ADOBE_STANDARD :: */ + /* Adobe Standard encoding, as found in Type~1, CFF, and */ + /* OpenType/CFF fonts. It is limited to 256 character codes. */ + /* */ + /* FT_ENCODING_ADOBE_EXPERT :: */ + /* Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF */ + /* fonts. It is limited to 256 character codes. */ + /* */ + /* FT_ENCODING_ADOBE_CUSTOM :: */ + /* Corresponds to a custom encoding, as found in Type~1, CFF, and */ + /* OpenType/CFF fonts. It is limited to 256 character codes. */ + /* */ + /* FT_ENCODING_APPLE_ROMAN :: */ + /* Apple roman encoding. Many TrueType and OpenType fonts contain */ + /* a charmap for this 8-bit encoding, since older versions of Mac */ + /* OS are able to use it. */ + /* */ + /* FT_ENCODING_OLD_LATIN_2 :: */ + /* This value is deprecated and was neither used nor reported by */ + /* FreeType. Don't use or test for it. */ + /* */ + /* FT_ENCODING_MS_SJIS :: */ + /* Same as FT_ENCODING_SJIS. Deprecated. */ + /* */ + /* FT_ENCODING_MS_GB2312 :: */ + /* Same as FT_ENCODING_PRC. Deprecated. */ + /* */ + /* FT_ENCODING_MS_BIG5 :: */ + /* Same as FT_ENCODING_BIG5. Deprecated. */ + /* */ + /* FT_ENCODING_MS_WANSUNG :: */ + /* Same as FT_ENCODING_WANSUNG. Deprecated. */ + /* */ + /* FT_ENCODING_MS_JOHAB :: */ + /* Same as FT_ENCODING_JOHAB. Deprecated. */ + /* */ + /* <Note> */ + /* By default, FreeType automatically synthesizes a Unicode charmap */ + /* for PostScript fonts, using their glyph name dictionaries. */ + /* However, it also reports the encodings defined explicitly in the */ + /* font file, for the cases when they are needed, with the Adobe */ + /* values as well. */ + /* */ + /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */ + /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */ + /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */ + /* which encoding is really present. If, for example, the */ + /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */ + /* the font is encoded in KOI8-R. */ + /* */ + /* FT_ENCODING_NONE is always set (with a single exception) by the */ + /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */ + /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */ + /* which encoding is really present. For example, */ + /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */ + /* Russian). */ + /* */ + /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */ + /* and `encoding_id' is not `TT_MAC_ID_ROMAN' (otherwise it is set to */ + /* FT_ENCODING_APPLE_ROMAN). */ + /* */ + /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */ + /* @FT_Get_CMap_Language_ID to query the Mac language ID that may */ + /* be needed to be able to distinguish Apple encoding variants. See */ + /* */ + /* https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt */ + /* */ + /* to get an idea how to do that. Basically, if the language ID */ + /* is~0, don't use it, otherwise subtract 1 from the language ID. */ + /* Then examine `encoding_id'. If, for example, `encoding_id' is */ + /* `TT_MAC_ID_ROMAN' and the language ID (minus~1) is */ + /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */ + /* `TT_MAC_ID_ARABIC' with `TT_MAC_LANGID_FARSI' means the Farsi */ + /* variant the Arabic encoding. */ + /* */ + typedef enum FT_Encoding_ + { + FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), + + FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ), + FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ), + + FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ), + FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ), + FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ), + FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ), + FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ), + + /* for backward compatibility */ + FT_ENCODING_GB2312 = FT_ENCODING_PRC, + FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS, + FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC, + FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5, + FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG, + FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB, + + FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ), + + FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ), + + FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' ) + + } FT_Encoding; + + + /* these constants are deprecated; use the corresponding `FT_Encoding' */ + /* values instead */ +#define ft_encoding_none FT_ENCODING_NONE +#define ft_encoding_unicode FT_ENCODING_UNICODE +#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL +#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1 +#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2 +#define ft_encoding_sjis FT_ENCODING_SJIS +#define ft_encoding_gb2312 FT_ENCODING_PRC +#define ft_encoding_big5 FT_ENCODING_BIG5 +#define ft_encoding_wansung FT_ENCODING_WANSUNG +#define ft_encoding_johab FT_ENCODING_JOHAB + +#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD +#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT +#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM +#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_CharMapRec */ + /* */ + /* <Description> */ + /* The base charmap structure. */ + /* */ + /* <Fields> */ + /* face :: A handle to the parent face object. */ + /* */ + /* encoding :: An @FT_Encoding tag identifying the charmap. Use */ + /* this with @FT_Select_Charmap. */ + /* */ + /* platform_id :: An ID number describing the platform for the */ + /* following encoding ID. This comes directly from */ + /* the TrueType specification and gets emulated for */ + /* other formats. */ + /* */ + /* encoding_id :: A platform specific encoding number. This also */ + /* comes from the TrueType specification and gets */ + /* emulated similarly. */ + /* */ + typedef struct FT_CharMapRec_ + { + FT_Face face; + FT_Encoding encoding; + FT_UShort platform_id; + FT_UShort encoding_id; + + } FT_CharMapRec; + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* B A S E O B J E C T C L A S S E S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Face_Internal */ + /* */ + /* <Description> */ + /* An opaque handle to an `FT_Face_InternalRec' structure that models */ + /* the private data of a given @FT_Face object. */ + /* */ + /* This structure might change between releases of FreeType~2 and is */ + /* not generally available to client applications. */ + /* */ + typedef struct FT_Face_InternalRec_* FT_Face_Internal; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_FaceRec */ + /* */ + /* <Description> */ + /* FreeType root face class structure. A face object models a */ + /* typeface in a font file. */ + /* */ + /* <Fields> */ + /* num_faces :: The number of faces in the font file. Some */ + /* font formats can have multiple faces in */ + /* a single font file. */ + /* */ + /* face_index :: This field holds two different values. */ + /* Bits 0-15 are the index of the face in the */ + /* font file (starting with value~0). They */ + /* are set to~0 if there is only one face in */ + /* the font file. */ + /* */ + /* [Since 2.6.1] Bits 16-30 are relevant to GX */ + /* and OpenType variation fonts only, holding */ + /* the named instance index for the current */ + /* face index (starting with value~1; value~0 */ + /* indicates font access without a named */ + /* instance). For non-variation fonts, bits */ + /* 16-30 are ignored. If we have the third */ + /* named instance of face~4, say, `face_index' */ + /* is set to 0x00030004. */ + /* */ + /* Bit 31 is always zero (this is, */ + /* `face_index' is always a positive value). */ + /* */ + /* [Since 2.9] Changing the design coordinates */ + /* with @FT_Set_Var_Design_Coordinates or */ + /* @FT_Set_Var_Blend_Coordinates does not */ + /* influence the named instance index value */ + /* (only @FT_Set_Named_Instance does that). */ + /* */ + /* face_flags :: A set of bit flags that give important */ + /* information about the face; see */ + /* @FT_FACE_FLAG_XXX for the details. */ + /* */ + /* style_flags :: The lower 16~bits contain a set of bit */ + /* flags indicating the style of the face; see */ + /* @FT_STYLE_FLAG_XXX for the details. */ + /* */ + /* [Since 2.6.1] Bits 16-30 hold the number */ + /* of named instances available for the */ + /* current face if we have a GX or OpenType */ + /* variation (sub)font. Bit 31 is always zero */ + /* (this is, `style_flags' is always a */ + /* positive value). Note that a variation */ + /* font has always at least one named */ + /* instance, namely the default instance. */ + /* */ + /* num_glyphs :: The number of glyphs in the face. If the */ + /* face is scalable and has sbits (see */ + /* `num_fixed_sizes'), it is set to the number */ + /* of outline glyphs. */ + /* */ + /* For CID-keyed fonts (not in an SFNT */ + /* wrapper) this value gives the highest CID */ + /* used in the font. */ + /* */ + /* family_name :: The face's family name. This is an ASCII */ + /* string, usually in English, that describes */ + /* the typeface's family (like `Times New */ + /* Roman', `Bodoni', `Garamond', etc). This */ + /* is a least common denominator used to list */ + /* fonts. Some formats (TrueType & OpenType) */ + /* provide localized and Unicode versions of */ + /* this string. Applications should use the */ + /* format specific interface to access them. */ + /* Can be NULL (e.g., in fonts embedded in a */ + /* PDF file). */ + /* */ + /* In case the font doesn't provide a specific */ + /* family name entry, FreeType tries to */ + /* synthesize one, deriving it from other name */ + /* entries. */ + /* */ + /* style_name :: The face's style name. This is an ASCII */ + /* string, usually in English, that describes */ + /* the typeface's style (like `Italic', */ + /* `Bold', `Condensed', etc). Not all font */ + /* formats provide a style name, so this field */ + /* is optional, and can be set to NULL. As */ + /* for `family_name', some formats provide */ + /* localized and Unicode versions of this */ + /* string. Applications should use the format */ + /* specific interface to access them. */ + /* */ + /* num_fixed_sizes :: The number of bitmap strikes in the face. */ + /* Even if the face is scalable, there might */ + /* still be bitmap strikes, which are called */ + /* `sbits' in that case. */ + /* */ + /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */ + /* strikes in the face. It is set to NULL if */ + /* there is no bitmap strike. */ + /* */ + /* Note that FreeType tries to sanitize the */ + /* strike data since they are sometimes sloppy */ + /* or incorrect, but this can easily fail. */ + /* */ + /* num_charmaps :: The number of charmaps in the face. */ + /* */ + /* charmaps :: An array of the charmaps of the face. */ + /* */ + /* generic :: A field reserved for client uses. See the */ + /* @FT_Generic type description. */ + /* */ + /* bbox :: The font bounding box. Coordinates are */ + /* expressed in font units (see */ + /* `units_per_EM'). The box is large enough */ + /* to contain any glyph from the font. Thus, */ + /* `bbox.yMax' can be seen as the `maximum */ + /* ascender', and `bbox.yMin' as the `minimum */ + /* descender'. Only relevant for scalable */ + /* formats. */ + /* */ + /* Note that the bounding box might be off by */ + /* (at least) one pixel for hinted fonts. See */ + /* @FT_Size_Metrics for further discussion. */ + /* */ + /* units_per_EM :: The number of font units per EM square for */ + /* this face. This is typically 2048 for */ + /* TrueType fonts, and 1000 for Type~1 fonts. */ + /* Only relevant for scalable formats. */ + /* */ + /* ascender :: The typographic ascender of the face, */ + /* expressed in font units. For font formats */ + /* not having this information, it is set to */ + /* `bbox.yMax'. Only relevant for scalable */ + /* formats. */ + /* */ + /* descender :: The typographic descender of the face, */ + /* expressed in font units. For font formats */ + /* not having this information, it is set to */ + /* `bbox.yMin'. Note that this field is */ + /* negative for values below the baseline. */ + /* Only relevant for scalable formats. */ + /* */ + /* height :: This value is the vertical distance */ + /* between two consecutive baselines, */ + /* expressed in font units. It is always */ + /* positive. Only relevant for scalable */ + /* formats. */ + /* */ + /* If you want the global glyph height, use */ + /* `ascender - descender'. */ + /* */ + /* max_advance_width :: The maximum advance width, in font units, */ + /* for all glyphs in this face. This can be */ + /* used to make word wrapping computations */ + /* faster. Only relevant for scalable */ + /* formats. */ + /* */ + /* max_advance_height :: The maximum advance height, in font units, */ + /* for all glyphs in this face. This is only */ + /* relevant for vertical layouts, and is set */ + /* to `height' for fonts that do not provide */ + /* vertical metrics. Only relevant for */ + /* scalable formats. */ + /* */ + /* underline_position :: The position, in font units, of the */ + /* underline line for this face. It is the */ + /* center of the underlining stem. Only */ + /* relevant for scalable formats. */ + /* */ + /* underline_thickness :: The thickness, in font units, of the */ + /* underline for this face. Only relevant for */ + /* scalable formats. */ + /* */ + /* glyph :: The face's associated glyph slot(s). */ + /* */ + /* size :: The current active size for this face. */ + /* */ + /* charmap :: The current active charmap for this face. */ + /* */ + /* <Note> */ + /* Fields may be changed after a call to @FT_Attach_File or */ + /* @FT_Attach_Stream. */ + /* */ + /* For an OpenType variation font, the values of the following fields */ + /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ + /* friends) if the font contains an `MVAR' table: `ascender', */ + /* `descender', `height', `underline_position', and */ + /* `underline_thickness'. */ + /* */ + /* Especially for TrueType fonts see also the documentation for */ + /* @FT_Size_Metrics. */ + /* */ + typedef struct FT_FaceRec_ + { + FT_Long num_faces; + FT_Long face_index; + + FT_Long face_flags; + FT_Long style_flags; + + FT_Long num_glyphs; + + FT_String* family_name; + FT_String* style_name; + + FT_Int num_fixed_sizes; + FT_Bitmap_Size* available_sizes; + + FT_Int num_charmaps; + FT_CharMap* charmaps; + + FT_Generic generic; + + /*# The following member variables (down to `underline_thickness') */ + /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */ + /*# for bitmap fonts. */ + FT_BBox bbox; + + FT_UShort units_per_EM; + FT_Short ascender; + FT_Short descender; + FT_Short height; + + FT_Short max_advance_width; + FT_Short max_advance_height; + + FT_Short underline_position; + FT_Short underline_thickness; + + FT_GlyphSlot glyph; + FT_Size size; + FT_CharMap charmap; + + /*@private begin */ + + FT_Driver driver; + FT_Memory memory; + FT_Stream stream; + + FT_ListRec sizes_list; + + FT_Generic autohint; /* face-specific auto-hinter data */ + void* extensions; /* unused */ + + FT_Face_Internal internal; + + /*@private end */ + + } FT_FaceRec; + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_FACE_FLAG_XXX */ + /* */ + /* <Description> */ + /* A list of bit flags used in the `face_flags' field of the */ + /* @FT_FaceRec structure. They inform client applications of */ + /* properties of the corresponding face. */ + /* */ + /* <Values> */ + /* FT_FACE_FLAG_SCALABLE :: */ + /* The face contains outline glyphs. Note that a face can contain */ + /* bitmap strikes also, i.e., a face can have both this flag and */ + /* @FT_FACE_FLAG_FIXED_SIZES set. */ + /* */ + /* FT_FACE_FLAG_FIXED_SIZES :: */ + /* The face contains bitmap strikes. See also the */ + /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */ + /* */ + /* FT_FACE_FLAG_FIXED_WIDTH :: */ + /* The face contains fixed-width characters (like Courier, Lucida, */ + /* MonoType, etc.). */ + /* */ + /* FT_FACE_FLAG_SFNT :: */ + /* The face uses the SFNT storage scheme. For now, this means */ + /* TrueType and OpenType. */ + /* */ + /* FT_FACE_FLAG_HORIZONTAL :: */ + /* The face contains horizontal glyph metrics. This should be set */ + /* for all common formats. */ + /* */ + /* FT_FACE_FLAG_VERTICAL :: */ + /* The face contains vertical glyph metrics. This is only */ + /* available in some formats, not all of them. */ + /* */ + /* FT_FACE_FLAG_KERNING :: */ + /* The face contains kerning information. If set, the kerning */ + /* distance can be retrieved using the function @FT_Get_Kerning. */ + /* Otherwise the function always return the vector (0,0). Note */ + /* that FreeType doesn't handle kerning data from the SFNT `GPOS' */ + /* table (as present in many OpenType fonts). */ + /* */ + /* FT_FACE_FLAG_FAST_GLYPHS :: */ + /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */ + /* */ + /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */ + /* The face contains multiple masters and is capable of */ + /* interpolating between them. Supported formats are Adobe MM, */ + /* TrueType GX, and OpenType variation fonts. */ + /* */ + /* See the multiple-masters specific API for details. */ + /* */ + /* FT_FACE_FLAG_GLYPH_NAMES :: */ + /* The face contains glyph names, which can be retrieved using */ + /* @FT_Get_Glyph_Name. Note that some TrueType fonts contain */ + /* broken glyph name tables. Use the function */ + /* @FT_Has_PS_Glyph_Names when needed. */ + /* */ + /* FT_FACE_FLAG_EXTERNAL_STREAM :: */ + /* Used internally by FreeType to indicate that a face's stream was */ + /* provided by the client application and should not be destroyed */ + /* when @FT_Done_Face is called. Don't read or test this flag. */ + /* */ + /* FT_FACE_FLAG_HINTER :: */ + /* The font driver has a hinting machine of its own. For example, */ + /* with TrueType fonts, it makes sense to use data from the SFNT */ + /* `gasp' table only if the native TrueType hinting engine (with */ + /* the bytecode interpreter) is available and active. */ + /* */ + /* FT_FACE_FLAG_CID_KEYED :: */ + /* The face is CID-keyed. In that case, the face is not accessed */ + /* by glyph indices but by CID values. For subsetted CID-keyed */ + /* fonts this has the consequence that not all index values are a */ + /* valid argument to @FT_Load_Glyph. Only the CID values for which */ + /* corresponding glyphs in the subsetted font exist make */ + /* `FT_Load_Glyph' return successfully; in all other cases you get */ + /* an `FT_Err_Invalid_Argument' error. */ + /* */ + /* Note that CID-keyed fonts that are in an SFNT wrapper (this is, */ + /* all OpenType/CFF fonts) don't have this flag set since the */ + /* glyphs are accessed in the normal way (using contiguous */ + /* indices); the `CID-ness' isn't visible to the application. */ + /* */ + /* FT_FACE_FLAG_TRICKY :: */ + /* The face is `tricky', this is, it always needs the font format's */ + /* native hinting engine to get a reasonable result. A typical */ + /* example is the old Chinese font `mingli.ttf' (but not */ + /* `mingliu.ttc') that uses TrueType bytecode instructions to move */ + /* and scale all of its subglyphs. */ + /* */ + /* It is not possible to auto-hint such fonts using */ + /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */ + /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */ + /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */ + /* probably never want this except for demonstration purposes. */ + /* */ + /* Currently, there are about a dozen TrueType fonts in the list of */ + /* tricky fonts; they are hard-coded in file `ttobjs.c'. */ + /* */ + /* FT_FACE_FLAG_COLOR :: */ + /* [Since 2.5.1] The face has color glyph tables. To access color */ + /* glyphs use @FT_LOAD_COLOR. */ + /* */ + /* FT_FACE_FLAG_VARIATION :: */ + /* [Since 2.9] Set if the current face (or named instance) has been */ + /* altered with @FT_Set_MM_Design_Coordinates, */ + /* @FT_Set_Var_Design_Coordinates, or */ + /* @FT_Set_Var_Blend_Coordinates. This flag is unset by a call to */ + /* @FT_Set_Named_Instance. */ + /* */ +#define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) +#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) +#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) +#define FT_FACE_FLAG_SFNT ( 1L << 3 ) +#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 ) +#define FT_FACE_FLAG_VERTICAL ( 1L << 5 ) +#define FT_FACE_FLAG_KERNING ( 1L << 6 ) +#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 ) +#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 ) +#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 ) +#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 ) +#define FT_FACE_FLAG_HINTER ( 1L << 11 ) +#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 ) +#define FT_FACE_FLAG_TRICKY ( 1L << 13 ) +#define FT_FACE_FLAG_COLOR ( 1L << 14 ) +#define FT_FACE_FLAG_VARIATION ( 1L << 15 ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_HORIZONTAL( face ) + * + * @description: + * A macro that returns true whenever a face object contains + * horizontal metrics (this is true for all font formats though). + * + * @also: + * @FT_HAS_VERTICAL can be used to check for vertical metrics. + * + */ +#define FT_HAS_HORIZONTAL( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_VERTICAL( face ) + * + * @description: + * A macro that returns true whenever a face object contains real + * vertical metrics (and not only synthesized ones). + * + */ +#define FT_HAS_VERTICAL( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_KERNING( face ) + * + * @description: + * A macro that returns true whenever a face object contains kerning + * data that can be accessed with @FT_Get_Kerning. + * + */ +#define FT_HAS_KERNING( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_KERNING ) + + + /************************************************************************* + * + * @macro: + * FT_IS_SCALABLE( face ) + * + * @description: + * A macro that returns true whenever a face object contains a scalable + * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, + * and PFR font formats). + * + */ +#define FT_IS_SCALABLE( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) + + + /************************************************************************* + * + * @macro: + * FT_IS_SFNT( face ) + * + * @description: + * A macro that returns true whenever a face object contains a font + * whose format is based on the SFNT storage scheme. This usually + * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded + * bitmap fonts. + * + * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and + * @FT_TRUETYPE_TABLES_H are available. + * + */ +#define FT_IS_SFNT( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_SFNT ) + + + /************************************************************************* + * + * @macro: + * FT_IS_FIXED_WIDTH( face ) + * + * @description: + * A macro that returns true whenever a face object contains a font face + * that contains fixed-width (or `monospace', `fixed-pitch', etc.) + * glyphs. + * + */ +#define FT_IS_FIXED_WIDTH( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_FIXED_SIZES( face ) + * + * @description: + * A macro that returns true whenever a face object contains some + * embedded bitmaps. See the `available_sizes' field of the + * @FT_FaceRec structure. + * + */ +#define FT_HAS_FIXED_SIZES( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_FAST_GLYPHS( face ) + * + * @description: + * Deprecated. + * + */ +#define FT_HAS_FAST_GLYPHS( face ) 0 + + + /************************************************************************* + * + * @macro: + * FT_HAS_GLYPH_NAMES( face ) + * + * @description: + * A macro that returns true whenever a face object contains some glyph + * names that can be accessed through @FT_Get_Glyph_Name. + * + */ +#define FT_HAS_GLYPH_NAMES( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_MULTIPLE_MASTERS( face ) + * + * @description: + * A macro that returns true whenever a face object contains some + * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H + * are then available to choose the exact design you want. + * + */ +#define FT_HAS_MULTIPLE_MASTERS( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) + + + /************************************************************************* + * + * @macro: + * FT_IS_NAMED_INSTANCE( face ) + * + * @description: + * A macro that returns true whenever a face object is a named instance + * of a GX or OpenType variation font. + * + * [Since 2.9] Changing the design coordinates with + * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does + * not influence the return value of this macro (only + * @FT_Set_Named_Instance does that). + * + * @since: + * 2.7 + * + */ +#define FT_IS_NAMED_INSTANCE( face ) \ + ( (face)->face_index & 0x7FFF0000L ) + + + /************************************************************************* + * + * @macro: + * FT_IS_VARIATION( face ) + * + * @description: + * A macro that returns true whenever a face object has been altered + * by @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, or + * @FT_Set_Var_Blend_Coordinates. + * + * @since: + * 2.9 + * + */ +#define FT_IS_VARIATION( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_VARIATION ) + + + /************************************************************************* + * + * @macro: + * FT_IS_CID_KEYED( face ) + * + * @description: + * A macro that returns true whenever a face object contains a CID-keyed + * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more + * details. + * + * If this macro is true, all functions defined in @FT_CID_H are + * available. + * + */ +#define FT_IS_CID_KEYED( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) + + + /************************************************************************* + * + * @macro: + * FT_IS_TRICKY( face ) + * + * @description: + * A macro that returns true whenever a face represents a `tricky' font. + * See the discussion of @FT_FACE_FLAG_TRICKY for more details. + * + */ +#define FT_IS_TRICKY( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_TRICKY ) + + + /************************************************************************* + * + * @macro: + * FT_HAS_COLOR( face ) + * + * @description: + * A macro that returns true whenever a face object contains + * tables for color glyphs. + * + * @since: + * 2.5.1 + * + */ +#define FT_HAS_COLOR( face ) \ + ( (face)->face_flags & FT_FACE_FLAG_COLOR ) + + + /*************************************************************************/ + /* */ + /* <Const> */ + /* FT_STYLE_FLAG_XXX */ + /* */ + /* <Description> */ + /* A list of bit flags to indicate the style of a given face. These */ + /* are used in the `style_flags' field of @FT_FaceRec. */ + /* */ + /* <Values> */ + /* FT_STYLE_FLAG_ITALIC :: */ + /* The face style is italic or oblique. */ + /* */ + /* FT_STYLE_FLAG_BOLD :: */ + /* The face is bold. */ + /* */ + /* <Note> */ + /* The style information as provided by FreeType is very basic. More */ + /* details are beyond the scope and should be done on a higher level */ + /* (for example, by analyzing various fields of the `OS/2' table in */ + /* SFNT based fonts). */ + /* */ +#define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) +#define FT_STYLE_FLAG_BOLD ( 1 << 1 ) + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Size_Internal */ + /* */ + /* <Description> */ + /* An opaque handle to an `FT_Size_InternalRec' structure, used to */ + /* model private data of a given @FT_Size object. */ + /* */ + typedef struct FT_Size_InternalRec_* FT_Size_Internal; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Size_Metrics */ + /* */ + /* <Description> */ + /* The size metrics structure gives the metrics of a size object. */ + /* */ + /* <Fields> */ + /* x_ppem :: The width of the scaled EM square in pixels, hence */ + /* the term `ppem' (pixels per EM). It is also */ + /* referred to as `nominal width'. */ + /* */ + /* y_ppem :: The height of the scaled EM square in pixels, */ + /* hence the term `ppem' (pixels per EM). It is also */ + /* referred to as `nominal height'. */ + /* */ + /* x_scale :: A 16.16 fractional scaling value to convert */ + /* horizontal metrics from font units to 26.6 */ + /* fractional pixels. Only relevant for scalable */ + /* font formats. */ + /* */ + /* y_scale :: A 16.16 fractional scaling value to convert */ + /* vertical metrics from font units to 26.6 */ + /* fractional pixels. Only relevant for scalable */ + /* font formats. */ + /* */ + /* ascender :: The ascender in 26.6 fractional pixels, rounded up */ + /* to an integer value. See @FT_FaceRec for the */ + /* details. */ + /* */ + /* descender :: The descender in 26.6 fractional pixels, rounded */ + /* down to an integer value. See @FT_FaceRec for the */ + /* details. */ + /* */ + /* height :: The height in 26.6 fractional pixels, rounded to */ + /* an integer value. See @FT_FaceRec for the */ + /* details. */ + /* */ + /* max_advance :: The maximum advance width in 26.6 fractional */ + /* pixels, rounded to an integer value. See */ + /* @FT_FaceRec for the details. */ + /* */ + /* <Note> */ + /* The scaling values, if relevant, are determined first during a */ + /* size changing operation. The remaining fields are then set by the */ + /* driver. For scalable formats, they are usually set to scaled */ + /* values of the corresponding fields in @FT_FaceRec. Some values */ + /* like ascender or descender are rounded for historical reasons; */ + /* more precise values (for outline fonts) can be derived by scaling */ + /* the corresponding @FT_FaceRec values manually, with code similar */ + /* to the following. */ + /* */ + /* { */ + /* scaled_ascender = FT_MulFix( face->ascender, */ + /* size_metrics->y_scale ); */ + /* } */ + /* */ + /* Note that due to glyph hinting and the selected rendering mode */ + /* these values are usually not exact; consequently, they must be */ + /* treated as unreliable with an error margin of at least one pixel! */ + /* */ + /* Indeed, the only way to get the exact metrics is to render _all_ */ + /* glyphs. As this would be a definite performance hit, it is up to */ + /* client applications to perform such computations. */ + /* */ + /* The `FT_Size_Metrics' structure is valid for bitmap fonts also. */ + /* */ + /* */ + /* *TrueType* *fonts* *with* *native* *bytecode* *hinting* */ + /* */ + /* All applications that handle TrueType fonts with native hinting */ + /* must be aware that TTFs expect different rounding of vertical font */ + /* dimensions. The application has to cater for this, especially if */ + /* it wants to rely on a TTF's vertical data (for example, to */ + /* properly align box characters vertically). */ + /* */ + /* Only the application knows _in_ _advance_ that it is going to use */ + /* native hinting for TTFs! FreeType, on the other hand, selects the */ + /* hinting mode not at the time of creating an @FT_Size object but */ + /* much later, namely while calling @FT_Load_Glyph. */ + /* */ + /* Here is some pseudo code that illustrates a possible solution. */ + /* */ + /* { */ + /* font_format = FT_Get_Font_Format( face ); */ + /* */ + /* if ( !strcmp( font_format, "TrueType" ) && */ + /* do_native_bytecode_hinting ) */ + /* { */ + /* ascender = ROUND( FT_MulFix( face->ascender, */ + /* size_metrics->y_scale ) ); */ + /* descender = ROUND( FT_MulFix( face->descender, */ + /* size_metrics->y_scale ) ); */ + /* } */ + /* else */ + /* { */ + /* ascender = size_metrics->ascender; */ + /* descender = size_metrics->descender; */ + /* } */ + /* */ + /* height = size_metrics->height; */ + /* max_advance = size_metrics->max_advance; */ + /* } */ + /* */ + typedef struct FT_Size_Metrics_ + { + FT_UShort x_ppem; /* horizontal pixels per EM */ + FT_UShort y_ppem; /* vertical pixels per EM */ + + FT_Fixed x_scale; /* scaling values used to convert font */ + FT_Fixed y_scale; /* units to 26.6 fractional pixels */ + + FT_Pos ascender; /* ascender in 26.6 frac. pixels */ + FT_Pos descender; /* descender in 26.6 frac. pixels */ + FT_Pos height; /* text height in 26.6 frac. pixels */ + FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */ + + } FT_Size_Metrics; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_SizeRec */ + /* */ + /* <Description> */ + /* FreeType root size class structure. A size object models a face */ + /* object at a given size. */ + /* */ + /* <Fields> */ + /* face :: Handle to the parent face object. */ + /* */ + /* generic :: A typeless pointer, unused by the FreeType library or */ + /* any of its drivers. It can be used by client */ + /* applications to link their own data to each size */ + /* object. */ + /* */ + /* metrics :: Metrics for this size object. This field is read-only. */ + /* */ + typedef struct FT_SizeRec_ + { + FT_Face face; /* parent face object */ + FT_Generic generic; /* generic pointer for client uses */ + FT_Size_Metrics metrics; /* size metrics */ + FT_Size_Internal internal; + + } FT_SizeRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_SubGlyph */ + /* */ + /* <Description> */ + /* The subglyph structure is an internal object used to describe */ + /* subglyphs (for example, in the case of composites). */ + /* */ + /* <Note> */ + /* The subglyph implementation is not part of the high-level API, */ + /* hence the forward structure declaration. */ + /* */ + /* You can however retrieve subglyph information with */ + /* @FT_Get_SubGlyph_Info. */ + /* */ + typedef struct FT_SubGlyphRec_* FT_SubGlyph; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Slot_Internal */ + /* */ + /* <Description> */ + /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */ + /* model private data of a given @FT_GlyphSlot object. */ + /* */ + typedef struct FT_Slot_InternalRec_* FT_Slot_Internal; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_GlyphSlotRec */ + /* */ + /* <Description> */ + /* FreeType root glyph slot class structure. A glyph slot is a */ + /* container where individual glyphs can be loaded, be they in */ + /* outline or bitmap format. */ + /* */ + /* <Fields> */ + /* library :: A handle to the FreeType library instance */ + /* this slot belongs to. */ + /* */ + /* face :: A handle to the parent face object. */ + /* */ + /* next :: In some cases (like some font tools), several */ + /* glyph slots per face object can be a good */ + /* thing. As this is rare, the glyph slots are */ + /* listed through a direct, single-linked list */ + /* using its `next' field. */ + /* */ + /* generic :: A typeless pointer unused by the FreeType */ + /* library or any of its drivers. It can be */ + /* used by client applications to link their own */ + /* data to each glyph slot object. */ + /* */ + /* metrics :: The metrics of the last loaded glyph in the */ + /* slot. The returned values depend on the last */ + /* load flags (see the @FT_Load_Glyph API */ + /* function) and can be expressed either in 26.6 */ + /* fractional pixels or font units. */ + /* */ + /* Note that even when the glyph image is */ + /* transformed, the metrics are not. */ + /* */ + /* linearHoriAdvance :: The advance width of the unhinted glyph. */ + /* Its value is expressed in 16.16 fractional */ + /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ + /* when loading the glyph. This field can be */ + /* important to perform correct WYSIWYG layout. */ + /* Only relevant for outline glyphs. */ + /* */ + /* linearVertAdvance :: The advance height of the unhinted glyph. */ + /* Its value is expressed in 16.16 fractional */ + /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ + /* when loading the glyph. This field can be */ + /* important to perform correct WYSIWYG layout. */ + /* Only relevant for outline glyphs. */ + /* */ + /* advance :: This shorthand is, depending on */ + /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */ + /* (hinted) advance width for the glyph, in 26.6 */ + /* fractional pixel format. As specified with */ + /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */ + /* `horiAdvance' or the `vertAdvance' value of */ + /* `metrics' field. */ + /* */ + /* format :: This field indicates the format of the image */ + /* contained in the glyph slot. Typically */ + /* @FT_GLYPH_FORMAT_BITMAP, */ + /* @FT_GLYPH_FORMAT_OUTLINE, or */ + /* @FT_GLYPH_FORMAT_COMPOSITE, but other values */ + /* are possible. */ + /* */ + /* bitmap :: This field is used as a bitmap descriptor. */ + /* Note that the address and content of the */ + /* bitmap buffer can change between calls of */ + /* @FT_Load_Glyph and a few other functions. */ + /* */ + /* bitmap_left :: The bitmap's left bearing expressed in */ + /* integer pixels. */ + /* */ + /* bitmap_top :: The bitmap's top bearing expressed in integer */ + /* pixels. This is the distance from the */ + /* baseline to the top-most glyph scanline, */ + /* upwards y~coordinates being *positive*. */ + /* */ + /* outline :: The outline descriptor for the current glyph */ + /* image if its format is */ + /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */ + /* loaded, `outline' can be transformed, */ + /* distorted, emboldened, etc. However, it must */ + /* not be freed. */ + /* */ + /* num_subglyphs :: The number of subglyphs in a composite glyph. */ + /* This field is only valid for the composite */ + /* glyph format that should normally only be */ + /* loaded with the @FT_LOAD_NO_RECURSE flag. */ + /* */ + /* subglyphs :: An array of subglyph descriptors for */ + /* composite glyphs. There are `num_subglyphs' */ + /* elements in there. Currently internal to */ + /* FreeType. */ + /* */ + /* control_data :: Certain font drivers can also return the */ + /* control data for a given glyph image (e.g. */ + /* TrueType bytecode, Type~1 charstrings, etc.). */ + /* This field is a pointer to such data; it is */ + /* currently internal to FreeType. */ + /* */ + /* control_len :: This is the length in bytes of the control */ + /* data. Currently internal to FreeType. */ + /* */ + /* other :: Reserved. */ + /* */ + /* lsb_delta :: The difference between hinted and unhinted */ + /* left side bearing while auto-hinting is */ + /* active. Zero otherwise. */ + /* */ + /* rsb_delta :: The difference between hinted and unhinted */ + /* right side bearing while auto-hinting is */ + /* active. Zero otherwise. */ + /* */ + /* <Note> */ + /* If @FT_Load_Glyph is called with default flags (see */ + /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */ + /* its native format (e.g., an outline glyph for TrueType and Type~1 */ + /* formats). [Since 2.9] The prospective bitmap metrics are */ + /* calculated according to @FT_LOAD_TARGET_XXX and other flags even */ + /* for the outline glyph, even if @FT_LOAD_RENDER is not set. */ + /* */ + /* This image can later be converted into a bitmap by calling */ + /* @FT_Render_Glyph. This function searches the current renderer for */ + /* the native image's format, then invokes it. */ + /* */ + /* The renderer is in charge of transforming the native image through */ + /* the slot's face transformation fields, then converting it into a */ + /* bitmap that is returned in `slot->bitmap'. */ + /* */ + /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */ + /* to specify the position of the bitmap relative to the current pen */ + /* position (e.g., coordinates (0,0) on the baseline). Of course, */ + /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */ + /* */ + /* Here is a small pseudo code fragment that shows how to use */ + /* `lsb_delta' and `rsb_delta' to do fractional positioning of */ + /* glyphs: */ + /* */ + /* { */ + /* FT_GlyphSlot slot = face->glyph; */ + /* FT_Pos origin_x = 0; */ + /* */ + /* */ + /* for all glyphs do */ + /* <load glyph with `FT_Load_Glyph'> */ + /* */ + /* FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); */ + /* */ + /* <save glyph image, or render glyph, or ...> */ + /* */ + /* <compute kern between current and next glyph */ + /* and add it to `origin_x'> */ + /* */ + /* origin_x += slot->advance.x; */ + /* origin_x += slot->rsb_delta - slot->lsb_delta; */ + /* endfor */ + /* } */ + /* */ + /* Here is another small pseudo code fragment that shows how to use */ + /* `lsb_delta' and `rsb_delta' to improve integer positioning of */ + /* glyphs: */ + /* */ + /* { */ + /* FT_GlyphSlot slot = face->glyph; */ + /* FT_Pos origin_x = 0; */ + /* FT_Pos prev_rsb_delta = 0; */ + /* */ + /* */ + /* for all glyphs do */ + /* <compute kern between current and previous glyph */ + /* and add it to `origin_x'> */ + /* */ + /* <load glyph with `FT_Load_Glyph'> */ + /* */ + /* if ( prev_rsb_delta - slot->lsb_delta > 32 ) */ + /* origin_x -= 64; */ + /* else if ( prev_rsb_delta - slot->lsb_delta < -31 ) */ + /* origin_x += 64; */ + /* */ + /* prev_rsb_delta = slot->rsb_delta; */ + /* */ + /* <save glyph image, or render glyph, or ...> */ + /* */ + /* origin_x += slot->advance.x; */ + /* endfor */ + /* } */ + /* */ + /* If you use strong auto-hinting, you *must* apply these delta */ + /* values! Otherwise you will experience far too large inter-glyph */ + /* spacing at small rendering sizes in most cases. Note that it */ + /* doesn't harm to use the above code for other hinting modes also, */ + /* since the delta values are zero then. */ + /* */ + typedef struct FT_GlyphSlotRec_ + { + FT_Library library; + FT_Face face; + FT_GlyphSlot next; + FT_UInt reserved; /* retained for binary compatibility */ + FT_Generic generic; + + FT_Glyph_Metrics metrics; + FT_Fixed linearHoriAdvance; + FT_Fixed linearVertAdvance; + FT_Vector advance; + + FT_Glyph_Format format; + + FT_Bitmap bitmap; + FT_Int bitmap_left; + FT_Int bitmap_top; + + FT_Outline outline; + + FT_UInt num_subglyphs; + FT_SubGlyph subglyphs; + + void* control_data; + long control_len; + + FT_Pos lsb_delta; + FT_Pos rsb_delta; + + void* other; + + FT_Slot_Internal internal; + + } FT_GlyphSlotRec; + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* F U N C T I O N S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Init_FreeType */ + /* */ + /* <Description> */ + /* Initialize a new FreeType library object. The set of modules */ + /* that are registered by this function is determined at build time. */ + /* */ + /* <Output> */ + /* alibrary :: A handle to a new library object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* In case you want to provide your own memory allocating routines, */ + /* use @FT_New_Library instead, followed by a call to */ + /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module) */ + /* and @FT_Set_Default_Properties. */ + /* */ + /* See the documentation of @FT_Library and @FT_Face for */ + /* multi-threading issues. */ + /* */ + /* If you need reference-counting (cf. @FT_Reference_Library), use */ + /* @FT_New_Library and @FT_Done_Library. */ + /* */ + /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */ + /* set, this function reads the `FREETYPE_PROPERTIES' environment */ + /* variable to control driver properties. See section @properties */ + /* for more. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Init_FreeType( FT_Library *alibrary ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_FreeType */ + /* */ + /* <Description> */ + /* Destroy a given FreeType library object and all of its children, */ + /* including resources, drivers, faces, sizes, etc. */ + /* */ + /* <Input> */ + /* library :: A handle to the target library object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Done_FreeType( FT_Library library ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_OPEN_XXX */ + /* */ + /* <Description> */ + /* A list of bit field constants used within the `flags' field of the */ + /* @FT_Open_Args structure. */ + /* */ + /* <Values> */ + /* FT_OPEN_MEMORY :: This is a memory-based stream. */ + /* */ + /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */ + /* */ + /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */ + /* name. */ + /* */ + /* FT_OPEN_DRIVER :: Use the `driver' field. */ + /* */ + /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */ + /* */ + /* <Note> */ + /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */ + /* flags are mutually exclusive. */ + /* */ +#define FT_OPEN_MEMORY 0x1 +#define FT_OPEN_STREAM 0x2 +#define FT_OPEN_PATHNAME 0x4 +#define FT_OPEN_DRIVER 0x8 +#define FT_OPEN_PARAMS 0x10 + + + /* these constants are deprecated; use the corresponding `FT_OPEN_XXX' */ + /* values instead */ +#define ft_open_memory FT_OPEN_MEMORY +#define ft_open_stream FT_OPEN_STREAM +#define ft_open_pathname FT_OPEN_PATHNAME +#define ft_open_driver FT_OPEN_DRIVER +#define ft_open_params FT_OPEN_PARAMS + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Parameter */ + /* */ + /* <Description> */ + /* A simple structure to pass more or less generic parameters to */ + /* @FT_Open_Face and @FT_Face_Properties. */ + /* */ + /* <Fields> */ + /* tag :: A four-byte identification tag. */ + /* */ + /* data :: A pointer to the parameter data. */ + /* */ + /* <Note> */ + /* The ID and function of parameters are driver-specific. See the */ + /* various FT_PARAM_TAG_XXX flags for more information. */ + /* */ + typedef struct FT_Parameter_ + { + FT_ULong tag; + FT_Pointer data; + + } FT_Parameter; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Open_Args */ + /* */ + /* <Description> */ + /* A structure to indicate how to open a new font file or stream. A */ + /* pointer to such a structure can be used as a parameter for the */ + /* functions @FT_Open_Face and @FT_Attach_Stream. */ + /* */ + /* <Fields> */ + /* flags :: A set of bit flags indicating how to use the */ + /* structure. */ + /* */ + /* memory_base :: The first byte of the file in memory. */ + /* */ + /* memory_size :: The size in bytes of the file in memory. */ + /* */ + /* pathname :: A pointer to an 8-bit file pathname. */ + /* */ + /* stream :: A handle to a source stream object. */ + /* */ + /* driver :: This field is exclusively used by @FT_Open_Face; */ + /* it simply specifies the font driver to use for */ + /* opening the face. If set to NULL, FreeType tries */ + /* to load the face with each one of the drivers in */ + /* its list. */ + /* */ + /* num_params :: The number of extra parameters. */ + /* */ + /* params :: Extra parameters passed to the font driver when */ + /* opening a new face. */ + /* */ + /* <Note> */ + /* The stream type is determined by the contents of `flags' that */ + /* are tested in the following order by @FT_Open_Face: */ + /* */ + /* If the @FT_OPEN_MEMORY bit is set, assume that this is a */ + /* memory file of `memory_size' bytes, located at `memory_address'. */ + /* The data are not copied, and the client is responsible for */ + /* releasing and destroying them _after_ the corresponding call to */ + /* @FT_Done_Face. */ + /* */ + /* Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a */ + /* custom input stream `stream' is used. */ + /* */ + /* Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this */ + /* is a normal file and use `pathname' to open it. */ + /* */ + /* If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to */ + /* open the file with the driver whose handler is in `driver'. */ + /* */ + /* If the @FT_OPEN_PARAMS bit is set, the parameters given by */ + /* `num_params' and `params' is used. They are ignored otherwise. */ + /* */ + /* Ideally, both the `pathname' and `params' fields should be tagged */ + /* as `const'; this is missing for API backward compatibility. In */ + /* other words, applications should treat them as read-only. */ + /* */ + typedef struct FT_Open_Args_ + { + FT_UInt flags; + const FT_Byte* memory_base; + FT_Long memory_size; + FT_String* pathname; + FT_Stream stream; + FT_Module driver; + FT_Int num_params; + FT_Parameter* params; + + } FT_Open_Args; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Face */ + /* */ + /* <Description> */ + /* Call @FT_Open_Face to open a font by its pathname. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* pathname :: A path to the font file. */ + /* */ + /* face_index :: See @FT_Open_Face for a detailed description of this */ + /* parameter. */ + /* */ + /* <Output> */ + /* aface :: A handle to a new face object. If `face_index' is */ + /* greater than or equal to zero, it must be non-NULL. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Use @FT_Done_Face to destroy the created @FT_Face object (along */ + /* with its slot and sizes). */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Face( FT_Library library, + const char* filepathname, + FT_Long face_index, + FT_Face *aface ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Memory_Face */ + /* */ + /* <Description> */ + /* Call @FT_Open_Face to open a font that has been loaded into */ + /* memory. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* file_base :: A pointer to the beginning of the font data. */ + /* */ + /* file_size :: The size of the memory chunk used by the font data. */ + /* */ + /* face_index :: See @FT_Open_Face for a detailed description of this */ + /* parameter. */ + /* */ + /* <Output> */ + /* aface :: A handle to a new face object. If `face_index' is */ + /* greater than or equal to zero, it must be non-NULL. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* You must not deallocate the memory before calling @FT_Done_Face. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Memory_Face( FT_Library library, + const FT_Byte* file_base, + FT_Long file_size, + FT_Long face_index, + FT_Face *aface ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Open_Face */ + /* */ + /* <Description> */ + /* Create a face object from a given resource described by */ + /* @FT_Open_Args. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* args :: A pointer to an `FT_Open_Args' structure that must */ + /* be filled by the caller. */ + /* */ + /* face_index :: This field holds two different values. Bits 0-15 */ + /* are the index of the face in the font file (starting */ + /* with value~0). Set it to~0 if there is only one */ + /* face in the font file. */ + /* */ + /* [Since 2.6.1] Bits 16-30 are relevant to GX and */ + /* OpenType variation fonts only, specifying the named */ + /* instance index for the current face index (starting */ + /* with value~1; value~0 makes FreeType ignore named */ + /* instances). For non-variation fonts, bits 16-30 are */ + /* ignored. Assuming that you want to access the third */ + /* named instance in face~4, `face_index' should be set */ + /* to 0x00030004. If you want to access face~4 without */ + /* variation handling, simply set `face_index' to */ + /* value~4. */ + /* */ + /* `FT_Open_Face' and its siblings can be used to */ + /* quickly check whether the font format of a given */ + /* font resource is supported by FreeType. In general, */ + /* if the `face_index' argument is negative, the */ + /* function's return value is~0 if the font format is */ + /* recognized, or non-zero otherwise. The function */ + /* allocates a more or less empty face handle in */ + /* `*aface' (if `aface' isn't NULL); the only two */ + /* useful fields in this special case are */ + /* `face->num_faces' and `face->style_flags'. For any */ + /* negative value of `face_index', `face->num_faces' */ + /* gives the number of faces within the font file. For */ + /* the negative value `-(N+1)' (with `N' a non-negative */ + /* 16-bit value), bits 16-30 in `face->style_flags' */ + /* give the number of named instances in face `N' if we */ + /* have a variation font (or zero otherwise). After */ + /* examination, the returned @FT_Face structure should */ + /* be deallocated with a call to @FT_Done_Face. */ + /* */ + /* <Output> */ + /* aface :: A handle to a new face object. If `face_index' is */ + /* greater than or equal to zero, it must be non-NULL. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Unlike FreeType 1.x, this function automatically creates a glyph */ + /* slot for the face object that can be accessed directly through */ + /* `face->glyph'. */ + /* */ + /* Each new face object created with this function also owns a */ + /* default @FT_Size object, accessible as `face->size'. */ + /* */ + /* One @FT_Library instance can have multiple face objects, this is, */ + /* @FT_Open_Face and its siblings can be called multiple times using */ + /* the same `library' argument. */ + /* */ + /* See the discussion of reference counters in the description of */ + /* @FT_Reference_Face. */ + /* */ + /* To loop over all faces, use code similar to the following snippet */ + /* (omitting the error handling). */ + /* */ + /* { */ + /* ... */ + /* FT_Face face; */ + /* FT_Long i, num_faces; */ + /* */ + /* */ + /* error = FT_Open_Face( library, args, -1, &face ); */ + /* if ( error ) { ... } */ + /* */ + /* num_faces = face->num_faces; */ + /* FT_Done_Face( face ); */ + /* */ + /* for ( i = 0; i < num_faces; i++ ) */ + /* { */ + /* ... */ + /* error = FT_Open_Face( library, args, i, &face ); */ + /* ... */ + /* FT_Done_Face( face ); */ + /* ... */ + /* } */ + /* } */ + /* */ + /* To loop over all valid values for `face_index', use something */ + /* similar to the following snippet, again without error handling. */ + /* The code accesses all faces immediately (thus only a single call */ + /* of `FT_Open_Face' within the do-loop), with and without named */ + /* instances. */ + /* */ + /* { */ + /* ... */ + /* FT_Face face; */ + /* */ + /* FT_Long num_faces = 0; */ + /* FT_Long num_instances = 0; */ + /* */ + /* FT_Long face_idx = 0; */ + /* FT_Long instance_idx = 0; */ + /* */ + /* */ + /* do */ + /* { */ + /* FT_Long id = ( instance_idx << 16 ) + face_idx; */ + /* */ + /* */ + /* error = FT_Open_Face( library, args, id, &face ); */ + /* if ( error ) { ... } */ + /* */ + /* num_faces = face->num_faces; */ + /* num_instances = face->style_flags >> 16; */ + /* */ + /* ... */ + /* */ + /* FT_Done_Face( face ); */ + /* */ + /* if ( instance_idx < num_instances ) */ + /* instance_idx++; */ + /* else */ + /* { */ + /* face_idx++; */ + /* instance_idx = 0; */ + /* } */ + /* */ + /* } while ( face_idx < num_faces ) */ + /* } */ + /* */ + FT_EXPORT( FT_Error ) + FT_Open_Face( FT_Library library, + const FT_Open_Args* args, + FT_Long face_index, + FT_Face *aface ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Attach_File */ + /* */ + /* <Description> */ + /* Call @FT_Attach_Stream to attach a file. */ + /* */ + /* <InOut> */ + /* face :: The target face object. */ + /* */ + /* <Input> */ + /* filepathname :: The pathname. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Attach_File( FT_Face face, + const char* filepathname ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Attach_Stream */ + /* */ + /* <Description> */ + /* `Attach' data to a face object. Normally, this is used to read */ + /* additional information for the face object. For example, you can */ + /* attach an AFM file that comes with a Type~1 font to get the */ + /* kerning values and other metrics. */ + /* */ + /* <InOut> */ + /* face :: The target face object. */ + /* */ + /* <Input> */ + /* parameters :: A pointer to @FT_Open_Args that must be filled by */ + /* the caller. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The meaning of the `attach' (i.e., what really happens when the */ + /* new file is read) is not fixed by FreeType itself. It really */ + /* depends on the font format (and thus the font driver). */ + /* */ + /* Client applications are expected to know what they are doing */ + /* when invoking this function. Most drivers simply do not implement */ + /* file or stream attachments. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Attach_Stream( FT_Face face, + FT_Open_Args* parameters ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Reference_Face */ + /* */ + /* <Description> */ + /* A counter gets initialized to~1 at the time an @FT_Face structure */ + /* is created. This function increments the counter. @FT_Done_Face */ + /* then only destroys a face if the counter is~1, otherwise it simply */ + /* decrements the counter. */ + /* */ + /* This function helps in managing life-cycles of structures that */ + /* reference @FT_Face objects. */ + /* */ + /* <Input> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Since> */ + /* 2.4.2 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Reference_Face( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_Face */ + /* */ + /* <Description> */ + /* Discard a given face object, as well as all of its child slots and */ + /* sizes. */ + /* */ + /* <Input> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* See the discussion of reference counters in the description of */ + /* @FT_Reference_Face. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Done_Face( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Select_Size */ + /* */ + /* <Description> */ + /* Select a bitmap strike. To be more precise, this function sets */ + /* the scaling factors of the active @FT_Size object in a face so */ + /* that bitmaps from this particular strike are taken by */ + /* @FT_Load_Glyph and friends. */ + /* */ + /* <InOut> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Input> */ + /* strike_index :: The index of the bitmap strike in the */ + /* `available_sizes' field of @FT_FaceRec structure. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* For bitmaps embedded in outline fonts it is common that only a */ + /* subset of the available glyphs at a given ppem value is available. */ + /* FreeType silently uses outlines if there is no bitmap for a given */ + /* glyph index. */ + /* */ + /* For GX and OpenType variation fonts, a bitmap strike makes sense */ + /* only if the default instance is active (this is, no glyph */ + /* variation takes place); otherwise, FreeType simply ignores bitmap */ + /* strikes. The same is true for all named instances that are */ + /* different from the default instance. */ + /* */ + /* Don't use this function if you are using the FreeType cache API. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Select_Size( FT_Face face, + FT_Int strike_index ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Size_Request_Type */ + /* */ + /* <Description> */ + /* An enumeration type that lists the supported size request types, */ + /* i.e., what input size (in font units) maps to the requested output */ + /* size (in pixels, as computed from the arguments of */ + /* @FT_Size_Request). */ + /* */ + /* <Values> */ + /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */ + /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */ + /* used to determine both scaling values. */ + /* */ + /* This is the standard scaling found in most applications. In */ + /* particular, use this size request type for TrueType fonts if */ + /* they provide optical scaling or something similar. Note, */ + /* however, that `units_per_EM' is a rather abstract value which */ + /* bears no relation to the actual size of the glyphs in a font. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */ + /* The real dimension. The sum of the `ascender' and (minus of) */ + /* the `descender' fields of @FT_FaceRec is used to determine both */ + /* scaling values. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_BBOX :: */ + /* The font bounding box. The width and height of the `bbox' field */ + /* of @FT_FaceRec are used to determine the horizontal and vertical */ + /* scaling value, respectively. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_CELL :: */ + /* The `max_advance_width' field of @FT_FaceRec is used to */ + /* determine the horizontal scaling value; the vertical scaling */ + /* value is determined the same way as */ + /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */ + /* values are set to the smaller one. This type is useful if you */ + /* want to specify the font size for, say, a window of a given */ + /* dimension and 80x24 cells. */ + /* */ + /* FT_SIZE_REQUEST_TYPE_SCALES :: */ + /* Specify the scaling values directly. */ + /* */ + /* <Note> */ + /* The above descriptions only apply to scalable formats. For bitmap */ + /* formats, the behaviour is up to the driver. */ + /* */ + /* See the note section of @FT_Size_Metrics if you wonder how size */ + /* requesting relates to scaling values. */ + /* */ + typedef enum FT_Size_Request_Type_ + { + FT_SIZE_REQUEST_TYPE_NOMINAL, + FT_SIZE_REQUEST_TYPE_REAL_DIM, + FT_SIZE_REQUEST_TYPE_BBOX, + FT_SIZE_REQUEST_TYPE_CELL, + FT_SIZE_REQUEST_TYPE_SCALES, + + FT_SIZE_REQUEST_TYPE_MAX + + } FT_Size_Request_Type; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Size_RequestRec */ + /* */ + /* <Description> */ + /* A structure to model a size request. */ + /* */ + /* <Fields> */ + /* type :: See @FT_Size_Request_Type. */ + /* */ + /* width :: The desired width, given as a 26.6 fractional */ + /* point value (with 72pt = 1in). */ + /* */ + /* height :: The desired height, given as a 26.6 fractional */ + /* point value (with 72pt = 1in). */ + /* */ + /* horiResolution :: The horizontal resolution (dpi, i.e., pixels per */ + /* inch). If set to zero, `width' is treated as a */ + /* 26.6 fractional *pixel* value, which gets */ + /* internally rounded to an integer. */ + /* */ + /* vertResolution :: The vertical resolution (dpi, i.e., pixels per */ + /* inch). If set to zero, `height' is treated as a */ + /* 26.6 fractional *pixel* value, which gets */ + /* internally rounded to an integer. */ + /* */ + /* <Note> */ + /* If `width' is zero, the horizontal scaling value is set equal */ + /* to the vertical scaling value, and vice versa. */ + /* */ + /* If `type' is FT_SIZE_REQUEST_TYPE_SCALES, `width' and `height' are */ + /* interpreted directly as 16.16 fractional scaling values, without */ + /* any further modification, and both `horiResolution' and */ + /* `vertResolution' are ignored. */ + /* */ + typedef struct FT_Size_RequestRec_ + { + FT_Size_Request_Type type; + FT_Long width; + FT_Long height; + FT_UInt horiResolution; + FT_UInt vertResolution; + + } FT_Size_RequestRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Size_Request */ + /* */ + /* <Description> */ + /* A handle to a size request structure. */ + /* */ + typedef struct FT_Size_RequestRec_ *FT_Size_Request; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Request_Size */ + /* */ + /* <Description> */ + /* Resize the scale of the active @FT_Size object in a face. */ + /* */ + /* <InOut> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Input> */ + /* req :: A pointer to a @FT_Size_RequestRec. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Although drivers may select the bitmap strike matching the */ + /* request, you should not rely on this if you intend to select a */ + /* particular bitmap strike. Use @FT_Select_Size instead in that */ + /* case. */ + /* */ + /* The relation between the requested size and the resulting glyph */ + /* size is dependent entirely on how the size is defined in the */ + /* source face. The font designer chooses the final size of each */ + /* glyph relative to this size. For more information refer to */ + /* `https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. */ + /* */ + /* Contrary to @FT_Set_Char_Size, this function doesn't have special */ + /* code to normalize zero-valued widths, heights, or resolutions */ + /* (which lead to errors in most cases). */ + /* */ + /* Don't use this function if you are using the FreeType cache API. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Request_Size( FT_Face face, + FT_Size_Request req ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Char_Size */ + /* */ + /* <Description> */ + /* Call @FT_Request_Size to request the nominal size (in points). */ + /* */ + /* <InOut> */ + /* face :: A handle to a target face object. */ + /* */ + /* <Input> */ + /* char_width :: The nominal width, in 26.6 fractional points. */ + /* */ + /* char_height :: The nominal height, in 26.6 fractional points. */ + /* */ + /* horz_resolution :: The horizontal resolution in dpi. */ + /* */ + /* vert_resolution :: The vertical resolution in dpi. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* While this function allows fractional points as input values, the */ + /* resulting ppem value for the given resolution is always rounded to */ + /* the nearest integer. */ + /* */ + /* If either the character width or height is zero, it is set equal */ + /* to the other value. */ + /* */ + /* If either the horizontal or vertical resolution is zero, it is set */ + /* equal to the other value. */ + /* */ + /* A character width or height smaller than 1pt is set to 1pt; if */ + /* both resolution values are zero, they are set to 72dpi. */ + /* */ + /* Don't use this function if you are using the FreeType cache API. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Char_Size( FT_Face face, + FT_F26Dot6 char_width, + FT_F26Dot6 char_height, + FT_UInt horz_resolution, + FT_UInt vert_resolution ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Pixel_Sizes */ + /* */ + /* <Description> */ + /* Call @FT_Request_Size to request the nominal size (in pixels). */ + /* */ + /* <InOut> */ + /* face :: A handle to the target face object. */ + /* */ + /* <Input> */ + /* pixel_width :: The nominal width, in pixels. */ + /* */ + /* pixel_height :: The nominal height, in pixels. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* You should not rely on the resulting glyphs matching or being */ + /* constrained to this pixel size. Refer to @FT_Request_Size to */ + /* understand how requested sizes relate to actual sizes. */ + /* */ + /* Don't use this function if you are using the FreeType cache API. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Pixel_Sizes( FT_Face face, + FT_UInt pixel_width, + FT_UInt pixel_height ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Load_Glyph */ + /* */ + /* <Description> */ + /* Load a glyph into the glyph slot of a face object. */ + /* */ + /* <InOut> */ + /* face :: A handle to the target face object where the glyph */ + /* is loaded. */ + /* */ + /* <Input> */ + /* glyph_index :: The index of the glyph in the font file. For */ + /* CID-keyed fonts (either in PS or in CFF format) */ + /* this argument specifies the CID value. */ + /* */ + /* load_flags :: A flag indicating what to load for this glyph. The */ + /* @FT_LOAD_XXX constants can be used to control the */ + /* glyph loading process (e.g., whether the outline */ + /* should be scaled, whether to load bitmaps or not, */ + /* whether to hint the outline, etc). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The loaded glyph may be transformed. See @FT_Set_Transform for */ + /* the details. */ + /* */ + /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */ + /* returned for invalid CID values (this is, for CID values that */ + /* don't have a corresponding glyph in the font). See the discussion */ + /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */ + /* */ + /* If you receive `FT_Err_Glyph_Too_Big', try getting the glyph */ + /* outline at EM size, then scale it manually and fill it as a */ + /* graphics operation. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Load_Glyph( FT_Face face, + FT_UInt glyph_index, + FT_Int32 load_flags ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Load_Char */ + /* */ + /* <Description> */ + /* Load a glyph into the glyph slot of a face object, accessed by its */ + /* character code. */ + /* */ + /* <InOut> */ + /* face :: A handle to a target face object where the glyph */ + /* is loaded. */ + /* */ + /* <Input> */ + /* char_code :: The glyph's character code, according to the */ + /* current charmap used in the face. */ + /* */ + /* load_flags :: A flag indicating what to load for this glyph. The */ + /* @FT_LOAD_XXX constants can be used to control the */ + /* glyph loading process (e.g., whether the outline */ + /* should be scaled, whether to load bitmaps or not, */ + /* whether to hint the outline, etc). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */ + /* */ + /* Many fonts contain glyphs that can't be loaded by this function */ + /* since its glyph indices are not listed in any of the font's */ + /* charmaps. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Load_Char( FT_Face face, + FT_ULong char_code, + FT_Int32 load_flags ); + + + /************************************************************************* + * + * @enum: + * FT_LOAD_XXX + * + * @description: + * A list of bit field constants for @FT_Load_Glyph to indicate what + * kind of operations to perform during glyph loading. + * + * @values: + * FT_LOAD_DEFAULT :: + * Corresponding to~0, this value is used as the default glyph load + * operation. In this case, the following happens: + * + * 1. FreeType looks for a bitmap for the glyph corresponding to the + * face's current size. If one is found, the function returns. + * The bitmap data can be accessed from the glyph slot (see note + * below). + * + * 2. If no embedded bitmap is searched for or found, FreeType looks + * for a scalable outline. If one is found, it is loaded from + * the font file, scaled to device pixels, then `hinted' to the + * pixel grid in order to optimize it. The outline data can be + * accessed from the glyph slot (see note below). + * + * Note that by default the glyph loader doesn't render outlines into + * bitmaps. The following flags are used to modify this default + * behaviour to more specific and useful cases. + * + * FT_LOAD_NO_SCALE :: + * Don't scale the loaded outline glyph but keep it in font units. + * + * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and + * unsets @FT_LOAD_RENDER. + * + * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using + * FT_LOAD_NO_SCALE usually yields meaningless outlines because the + * subglyphs must be scaled and positioned with hinting instructions. + * This can be solved by loading the font without FT_LOAD_NO_SCALE and + * setting the character size to `font->units_per_EM'. + * + * FT_LOAD_NO_HINTING :: + * Disable hinting. This generally generates `blurrier' bitmap glyphs + * when the glyph are rendered in any of the anti-aliased modes. See + * also the note below. + * + * This flag is implied by @FT_LOAD_NO_SCALE. + * + * FT_LOAD_RENDER :: + * Call @FT_Render_Glyph after the glyph is loaded. By default, the + * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be + * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME. + * + * This flag is unset by @FT_LOAD_NO_SCALE. + * + * FT_LOAD_NO_BITMAP :: + * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this + * flag. + * + * @FT_LOAD_NO_SCALE always sets this flag. + * + * FT_LOAD_VERTICAL_LAYOUT :: + * Load the glyph for vertical text layout. In particular, the + * `advance' value in the @FT_GlyphSlotRec structure is set to the + * `vertAdvance' value of the `metrics' field. + * + * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use + * this flag currently. Reason is that in this case vertical metrics + * get synthesized, and those values are not always consistent across + * various font formats. + * + * FT_LOAD_FORCE_AUTOHINT :: + * Prefer the auto-hinter over the font's native hinter. See also + * the note below. + * + * FT_LOAD_PEDANTIC :: + * Make the font driver perform pedantic verifications during glyph + * loading. This is mostly used to detect broken glyphs in fonts. + * By default, FreeType tries to handle broken fonts also. + * + * In particular, errors from the TrueType bytecode engine are not + * passed to the application if this flag is not set; this might + * result in partially hinted or distorted glyphs in case a glyph's + * bytecode is buggy. + * + * FT_LOAD_NO_RECURSE :: + * Don't load composite glyphs recursively. Instead, the font + * driver should set the `num_subglyph' and `subglyphs' values of + * the glyph slot accordingly, and set `glyph->format' to + * @FT_GLYPH_FORMAT_COMPOSITE. The description of subglyphs can + * then be accessed with @FT_Get_SubGlyph_Info. + * + * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM. + * + * FT_LOAD_IGNORE_TRANSFORM :: + * Ignore the transform matrix set by @FT_Set_Transform. + * + * FT_LOAD_MONOCHROME :: + * This flag is used with @FT_LOAD_RENDER to indicate that you want to + * render an outline glyph to a 1-bit monochrome bitmap glyph, with + * 8~pixels packed into each byte of the bitmap data. + * + * Note that this has no effect on the hinting algorithm used. You + * should rather use @FT_LOAD_TARGET_MONO so that the + * monochrome-optimized hinting algorithm is used. + * + * FT_LOAD_LINEAR_DESIGN :: + * Keep `linearHoriAdvance' and `linearVertAdvance' fields of + * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for + * details. + * + * FT_LOAD_NO_AUTOHINT :: + * Disable the auto-hinter. See also the note below. + * + * FT_LOAD_COLOR :: + * [Since 2.5] Load embedded color bitmap images. The resulting color + * bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format. + * If the flag is not set and color bitmaps are found, they are + * converted to 256-level gray bitmaps transparently, using the + * @FT_PIXEL_MODE_GRAY format. + * + * FT_LOAD_COMPUTE_METRICS :: + * [Since 2.6.1] Compute glyph metrics from the glyph data, without + * the use of bundled metrics tables (for example, the `hdmx' table in + * TrueType fonts). This flag is mainly used by font validating or + * font editing applications, which need to ignore, verify, or edit + * those tables. + * + * Currently, this flag is only implemented for TrueType fonts. + * + * FT_LOAD_BITMAP_METRICS_ONLY :: + * [Since 2.7.1] Request loading of the metrics and bitmap image + * information of a (possibly embedded) bitmap glyph without + * allocating or copying the bitmap image data itself. No effect if + * the target glyph is not a bitmap image. + * + * This flag unsets @FT_LOAD_RENDER. + * + * FT_LOAD_CROP_BITMAP :: + * Ignored. Deprecated. + * + * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH :: + * Ignored. Deprecated. + * + * @note: + * By default, hinting is enabled and the font's native hinter (see + * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can + * disable hinting by setting @FT_LOAD_NO_HINTING or change the + * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set + * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be + * used at all. + * + * See the description of @FT_FACE_FLAG_TRICKY for a special exception + * (affecting only a handful of Asian fonts). + * + * Besides deciding which hinter to use, you can also decide which + * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details. + * + * Note that the auto-hinter needs a valid Unicode cmap (either a native + * one or synthesized by FreeType) for producing correct results. If a + * font provides an incorrect mapping (for example, assigning the + * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a + * mathematical integral sign), the auto-hinter might produce useless + * results. + * + */ +#define FT_LOAD_DEFAULT 0x0 +#define FT_LOAD_NO_SCALE ( 1L << 0 ) +#define FT_LOAD_NO_HINTING ( 1L << 1 ) +#define FT_LOAD_RENDER ( 1L << 2 ) +#define FT_LOAD_NO_BITMAP ( 1L << 3 ) +#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 ) +#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 ) +#define FT_LOAD_CROP_BITMAP ( 1L << 6 ) +#define FT_LOAD_PEDANTIC ( 1L << 7 ) +#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 ) +#define FT_LOAD_NO_RECURSE ( 1L << 10 ) +#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 ) +#define FT_LOAD_MONOCHROME ( 1L << 12 ) +#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 ) +#define FT_LOAD_NO_AUTOHINT ( 1L << 15 ) + /* Bits 16-19 are used by `FT_LOAD_TARGET_' */ +#define FT_LOAD_COLOR ( 1L << 20 ) +#define FT_LOAD_COMPUTE_METRICS ( 1L << 21 ) +#define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 ) + + /* */ + + /* used internally only by certain font drivers */ +#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 ) +#define FT_LOAD_SBITS_ONLY ( 1L << 14 ) + + + /************************************************************************** + * + * @enum: + * FT_LOAD_TARGET_XXX + * + * @description: + * A list of values to select a specific hinting algorithm for the + * hinter. You should OR one of these values to your `load_flags' + * when calling @FT_Load_Glyph. + * + * Note that a font's native hinters may ignore the hinting algorithm + * you have specified (e.g., the TrueType bytecode interpreter). You + * can set @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is + * used. + * + * @values: + * FT_LOAD_TARGET_NORMAL :: + * The default hinting algorithm, optimized for standard gray-level + * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO + * instead. + * + * FT_LOAD_TARGET_LIGHT :: + * A lighter hinting algorithm for gray-level modes. Many generated + * glyphs are fuzzier but better resemble their original shape. This + * is achieved by snapping glyphs to the pixel grid only vertically + * (Y-axis), as is done by FreeType's new CFF engine or Microsoft's + * ClearType font renderer. This preserves inter-glyph spacing in + * horizontal text. The snapping is done either by the native font + * driver, if the driver itself and the font support it, or by the + * auto-hinter. + * + * Advance widths are rounded to integer values; however, using the + * `lsb_delta' and `rsb_delta' fields of @FT_GlyphSlotRec, it is + * possible to get fractional advance widths for sub-pixel positioning + * (which is recommended to use). + * + * If configuration option AF_CONFIG_OPTION_TT_SIZE_METRICS is active, + * TrueType-like metrics are used to make this mode behave similarly + * as in unpatched FreeType versions between 2.4.6 and 2.7.1 + * (inclusive). + * + * FT_LOAD_TARGET_MONO :: + * Strong hinting algorithm that should only be used for monochrome + * output. The result is probably unpleasant if the glyph is rendered + * in non-monochrome modes. + * + * FT_LOAD_TARGET_LCD :: + * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally + * decimated LCD displays. + * + * FT_LOAD_TARGET_LCD_V :: + * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically + * decimated LCD displays. + * + * @note: + * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your + * `load_flags'. They can't be ORed. + * + * If @FT_LOAD_RENDER is also set, the glyph is rendered in the + * corresponding mode (i.e., the mode that matches the used algorithm + * best). An exception is FT_LOAD_TARGET_MONO since it implies + * @FT_LOAD_MONOCHROME. + * + * You can use a hinting algorithm that doesn't correspond to the same + * rendering mode. As an example, it is possible to use the `light' + * hinting algorithm and have the results rendered in horizontal LCD + * pixel mode, with code like + * + * { + * FT_Load_Glyph( face, glyph_index, + * load_flags | FT_LOAD_TARGET_LIGHT ); + * + * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); + * } + * + * In general, you should stick with one rendering mode. For example, + * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO + * enforces a lot of recomputation for TrueType fonts, which is slow. + * Another reason is caching: Selecting a different mode usually causes + * changes in both the outlines and the rasterized bitmaps; it is thus + * necessary to empty the cache after a mode switch to avoid false hits. + * + */ +#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 ) + +#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) +#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) +#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO ) +#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD ) +#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V ) + + + /************************************************************************** + * + * @macro: + * FT_LOAD_TARGET_MODE + * + * @description: + * Return the @FT_Render_Mode corresponding to a given + * @FT_LOAD_TARGET_XXX value. + * + */ +#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Transform */ + /* */ + /* <Description> */ + /* Set the transformation that is applied to glyph images when they */ + /* are loaded into a glyph slot through @FT_Load_Glyph. */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Input> */ + /* matrix :: A pointer to the transformation's 2x2 matrix. Use NULL */ + /* for the identity matrix. */ + /* delta :: A pointer to the translation vector. Use NULL for the */ + /* null vector. */ + /* */ + /* <Note> */ + /* The transformation is only applied to scalable image formats after */ + /* the glyph has been loaded. It means that hinting is unaltered by */ + /* the transformation and is performed on the character size given in */ + /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */ + /* */ + /* Note that this also transforms the `face.glyph.advance' field, but */ + /* *not* the values in `face.glyph.metrics'. */ + /* */ + FT_EXPORT( void ) + FT_Set_Transform( FT_Face face, + FT_Matrix* matrix, + FT_Vector* delta ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Render_Mode */ + /* */ + /* <Description> */ + /* Render modes supported by FreeType~2. Each mode corresponds to a */ + /* specific type of scanline conversion performed on the outline. */ + /* */ + /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */ + /* field in the @FT_GlyphSlotRec structure gives the format of the */ + /* returned bitmap. */ + /* */ + /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, */ + /* indicating pixel coverage. Use linear alpha blending and gamma */ + /* correction to correctly render non-monochrome glyph bitmaps onto a */ + /* surface; see @FT_Render_Glyph. */ + /* */ + /* <Values> */ + /* FT_RENDER_MODE_NORMAL :: */ + /* Default render mode; it corresponds to 8-bit anti-aliased */ + /* bitmaps. */ + /* */ + /* FT_RENDER_MODE_LIGHT :: */ + /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */ + /* defined as a separate value because render modes are also used */ + /* indirectly to define hinting algorithm selectors. See */ + /* @FT_LOAD_TARGET_XXX for details. */ + /* */ + /* FT_RENDER_MODE_MONO :: */ + /* This mode corresponds to 1-bit bitmaps (with 2~levels of */ + /* opacity). */ + /* */ + /* FT_RENDER_MODE_LCD :: */ + /* This mode corresponds to horizontal RGB and BGR sub-pixel */ + /* displays like LCD screens. It produces 8-bit bitmaps that are */ + /* 3~times the width of the original glyph outline in pixels, and */ + /* which use the @FT_PIXEL_MODE_LCD mode. */ + /* */ + /* FT_RENDER_MODE_LCD_V :: */ + /* This mode corresponds to vertical RGB and BGR sub-pixel displays */ + /* (like PDA screens, rotated LCD displays, etc.). It produces */ + /* 8-bit bitmaps that are 3~times the height of the original */ + /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ + /* */ + /* <Note> */ + /* Should you define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your */ + /* `ftoption.h', which enables patented ClearType-style rendering, */ + /* the LCD-optimized glyph bitmaps should be filtered to reduce color */ + /* fringes inherent to this technology. You can either set up LCD */ + /* filtering with @FT_Library_SetLcdFilter or @FT_Face_Properties, */ + /* or do the filtering yourself. The default FreeType LCD rendering */ + /* technology does not require filtering. */ + /* */ + /* The selected render mode only affects vector glyphs of a font. */ + /* Embedded bitmaps often have a different pixel mode like */ + /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */ + /* them into 8-bit pixmaps. */ + /* */ + typedef enum FT_Render_Mode_ + { + FT_RENDER_MODE_NORMAL = 0, + FT_RENDER_MODE_LIGHT, + FT_RENDER_MODE_MONO, + FT_RENDER_MODE_LCD, + FT_RENDER_MODE_LCD_V, + + FT_RENDER_MODE_MAX + + } FT_Render_Mode; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Render_Mode' values instead */ +#define ft_render_mode_normal FT_RENDER_MODE_NORMAL +#define ft_render_mode_mono FT_RENDER_MODE_MONO + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Render_Glyph */ + /* */ + /* <Description> */ + /* Convert a given glyph image to a bitmap. It does so by inspecting */ + /* the glyph image format, finding the relevant renderer, and */ + /* invoking it. */ + /* */ + /* <InOut> */ + /* slot :: A handle to the glyph slot containing the image to */ + /* convert. */ + /* */ + /* <Input> */ + /* render_mode :: The render mode used to render the glyph image into */ + /* a bitmap. See @FT_Render_Mode for a list of */ + /* possible values. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* To get meaningful results, font scaling values must be set with */ + /* functions like @FT_Set_Char_Size before calling `FT_Render_Glyph'. */ + /* */ + /* When FreeType outputs a bitmap of a glyph, it really outputs an */ + /* alpha coverage map. If a pixel is completely covered by a */ + /* filled-in outline, the bitmap contains 0xFF at that pixel, meaning */ + /* that 0xFF/0xFF fraction of that pixel is covered, meaning the */ + /* pixel is 100% black (or 0% bright). If a pixel is only 50% */ + /* covered (value 0x80), the pixel is made 50% black (50% bright or a */ + /* middle shade of grey). 0% covered means 0% black (100% bright or */ + /* white). */ + /* */ + /* On high-DPI screens like on smartphones and tablets, the pixels */ + /* are so small that their chance of being completely covered and */ + /* therefore completely black are fairly good. On the low-DPI */ + /* screens, however, the situation is different. The pixels are too */ + /* large for most of the details of a glyph and shades of gray are */ + /* the norm rather than the exception. */ + /* */ + /* This is relevant because all our screens have a second problem: */ + /* they are not linear. 1~+~1 is not~2. Twice the value does not */ + /* result in twice the brightness. When a pixel is only 50% covered, */ + /* the coverage map says 50% black, and this translates to a pixel */ + /* value of 128 when you use 8~bits per channel (0-255). However, */ + /* this does not translate to 50% brightness for that pixel on our */ + /* sRGB and gamma~2.2 screens. Due to their non-linearity, they */ + /* dwell longer in the darks and only a pixel value of about 186 */ + /* results in 50% brightness -- 128 ends up too dark on both bright */ + /* and dark backgrounds. The net result is that dark text looks */ + /* burnt-out, pixely and blotchy on bright background, bright text */ + /* too frail on dark backgrounds, and colored text on colored */ + /* background (for example, red on green) seems to have dark halos or */ + /* `dirt' around it. The situation is especially ugly for diagonal */ + /* stems like in `w' glyph shapes where the quality of FreeType's */ + /* anti-aliasing depends on the correct display of grays. On */ + /* high-DPI screens where smaller, fully black pixels reign supreme, */ + /* this doesn't matter, but on our low-DPI screens with all the gray */ + /* shades, it does. 0% and 100% brightness are the same things in */ + /* linear and non-linear space, just all the shades in-between */ + /* aren't. */ + /* */ + /* The blending function for placing text over a background is */ + /* */ + /* { */ + /* dst = alpha * src + (1 - alpha) * dst , */ + /* } */ + /* */ + /* which is known as the OVER operator. */ + /* */ + /* To correctly composite an antialiased pixel of a glyph onto a */ + /* surface, */ + /* */ + /* 1. take the foreground and background colors (e.g., in sRGB space) */ + /* and apply gamma to get them in a linear space, */ + /* */ + /* 2. use OVER to blend the two linear colors using the glyph pixel */ + /* as the alpha value (remember, the glyph bitmap is an alpha */ + /* coverage bitmap), and */ + /* */ + /* 3. apply inverse gamma to the blended pixel and write it back to */ + /* the image. */ + /* */ + /* Internal testing at Adobe found that a target inverse gamma of~1.8 */ + /* for step~3 gives good results across a wide range of displays with */ + /* an sRGB gamma curve or a similar one. */ + /* */ + /* This process can cost performance. There is an approximation that */ + /* does not need to know about the background color; see */ + /* https://bel.fi/alankila/lcd/ and */ + /* https://bel.fi/alankila/lcd/alpcor.html for details. */ + /* */ + /* *ATTENTION*: Linear blending is even more important when dealing */ + /* with subpixel-rendered glyphs to prevent color-fringing! A */ + /* subpixel-rendered glyph must first be filtered with a filter that */ + /* gives equal weight to the three color primaries and does not */ + /* exceed a sum of 0x100, see section @lcd_filtering. Then the */ + /* only difference to gray linear blending is that subpixel-rendered */ + /* linear blending is done 3~times per pixel: red foreground subpixel */ + /* to red background subpixel and so on for green and blue. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Render_Glyph( FT_GlyphSlot slot, + FT_Render_Mode render_mode ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Kerning_Mode */ + /* */ + /* <Description> */ + /* An enumeration to specify the format of kerning values returned by */ + /* @FT_Get_Kerning. */ + /* */ + /* <Values> */ + /* FT_KERNING_DEFAULT :: Return grid-fitted kerning distances in */ + /* 26.6 fractional pixels. */ + /* */ + /* FT_KERNING_UNFITTED :: Return un-grid-fitted kerning distances in */ + /* 26.6 fractional pixels. */ + /* */ + /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */ + /* units. */ + /* */ + /* <Note> */ + /* FT_KERNING_DEFAULT returns full pixel values; it also makes */ + /* FreeType heuristically scale down kerning distances at small ppem */ + /* values so that they don't become too big. */ + /* */ + /* Both FT_KERNING_DEFAULT and FT_KERNING_UNFITTED use the current */ + /* horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to */ + /* convert font units to pixels. */ + /* */ + typedef enum FT_Kerning_Mode_ + { + FT_KERNING_DEFAULT = 0, + FT_KERNING_UNFITTED, + FT_KERNING_UNSCALED + + } FT_Kerning_Mode; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Kerning_Mode' values instead */ +#define ft_kerning_default FT_KERNING_DEFAULT +#define ft_kerning_unfitted FT_KERNING_UNFITTED +#define ft_kerning_unscaled FT_KERNING_UNSCALED + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Kerning */ + /* */ + /* <Description> */ + /* Return the kerning vector between two glyphs of the same face. */ + /* */ + /* <Input> */ + /* face :: A handle to a source face object. */ + /* */ + /* left_glyph :: The index of the left glyph in the kern pair. */ + /* */ + /* right_glyph :: The index of the right glyph in the kern pair. */ + /* */ + /* kern_mode :: See @FT_Kerning_Mode for more information. */ + /* Determines the scale and dimension of the returned */ + /* kerning vector. */ + /* */ + /* <Output> */ + /* akerning :: The kerning vector. This is either in font units, */ + /* fractional pixels (26.6 format), or pixels for */ + /* scalable formats, and in pixels for fixed-sizes */ + /* formats. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Only horizontal layouts (left-to-right & right-to-left) are */ + /* supported by this method. Other layouts, or more sophisticated */ + /* kernings, are out of the scope of this API function -- they can be */ + /* implemented through format-specific interfaces. */ + /* */ + /* Kerning for OpenType fonts implemented in a `GPOS' table is not */ + /* supported; use @FT_HAS_KERNING to find out whether a font has data */ + /* that can be extracted with `FT_Get_Kerning'. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Kerning( FT_Face face, + FT_UInt left_glyph, + FT_UInt right_glyph, + FT_UInt kern_mode, + FT_Vector *akerning ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Track_Kerning */ + /* */ + /* <Description> */ + /* Return the track kerning for a given face object at a given size. */ + /* */ + /* <Input> */ + /* face :: A handle to a source face object. */ + /* */ + /* point_size :: The point size in 16.16 fractional points. */ + /* */ + /* degree :: The degree of tightness. Increasingly negative */ + /* values represent tighter track kerning, while */ + /* increasingly positive values represent looser track */ + /* kerning. Value zero means no track kerning. */ + /* */ + /* <Output> */ + /* akerning :: The kerning in 16.16 fractional points, to be */ + /* uniformly applied between all glyphs. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Currently, only the Type~1 font driver supports track kerning, */ + /* using data from AFM files (if attached with @FT_Attach_File or */ + /* @FT_Attach_Stream). */ + /* */ + /* Only very few AFM files come with track kerning data; please refer */ + /* to Adobe's AFM specification for more details. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Track_Kerning( FT_Face face, + FT_Fixed point_size, + FT_Int degree, + FT_Fixed* akerning ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Glyph_Name */ + /* */ + /* <Description> */ + /* Retrieve the ASCII name of a given glyph in a face. This only */ + /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */ + /* */ + /* <Input> */ + /* face :: A handle to a source face object. */ + /* */ + /* glyph_index :: The glyph index. */ + /* */ + /* buffer_max :: The maximum number of bytes available in the */ + /* buffer. */ + /* */ + /* <Output> */ + /* buffer :: A pointer to a target buffer where the name is */ + /* copied to. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* An error is returned if the face doesn't provide glyph names or if */ + /* the glyph index is invalid. In all cases of failure, the first */ + /* byte of `buffer' is set to~0 to indicate an empty name. */ + /* */ + /* The glyph name is truncated to fit within the buffer if it is too */ + /* long. The returned string is always zero-terminated. */ + /* */ + /* Be aware that FreeType reorders glyph indices internally so that */ + /* glyph index~0 always corresponds to the `missing glyph' (called */ + /* `.notdef'). */ + /* */ + /* This function always returns an error if the config macro */ + /* `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is not defined in `ftoption.h'. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Glyph_Name( FT_Face face, + FT_UInt glyph_index, + FT_Pointer buffer, + FT_UInt buffer_max ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Postscript_Name */ + /* */ + /* <Description> */ + /* Retrieve the ASCII PostScript name of a given face, if available. */ + /* This only works with PostScript, TrueType, and OpenType fonts. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Return> */ + /* A pointer to the face's PostScript name. NULL if unavailable. */ + /* */ + /* <Note> */ + /* The returned pointer is owned by the face and is destroyed with */ + /* it. */ + /* */ + /* For variation fonts, this string changes if you select a different */ + /* instance, and you have to call `FT_Get_PostScript_Name' again to */ + /* retrieve it. FreeType follows Adobe TechNote #5902, `Generating */ + /* PostScript Names for Fonts Using OpenType Font Variations'. */ + /* */ + /* https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html */ + /* */ + /* [Since 2.9] Special PostScript names for named instances are only */ + /* returned if the named instance is set with @FT_Set_Named_Instance */ + /* (and the font has corresponding entries in its `fvar' table). If */ + /* @FT_IS_VARIATION returns true, the algorithmically derived */ + /* PostScript name is provided, not looking up special entries for */ + /* named instances. */ + /* */ + FT_EXPORT( const char* ) + FT_Get_Postscript_Name( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Select_Charmap */ + /* */ + /* <Description> */ + /* Select a given charmap by its encoding tag (as listed in */ + /* `freetype.h'). */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Input> */ + /* encoding :: A handle to the selected encoding. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function returns an error if no charmap in the face */ + /* corresponds to the encoding queried here. */ + /* */ + /* Because many fonts contain more than a single cmap for Unicode */ + /* encoding, this function has some special code to select the one */ + /* that covers Unicode best (`best' in the sense that a UCS-4 cmap is */ + /* preferred to a UCS-2 cmap). It is thus preferable to */ + /* @FT_Set_Charmap in this case. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Select_Charmap( FT_Face face, + FT_Encoding encoding ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Charmap */ + /* */ + /* <Description> */ + /* Select a given charmap for character code to glyph index mapping. */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Input> */ + /* charmap :: A handle to the selected charmap. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function returns an error if the charmap is not part of */ + /* the face (i.e., if it is not listed in the `face->charmaps' */ + /* table). */ + /* */ + /* It also fails if an OpenType type~14 charmap is selected (which */ + /* doesn't map character codes to glyph indices at all). */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Charmap( FT_Face face, + FT_CharMap charmap ); + + + /************************************************************************* + * + * @function: + * FT_Get_Charmap_Index + * + * @description: + * Retrieve index of a given charmap. + * + * @input: + * charmap :: + * A handle to a charmap. + * + * @return: + * The index into the array of character maps within the face to which + * `charmap' belongs. If an error occurs, -1 is returned. + * + */ + FT_EXPORT( FT_Int ) + FT_Get_Charmap_Index( FT_CharMap charmap ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Char_Index */ + /* */ + /* <Description> */ + /* Return the glyph index of a given character code. This function */ + /* uses the currently selected charmap to do the mapping. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* charcode :: The character code. */ + /* */ + /* <Return> */ + /* The glyph index. 0~means `undefined character code'. */ + /* */ + /* <Note> */ + /* If you use FreeType to manipulate the contents of font files */ + /* directly, be aware that the glyph index returned by this function */ + /* doesn't always correspond to the internal indices used within the */ + /* file. This is done to ensure that value~0 always corresponds to */ + /* the `missing glyph'. If the first glyph is not named `.notdef', */ + /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */ + /* the glyph ID~0 position, and whatever was there will be moved to */ + /* the position `.notdef' had. For Type~1 fonts, if there is no */ + /* `.notdef' glyph at all, then one will be created at index~0 and */ + /* whatever was there will be moved to the last index -- Type~42 */ + /* fonts are considered invalid under this condition. */ + /* */ + FT_EXPORT( FT_UInt ) + FT_Get_Char_Index( FT_Face face, + FT_ULong charcode ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_First_Char */ + /* */ + /* <Description> */ + /* Return the first character code in the current charmap of a given */ + /* face, together with its corresponding glyph index. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Output> */ + /* agindex :: Glyph index of first character code. 0~if charmap is */ + /* empty. */ + /* */ + /* <Return> */ + /* The charmap's first character code. */ + /* */ + /* <Note> */ + /* You should use this function together with @FT_Get_Next_Char to */ + /* parse all character codes available in a given charmap. The code */ + /* should look like this: */ + /* */ + /* { */ + /* FT_ULong charcode; */ + /* FT_UInt gindex; */ + /* */ + /* */ + /* charcode = FT_Get_First_Char( face, &gindex ); */ + /* while ( gindex != 0 ) */ + /* { */ + /* ... do something with (charcode,gindex) pair ... */ + /* */ + /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */ + /* } */ + /* } */ + /* */ + /* Be aware that character codes can have values up to 0xFFFFFFFF; */ + /* this might happen for non-Unicode or malformed cmaps. However, */ + /* even with regular Unicode encoding, so-called `last resort fonts' */ + /* (using SFNT cmap format 13, see function @FT_Get_CMap_Format) */ + /* normally have entries for all Unicode characters up to 0x1FFFFF, */ + /* which can cause *a lot* of iterations. */ + /* */ + /* Note that `*agindex' is set to~0 if the charmap is empty. The */ + /* result itself can be~0 in two cases: if the charmap is empty or */ + /* if the value~0 is the first valid character code. */ + /* */ + FT_EXPORT( FT_ULong ) + FT_Get_First_Char( FT_Face face, + FT_UInt *agindex ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Next_Char */ + /* */ + /* <Description> */ + /* Return the next character code in the current charmap of a given */ + /* face following the value `char_code', as well as the corresponding */ + /* glyph index. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* char_code :: The starting character code. */ + /* */ + /* <Output> */ + /* agindex :: Glyph index of next character code. 0~if charmap */ + /* is empty. */ + /* */ + /* <Return> */ + /* The charmap's next character code. */ + /* */ + /* <Note> */ + /* You should use this function with @FT_Get_First_Char to walk */ + /* over all character codes available in a given charmap. See the */ + /* note for that function for a simple code example. */ + /* */ + /* Note that `*agindex' is set to~0 when there are no more codes in */ + /* the charmap. */ + /* */ + FT_EXPORT( FT_ULong ) + FT_Get_Next_Char( FT_Face face, + FT_ULong char_code, + FT_UInt *agindex ); + + + /************************************************************************* + * + * @function: + * FT_Face_Properties + * + * @description: + * Set or override certain (library or module-wide) properties on a + * face-by-face basis. Useful for finer-grained control and avoiding + * locks on shared structures (threads can modify their own faces as + * they see fit). + * + * Contrary to @FT_Property_Set, this function uses @FT_Parameter so + * that you can pass multiple properties to the target face in one call. + * Note that only a subset of the available properties can be + * controlled. + * + * * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the + * property `no-stem-darkening' provided by the `autofit', `cff', + * `type1', and `t1cid' modules; see @no-stem-darkening). + * + * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding + * to function @FT_Library_SetLcdFilterWeights). + * + * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID + * `random' operator, corresponding to the `random-seed' property + * provided by the `cff', `type1', and `t1cid' modules; see + * @random-seed). + * + * Pass NULL as `data' in @FT_Parameter for a given tag to reset the + * option and use the library or module default again. + * + * @input: + * face :: + * A handle to the source face object. + * + * num_properties :: + * The number of properties that follow. + * + * properties :: + * A handle to an @FT_Parameter array with `num_properties' elements. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Here an example that sets three properties. You must define + * FT_CONFIG_OPTION_SUBPIXEL_RENDERING to make the LCD filter examples + * work. + * + * { + * FT_Parameter property1; + * FT_Bool darken_stems = 1; + * + * FT_Parameter property2; + * FT_LcdFiveTapFilter custom_weight = + * { 0x11, 0x44, 0x56, 0x44, 0x11 }; + * + * FT_Parameter property3; + * FT_Int32 random_seed = 314159265; + * + * FT_Parameter properties[3] = { property1, + * property2, + * property3 }; + * + * + * property1.tag = FT_PARAM_TAG_STEM_DARKENING; + * property1.data = &darken_stems; + * + * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; + * property2.data = custom_weight; + * + * property3.tag = FT_PARAM_TAG_RANDOM_SEED; + * property3.data = &random_seed; + * + * FT_Face_Properties( face, 3, properties ); + * } + * + * The next example resets a single property to its default value. + * + * { + * FT_Parameter property; + * + * + * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; + * property.data = NULL; + * + * FT_Face_Properties( face, 1, &property ); + * } + * + * @since: + * 2.8 + * + */ + FT_EXPORT( FT_Error ) + FT_Face_Properties( FT_Face face, + FT_UInt num_properties, + FT_Parameter* properties ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Name_Index */ + /* */ + /* <Description> */ + /* Return the glyph index of a given glyph name. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* glyph_name :: The glyph name. */ + /* */ + /* <Return> */ + /* The glyph index. 0~means `undefined character code'. */ + /* */ + FT_EXPORT( FT_UInt ) + FT_Get_Name_Index( FT_Face face, + FT_String* glyph_name ); + + + /************************************************************************* + * + * @macro: + * FT_SUBGLYPH_FLAG_XXX + * + * @description: + * A list of constants describing subglyphs. Please refer to the + * `glyf' table description in the OpenType specification for the + * meaning of the various flags (which get synthesized for + * non-OpenType subglyphs). + * + * @values: + * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS :: + * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES :: + * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID :: + * FT_SUBGLYPH_FLAG_SCALE :: + * FT_SUBGLYPH_FLAG_XY_SCALE :: + * FT_SUBGLYPH_FLAG_2X2 :: + * FT_SUBGLYPH_FLAG_USE_MY_METRICS :: + * + */ +#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1 +#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2 +#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4 +#define FT_SUBGLYPH_FLAG_SCALE 8 +#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40 +#define FT_SUBGLYPH_FLAG_2X2 0x80 +#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 + + + /************************************************************************* + * + * @func: + * FT_Get_SubGlyph_Info + * + * @description: + * Retrieve a description of a given subglyph. Only use it if + * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is + * returned otherwise. + * + * @input: + * glyph :: + * The source glyph slot. + * + * sub_index :: + * The index of the subglyph. Must be less than + * `glyph->num_subglyphs'. + * + * @output: + * p_index :: + * The glyph index of the subglyph. + * + * p_flags :: + * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. + * + * p_arg1 :: + * The subglyph's first argument (if any). + * + * p_arg2 :: + * The subglyph's second argument (if any). + * + * p_transform :: + * The subglyph transformation (if any). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be + * interpreted depending on the flags returned in `*p_flags'. See the + * OpenType specification for details. + * + */ + FT_EXPORT( FT_Error ) + FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, + FT_UInt sub_index, + FT_Int *p_index, + FT_UInt *p_flags, + FT_Int *p_arg1, + FT_Int *p_arg2, + FT_Matrix *p_transform ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_FSTYPE_XXX */ + /* */ + /* <Description> */ + /* A list of bit flags used in the `fsType' field of the OS/2 table */ + /* in a TrueType or OpenType font and the `FSType' entry in a */ + /* PostScript font. These bit flags are returned by */ + /* @FT_Get_FSType_Flags; they inform client applications of embedding */ + /* and subsetting restrictions associated with a font. */ + /* */ + /* See */ + /* https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf */ + /* for more details. */ + /* */ + /* <Values> */ + /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */ + /* Fonts with no fsType bit set may be embedded and permanently */ + /* installed on the remote system by an application. */ + /* */ + /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */ + /* Fonts that have only this bit set must not be modified, embedded */ + /* or exchanged in any manner without first obtaining permission of */ + /* the font software copyright owner. */ + /* */ + /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */ + /* The font may be embedded and temporarily loaded on the remote */ + /* system. Documents containing Preview & Print fonts must be */ + /* opened `read-only'; no edits can be applied to the document. */ + /* */ + /* FT_FSTYPE_EDITABLE_EMBEDDING :: */ + /* The font may be embedded but must only be installed temporarily */ + /* on other systems. In contrast to Preview & Print fonts, */ + /* documents containing editable fonts may be opened for reading, */ + /* editing is permitted, and changes may be saved. */ + /* */ + /* FT_FSTYPE_NO_SUBSETTING :: */ + /* The font may not be subsetted prior to embedding. */ + /* */ + /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */ + /* Only bitmaps contained in the font may be embedded; no outline */ + /* data may be embedded. If there are no bitmaps available in the */ + /* font, then the font is unembeddable. */ + /* */ + /* <Note> */ + /* The flags are ORed together, thus more than a single value can be */ + /* returned. */ + /* */ + /* While the `fsType' flags can indicate that a font may be embedded, */ + /* a license with the font vendor may be separately required to use */ + /* the font in this way. */ + /* */ +#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000 +#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002 +#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004 +#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008 +#define FT_FSTYPE_NO_SUBSETTING 0x0100 +#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200 + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_FSType_Flags */ + /* */ + /* <Description> */ + /* Return the `fsType' flags for a font. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* <Return> */ + /* The `fsType' flags, see @FT_FSTYPE_XXX. */ + /* */ + /* <Note> */ + /* Use this function rather than directly reading the `fs_type' field */ + /* in the @PS_FontInfoRec structure, which is only guaranteed to */ + /* return the correct results for Type~1 fonts. */ + /* */ + /* <Since> */ + /* 2.3.8 */ + /* */ + FT_EXPORT( FT_UShort ) + FT_Get_FSType_Flags( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* glyph_variants */ + /* */ + /* <Title> */ + /* Unicode Variation Sequences */ + /* */ + /* <Abstract> */ + /* The FreeType~2 interface to Unicode Variation Sequences (UVS), */ + /* using the SFNT cmap format~14. */ + /* */ + /* <Description> */ + /* Many characters, especially for CJK scripts, have variant forms. */ + /* They are a sort of grey area somewhere between being totally */ + /* irrelevant and semantically distinct; for this reason, the Unicode */ + /* consortium decided to introduce Variation Sequences (VS), */ + /* consisting of a Unicode base character and a variation selector */ + /* instead of further extending the already huge number of */ + /* characters. */ + /* */ + /* Unicode maintains two different sets, namely `Standardized */ + /* Variation Sequences' and registered `Ideographic Variation */ + /* Sequences' (IVS), collected in the `Ideographic Variation */ + /* Database' (IVD). */ + /* */ + /* https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt */ + /* https://unicode.org/reports/tr37/ */ + /* https://unicode.org/ivd/ */ + /* */ + /* To date (January 2017), the character with the most ideographic */ + /* variations is U+9089, having 32 such IVS. */ + /* */ + /* Three Mongolian Variation Selectors have the values U+180B-U+180D; */ + /* 256 generic Variation Selectors are encoded in the ranges */ + /* U+FE00-U+FE0F and U+E0100-U+E01EF. IVS currently use Variation */ + /* Selectors from the range U+E0100-U+E01EF only. */ + /* */ + /* A VS consists of the base character value followed by a single */ + /* Variation Selector. For example, to get the first variation of */ + /* U+9089, you have to write the character sequence `U+9089 U+E0100'. */ + /* */ + /* Adobe and MS decided to support both standardized and ideographic */ + /* VS with a new cmap subtable (format~14). It is an odd subtable */ + /* because it is not a mapping of input code points to glyphs, but */ + /* contains lists of all variations supported by the font. */ + /* */ + /* A variation may be either `default' or `non-default' for a given */ + /* font. A default variation is the one you will get for that code */ + /* point if you look it up in the standard Unicode cmap. A */ + /* non-default variation is a different glyph. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_GetCharVariantIndex */ + /* */ + /* <Description> */ + /* Return the glyph index of a given character code as modified by */ + /* the variation selector. */ + /* */ + /* <Input> */ + /* face :: */ + /* A handle to the source face object. */ + /* */ + /* charcode :: */ + /* The character code point in Unicode. */ + /* */ + /* variantSelector :: */ + /* The Unicode code point of the variation selector. */ + /* */ + /* <Return> */ + /* The glyph index. 0~means either `undefined character code', or */ + /* `undefined selector code', or `no variation selector cmap */ + /* subtable', or `current CharMap is not Unicode'. */ + /* */ + /* <Note> */ + /* If you use FreeType to manipulate the contents of font files */ + /* directly, be aware that the glyph index returned by this function */ + /* doesn't always correspond to the internal indices used within */ + /* the file. This is done to ensure that value~0 always corresponds */ + /* to the `missing glyph'. */ + /* */ + /* This function is only meaningful if */ + /* a) the font has a variation selector cmap sub table, */ + /* and */ + /* b) the current charmap has a Unicode encoding. */ + /* */ + /* <Since> */ + /* 2.3.6 */ + /* */ + FT_EXPORT( FT_UInt ) + FT_Face_GetCharVariantIndex( FT_Face face, + FT_ULong charcode, + FT_ULong variantSelector ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_GetCharVariantIsDefault */ + /* */ + /* <Description> */ + /* Check whether this variation of this Unicode character is the one */ + /* to be found in the `cmap'. */ + /* */ + /* <Input> */ + /* face :: */ + /* A handle to the source face object. */ + /* */ + /* charcode :: */ + /* The character codepoint in Unicode. */ + /* */ + /* variantSelector :: */ + /* The Unicode codepoint of the variation selector. */ + /* */ + /* <Return> */ + /* 1~if found in the standard (Unicode) cmap, 0~if found in the */ + /* variation selector cmap, or -1 if it is not a variation. */ + /* */ + /* <Note> */ + /* This function is only meaningful if the font has a variation */ + /* selector cmap subtable. */ + /* */ + /* <Since> */ + /* 2.3.6 */ + /* */ + FT_EXPORT( FT_Int ) + FT_Face_GetCharVariantIsDefault( FT_Face face, + FT_ULong charcode, + FT_ULong variantSelector ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_GetVariantSelectors */ + /* */ + /* <Description> */ + /* Return a zero-terminated list of Unicode variation selectors found */ + /* in the font. */ + /* */ + /* <Input> */ + /* face :: */ + /* A handle to the source face object. */ + /* */ + /* <Return> */ + /* A pointer to an array of selector code points, or NULL if there is */ + /* no valid variation selector cmap subtable. */ + /* */ + /* <Note> */ + /* The last item in the array is~0; the array is owned by the */ + /* @FT_Face object but can be overwritten or released on the next */ + /* call to a FreeType function. */ + /* */ + /* <Since> */ + /* 2.3.6 */ + /* */ + FT_EXPORT( FT_UInt32* ) + FT_Face_GetVariantSelectors( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_GetVariantsOfChar */ + /* */ + /* <Description> */ + /* Return a zero-terminated list of Unicode variation selectors found */ + /* for the specified character code. */ + /* */ + /* <Input> */ + /* face :: */ + /* A handle to the source face object. */ + /* */ + /* charcode :: */ + /* The character codepoint in Unicode. */ + /* */ + /* <Return> */ + /* A pointer to an array of variation selector code points that are */ + /* active for the given character, or NULL if the corresponding list */ + /* is empty. */ + /* */ + /* <Note> */ + /* The last item in the array is~0; the array is owned by the */ + /* @FT_Face object but can be overwritten or released on the next */ + /* call to a FreeType function. */ + /* */ + /* <Since> */ + /* 2.3.6 */ + /* */ + FT_EXPORT( FT_UInt32* ) + FT_Face_GetVariantsOfChar( FT_Face face, + FT_ULong charcode ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_GetCharsOfVariant */ + /* */ + /* <Description> */ + /* Return a zero-terminated list of Unicode character codes found for */ + /* the specified variation selector. */ + /* */ + /* <Input> */ + /* face :: */ + /* A handle to the source face object. */ + /* */ + /* variantSelector :: */ + /* The variation selector code point in Unicode. */ + /* */ + /* <Return> */ + /* A list of all the code points that are specified by this selector */ + /* (both default and non-default codes are returned) or NULL if there */ + /* is no valid cmap or the variation selector is invalid. */ + /* */ + /* <Note> */ + /* The last item in the array is~0; the array is owned by the */ + /* @FT_Face object but can be overwritten or released on the next */ + /* call to a FreeType function. */ + /* */ + /* <Since> */ + /* 2.3.6 */ + /* */ + FT_EXPORT( FT_UInt32* ) + FT_Face_GetCharsOfVariant( FT_Face face, + FT_ULong variantSelector ); + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* computations */ + /* */ + /* <Title> */ + /* Computations */ + /* */ + /* <Abstract> */ + /* Crunching fixed numbers and vectors. */ + /* */ + /* <Description> */ + /* This section contains various functions used to perform */ + /* computations on 16.16 fixed-float numbers or 2d vectors. */ + /* */ + /* <Order> */ + /* FT_MulDiv */ + /* FT_MulFix */ + /* FT_DivFix */ + /* FT_RoundFix */ + /* FT_CeilFix */ + /* FT_FloorFix */ + /* FT_Vector_Transform */ + /* FT_Matrix_Multiply */ + /* FT_Matrix_Invert */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_MulDiv */ + /* */ + /* <Description> */ + /* Compute `(a*b)/c' with maximum accuracy, using a 64-bit */ + /* intermediate integer whenever necessary. */ + /* */ + /* This function isn't necessarily as fast as some processor specific */ + /* operations, but is at least completely portable. */ + /* */ + /* <Input> */ + /* a :: The first multiplier. */ + /* */ + /* b :: The second multiplier. */ + /* */ + /* c :: The divisor. */ + /* */ + /* <Return> */ + /* The result of `(a*b)/c'. This function never traps when trying to */ + /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ + /* on the signs of `a' and `b'. */ + /* */ + FT_EXPORT( FT_Long ) + FT_MulDiv( FT_Long a, + FT_Long b, + FT_Long c ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_MulFix */ + /* */ + /* <Description> */ + /* Compute `(a*b)/0x10000' with maximum accuracy. Its main use is to */ + /* multiply a given value by a 16.16 fixed-point factor. */ + /* */ + /* <Input> */ + /* a :: The first multiplier. */ + /* */ + /* b :: The second multiplier. Use a 16.16 factor here whenever */ + /* possible (see note below). */ + /* */ + /* <Return> */ + /* The result of `(a*b)/0x10000'. */ + /* */ + /* <Note> */ + /* This function has been optimized for the case where the absolute */ + /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */ + /* As this happens mainly when scaling from notional units to */ + /* fractional pixels in FreeType, it resulted in noticeable speed */ + /* improvements between versions 2.x and 1.x. */ + /* */ + /* As a conclusion, always try to place a 16.16 factor as the */ + /* _second_ argument of this function; this can make a great */ + /* difference. */ + /* */ + FT_EXPORT( FT_Long ) + FT_MulFix( FT_Long a, + FT_Long b ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_DivFix */ + /* */ + /* <Description> */ + /* Compute `(a*0x10000)/b' with maximum accuracy. Its main use is to */ + /* divide a given value by a 16.16 fixed-point factor. */ + /* */ + /* <Input> */ + /* a :: The numerator. */ + /* */ + /* b :: The denominator. Use a 16.16 factor here. */ + /* */ + /* <Return> */ + /* The result of `(a*0x10000)/b'. */ + /* */ + FT_EXPORT( FT_Long ) + FT_DivFix( FT_Long a, + FT_Long b ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_RoundFix */ + /* */ + /* <Description> */ + /* Round a 16.16 fixed number. */ + /* */ + /* <Input> */ + /* a :: The number to be rounded. */ + /* */ + /* <Return> */ + /* `a' rounded to the nearest 16.16 fixed integer, halfway cases away */ + /* from zero. */ + /* */ + /* <Note> */ + /* The function uses wrap-around arithmetic. */ + /* */ + FT_EXPORT( FT_Fixed ) + FT_RoundFix( FT_Fixed a ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_CeilFix */ + /* */ + /* <Description> */ + /* Compute the smallest following integer of a 16.16 fixed number. */ + /* */ + /* <Input> */ + /* a :: The number for which the ceiling function is to be computed. */ + /* */ + /* <Return> */ + /* `a' rounded towards plus infinity. */ + /* */ + /* <Note> */ + /* The function uses wrap-around arithmetic. */ + /* */ + FT_EXPORT( FT_Fixed ) + FT_CeilFix( FT_Fixed a ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_FloorFix */ + /* */ + /* <Description> */ + /* Compute the largest previous integer of a 16.16 fixed number. */ + /* */ + /* <Input> */ + /* a :: The number for which the floor function is to be computed. */ + /* */ + /* <Return> */ + /* `a' rounded towards minus infinity. */ + /* */ + FT_EXPORT( FT_Fixed ) + FT_FloorFix( FT_Fixed a ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Vector_Transform */ + /* */ + /* <Description> */ + /* Transform a single vector through a 2x2 matrix. */ + /* */ + /* <InOut> */ + /* vector :: The target vector to transform. */ + /* */ + /* <Input> */ + /* matrix :: A pointer to the source 2x2 matrix. */ + /* */ + /* <Note> */ + /* The result is undefined if either `vector' or `matrix' is invalid. */ + /* */ + FT_EXPORT( void ) + FT_Vector_Transform( FT_Vector* vec, + const FT_Matrix* matrix ); + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* version */ + /* */ + /* <Title> */ + /* FreeType Version */ + /* */ + /* <Abstract> */ + /* Functions and macros related to FreeType versions. */ + /* */ + /* <Description> */ + /* Note that those functions and macros are of limited use because */ + /* even a new release of FreeType with only documentation changes */ + /* increases the version number. */ + /* */ + /* <Order> */ + /* FT_Library_Version */ + /* */ + /* FREETYPE_MAJOR */ + /* FREETYPE_MINOR */ + /* FREETYPE_PATCH */ + /* */ + /* FT_Face_CheckTrueTypePatents */ + /* FT_Face_SetUnpatentedHinting */ + /* */ + /* FREETYPE_XXX */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @enum: + * FREETYPE_XXX + * + * @description: + * These three macros identify the FreeType source code version. + * Use @FT_Library_Version to access them at runtime. + * + * @values: + * FREETYPE_MAJOR :: The major version number. + * FREETYPE_MINOR :: The minor version number. + * FREETYPE_PATCH :: The patch level. + * + * @note: + * The version number of FreeType if built as a dynamic link library + * with the `libtool' package is _not_ controlled by these three + * macros. + * + */ +#define FREETYPE_MAJOR 2 +#define FREETYPE_MINOR 9 +#define FREETYPE_PATCH 0 + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Library_Version */ + /* */ + /* <Description> */ + /* Return the version of the FreeType library being used. This is */ + /* useful when dynamically linking to the library, since one cannot */ + /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */ + /* @FREETYPE_PATCH. */ + /* */ + /* <Input> */ + /* library :: A source library handle. */ + /* */ + /* <Output> */ + /* amajor :: The major version number. */ + /* */ + /* aminor :: The minor version number. */ + /* */ + /* apatch :: The patch version number. */ + /* */ + /* <Note> */ + /* The reason why this function takes a `library' argument is because */ + /* certain programs implement library initialization in a custom way */ + /* that doesn't use @FT_Init_FreeType. */ + /* */ + /* In such cases, the library version might not be available before */ + /* the library object has been created. */ + /* */ + FT_EXPORT( void ) + FT_Library_Version( FT_Library library, + FT_Int *amajor, + FT_Int *aminor, + FT_Int *apatch ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_CheckTrueTypePatents */ + /* */ + /* <Description> */ + /* Deprecated, does nothing. */ + /* */ + /* <Input> */ + /* face :: A face handle. */ + /* */ + /* <Return> */ + /* Always returns false. */ + /* */ + /* <Note> */ + /* Since May 2010, TrueType hinting is no longer patented. */ + /* */ + /* <Since> */ + /* 2.3.5 */ + /* */ + FT_EXPORT( FT_Bool ) + FT_Face_CheckTrueTypePatents( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Face_SetUnpatentedHinting */ + /* */ + /* <Description> */ + /* Deprecated, does nothing. */ + /* */ + /* <Input> */ + /* face :: A face handle. */ + /* */ + /* value :: New boolean setting. */ + /* */ + /* <Return> */ + /* Always returns false. */ + /* */ + /* <Note> */ + /* Since May 2010, TrueType hinting is no longer patented. */ + /* */ + /* <Since> */ + /* 2.3.5 */ + /* */ + FT_EXPORT( FT_Bool ) + FT_Face_SetUnpatentedHinting( FT_Face face, + FT_Bool value ); + + /* */ + + +FT_END_HEADER + +#endif /* FREETYPE_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftadvanc.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftadvanc.h new file mode 100644 index 0000000..f78e8b1 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftadvanc.h @@ -0,0 +1,187 @@ +/***************************************************************************/ +/* */ +/* ftadvanc.h */ +/* */ +/* Quick computation of advance widths (specification only). */ +/* */ +/* Copyright 2008-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTADVANC_H_ +#define FTADVANC_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * quick_advance + * + * @title: + * Quick retrieval of advance values + * + * @abstract: + * Retrieve horizontal and vertical advance values without processing + * glyph outlines, if possible. + * + * @description: + * This section contains functions to quickly extract advance values + * without handling glyph outlines, if possible. + * + * @order: + * FT_Get_Advance + * FT_Get_Advances + * + */ + + + /*************************************************************************/ + /* */ + /* <Const> */ + /* FT_ADVANCE_FLAG_FAST_ONLY */ + /* */ + /* <Description> */ + /* A bit-flag to be OR-ed with the `flags' parameter of the */ + /* @FT_Get_Advance and @FT_Get_Advances functions. */ + /* */ + /* If set, it indicates that you want these functions to fail if the */ + /* corresponding hinting mode or font driver doesn't allow for very */ + /* quick advance computation. */ + /* */ + /* Typically, glyphs that are either unscaled, unhinted, bitmapped, */ + /* or light-hinted can have their advance width computed very */ + /* quickly. */ + /* */ + /* Normal and bytecode hinted modes that require loading, scaling, */ + /* and hinting of the glyph outline, are extremely slow by */ + /* comparison. */ + /* */ +#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Advance */ + /* */ + /* <Description> */ + /* Retrieve the advance value of a given glyph outline in an */ + /* @FT_Face. */ + /* */ + /* <Input> */ + /* face :: The source @FT_Face handle. */ + /* */ + /* gindex :: The glyph index. */ + /* */ + /* load_flags :: A set of bit flags similar to those used when */ + /* calling @FT_Load_Glyph, used to determine what kind */ + /* of advances you need. */ + /* <Output> */ + /* padvance :: The advance value. If scaling is performed (based on */ + /* the value of `load_flags'), the advance value is in */ + /* 16.16 format. Otherwise, it is in font units. */ + /* */ + /* If @FT_LOAD_VERTICAL_LAYOUT is set, this is the */ + /* vertical advance corresponding to a vertical layout. */ + /* Otherwise, it is the horizontal advance in a */ + /* horizontal layout. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ + /* if the corresponding font backend doesn't have a quick way to */ + /* retrieve the advances. */ + /* */ + /* A scaled advance is returned in 16.16 format but isn't transformed */ + /* by the affine transformation specified by @FT_Set_Transform. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Advance( FT_Face face, + FT_UInt gindex, + FT_Int32 load_flags, + FT_Fixed *padvance ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Advances */ + /* */ + /* <Description> */ + /* Retrieve the advance values of several glyph outlines in an */ + /* @FT_Face. */ + /* */ + /* <Input> */ + /* face :: The source @FT_Face handle. */ + /* */ + /* start :: The first glyph index. */ + /* */ + /* count :: The number of advance values you want to retrieve. */ + /* */ + /* load_flags :: A set of bit flags similar to those used when */ + /* calling @FT_Load_Glyph. */ + /* */ + /* <Output> */ + /* padvance :: The advance values. This array, to be provided by the */ + /* caller, must contain at least `count' elements. */ + /* */ + /* If scaling is performed (based on the value of */ + /* `load_flags'), the advance values are in 16.16 format. */ + /* Otherwise, they are in font units. */ + /* */ + /* If @FT_LOAD_VERTICAL_LAYOUT is set, these are the */ + /* vertical advances corresponding to a vertical layout. */ + /* Otherwise, they are the horizontal advances in a */ + /* horizontal layout. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ + /* if the corresponding font backend doesn't have a quick way to */ + /* retrieve the advances. */ + /* */ + /* Scaled advances are returned in 16.16 format but aren't */ + /* transformed by the affine transformation specified by */ + /* @FT_Set_Transform. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Advances( FT_Face face, + FT_UInt start, + FT_UInt count, + FT_Int32 load_flags, + FT_Fixed *padvances ); + + /* */ + + +FT_END_HEADER + +#endif /* FTADVANC_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftbbox.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftbbox.h new file mode 100644 index 0000000..f9eb70b --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftbbox.h @@ -0,0 +1,101 @@ +/***************************************************************************/ +/* */ +/* ftbbox.h */ +/* */ +/* FreeType exact bbox computation (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This component has a _single_ role: to compute exact outline bounding */ + /* boxes. */ + /* */ + /* It is separated from the rest of the engine for various technical */ + /* reasons. It may well be integrated in `ftoutln' later. */ + /* */ + /*************************************************************************/ + + +#ifndef FTBBOX_H_ +#define FTBBOX_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* outline_processing */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Get_BBox */ + /* */ + /* <Description> */ + /* Compute the exact bounding box of an outline. This is slower */ + /* than computing the control box. However, it uses an advanced */ + /* algorithm that returns _very_ quickly when the two boxes */ + /* coincide. Otherwise, the outline Bezier arcs are traversed to */ + /* extract their extrema. */ + /* */ + /* <Input> */ + /* outline :: A pointer to the source outline. */ + /* */ + /* <Output> */ + /* abbox :: The outline's exact bounding box. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* If the font is tricky and the glyph has been loaded with */ + /* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get */ + /* reasonable values for the BBox it is necessary to load the glyph */ + /* at a large ppem value (so that the hinting instructions can */ + /* properly shift and scale the subglyphs), then extracting the BBox, */ + /* which can be eventually converted back to font units. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Get_BBox( FT_Outline* outline, + FT_BBox *abbox ); + + /* */ + + +FT_END_HEADER + +#endif /* FTBBOX_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftbdf.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftbdf.h new file mode 100644 index 0000000..1b6dea6 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftbdf.h @@ -0,0 +1,210 @@ +/***************************************************************************/ +/* */ +/* ftbdf.h */ +/* */ +/* FreeType API for accessing BDF-specific strings (specification). */ +/* */ +/* Copyright 2002-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTBDF_H_ +#define FTBDF_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* bdf_fonts */ + /* */ + /* <Title> */ + /* BDF and PCF Files */ + /* */ + /* <Abstract> */ + /* BDF and PCF specific API. */ + /* */ + /* <Description> */ + /* This section contains the declaration of functions specific to BDF */ + /* and PCF fonts. */ + /* */ + /*************************************************************************/ + + + /********************************************************************** + * + * @enum: + * BDF_PropertyType + * + * @description: + * A list of BDF property types. + * + * @values: + * BDF_PROPERTY_TYPE_NONE :: + * Value~0 is used to indicate a missing property. + * + * BDF_PROPERTY_TYPE_ATOM :: + * Property is a string atom. + * + * BDF_PROPERTY_TYPE_INTEGER :: + * Property is a 32-bit signed integer. + * + * BDF_PROPERTY_TYPE_CARDINAL :: + * Property is a 32-bit unsigned integer. + */ + typedef enum BDF_PropertyType_ + { + BDF_PROPERTY_TYPE_NONE = 0, + BDF_PROPERTY_TYPE_ATOM = 1, + BDF_PROPERTY_TYPE_INTEGER = 2, + BDF_PROPERTY_TYPE_CARDINAL = 3 + + } BDF_PropertyType; + + + /********************************************************************** + * + * @type: + * BDF_Property + * + * @description: + * A handle to a @BDF_PropertyRec structure to model a given + * BDF/PCF property. + */ + typedef struct BDF_PropertyRec_* BDF_Property; + + + /********************************************************************** + * + * @struct: + * BDF_PropertyRec + * + * @description: + * This structure models a given BDF/PCF property. + * + * @fields: + * type :: + * The property type. + * + * u.atom :: + * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be + * NULL, indicating an empty string. + * + * u.integer :: + * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. + * + * u.cardinal :: + * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. + */ + typedef struct BDF_PropertyRec_ + { + BDF_PropertyType type; + union { + const char* atom; + FT_Int32 integer; + FT_UInt32 cardinal; + + } u; + + } BDF_PropertyRec; + + + /********************************************************************** + * + * @function: + * FT_Get_BDF_Charset_ID + * + * @description: + * Retrieve a BDF font character set identity, according to + * the BDF specification. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * acharset_encoding :: + * Charset encoding, as a C~string, owned by the face. + * + * acharset_registry :: + * Charset registry, as a C~string, owned by the face. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with BDF faces, returning an error otherwise. + */ + FT_EXPORT( FT_Error ) + FT_Get_BDF_Charset_ID( FT_Face face, + const char* *acharset_encoding, + const char* *acharset_registry ); + + + /********************************************************************** + * + * @function: + * FT_Get_BDF_Property + * + * @description: + * Retrieve a BDF property from a BDF or PCF font file. + * + * @input: + * face :: A handle to the input face. + * + * name :: The property name. + * + * @output: + * aproperty :: The property. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function works with BDF _and_ PCF fonts. It returns an error + * otherwise. It also returns an error if the property is not in the + * font. + * + * A `property' is a either key-value pair within the STARTPROPERTIES + * ... ENDPROPERTIES block of a BDF font or a key-value pair from the + * `info->props' array within a `FontRec' structure of a PCF font. + * + * Integer properties are always stored as `signed' within PCF fonts; + * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value + * for BDF fonts only. + * + * In case of error, `aproperty->type' is always set to + * @BDF_PROPERTY_TYPE_NONE. + */ + FT_EXPORT( FT_Error ) + FT_Get_BDF_Property( FT_Face face, + const char* prop_name, + BDF_PropertyRec *aproperty ); + + /* */ + +FT_END_HEADER + +#endif /* FTBDF_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftbitmap.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftbitmap.h new file mode 100644 index 0000000..a43187c --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftbitmap.h @@ -0,0 +1,240 @@ +/***************************************************************************/ +/* */ +/* ftbitmap.h */ +/* */ +/* FreeType utility functions for bitmaps (specification). */ +/* */ +/* Copyright 2004-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTBITMAP_H_ +#define FTBITMAP_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* bitmap_handling */ + /* */ + /* <Title> */ + /* Bitmap Handling */ + /* */ + /* <Abstract> */ + /* Handling FT_Bitmap objects. */ + /* */ + /* <Description> */ + /* This section contains functions for handling @FT_Bitmap objects. */ + /* Note that none of the functions changes the bitmap's `flow' (as */ + /* indicated by the sign of the `pitch' field in `FT_Bitmap'). */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Bitmap_Init */ + /* */ + /* <Description> */ + /* Initialize a pointer to an @FT_Bitmap structure. */ + /* */ + /* <InOut> */ + /* abitmap :: A pointer to the bitmap structure. */ + /* */ + /* <Note> */ + /* A deprecated name for the same function is `FT_Bitmap_New'. */ + /* */ + FT_EXPORT( void ) + FT_Bitmap_Init( FT_Bitmap *abitmap ); + + + /* deprecated */ + FT_EXPORT( void ) + FT_Bitmap_New( FT_Bitmap *abitmap ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Bitmap_Copy */ + /* */ + /* <Description> */ + /* Copy a bitmap into another one. */ + /* */ + /* <Input> */ + /* library :: A handle to a library object. */ + /* */ + /* source :: A handle to the source bitmap. */ + /* */ + /* <Output> */ + /* target :: A handle to the target bitmap. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Copy( FT_Library library, + const FT_Bitmap *source, + FT_Bitmap *target ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Bitmap_Embolden */ + /* */ + /* <Description> */ + /* Embolden a bitmap. The new bitmap will be about `xStrength' */ + /* pixels wider and `yStrength' pixels higher. The left and bottom */ + /* borders are kept unchanged. */ + /* */ + /* <Input> */ + /* library :: A handle to a library object. */ + /* */ + /* xStrength :: How strong the glyph is emboldened horizontally. */ + /* Expressed in 26.6 pixel format. */ + /* */ + /* yStrength :: How strong the glyph is emboldened vertically. */ + /* Expressed in 26.6 pixel format. */ + /* */ + /* <InOut> */ + /* bitmap :: A handle to the target bitmap. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The current implementation restricts `xStrength' to be less than */ + /* or equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */ + /* */ + /* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */ + /* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */ + /* */ + /* Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format */ + /* are converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). */ + /* */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Embolden( FT_Library library, + FT_Bitmap* bitmap, + FT_Pos xStrength, + FT_Pos yStrength ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Bitmap_Convert */ + /* */ + /* <Description> */ + /* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp */ + /* to a bitmap object with depth 8bpp, making the number of used */ + /* bytes line (a.k.a. the `pitch') a multiple of `alignment'. */ + /* */ + /* <Input> */ + /* library :: A handle to a library object. */ + /* */ + /* source :: The source bitmap. */ + /* */ + /* alignment :: The pitch of the bitmap is a multiple of this */ + /* parameter. Common values are 1, 2, or 4. */ + /* */ + /* <Output> */ + /* target :: The target bitmap. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* It is possible to call @FT_Bitmap_Convert multiple times without */ + /* calling @FT_Bitmap_Done (the memory is simply reallocated). */ + /* */ + /* Use @FT_Bitmap_Done to finally remove the bitmap object. */ + /* */ + /* The `library' argument is taken to have access to FreeType's */ + /* memory handling functions. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Convert( FT_Library library, + const FT_Bitmap *source, + FT_Bitmap *target, + FT_Int alignment ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_GlyphSlot_Own_Bitmap */ + /* */ + /* <Description> */ + /* Make sure that a glyph slot owns `slot->bitmap'. */ + /* */ + /* <Input> */ + /* slot :: The glyph slot. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function is to be used in combination with */ + /* @FT_Bitmap_Embolden. */ + /* */ + FT_EXPORT( FT_Error ) + FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Bitmap_Done */ + /* */ + /* <Description> */ + /* Destroy a bitmap object initialized with @FT_Bitmap_Init. */ + /* */ + /* <Input> */ + /* library :: A handle to a library object. */ + /* */ + /* bitmap :: The bitmap object to be freed. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The `library' argument is taken to have access to FreeType's */ + /* memory handling functions. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Done( FT_Library library, + FT_Bitmap *bitmap ); + + + /* */ + + +FT_END_HEADER + +#endif /* FTBITMAP_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftbzip2.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftbzip2.h new file mode 100644 index 0000000..6edfa03 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftbzip2.h @@ -0,0 +1,102 @@ +/***************************************************************************/ +/* */ +/* ftbzip2.h */ +/* */ +/* Bzip2-compressed stream support. */ +/* */ +/* Copyright 2010-2018 by */ +/* Joel Klinghed. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTBZIP2_H_ +#define FTBZIP2_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* <Section> */ + /* bzip2 */ + /* */ + /* <Title> */ + /* BZIP2 Streams */ + /* */ + /* <Abstract> */ + /* Using bzip2-compressed font files. */ + /* */ + /* <Description> */ + /* This section contains the declaration of Bzip2-specific functions. */ + /* */ + /*************************************************************************/ + + + /************************************************************************ + * + * @function: + * FT_Stream_OpenBzip2 + * + * @description: + * Open a new stream to parse bzip2-compressed font files. This is + * mainly used to support the compressed `*.pcf.bz2' fonts that come + * with XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close' on the new stream will + * *not* call `FT_Stream_Close' on the source stream. None of the stream + * objects will be released to the heap. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream. + * + * In certain builds of the library, bzip2 compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a bzip2 compressed stream + * from it and re-open the face with it. + * + * This function may return `FT_Err_Unimplemented_Feature' if your build + * of FreeType was not compiled with bzip2 support. + */ + FT_EXPORT( FT_Error ) + FT_Stream_OpenBzip2( FT_Stream stream, + FT_Stream source ); + + /* */ + + +FT_END_HEADER + +#endif /* FTBZIP2_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftcache.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftcache.h new file mode 100644 index 0000000..52d5f00 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftcache.h @@ -0,0 +1,1042 @@ +/***************************************************************************/ +/* */ +/* ftcache.h */ +/* */ +/* FreeType Cache subsystem (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTCACHE_H_ +#define FTCACHE_H_ + + +#include <ft2build.h> +#include FT_GLYPH_H + + +FT_BEGIN_HEADER + + + /************************************************************************* + * + * <Section> + * cache_subsystem + * + * <Title> + * Cache Sub-System + * + * <Abstract> + * How to cache face, size, and glyph data with FreeType~2. + * + * <Description> + * This section describes the FreeType~2 cache sub-system, which is used + * to limit the number of concurrently opened @FT_Face and @FT_Size + * objects, as well as caching information like character maps and glyph + * images while limiting their maximum memory usage. + * + * Note that all types and functions begin with the `FTC_' prefix. + * + * The cache is highly portable and thus doesn't know anything about the + * fonts installed on your system, or how to access them. This implies + * the following scheme: + * + * First, available or installed font faces are uniquely identified by + * @FTC_FaceID values, provided to the cache by the client. Note that + * the cache only stores and compares these values, and doesn't try to + * interpret them in any way. + * + * Second, the cache calls, only when needed, a client-provided function + * to convert an @FTC_FaceID into a new @FT_Face object. The latter is + * then completely managed by the cache, including its termination + * through @FT_Done_Face. To monitor termination of face objects, the + * finalizer callback in the `generic' field of the @FT_Face object can + * be used, which might also be used to store the @FTC_FaceID of the + * face. + * + * Clients are free to map face IDs to anything else. The most simple + * usage is to associate them to a (pathname,face_index) pair that is + * used to call @FT_New_Face. However, more complex schemes are also + * possible. + * + * Note that for the cache to work correctly, the face ID values must be + * *persistent*, which means that the contents they point to should not + * change at runtime, or that their value should not become invalid. + * + * If this is unavoidable (e.g., when a font is uninstalled at runtime), + * you should call @FTC_Manager_RemoveFaceID as soon as possible, to let + * the cache get rid of any references to the old @FTC_FaceID it may + * keep internally. Failure to do so will lead to incorrect behaviour + * or even crashes. + * + * To use the cache, start with calling @FTC_Manager_New to create a new + * @FTC_Manager object, which models a single cache instance. You can + * then look up @FT_Face and @FT_Size objects with + * @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively. + * + * If you want to use the charmap caching, call @FTC_CMapCache_New, then + * later use @FTC_CMapCache_Lookup to perform the equivalent of + * @FT_Get_Char_Index, only much faster. + * + * If you want to use the @FT_Glyph caching, call @FTC_ImageCache, then + * later use @FTC_ImageCache_Lookup to retrieve the corresponding + * @FT_Glyph objects from the cache. + * + * If you need lots of small bitmaps, it is much more memory efficient + * to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This + * returns @FTC_SBitRec structures, which are used to store small + * bitmaps directly. (A small bitmap is one whose metrics and + * dimensions all fit into 8-bit integers). + * + * We hope to also provide a kerning cache in the near future. + * + * + * <Order> + * FTC_Manager + * FTC_FaceID + * FTC_Face_Requester + * + * FTC_Manager_New + * FTC_Manager_Reset + * FTC_Manager_Done + * FTC_Manager_LookupFace + * FTC_Manager_LookupSize + * FTC_Manager_RemoveFaceID + * + * FTC_Node + * FTC_Node_Unref + * + * FTC_ImageCache + * FTC_ImageCache_New + * FTC_ImageCache_Lookup + * + * FTC_SBit + * FTC_SBitCache + * FTC_SBitCache_New + * FTC_SBitCache_Lookup + * + * FTC_CMapCache + * FTC_CMapCache_New + * FTC_CMapCache_Lookup + * + *************************************************************************/ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** BASIC TYPE DEFINITIONS *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************* + * + * @type: FTC_FaceID + * + * @description: + * An opaque pointer type that is used to identity face objects. The + * contents of such objects is application-dependent. + * + * These pointers are typically used to point to a user-defined + * structure containing a font file path, and face index. + * + * @note: + * Never use NULL as a valid @FTC_FaceID. + * + * Face IDs are passed by the client to the cache manager that calls, + * when needed, the @FTC_Face_Requester to translate them into new + * @FT_Face objects. + * + * If the content of a given face ID changes at runtime, or if the value + * becomes invalid (e.g., when uninstalling a font), you should + * immediately call @FTC_Manager_RemoveFaceID before any other cache + * function. + * + * Failure to do so will result in incorrect behaviour or even + * memory leaks and crashes. + */ + typedef FT_Pointer FTC_FaceID; + + + /************************************************************************ + * + * @functype: + * FTC_Face_Requester + * + * @description: + * A callback function provided by client applications. It is used by + * the cache manager to translate a given @FTC_FaceID into a new valid + * @FT_Face object, on demand. + * + * <Input> + * face_id :: + * The face ID to resolve. + * + * library :: + * A handle to a FreeType library object. + * + * req_data :: + * Application-provided request data (see note below). + * + * <Output> + * aface :: + * A new @FT_Face handle. + * + * <Return> + * FreeType error code. 0~means success. + * + * <Note> + * The third parameter `req_data' is the same as the one passed by the + * client when @FTC_Manager_New is called. + * + * The face requester should not perform funny things on the returned + * face object, like creating a new @FT_Size for it, or setting a + * transformation through @FT_Set_Transform! + */ + typedef FT_Error + (*FTC_Face_Requester)( FTC_FaceID face_id, + FT_Library library, + FT_Pointer req_data, + FT_Face* aface ); + + /* */ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** CACHE MANAGER OBJECT *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FTC_Manager */ + /* */ + /* <Description> */ + /* This object corresponds to one instance of the cache-subsystem. */ + /* It is used to cache one or more @FT_Face objects, along with */ + /* corresponding @FT_Size objects. */ + /* */ + /* The manager intentionally limits the total number of opened */ + /* @FT_Face and @FT_Size objects to control memory usage. See the */ + /* `max_faces' and `max_sizes' parameters of @FTC_Manager_New. */ + /* */ + /* The manager is also used to cache `nodes' of various types while */ + /* limiting their total memory usage. */ + /* */ + /* All limitations are enforced by keeping lists of managed objects */ + /* in most-recently-used order, and flushing old nodes to make room */ + /* for new ones. */ + /* */ + typedef struct FTC_ManagerRec_* FTC_Manager; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FTC_Node */ + /* */ + /* <Description> */ + /* An opaque handle to a cache node object. Each cache node is */ + /* reference-counted. A node with a count of~0 might be flushed */ + /* out of a full cache whenever a lookup request is performed. */ + /* */ + /* If you look up nodes, you have the ability to `acquire' them, */ + /* i.e., to increment their reference count. This will prevent the */ + /* node from being flushed out of the cache until you explicitly */ + /* `release' it (see @FTC_Node_Unref). */ + /* */ + /* See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. */ + /* */ + typedef struct FTC_NodeRec_* FTC_Node; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Manager_New */ + /* */ + /* <Description> */ + /* Create a new cache manager. */ + /* */ + /* <Input> */ + /* library :: The parent FreeType library handle to use. */ + /* */ + /* max_faces :: Maximum number of opened @FT_Face objects managed by */ + /* this cache instance. Use~0 for defaults. */ + /* */ + /* max_sizes :: Maximum number of opened @FT_Size objects managed by */ + /* this cache instance. Use~0 for defaults. */ + /* */ + /* max_bytes :: Maximum number of bytes to use for cached data nodes. */ + /* Use~0 for defaults. Note that this value does not */ + /* account for managed @FT_Face and @FT_Size objects. */ + /* */ + /* requester :: An application-provided callback used to translate */ + /* face IDs into real @FT_Face objects. */ + /* */ + /* req_data :: A generic pointer that is passed to the requester */ + /* each time it is called (see @FTC_Face_Requester). */ + /* */ + /* <Output> */ + /* amanager :: A handle to a new manager object. 0~in case of */ + /* failure. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_Manager_New( FT_Library library, + FT_UInt max_faces, + FT_UInt max_sizes, + FT_ULong max_bytes, + FTC_Face_Requester requester, + FT_Pointer req_data, + FTC_Manager *amanager ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Manager_Reset */ + /* */ + /* <Description> */ + /* Empty a given cache manager. This simply gets rid of all the */ + /* currently cached @FT_Face and @FT_Size objects within the manager. */ + /* */ + /* <InOut> */ + /* manager :: A handle to the manager. */ + /* */ + FT_EXPORT( void ) + FTC_Manager_Reset( FTC_Manager manager ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Manager_Done */ + /* */ + /* <Description> */ + /* Destroy a given manager after emptying it. */ + /* */ + /* <Input> */ + /* manager :: A handle to the target cache manager object. */ + /* */ + FT_EXPORT( void ) + FTC_Manager_Done( FTC_Manager manager ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Manager_LookupFace */ + /* */ + /* <Description> */ + /* Retrieve the @FT_Face object that corresponds to a given face ID */ + /* through a cache manager. */ + /* */ + /* <Input> */ + /* manager :: A handle to the cache manager. */ + /* */ + /* face_id :: The ID of the face object. */ + /* */ + /* <Output> */ + /* aface :: A handle to the face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The returned @FT_Face object is always owned by the manager. You */ + /* should never try to discard it yourself. */ + /* */ + /* The @FT_Face object doesn't necessarily have a current size object */ + /* (i.e., face->size can be~0). If you need a specific `font size', */ + /* use @FTC_Manager_LookupSize instead. */ + /* */ + /* Never change the face's transformation matrix (i.e., never call */ + /* the @FT_Set_Transform function) on a returned face! If you need */ + /* to transform glyphs, do it yourself after glyph loading. */ + /* */ + /* When you perform a lookup, out-of-memory errors are detected */ + /* _within_ the lookup and force incremental flushes of the cache */ + /* until enough memory is released for the lookup to succeed. */ + /* */ + /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ + /* already been completely flushed, and still no memory was available */ + /* for the operation. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_Manager_LookupFace( FTC_Manager manager, + FTC_FaceID face_id, + FT_Face *aface ); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FTC_ScalerRec */ + /* */ + /* <Description> */ + /* A structure used to describe a given character size in either */ + /* pixels or points to the cache manager. See */ + /* @FTC_Manager_LookupSize. */ + /* */ + /* <Fields> */ + /* face_id :: The source face ID. */ + /* */ + /* width :: The character width. */ + /* */ + /* height :: The character height. */ + /* */ + /* pixel :: A Boolean. If 1, the `width' and `height' fields are */ + /* interpreted as integer pixel character sizes. */ + /* Otherwise, they are expressed as 1/64th of points. */ + /* */ + /* x_res :: Only used when `pixel' is value~0 to indicate the */ + /* horizontal resolution in dpi. */ + /* */ + /* y_res :: Only used when `pixel' is value~0 to indicate the */ + /* vertical resolution in dpi. */ + /* */ + /* <Note> */ + /* This type is mainly used to retrieve @FT_Size objects through the */ + /* cache manager. */ + /* */ + typedef struct FTC_ScalerRec_ + { + FTC_FaceID face_id; + FT_UInt width; + FT_UInt height; + FT_Int pixel; + FT_UInt x_res; + FT_UInt y_res; + + } FTC_ScalerRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FTC_Scaler */ + /* */ + /* <Description> */ + /* A handle to an @FTC_ScalerRec structure. */ + /* */ + typedef struct FTC_ScalerRec_* FTC_Scaler; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Manager_LookupSize */ + /* */ + /* <Description> */ + /* Retrieve the @FT_Size object that corresponds to a given */ + /* @FTC_ScalerRec pointer through a cache manager. */ + /* */ + /* <Input> */ + /* manager :: A handle to the cache manager. */ + /* */ + /* scaler :: A scaler handle. */ + /* */ + /* <Output> */ + /* asize :: A handle to the size object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The returned @FT_Size object is always owned by the manager. You */ + /* should never try to discard it by yourself. */ + /* */ + /* You can access the parent @FT_Face object simply as `size->face' */ + /* if you need it. Note that this object is also owned by the */ + /* manager. */ + /* */ + /* <Note> */ + /* When you perform a lookup, out-of-memory errors are detected */ + /* _within_ the lookup and force incremental flushes of the cache */ + /* until enough memory is released for the lookup to succeed. */ + /* */ + /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ + /* already been completely flushed, and still no memory is available */ + /* for the operation. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_Manager_LookupSize( FTC_Manager manager, + FTC_Scaler scaler, + FT_Size *asize ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_Node_Unref */ + /* */ + /* <Description> */ + /* Decrement a cache node's internal reference count. When the count */ + /* reaches 0, it is not destroyed but becomes eligible for subsequent */ + /* cache flushes. */ + /* */ + /* <Input> */ + /* node :: The cache node handle. */ + /* */ + /* manager :: The cache manager handle. */ + /* */ + FT_EXPORT( void ) + FTC_Node_Unref( FTC_Node node, + FTC_Manager manager ); + + + /************************************************************************* + * + * @function: + * FTC_Manager_RemoveFaceID + * + * @description: + * A special function used to indicate to the cache manager that + * a given @FTC_FaceID is no longer valid, either because its + * content changed, or because it was deallocated or uninstalled. + * + * @input: + * manager :: + * The cache manager handle. + * + * face_id :: + * The @FTC_FaceID to be removed. + * + * @note: + * This function flushes all nodes from the cache corresponding to this + * `face_id', with the exception of nodes with a non-null reference + * count. + * + * Such nodes are however modified internally so as to never appear + * in later lookups with the same `face_id' value, and to be immediately + * destroyed when released by all their users. + * + */ + FT_EXPORT( void ) + FTC_Manager_RemoveFaceID( FTC_Manager manager, + FTC_FaceID face_id ); + + + /************************************************************************* + * + * @type: + * FTC_CMapCache + * + * @description: + * An opaque handle used to model a charmap cache. This cache is to + * hold character codes -> glyph indices mappings. + * + */ + typedef struct FTC_CMapCacheRec_* FTC_CMapCache; + + + /************************************************************************* + * + * @function: + * FTC_CMapCache_New + * + * @description: + * Create a new charmap cache. + * + * @input: + * manager :: + * A handle to the cache manager. + * + * @output: + * acache :: + * A new cache handle. NULL in case of error. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Like all other caches, this one will be destroyed with the cache + * manager. + * + */ + FT_EXPORT( FT_Error ) + FTC_CMapCache_New( FTC_Manager manager, + FTC_CMapCache *acache ); + + + /************************************************************************ + * + * @function: + * FTC_CMapCache_Lookup + * + * @description: + * Translate a character code into a glyph index, using the charmap + * cache. + * + * @input: + * cache :: + * A charmap cache handle. + * + * face_id :: + * The source face ID. + * + * cmap_index :: + * The index of the charmap in the source face. Any negative value + * means to use the cache @FT_Face's default charmap. + * + * char_code :: + * The character code (in the corresponding charmap). + * + * @return: + * Glyph index. 0~means `no glyph'. + * + */ + FT_EXPORT( FT_UInt ) + FTC_CMapCache_Lookup( FTC_CMapCache cache, + FTC_FaceID face_id, + FT_Int cmap_index, + FT_UInt32 char_code ); + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** IMAGE CACHE OBJECT *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************* + * + * @struct: + * FTC_ImageTypeRec + * + * @description: + * A structure used to model the type of images in a glyph cache. + * + * @fields: + * face_id :: + * The face ID. + * + * width :: + * The width in pixels. + * + * height :: + * The height in pixels. + * + * flags :: + * The load flags, as in @FT_Load_Glyph. + * + */ + typedef struct FTC_ImageTypeRec_ + { + FTC_FaceID face_id; + FT_UInt width; + FT_UInt height; + FT_Int32 flags; + + } FTC_ImageTypeRec; + + + /************************************************************************* + * + * @type: + * FTC_ImageType + * + * @description: + * A handle to an @FTC_ImageTypeRec structure. + * + */ + typedef struct FTC_ImageTypeRec_* FTC_ImageType; + + + /* */ + + +#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \ + ( (d1)->face_id == (d2)->face_id && \ + (d1)->width == (d2)->width && \ + (d1)->flags == (d2)->flags ) + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FTC_ImageCache */ + /* */ + /* <Description> */ + /* A handle to a glyph image cache object. They are designed to */ + /* hold many distinct glyph images while not exceeding a certain */ + /* memory threshold. */ + /* */ + typedef struct FTC_ImageCacheRec_* FTC_ImageCache; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_ImageCache_New */ + /* */ + /* <Description> */ + /* Create a new glyph image cache. */ + /* */ + /* <Input> */ + /* manager :: The parent manager for the image cache. */ + /* */ + /* <Output> */ + /* acache :: A handle to the new glyph image cache object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_ImageCache_New( FTC_Manager manager, + FTC_ImageCache *acache ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_ImageCache_Lookup */ + /* */ + /* <Description> */ + /* Retrieve a given glyph image from a glyph image cache. */ + /* */ + /* <Input> */ + /* cache :: A handle to the source glyph image cache. */ + /* */ + /* type :: A pointer to a glyph image type descriptor. */ + /* */ + /* gindex :: The glyph index to retrieve. */ + /* */ + /* <Output> */ + /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */ + /* failure. */ + /* */ + /* anode :: Used to return the address of the corresponding cache */ + /* node after incrementing its reference count (see note */ + /* below). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The returned glyph is owned and managed by the glyph image cache. */ + /* Never try to transform or discard it manually! You can however */ + /* create a copy with @FT_Glyph_Copy and modify the new one. */ + /* */ + /* If `anode' is _not_ NULL, it receives the address of the cache */ + /* node containing the glyph image, after increasing its reference */ + /* count. This ensures that the node (as well as the @FT_Glyph) will */ + /* always be kept in the cache until you call @FTC_Node_Unref to */ + /* `release' it. */ + /* */ + /* If `anode' is NULL, the cache node is left unchanged, which means */ + /* that the @FT_Glyph could be flushed out of the cache on the next */ + /* call to one of the caching sub-system APIs. Don't assume that it */ + /* is persistent! */ + /* */ + FT_EXPORT( FT_Error ) + FTC_ImageCache_Lookup( FTC_ImageCache cache, + FTC_ImageType type, + FT_UInt gindex, + FT_Glyph *aglyph, + FTC_Node *anode ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_ImageCache_LookupScaler */ + /* */ + /* <Description> */ + /* A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec */ + /* to specify the face ID and its size. */ + /* */ + /* <Input> */ + /* cache :: A handle to the source glyph image cache. */ + /* */ + /* scaler :: A pointer to a scaler descriptor. */ + /* */ + /* load_flags :: The corresponding load flags. */ + /* */ + /* gindex :: The glyph index to retrieve. */ + /* */ + /* <Output> */ + /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */ + /* failure. */ + /* */ + /* anode :: Used to return the address of the corresponding */ + /* cache node after incrementing its reference count */ + /* (see note below). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The returned glyph is owned and managed by the glyph image cache. */ + /* Never try to transform or discard it manually! You can however */ + /* create a copy with @FT_Glyph_Copy and modify the new one. */ + /* */ + /* If `anode' is _not_ NULL, it receives the address of the cache */ + /* node containing the glyph image, after increasing its reference */ + /* count. This ensures that the node (as well as the @FT_Glyph) will */ + /* always be kept in the cache until you call @FTC_Node_Unref to */ + /* `release' it. */ + /* */ + /* If `anode' is NULL, the cache node is left unchanged, which means */ + /* that the @FT_Glyph could be flushed out of the cache on the next */ + /* call to one of the caching sub-system APIs. Don't assume that it */ + /* is persistent! */ + /* */ + /* Calls to @FT_Set_Char_Size and friends have no effect on cached */ + /* glyphs; you should always use the FreeType cache API instead. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_ImageCache_LookupScaler( FTC_ImageCache cache, + FTC_Scaler scaler, + FT_ULong load_flags, + FT_UInt gindex, + FT_Glyph *aglyph, + FTC_Node *anode ); + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FTC_SBit */ + /* */ + /* <Description> */ + /* A handle to a small bitmap descriptor. See the @FTC_SBitRec */ + /* structure for details. */ + /* */ + typedef struct FTC_SBitRec_* FTC_SBit; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FTC_SBitRec */ + /* */ + /* <Description> */ + /* A very compact structure used to describe a small glyph bitmap. */ + /* */ + /* <Fields> */ + /* width :: The bitmap width in pixels. */ + /* */ + /* height :: The bitmap height in pixels. */ + /* */ + /* left :: The horizontal distance from the pen position to the */ + /* left bitmap border (a.k.a. `left side bearing', or */ + /* `lsb'). */ + /* */ + /* top :: The vertical distance from the pen position (on the */ + /* baseline) to the upper bitmap border (a.k.a. `top */ + /* side bearing'). The distance is positive for upwards */ + /* y~coordinates. */ + /* */ + /* format :: The format of the glyph bitmap (monochrome or gray). */ + /* */ + /* max_grays :: Maximum gray level value (in the range 1 to~255). */ + /* */ + /* pitch :: The number of bytes per bitmap line. May be positive */ + /* or negative. */ + /* */ + /* xadvance :: The horizontal advance width in pixels. */ + /* */ + /* yadvance :: The vertical advance height in pixels. */ + /* */ + /* buffer :: A pointer to the bitmap pixels. */ + /* */ + typedef struct FTC_SBitRec_ + { + FT_Byte width; + FT_Byte height; + FT_Char left; + FT_Char top; + + FT_Byte format; + FT_Byte max_grays; + FT_Short pitch; + FT_Char xadvance; + FT_Char yadvance; + + FT_Byte* buffer; + + } FTC_SBitRec; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FTC_SBitCache */ + /* */ + /* <Description> */ + /* A handle to a small bitmap cache. These are special cache objects */ + /* used to store small glyph bitmaps (and anti-aliased pixmaps) in a */ + /* much more efficient way than the traditional glyph image cache */ + /* implemented by @FTC_ImageCache. */ + /* */ + typedef struct FTC_SBitCacheRec_* FTC_SBitCache; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_SBitCache_New */ + /* */ + /* <Description> */ + /* Create a new cache to store small glyph bitmaps. */ + /* */ + /* <Input> */ + /* manager :: A handle to the source cache manager. */ + /* */ + /* <Output> */ + /* acache :: A handle to the new sbit cache. NULL in case of error. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FTC_SBitCache_New( FTC_Manager manager, + FTC_SBitCache *acache ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_SBitCache_Lookup */ + /* */ + /* <Description> */ + /* Look up a given small glyph bitmap in a given sbit cache and */ + /* `lock' it to prevent its flushing from the cache until needed. */ + /* */ + /* <Input> */ + /* cache :: A handle to the source sbit cache. */ + /* */ + /* type :: A pointer to the glyph image type descriptor. */ + /* */ + /* gindex :: The glyph index. */ + /* */ + /* <Output> */ + /* sbit :: A handle to a small bitmap descriptor. */ + /* */ + /* anode :: Used to return the address of the corresponding cache */ + /* node after incrementing its reference count (see note */ + /* below). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The small bitmap descriptor and its bit buffer are owned by the */ + /* cache and should never be freed by the application. They might */ + /* as well disappear from memory on the next cache lookup, so don't */ + /* treat them as persistent data. */ + /* */ + /* The descriptor's `buffer' field is set to~0 to indicate a missing */ + /* glyph bitmap. */ + /* */ + /* If `anode' is _not_ NULL, it receives the address of the cache */ + /* node containing the bitmap, after increasing its reference count. */ + /* This ensures that the node (as well as the image) will always be */ + /* kept in the cache until you call @FTC_Node_Unref to `release' it. */ + /* */ + /* If `anode' is NULL, the cache node is left unchanged, which means */ + /* that the bitmap could be flushed out of the cache on the next */ + /* call to one of the caching sub-system APIs. Don't assume that it */ + /* is persistent! */ + /* */ + FT_EXPORT( FT_Error ) + FTC_SBitCache_Lookup( FTC_SBitCache cache, + FTC_ImageType type, + FT_UInt gindex, + FTC_SBit *sbit, + FTC_Node *anode ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FTC_SBitCache_LookupScaler */ + /* */ + /* <Description> */ + /* A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec */ + /* to specify the face ID and its size. */ + /* */ + /* <Input> */ + /* cache :: A handle to the source sbit cache. */ + /* */ + /* scaler :: A pointer to the scaler descriptor. */ + /* */ + /* load_flags :: The corresponding load flags. */ + /* */ + /* gindex :: The glyph index. */ + /* */ + /* <Output> */ + /* sbit :: A handle to a small bitmap descriptor. */ + /* */ + /* anode :: Used to return the address of the corresponding */ + /* cache node after incrementing its reference count */ + /* (see note below). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The small bitmap descriptor and its bit buffer are owned by the */ + /* cache and should never be freed by the application. They might */ + /* as well disappear from memory on the next cache lookup, so don't */ + /* treat them as persistent data. */ + /* */ + /* The descriptor's `buffer' field is set to~0 to indicate a missing */ + /* glyph bitmap. */ + /* */ + /* If `anode' is _not_ NULL, it receives the address of the cache */ + /* node containing the bitmap, after increasing its reference count. */ + /* This ensures that the node (as well as the image) will always be */ + /* kept in the cache until you call @FTC_Node_Unref to `release' it. */ + /* */ + /* If `anode' is NULL, the cache node is left unchanged, which means */ + /* that the bitmap could be flushed out of the cache on the next */ + /* call to one of the caching sub-system APIs. Don't assume that it */ + /* is persistent! */ + /* */ + FT_EXPORT( FT_Error ) + FTC_SBitCache_LookupScaler( FTC_SBitCache cache, + FTC_Scaler scaler, + FT_ULong load_flags, + FT_UInt gindex, + FTC_SBit *sbit, + FTC_Node *anode ); + + /* */ + + +FT_END_HEADER + +#endif /* FTCACHE_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftchapters.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftchapters.h new file mode 100644 index 0000000..51257bb --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftchapters.h @@ -0,0 +1,139 @@ +/***************************************************************************/ +/* */ +/* This file defines the structure of the FreeType reference. */ +/* It is used by the python script that generates the HTML files. */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* general_remarks */ +/* */ +/* <Title> */ +/* General Remarks */ +/* */ +/* <Sections> */ +/* header_inclusion */ +/* user_allocation */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* core_api */ +/* */ +/* <Title> */ +/* Core API */ +/* */ +/* <Sections> */ +/* version */ +/* basic_types */ +/* base_interface */ +/* glyph_variants */ +/* glyph_management */ +/* mac_specific */ +/* sizes_management */ +/* header_file_macros */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* format_specific */ +/* */ +/* <Title> */ +/* Format-Specific API */ +/* */ +/* <Sections> */ +/* multiple_masters */ +/* truetype_tables */ +/* type1_tables */ +/* sfnt_names */ +/* bdf_fonts */ +/* cid_fonts */ +/* pfr_fonts */ +/* winfnt_fonts */ +/* font_formats */ +/* gasp_table */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* module_specific */ +/* */ +/* <Title> */ +/* Controlling FreeType Modules */ +/* */ +/* <Sections> */ +/* auto_hinter */ +/* cff_driver */ +/* t1_cid_driver */ +/* tt_driver */ +/* pcf_driver */ +/* properties */ +/* parameter_tags */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* cache_subsystem */ +/* */ +/* <Title> */ +/* Cache Sub-System */ +/* */ +/* <Sections> */ +/* cache_subsystem */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* support_api */ +/* */ +/* <Title> */ +/* Support API */ +/* */ +/* <Sections> */ +/* computations */ +/* list_processing */ +/* outline_processing */ +/* quick_advance */ +/* bitmap_handling */ +/* raster */ +/* glyph_stroker */ +/* system_interface */ +/* module_management */ +/* gzip */ +/* lzw */ +/* bzip2 */ +/* lcd_filtering */ +/* */ +/***************************************************************************/ + +/***************************************************************************/ +/* */ +/* <Chapter> */ +/* error_codes */ +/* */ +/* <Title> */ +/* Error Codes */ +/* */ +/* <Sections> */ +/* error_enumerations */ +/* error_code_values */ +/* */ +/***************************************************************************/ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftcid.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftcid.h new file mode 100644 index 0000000..5e9100a --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftcid.h @@ -0,0 +1,168 @@ +/***************************************************************************/ +/* */ +/* ftcid.h */ +/* */ +/* FreeType API for accessing CID font information (specification). */ +/* */ +/* Copyright 2007-2018 by */ +/* Dereg Clegg and Michael Toftdal. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTCID_H_ +#define FTCID_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* cid_fonts */ + /* */ + /* <Title> */ + /* CID Fonts */ + /* */ + /* <Abstract> */ + /* CID-keyed font specific API. */ + /* */ + /* <Description> */ + /* This section contains the declaration of CID-keyed font specific */ + /* functions. */ + /* */ + /*************************************************************************/ + + + /********************************************************************** + * + * @function: + * FT_Get_CID_Registry_Ordering_Supplement + * + * @description: + * Retrieve the Registry/Ordering/Supplement triple (also known as the + * "R/O/S") from a CID-keyed font. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * registry :: + * The registry, as a C~string, owned by the face. + * + * ordering :: + * The ordering, as a C~string, owned by the face. + * + * supplement :: + * The supplement. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with CID faces, returning an error + * otherwise. + * + * @since: + * 2.3.6 + */ + FT_EXPORT( FT_Error ) + FT_Get_CID_Registry_Ordering_Supplement( FT_Face face, + const char* *registry, + const char* *ordering, + FT_Int *supplement ); + + + /********************************************************************** + * + * @function: + * FT_Get_CID_Is_Internally_CID_Keyed + * + * @description: + * Retrieve the type of the input face, CID keyed or not. In + * contrast to the @FT_IS_CID_KEYED macro this function returns + * successfully also for CID-keyed fonts in an SFNT wrapper. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * is_cid :: + * The type of the face as an @FT_Bool. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with CID faces and OpenType fonts, + * returning an error otherwise. + * + * @since: + * 2.3.9 + */ + FT_EXPORT( FT_Error ) + FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face, + FT_Bool *is_cid ); + + + /********************************************************************** + * + * @function: + * FT_Get_CID_From_Glyph_Index + * + * @description: + * Retrieve the CID of the input glyph index. + * + * @input: + * face :: + * A handle to the input face. + * + * glyph_index :: + * The input glyph index. + * + * @output: + * cid :: + * The CID as an @FT_UInt. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with CID faces and OpenType fonts, + * returning an error otherwise. + * + * @since: + * 2.3.9 + */ + FT_EXPORT( FT_Error ) + FT_Get_CID_From_Glyph_Index( FT_Face face, + FT_UInt glyph_index, + FT_UInt *cid ); + + /* */ + + +FT_END_HEADER + +#endif /* FTCID_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftdriver.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftdriver.h new file mode 100644 index 0000000..02d104d --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftdriver.h @@ -0,0 +1,1225 @@ +/***************************************************************************/ +/* */ +/* ftdriver.h */ +/* */ +/* FreeType API for controlling driver modules (specification only). */ +/* */ +/* Copyright 2017-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTDRIVER_H_ +#define FTDRIVER_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_PARAMETER_TAGS_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * auto_hinter + * + * @title: + * The auto-hinter + * + * @abstract: + * Controlling the auto-hinting module. + * + * @description: + * While FreeType's auto-hinter doesn't expose API functions by itself, + * it is possible to control its behaviour with @FT_Property_Set and + * @FT_Property_Get. The following lists the available properties + * together with the necessary macros and structures. + * + * Note that the auto-hinter's module name is `autofitter' for + * historical reasons. + * + * Available properties are @increase-x-height, @no-stem-darkening + * (experimental), @darkening-parameters (experimental), @warping + * (experimental), @glyph-to-script-map (experimental), @fallback-script + * (experimental), and @default-script (experimental), as documented in + * the @properties section. + * + */ + + + /************************************************************************** + * + * @section: + * cff_driver + * + * @title: + * The CFF driver + * + * @abstract: + * Controlling the CFF driver module. + * + * @description: + * While FreeType's CFF driver doesn't expose API functions by itself, + * it is possible to control its behaviour with @FT_Property_Set and + * @FT_Property_Get. + * + * The CFF driver's module name is `cff'. + * + * Available properties are @hinting-engine, @no-stem-darkening, + * @darkening-parameters, and @random-seed, as documented in the + * @properties section. + * + * + * *Hinting* *and* *antialiasing* *principles* *of* *the* *new* *engine* + * + * The rasterizer is positioning horizontal features (e.g., ascender + * height & x-height, or crossbars) on the pixel grid and minimizing the + * amount of antialiasing applied to them, while placing vertical + * features (vertical stems) on the pixel grid without hinting, thus + * representing the stem position and weight accurately. Sometimes the + * vertical stems may be only partially black. In this context, + * `antialiasing' means that stems are not positioned exactly on pixel + * borders, causing a fuzzy appearance. + * + * There are two principles behind this approach. + * + * 1) No hinting in the horizontal direction: Unlike `superhinted' + * TrueType, which changes glyph widths to accommodate regular + * inter-glyph spacing, Adobe's approach is `faithful to the design' in + * representing both the glyph width and the inter-glyph spacing + * designed for the font. This makes the screen display as close as it + * can be to the result one would get with infinite resolution, while + * preserving what is considered the key characteristics of each glyph. + * Note that the distances between unhinted and grid-fitted positions at + * small sizes are comparable to kerning values and thus would be + * noticeable (and distracting) while reading if hinting were applied. + * + * One of the reasons to not hint horizontally is antialiasing for LCD + * screens: The pixel geometry of modern displays supplies three + * vertical sub-pixels as the eye moves horizontally across each visible + * pixel. On devices where we can be certain this characteristic is + * present a rasterizer can take advantage of the sub-pixels to add + * increments of weight. In Western writing systems this turns out to + * be the more critical direction anyway; the weights and spacing of + * vertical stems (see above) are central to Armenian, Cyrillic, Greek, + * and Latin type designs. Even when the rasterizer uses greyscale + * antialiasing instead of color (a necessary compromise when one + * doesn't know the screen characteristics), the unhinted vertical + * features preserve the design's weight and spacing much better than + * aliased type would. + * + * 2) Alignment in the vertical direction: Weights and spacing along the + * y~axis are less critical; what is much more important is the visual + * alignment of related features (like cap-height and x-height). The + * sense of alignment for these is enhanced by the sharpness of grid-fit + * edges, while the cruder vertical resolution (full pixels instead of + * 1/3 pixels) is less of a problem. + * + * On the technical side, horizontal alignment zones for ascender, + * x-height, and other important height values (traditionally called + * `blue zones') as defined in the font are positioned independently, + * each being rounded to the nearest pixel edge, taking care of + * overshoot suppression at small sizes, stem darkening, and scaling. + * + * Hstems (this is, hint values defined in the font to help align + * horizontal features) that fall within a blue zone are said to be + * `captured' and are aligned to that zone. Uncaptured stems are moved + * in one of four ways, top edge up or down, bottom edge up or down. + * Unless there are conflicting hstems, the smallest movement is taken + * to minimize distortion. + * + */ + + + /************************************************************************** + * + * @section: + * pcf_driver + * + * @title: + * The PCF driver + * + * @abstract: + * Controlling the PCF driver module. + * + * @description: + * While FreeType's PCF driver doesn't expose API functions by itself, + * it is possible to control its behaviour with @FT_Property_Set and + * @FT_Property_Get. Right now, there is a single property + * @no-long-family-names available if FreeType is compiled with + * PCF_CONFIG_OPTION_LONG_FAMILY_NAMES. + * + * The PCF driver's module name is `pcf'. + * + */ + + + /************************************************************************** + * + * @section: + * t1_cid_driver + * + * @title: + * The Type 1 and CID drivers + * + * @abstract: + * Controlling the Type~1 and CID driver modules. + * + * @description: + * It is possible to control the behaviour of FreeType's Type~1 and + * Type~1 CID drivers with @FT_Property_Set and @FT_Property_Get. + * + * Behind the scenes, both drivers use the Adobe CFF engine for hinting; + * however, the used properties must be specified separately. + * + * The Type~1 driver's module name is `type1'; the CID driver's module + * name is `t1cid'. + * + * Available properties are @hinting-engine, @no-stem-darkening, + * @darkening-parameters, and @random-seed, as documented in the + * @properties section. + * + * Please see the @cff_driver section for more details on the new + * hinting engine. + * + */ + + + /************************************************************************** + * + * @section: + * tt_driver + * + * @title: + * The TrueType driver + * + * @abstract: + * Controlling the TrueType driver module. + * + * @description: + * While FreeType's TrueType driver doesn't expose API functions by + * itself, it is possible to control its behaviour with @FT_Property_Set + * and @FT_Property_Get. The following lists the available properties + * together with the necessary macros and structures. + * + * The TrueType driver's module name is `truetype'. + * + * A single property @interpreter-version is available, as documented in + * the @properties section. + * + * We start with a list of definitions, kindly provided by Greg + * Hitchcock. + * + * _Bi-Level_ _Rendering_ + * + * Monochromatic rendering, exclusively used in the early days of + * TrueType by both Apple and Microsoft. Microsoft's GDI interface + * supported hinting of the right-side bearing point, such that the + * advance width could be non-linear. Most often this was done to + * achieve some level of glyph symmetry. To enable reasonable + * performance (e.g., not having to run hinting on all glyphs just to + * get the widths) there was a bit in the head table indicating if the + * side bearing was hinted, and additional tables, `hdmx' and `LTSH', to + * cache hinting widths across multiple sizes and device aspect ratios. + * + * _Font_ _Smoothing_ + * + * Microsoft's GDI implementation of anti-aliasing. Not traditional + * anti-aliasing as the outlines were hinted before the sampling. The + * widths matched the bi-level rendering. + * + * _ClearType_ _Rendering_ + * + * Technique that uses physical subpixels to improve rendering on LCD + * (and other) displays. Because of the higher resolution, many methods + * of improving symmetry in glyphs through hinting the right-side + * bearing were no longer necessary. This lead to what GDI calls + * `natural widths' ClearType, see + * http://www.beatstamm.com/typography/RTRCh4.htm#Sec21. Since hinting + * has extra resolution, most non-linearity went away, but it is still + * possible for hints to change the advance widths in this mode. + * + * _ClearType_ _Compatible_ _Widths_ + * + * One of the earliest challenges with ClearType was allowing the + * implementation in GDI to be selected without requiring all UI and + * documents to reflow. To address this, a compatible method of + * rendering ClearType was added where the font hints are executed once + * to determine the width in bi-level rendering, and then re-run in + * ClearType, with the difference in widths being absorbed in the font + * hints for ClearType (mostly in the white space of hints); see + * http://www.beatstamm.com/typography/RTRCh4.htm#Sec20. Somewhat by + * definition, compatible width ClearType allows for non-linear widths, + * but only when the bi-level version has non-linear widths. + * + * _ClearType_ _Subpixel_ _Positioning_ + * + * One of the nice benefits of ClearType is the ability to more crisply + * display fractional widths; unfortunately, the GDI model of integer + * bitmaps did not support this. However, the WPF and Direct Write + * frameworks do support fractional widths. DWrite calls this `natural + * mode', not to be confused with GDI's `natural widths'. Subpixel + * positioning, in the current implementation of Direct Write, + * unfortunately does not support hinted advance widths, see + * http://www.beatstamm.com/typography/RTRCh4.htm#Sec22. Note that the + * TrueType interpreter fully allows the advance width to be adjusted in + * this mode, just the DWrite client will ignore those changes. + * + * _ClearType_ _Backward_ _Compatibility_ + * + * This is a set of exceptions made in the TrueType interpreter to + * minimize hinting techniques that were problematic with the extra + * resolution of ClearType; see + * http://www.beatstamm.com/typography/RTRCh4.htm#Sec1 and + * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx. + * This technique is not to be confused with ClearType compatible + * widths. ClearType backward compatibility has no direct impact on + * changing advance widths, but there might be an indirect impact on + * disabling some deltas. This could be worked around in backward + * compatibility mode. + * + * _Native_ _ClearType_ _Mode_ + * + * (Not to be confused with `natural widths'.) This mode removes all + * the exceptions in the TrueType interpreter when running with + * ClearType. Any issues on widths would still apply, though. + * + */ + + + /************************************************************************** + * + * @section: + * properties + * + * @title: + * Driver properties + * + * @abstract: + * Controlling driver modules. + * + * @description: + * Driver modules can be controlled by setting and unsetting properties, + * using the functions @FT_Property_Set and @FT_Property_Get. This + * section documents the available properties, together with auxiliary + * macros and structures. + * + */ + + + /************************************************************************** + * + * @enum: + * FT_HINTING_XXX + * + * @description: + * A list of constants used for the @hinting-engine property to + * select the hinting engine for CFF, Type~1, and CID fonts. + * + * @values: + * FT_HINTING_FREETYPE :: + * Use the old FreeType hinting engine. + * + * FT_HINTING_ADOBE :: + * Use the hinting engine contributed by Adobe. + * + * @since: + * 2.9 + * + */ +#define FT_HINTING_FREETYPE 0 +#define FT_HINTING_ADOBE 1 + + /* these constants (introduced in 2.4.12) are deprecated */ +#define FT_CFF_HINTING_FREETYPE FT_HINTING_FREETYPE +#define FT_CFF_HINTING_ADOBE FT_HINTING_ADOBE + + + /************************************************************************** + * + * @property: + * hinting-engine + * + * @description: + * Thanks to Adobe, which contributed a new hinting (and parsing) + * engine, an application can select between `freetype' and `adobe' if + * compiled with CFF_CONFIG_OPTION_OLD_ENGINE. If this configuration + * macro isn't defined, `hinting-engine' does nothing. + * + * The same holds for the Type~1 and CID modules if compiled with + * T1_CONFIG_OPTION_OLD_ENGINE. + * + * For the `cff' module, the default engine is `freetype' if + * CFF_CONFIG_OPTION_OLD_ENGINE is defined, and `adobe' otherwise. + * + * For both the `type1' and `t1cid' modules, the default engine is + * `freetype' if T1_CONFIG_OPTION_OLD_ENGINE is defined, and `adobe' + * otherwise. + * + * The following example code demonstrates how to select Adobe's hinting + * engine for the `cff' module (omitting the error handling). + * + * { + * FT_Library library; + * FT_UInt hinting_engine = FT_CFF_HINTING_ADOBE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "cff", + * "hinting-engine", &hinting_engine ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable (using values `adobe' or `freetype'). + * + * @since: + * 2.4.12 (for `cff' module) + * + * 2.9 (for `type1' and `t1cid' modules) + * + */ + + + /************************************************************************** + * + * @property: + * no-stem-darkening + * + * @description: + * All glyphs that pass through the auto-hinter will be emboldened + * unless this property is set to TRUE. The same is true for the CFF, + * Type~1, and CID font modules if the `Adobe' engine is selected (which + * is the default). + * + * Stem darkening emboldens glyphs at smaller sizes to make them more + * readable on common low-DPI screens when using linear alpha blending + * and gamma correction, see @FT_Render_Glyph. When not using linear + * alpha blending and gamma correction, glyphs will appear heavy and + * fuzzy! + * + * Gamma correction essentially lightens fonts since shades of grey are + * shifted to higher pixel values (=~higher brightness) to match the + * original intention to the reality of our screens. The side-effect is + * that glyphs `thin out'. Mac OS~X and Adobe's proprietary font + * rendering library implement a counter-measure: stem darkening at + * smaller sizes where shades of gray dominate. By emboldening a glyph + * slightly in relation to its pixel size, individual pixels get higher + * coverage of filled-in outlines and are therefore `blacker'. This + * counteracts the `thinning out' of glyphs, making text remain readable + * at smaller sizes. + * + * By default, the Adobe engines for CFF, Type~1, and CID fonts darken + * stems at smaller sizes, regardless of hinting, to enhance contrast. + * Setting this property, stem darkening gets switched off. + * + * For the auto-hinter, stem-darkening is experimental currently and + * thus switched off by default (this is, `no-stem-darkening' is set to + * TRUE by default). Total consistency with the CFF driver is not + * achieved right now because the emboldening method differs and glyphs + * must be scaled down on the Y-axis to keep outline points inside their + * precomputed blue zones. The smaller the size (especially 9ppem and + * down), the higher the loss of emboldening versus the CFF driver. + * + * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is + * set. + * + * { + * FT_Library library; + * FT_Bool no_stem_darkening = TRUE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "cff", + * "no-stem-darkening", &no_stem_darkening ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable (using values 1 and 0 for `on' and `off', respectively). + * It can also be set per face using @FT_Face_Properties with + * @FT_PARAM_TAG_STEM_DARKENING. + * + * @since: + * 2.4.12 (for `cff' module) + * + * 2.6.2 (for `autofitter' module) + * + * 2.9 (for `type1' and `t1cid' modules) + * + */ + + + /************************************************************************** + * + * @property: + * darkening-parameters + * + * @description: + * By default, the Adobe hinting engine, as used by the CFF, Type~1, and + * CID font drivers, darkens stems as follows (if the + * `no-stem-darkening' property isn't set): + * + * { + * stem width <= 0.5px: darkening amount = 0.4px + * stem width = 1px: darkening amount = 0.275px + * stem width = 1.667px: darkening amount = 0.275px + * stem width >= 2.333px: darkening amount = 0px + * } + * + * and piecewise linear in-between. At configuration time, these four + * control points can be set with the macro + * `CFF_CONFIG_OPTION_DARKENING_PARAMETERS'; the CFF, Type~1, and CID + * drivers share these values. At runtime, the control points can be + * changed using the `darkening-parameters' property, as the following + * example demonstrates for the Type~1 driver. + * + * { + * FT_Library library; + * FT_Int darken_params[8] = { 500, 300, // x1, y1 + * 1000, 200, // x2, y2 + * 1500, 100, // x3, y3 + * 2000, 0 }; // x4, y4 + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "type1", + * "darkening-parameters", darken_params ); + * } + * + * The x~values give the stem width, and the y~values the darkening + * amount. The unit is 1000th of pixels. All coordinate values must be + * positive; the x~values must be monotonically increasing; the + * y~values must be monotonically decreasing and smaller than or + * equal to 500 (corresponding to half a pixel); the slope of each + * linear piece must be shallower than -1 (e.g., -.4). + * + * The auto-hinter provides this property, too, as an experimental + * feature. See @no-stem-darkening for more. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable, using eight comma-separated integers without spaces. Here + * the above example, using `\' to break the line for readability. + * + * { + * FREETYPE_PROPERTIES=\ + * type1:darkening-parameters=500,300,1000,200,1500,100,2000,0 + * } + * + * @since: + * 2.5.1 (for `cff' module) + * + * 2.6.2 (for `autofitter' module) + * + * 2.9 (for `type1' and `t1cid' modules) + * + */ + + + /************************************************************************** + * + * @property: + * random-seed + * + * @description: + * By default, the seed value for the CFF `random' operator and the + * similar `0 28 callothersubr pop' command for the Type~1 and CID + * drivers is set to a random value. However, mainly for debugging + * purposes, it is often necessary to use a known value as a seed so + * that the pseudo-random number sequences generated by `random' are + * repeatable. + * + * The `random-seed' property does that. Its argument is a signed 32bit + * integer; if the value is zero or negative, the seed given by the + * `intitialRandomSeed' private DICT operator in a CFF file gets used + * (or a default value if there is no such operator). If the value is + * positive, use it instead of `initialRandomSeed', which is + * consequently ignored. + * + * @note: + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable. It can also be set per face using @FT_Face_Properties with + * @FT_PARAM_TAG_RANDOM_SEED. + * + * @since: + * 2.8 (for `cff' module) + * + * 2.9 (for `type1' and `t1cid' modules) + * + */ + + + /************************************************************************** + * + * @property: + * no-long-family-names + * + * @description: + * If PCF_CONFIG_OPTION_LONG_FAMILY_NAMES is active while compiling + * FreeType, the PCF driver constructs long family names. + * + * There are many PCF fonts just called `Fixed' which look completely + * different, and which have nothing to do with each other. When + * selecting `Fixed' in KDE or Gnome one gets results that appear rather + * random, the style changes often if one changes the size and one + * cannot select some fonts at all. The improve this situation, the PCF + * module prepends the foundry name (plus a space) to the family name. + * It also checks whether there are `wide' characters; all put together, + * family names like `Sony Fixed' or `Misc Fixed Wide' are constructed. + * + * If `no-long-family-names' is set, this feature gets switched off. + * + * { + * FT_Library library; + * FT_Bool no_long_family_names = TRUE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "pcf", + * "no-long-family-names", + * &no_long_family_names ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable (using values 1 and 0 for `on' and `off', respectively). + * + * @since: + * 2.8 + */ + + + /************************************************************************** + * + * @enum: + * TT_INTERPRETER_VERSION_XXX + * + * @description: + * A list of constants used for the @interpreter-version property to + * select the hinting engine for Truetype fonts. + * + * The numeric value in the constant names represents the version + * number as returned by the `GETINFO' bytecode instruction. + * + * @values: + * TT_INTERPRETER_VERSION_35 :: + * Version~35 corresponds to MS rasterizer v.1.7 as used e.g. in + * Windows~98; only grayscale and B/W rasterizing is supported. + * + * TT_INTERPRETER_VERSION_38 :: + * Version~38 corresponds to MS rasterizer v.1.9; it is roughly + * equivalent to the hinting provided by DirectWrite ClearType (as can + * be found, for example, in the Internet Explorer~9 running on + * Windows~7). It is used in FreeType to select the `Infinality' + * subpixel hinting code. The code may be removed in a future + * version. + * + * TT_INTERPRETER_VERSION_40 :: + * Version~40 corresponds to MS rasterizer v.2.1; it is roughly + * equivalent to the hinting provided by DirectWrite ClearType (as can + * be found, for example, in Microsoft's Edge Browser on Windows~10). + * It is used in FreeType to select the `minimal' subpixel hinting + * code, a stripped-down and higher performance version of the + * `Infinality' code. + * + * @note: + * This property controls the behaviour of the bytecode interpreter + * and thus how outlines get hinted. It does *not* control how glyph + * get rasterized! In particular, it does not control subpixel color + * filtering. + * + * If FreeType has not been compiled with the configuration option + * TT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 or~40 causes + * an `FT_Err_Unimplemented_Feature' error. + * + * Depending on the graphics framework, Microsoft uses different + * bytecode and rendering engines. As a consequence, the version + * numbers returned by a call to the `GETINFO' bytecode instruction are + * more convoluted than desired. + * + * Here are two tables that try to shed some light on the possible + * values for the MS rasterizer engine, together with the additional + * features introduced by it. + * + * { + * GETINFO framework version feature + * ------------------------------------------------------------------- + * 3 GDI (Win 3.1), v1.0 16-bit, first version + * TrueImage + * 33 GDI (Win NT 3.1), v1.5 32-bit + * HP Laserjet + * 34 GDI (Win 95) v1.6 font smoothing, + * new SCANTYPE opcode + * 35 GDI (Win 98/2000) v1.7 (UN)SCALED_COMPONENT_OFFSET + * bits in composite glyphs + * 36 MGDI (Win CE 2) v1.6+ classic ClearType + * 37 GDI (XP and later), v1.8 ClearType + * GDI+ old (before Vista) + * 38 GDI+ old (Vista, Win 7), v1.9 subpixel ClearType, + * WPF Y-direction ClearType, + * additional error checking + * 39 DWrite (before Win 8) v2.0 subpixel ClearType flags + * in GETINFO opcode, + * bug fixes + * 40 GDI+ (after Win 7), v2.1 Y-direction ClearType flag + * DWrite (Win 8) in GETINFO opcode, + * Gray ClearType + * } + * + * The `version' field gives a rough orientation only, since some + * applications provided certain features much earlier (as an example, + * Microsoft Reader used subpixel and Y-direction ClearType already in + * Windows 2000). Similarly, updates to a given framework might include + * improved hinting support. + * + * { + * version sampling rendering comment + * x y x y + * -------------------------------------------------------------- + * v1.0 normal normal B/W B/W bi-level + * v1.6 high high gray gray grayscale + * v1.8 high normal color-filter B/W (GDI) ClearType + * v1.9 high high color-filter gray Color ClearType + * v2.1 high normal gray B/W Gray ClearType + * v2.1 high high gray gray Gray ClearType + * } + * + * Color and Gray ClearType are the two available variants of + * `Y-direction ClearType', meaning grayscale rasterization along the + * Y-direction; the name used in the TrueType specification for this + * feature is `symmetric smoothing'. `Classic ClearType' is the + * original algorithm used before introducing a modified version in + * Win~XP. Another name for v1.6's grayscale rendering is `font + * smoothing', and `Color ClearType' is sometimes also called `DWrite + * ClearType'. To differentiate between today's Color ClearType and the + * earlier ClearType variant with B/W rendering along the vertical axis, + * the latter is sometimes called `GDI ClearType'. + * + * `Normal' and `high' sampling describe the (virtual) resolution to + * access the rasterized outline after the hinting process. `Normal' + * means 1 sample per grid line (i.e., B/W). In the current Microsoft + * implementation, `high' means an extra virtual resolution of 16x16 (or + * 16x1) grid lines per pixel for bytecode instructions like `MIRP'. + * After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid + * lines for color filtering if Color ClearType is activated. + * + * Note that `Gray ClearType' is essentially the same as v1.6's + * grayscale rendering. However, the GETINFO instruction handles it + * differently: v1.6 returns bit~12 (hinting for grayscale), while v2.1 + * returns bits~13 (hinting for ClearType), 18 (symmetrical smoothing), + * and~19 (Gray ClearType). Also, this mode respects bits 2 and~3 for + * the version~1 gasp table exclusively (like Color ClearType), while + * v1.6 only respects the values of version~0 (bits 0 and~1). + * + * Keep in mind that the features of the above interpreter versions + * might not map exactly to FreeType features or behavior because it is + * a fundamentally different library with different internals. + * + */ +#define TT_INTERPRETER_VERSION_35 35 +#define TT_INTERPRETER_VERSION_38 38 +#define TT_INTERPRETER_VERSION_40 40 + + + /************************************************************************** + * + * @property: + * interpreter-version + * + * @description: + * Currently, three versions are available, two representing the + * bytecode interpreter with subpixel hinting support (old `Infinality' + * code and new stripped-down and higher performance `minimal' code) and + * one without, respectively. The default is subpixel support if + * TT_CONFIG_OPTION_SUBPIXEL_HINTING is defined, and no subpixel support + * otherwise (since it isn't available then). + * + * If subpixel hinting is on, many TrueType bytecode instructions behave + * differently compared to B/W or grayscale rendering (except if `native + * ClearType' is selected by the font). Microsoft's main idea is to + * render at a much increased horizontal resolution, then sampling down + * the created output to subpixel precision. However, many older fonts + * are not suited to this and must be specially taken care of by + * applying (hardcoded) tweaks in Microsoft's interpreter. + * + * Details on subpixel hinting and some of the necessary tweaks can be + * found in Greg Hitchcock's whitepaper at + * `https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'. + * Note that FreeType currently doesn't really `subpixel hint' (6x1, 6x2, + * or 6x5 supersampling) like discussed in the paper. Depending on the + * chosen interpreter, it simply ignores instructions on vertical stems + * to arrive at very similar results. + * + * The following example code demonstrates how to deactivate subpixel + * hinting (omitting the error handling). + * + * { + * FT_Library library; + * FT_Face face; + * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_35; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "truetype", + * "interpreter-version", + * &interpreter_version ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable (using values `35', `38', or `40'). + * + * @since: + * 2.5 + */ + + + /************************************************************************** + * + * @property: + * glyph-to-script-map + * + * @description: + * *Experimental* *only* + * + * The auto-hinter provides various script modules to hint glyphs. + * Examples of supported scripts are Latin or CJK. Before a glyph is + * auto-hinted, the Unicode character map of the font gets examined, and + * the script is then determined based on Unicode character ranges, see + * below. + * + * OpenType fonts, however, often provide much more glyphs than + * character codes (small caps, superscripts, ligatures, swashes, etc.), + * to be controlled by so-called `features'. Handling OpenType features + * can be quite complicated and thus needs a separate library on top of + * FreeType. + * + * The mapping between glyph indices and scripts (in the auto-hinter + * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an + * array with `num_glyphs' elements, as found in the font's @FT_Face + * structure. The `glyph-to-script-map' property returns a pointer to + * this array, which can be modified as needed. Note that the + * modification should happen before the first glyph gets processed by + * the auto-hinter so that the global analysis of the font shapes + * actually uses the modified mapping. + * + * The following example code demonstrates how to access it (omitting + * the error handling). + * + * { + * FT_Library library; + * FT_Face face; + * FT_Prop_GlyphToScriptMap prop; + * + * + * FT_Init_FreeType( &library ); + * FT_New_Face( library, "foo.ttf", 0, &face ); + * + * prop.face = face; + * + * FT_Property_Get( library, "autofitter", + * "glyph-to-script-map", &prop ); + * + * // adjust `prop.map' as needed right here + * + * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT ); + * } + * + * @since: + * 2.4.11 + * + */ + + + /************************************************************************** + * + * @enum: + * FT_AUTOHINTER_SCRIPT_XXX + * + * @description: + * *Experimental* *only* + * + * A list of constants used for the @glyph-to-script-map property to + * specify the script submodule the auto-hinter should use for hinting a + * particular glyph. + * + * @values: + * FT_AUTOHINTER_SCRIPT_NONE :: + * Don't auto-hint this glyph. + * + * FT_AUTOHINTER_SCRIPT_LATIN :: + * Apply the latin auto-hinter. For the auto-hinter, `latin' is a + * very broad term, including Cyrillic and Greek also since characters + * from those scripts share the same design constraints. + * + * By default, characters from the following Unicode ranges are + * assigned to this submodule. + * + * { + * U+0020 - U+007F // Basic Latin (no control characters) + * U+00A0 - U+00FF // Latin-1 Supplement (no control characters) + * U+0100 - U+017F // Latin Extended-A + * U+0180 - U+024F // Latin Extended-B + * U+0250 - U+02AF // IPA Extensions + * U+02B0 - U+02FF // Spacing Modifier Letters + * U+0300 - U+036F // Combining Diacritical Marks + * U+0370 - U+03FF // Greek and Coptic + * U+0400 - U+04FF // Cyrillic + * U+0500 - U+052F // Cyrillic Supplement + * U+1D00 - U+1D7F // Phonetic Extensions + * U+1D80 - U+1DBF // Phonetic Extensions Supplement + * U+1DC0 - U+1DFF // Combining Diacritical Marks Supplement + * U+1E00 - U+1EFF // Latin Extended Additional + * U+1F00 - U+1FFF // Greek Extended + * U+2000 - U+206F // General Punctuation + * U+2070 - U+209F // Superscripts and Subscripts + * U+20A0 - U+20CF // Currency Symbols + * U+2150 - U+218F // Number Forms + * U+2460 - U+24FF // Enclosed Alphanumerics + * U+2C60 - U+2C7F // Latin Extended-C + * U+2DE0 - U+2DFF // Cyrillic Extended-A + * U+2E00 - U+2E7F // Supplemental Punctuation + * U+A640 - U+A69F // Cyrillic Extended-B + * U+A720 - U+A7FF // Latin Extended-D + * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures) + * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols + * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement + * } + * + * FT_AUTOHINTER_SCRIPT_CJK :: + * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old + * Vietnamese, and some other scripts. + * + * By default, characters from the following Unicode ranges are + * assigned to this submodule. + * + * { + * U+1100 - U+11FF // Hangul Jamo + * U+2E80 - U+2EFF // CJK Radicals Supplement + * U+2F00 - U+2FDF // Kangxi Radicals + * U+2FF0 - U+2FFF // Ideographic Description Characters + * U+3000 - U+303F // CJK Symbols and Punctuation + * U+3040 - U+309F // Hiragana + * U+30A0 - U+30FF // Katakana + * U+3100 - U+312F // Bopomofo + * U+3130 - U+318F // Hangul Compatibility Jamo + * U+3190 - U+319F // Kanbun + * U+31A0 - U+31BF // Bopomofo Extended + * U+31C0 - U+31EF // CJK Strokes + * U+31F0 - U+31FF // Katakana Phonetic Extensions + * U+3200 - U+32FF // Enclosed CJK Letters and Months + * U+3300 - U+33FF // CJK Compatibility + * U+3400 - U+4DBF // CJK Unified Ideographs Extension A + * U+4DC0 - U+4DFF // Yijing Hexagram Symbols + * U+4E00 - U+9FFF // CJK Unified Ideographs + * U+A960 - U+A97F // Hangul Jamo Extended-A + * U+AC00 - U+D7AF // Hangul Syllables + * U+D7B0 - U+D7FF // Hangul Jamo Extended-B + * U+F900 - U+FAFF // CJK Compatibility Ideographs + * U+FE10 - U+FE1F // Vertical forms + * U+FE30 - U+FE4F // CJK Compatibility Forms + * U+FF00 - U+FFEF // Halfwidth and Fullwidth Forms + * U+1B000 - U+1B0FF // Kana Supplement + * U+1D300 - U+1D35F // Tai Xuan Hing Symbols + * U+1F200 - U+1F2FF // Enclosed Ideographic Supplement + * U+20000 - U+2A6DF // CJK Unified Ideographs Extension B + * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C + * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D + * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement + * } + * + * FT_AUTOHINTER_SCRIPT_INDIC :: + * Apply the indic auto-hinter, covering all major scripts from the + * Indian sub-continent and some other related scripts like Thai, Lao, + * or Tibetan. + * + * By default, characters from the following Unicode ranges are + * assigned to this submodule. + * + * { + * U+0900 - U+0DFF // Indic Range + * U+0F00 - U+0FFF // Tibetan + * U+1900 - U+194F // Limbu + * U+1B80 - U+1BBF // Sundanese + * U+A800 - U+A82F // Syloti Nagri + * U+ABC0 - U+ABFF // Meetei Mayek + * U+11800 - U+118DF // Sharada + * } + * + * Note that currently Indic support is rudimentary only, missing blue + * zone support. + * + * @since: + * 2.4.11 + * + */ +#define FT_AUTOHINTER_SCRIPT_NONE 0 +#define FT_AUTOHINTER_SCRIPT_LATIN 1 +#define FT_AUTOHINTER_SCRIPT_CJK 2 +#define FT_AUTOHINTER_SCRIPT_INDIC 3 + + + /************************************************************************** + * + * @struct: + * FT_Prop_GlyphToScriptMap + * + * @description: + * *Experimental* *only* + * + * The data exchange structure for the @glyph-to-script-map property. + * + * @since: + * 2.4.11 + * + */ + typedef struct FT_Prop_GlyphToScriptMap_ + { + FT_Face face; + FT_UShort* map; + + } FT_Prop_GlyphToScriptMap; + + + /************************************************************************** + * + * @property: + * fallback-script + * + * @description: + * *Experimental* *only* + * + * If no auto-hinter script module can be assigned to a glyph, a + * fallback script gets assigned to it (see also the + * @glyph-to-script-map property). By default, this is + * @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property, + * this fallback value can be changed. + * + * { + * FT_Library library; + * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "fallback-script", &fallback_script ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * It's important to use the right timing for changing this value: The + * creation of the glyph-to-script map that eventually uses the + * fallback script value gets triggered either by setting or reading a + * face-specific property like @glyph-to-script-map, or by auto-hinting + * any glyph from that face. In particular, if you have already created + * an @FT_Face structure but not loaded any glyph (using the + * auto-hinter), a change of the fallback script will affect this face. + * + * @since: + * 2.4.11 + * + */ + + + /************************************************************************** + * + * @property: + * default-script + * + * @description: + * *Experimental* *only* + * + * If FreeType gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make + * the HarfBuzz library access OpenType features for getting better + * glyph coverages, this property sets the (auto-fitter) script to be + * used for the default (OpenType) script data of a font's GSUB table. + * Features for the default script are intended for all scripts not + * explicitly handled in GSUB; an example is a `dlig' feature, + * containing the combination of the characters `T', `E', and `L' to + * form a `TEL' ligature. + * + * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the + * `default-script' property, this default value can be changed. + * + * { + * FT_Library library; + * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "default-script", &default_script ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * It's important to use the right timing for changing this value: The + * creation of the glyph-to-script map that eventually uses the + * default script value gets triggered either by setting or reading a + * face-specific property like @glyph-to-script-map, or by auto-hinting + * any glyph from that face. In particular, if you have already created + * an @FT_Face structure but not loaded any glyph (using the + * auto-hinter), a change of the default script will affect this face. + * + * @since: + * 2.5.3 + * + */ + + + /************************************************************************** + * + * @property: + * increase-x-height + * + * @description: + * For ppem values in the range 6~<= ppem <= `increase-x-height', round + * up the font's x~height much more often than normally. If the value + * is set to~0, which is the default, this feature is switched off. Use + * this property to improve the legibility of small font sizes if + * necessary. + * + * { + * FT_Library library; + * FT_Face face; + * FT_Prop_IncreaseXHeight prop; + * + * + * FT_Init_FreeType( &library ); + * FT_New_Face( library, "foo.ttf", 0, &face ); + * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 ); + * + * prop.face = face; + * prop.limit = 14; + * + * FT_Property_Set( library, "autofitter", + * "increase-x-height", &prop ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * Set this value right after calling @FT_Set_Char_Size, but before + * loading any glyph (using the auto-hinter). + * + * @since: + * 2.4.11 + * + */ + + + /************************************************************************** + * + * @struct: + * FT_Prop_IncreaseXHeight + * + * @description: + * The data exchange structure for the @increase-x-height property. + * + */ + typedef struct FT_Prop_IncreaseXHeight_ + { + FT_Face face; + FT_UInt limit; + + } FT_Prop_IncreaseXHeight; + + + /************************************************************************** + * + * @property: + * warping + * + * @description: + * *Experimental* *only* + * + * If FreeType gets compiled with option AF_CONFIG_OPTION_USE_WARPER to + * activate the warp hinting code in the auto-hinter, this property + * switches warping on and off. + * + * Warping only works in `normal' auto-hinting mode replacing it. + * The idea of the code is to slightly scale and shift a glyph along + * the non-hinted dimension (which is usually the horizontal axis) so + * that as much of its segments are aligned (more or less) to the grid. + * To find out a glyph's optimal scaling and shifting value, various + * parameter combinations are tried and scored. + * + * By default, warping is off. The example below shows how to switch on + * warping (omitting the error handling). + * + * { + * FT_Library library; + * FT_Bool warping = 1; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "warping", &warping ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable (using values 1 and 0 for `on' and `off', respectively). + * + * The warping code can also change advance widths. Have a look at the + * `lsb_delta' and `rsb_delta' fields in the @FT_GlyphSlotRec structure + * for details on improving inter-glyph distances while rendering. + * + * Since warping is a global property of the auto-hinter it is best to + * change its value before rendering any face. Otherwise, you should + * reload all faces that get auto-hinted in `normal' hinting mode. + * + * @since: + * 2.6 + * + */ + + + /* */ + + +FT_END_HEADER + + +#endif /* FTDRIVER_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/fterrdef.h b/src_v2/libs/sloth/freetype/freetype2/freetype/fterrdef.h new file mode 100644 index 0000000..8ffd346 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/fterrdef.h @@ -0,0 +1,280 @@ +/***************************************************************************/ +/* */ +/* fterrdef.h */ +/* */ +/* FreeType error codes (specification). */ +/* */ +/* Copyright 2002-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* error_code_values */ + /* */ + /* <Title> */ + /* Error Code Values */ + /* */ + /* <Abstract> */ + /* All possible error codes returned by FreeType functions. */ + /* */ + /* <Description> */ + /* The list below is taken verbatim from the file `fterrdef.h' */ + /* (loaded automatically by including `FT_FREETYPE_H'). The first */ + /* argument of the `FT_ERROR_DEF_' macro is the error label; by */ + /* default, the prefix `FT_Err_' gets added so that you get error */ + /* names like `FT_Err_Cannot_Open_Resource'. The second argument is */ + /* the error code, and the last argument an error string, which is not */ + /* used by FreeType. */ + /* */ + /* Within your application you should *only* use error names and */ + /* *never* its numeric values! The latter might (and actually do) */ + /* change in forthcoming FreeType versions. */ + /* */ + /* Macro `FT_NOERRORDEF_' defines `FT_Err_Ok', which is always zero. */ + /* See the `Error Enumerations' subsection how to automatically */ + /* generate a list of error strings. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Err_XXX */ + /* */ + /*************************************************************************/ + + /* generic errors */ + + FT_NOERRORDEF_( Ok, 0x00, + "no error" ) + + FT_ERRORDEF_( Cannot_Open_Resource, 0x01, + "cannot open resource" ) + FT_ERRORDEF_( Unknown_File_Format, 0x02, + "unknown file format" ) + FT_ERRORDEF_( Invalid_File_Format, 0x03, + "broken file" ) + FT_ERRORDEF_( Invalid_Version, 0x04, + "invalid FreeType version" ) + FT_ERRORDEF_( Lower_Module_Version, 0x05, + "module version is too low" ) + FT_ERRORDEF_( Invalid_Argument, 0x06, + "invalid argument" ) + FT_ERRORDEF_( Unimplemented_Feature, 0x07, + "unimplemented feature" ) + FT_ERRORDEF_( Invalid_Table, 0x08, + "broken table" ) + FT_ERRORDEF_( Invalid_Offset, 0x09, + "broken offset within table" ) + FT_ERRORDEF_( Array_Too_Large, 0x0A, + "array allocation size too large" ) + FT_ERRORDEF_( Missing_Module, 0x0B, + "missing module" ) + FT_ERRORDEF_( Missing_Property, 0x0C, + "missing property" ) + + /* glyph/character errors */ + + FT_ERRORDEF_( Invalid_Glyph_Index, 0x10, + "invalid glyph index" ) + FT_ERRORDEF_( Invalid_Character_Code, 0x11, + "invalid character code" ) + FT_ERRORDEF_( Invalid_Glyph_Format, 0x12, + "unsupported glyph image format" ) + FT_ERRORDEF_( Cannot_Render_Glyph, 0x13, + "cannot render this glyph format" ) + FT_ERRORDEF_( Invalid_Outline, 0x14, + "invalid outline" ) + FT_ERRORDEF_( Invalid_Composite, 0x15, + "invalid composite glyph" ) + FT_ERRORDEF_( Too_Many_Hints, 0x16, + "too many hints" ) + FT_ERRORDEF_( Invalid_Pixel_Size, 0x17, + "invalid pixel size" ) + + /* handle errors */ + + FT_ERRORDEF_( Invalid_Handle, 0x20, + "invalid object handle" ) + FT_ERRORDEF_( Invalid_Library_Handle, 0x21, + "invalid library handle" ) + FT_ERRORDEF_( Invalid_Driver_Handle, 0x22, + "invalid module handle" ) + FT_ERRORDEF_( Invalid_Face_Handle, 0x23, + "invalid face handle" ) + FT_ERRORDEF_( Invalid_Size_Handle, 0x24, + "invalid size handle" ) + FT_ERRORDEF_( Invalid_Slot_Handle, 0x25, + "invalid glyph slot handle" ) + FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26, + "invalid charmap handle" ) + FT_ERRORDEF_( Invalid_Cache_Handle, 0x27, + "invalid cache manager handle" ) + FT_ERRORDEF_( Invalid_Stream_Handle, 0x28, + "invalid stream handle" ) + + /* driver errors */ + + FT_ERRORDEF_( Too_Many_Drivers, 0x30, + "too many modules" ) + FT_ERRORDEF_( Too_Many_Extensions, 0x31, + "too many extensions" ) + + /* memory errors */ + + FT_ERRORDEF_( Out_Of_Memory, 0x40, + "out of memory" ) + FT_ERRORDEF_( Unlisted_Object, 0x41, + "unlisted object" ) + + /* stream errors */ + + FT_ERRORDEF_( Cannot_Open_Stream, 0x51, + "cannot open stream" ) + FT_ERRORDEF_( Invalid_Stream_Seek, 0x52, + "invalid stream seek" ) + FT_ERRORDEF_( Invalid_Stream_Skip, 0x53, + "invalid stream skip" ) + FT_ERRORDEF_( Invalid_Stream_Read, 0x54, + "invalid stream read" ) + FT_ERRORDEF_( Invalid_Stream_Operation, 0x55, + "invalid stream operation" ) + FT_ERRORDEF_( Invalid_Frame_Operation, 0x56, + "invalid frame operation" ) + FT_ERRORDEF_( Nested_Frame_Access, 0x57, + "nested frame access" ) + FT_ERRORDEF_( Invalid_Frame_Read, 0x58, + "invalid frame read" ) + + /* raster errors */ + + FT_ERRORDEF_( Raster_Uninitialized, 0x60, + "raster uninitialized" ) + FT_ERRORDEF_( Raster_Corrupted, 0x61, + "raster corrupted" ) + FT_ERRORDEF_( Raster_Overflow, 0x62, + "raster overflow" ) + FT_ERRORDEF_( Raster_Negative_Height, 0x63, + "negative height while rastering" ) + + /* cache errors */ + + FT_ERRORDEF_( Too_Many_Caches, 0x70, + "too many registered caches" ) + + /* TrueType and SFNT errors */ + + FT_ERRORDEF_( Invalid_Opcode, 0x80, + "invalid opcode" ) + FT_ERRORDEF_( Too_Few_Arguments, 0x81, + "too few arguments" ) + FT_ERRORDEF_( Stack_Overflow, 0x82, + "stack overflow" ) + FT_ERRORDEF_( Code_Overflow, 0x83, + "code overflow" ) + FT_ERRORDEF_( Bad_Argument, 0x84, + "bad argument" ) + FT_ERRORDEF_( Divide_By_Zero, 0x85, + "division by zero" ) + FT_ERRORDEF_( Invalid_Reference, 0x86, + "invalid reference" ) + FT_ERRORDEF_( Debug_OpCode, 0x87, + "found debug opcode" ) + FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88, + "found ENDF opcode in execution stream" ) + FT_ERRORDEF_( Nested_DEFS, 0x89, + "nested DEFS" ) + FT_ERRORDEF_( Invalid_CodeRange, 0x8A, + "invalid code range" ) + FT_ERRORDEF_( Execution_Too_Long, 0x8B, + "execution context too long" ) + FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C, + "too many function definitions" ) + FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D, + "too many instruction definitions" ) + FT_ERRORDEF_( Table_Missing, 0x8E, + "SFNT font table missing" ) + FT_ERRORDEF_( Horiz_Header_Missing, 0x8F, + "horizontal header (hhea) table missing" ) + FT_ERRORDEF_( Locations_Missing, 0x90, + "locations (loca) table missing" ) + FT_ERRORDEF_( Name_Table_Missing, 0x91, + "name table missing" ) + FT_ERRORDEF_( CMap_Table_Missing, 0x92, + "character map (cmap) table missing" ) + FT_ERRORDEF_( Hmtx_Table_Missing, 0x93, + "horizontal metrics (hmtx) table missing" ) + FT_ERRORDEF_( Post_Table_Missing, 0x94, + "PostScript (post) table missing" ) + FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95, + "invalid horizontal metrics" ) + FT_ERRORDEF_( Invalid_CharMap_Format, 0x96, + "invalid character map (cmap) format" ) + FT_ERRORDEF_( Invalid_PPem, 0x97, + "invalid ppem value" ) + FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98, + "invalid vertical metrics" ) + FT_ERRORDEF_( Could_Not_Find_Context, 0x99, + "could not find context" ) + FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A, + "invalid PostScript (post) table format" ) + FT_ERRORDEF_( Invalid_Post_Table, 0x9B, + "invalid PostScript (post) table" ) + FT_ERRORDEF_( DEF_In_Glyf_Bytecode, 0x9C, + "found FDEF or IDEF opcode in glyf bytecode" ) + FT_ERRORDEF_( Missing_Bitmap, 0x9D, + "missing bitmap in strike" ) + + /* CFF, CID, and Type 1 errors */ + + FT_ERRORDEF_( Syntax_Error, 0xA0, + "opcode syntax error" ) + FT_ERRORDEF_( Stack_Underflow, 0xA1, + "argument stack underflow" ) + FT_ERRORDEF_( Ignore, 0xA2, + "ignore" ) + FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3, + "no Unicode glyph name found" ) + FT_ERRORDEF_( Glyph_Too_Big, 0xA4, + "glyph too big for hinting" ) + + /* BDF errors */ + + FT_ERRORDEF_( Missing_Startfont_Field, 0xB0, + "`STARTFONT' field missing" ) + FT_ERRORDEF_( Missing_Font_Field, 0xB1, + "`FONT' field missing" ) + FT_ERRORDEF_( Missing_Size_Field, 0xB2, + "`SIZE' field missing" ) + FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, + "`FONTBOUNDINGBOX' field missing" ) + FT_ERRORDEF_( Missing_Chars_Field, 0xB4, + "`CHARS' field missing" ) + FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, + "`STARTCHAR' field missing" ) + FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, + "`ENCODING' field missing" ) + FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, + "`BBX' field missing" ) + FT_ERRORDEF_( Bbx_Too_Big, 0xB8, + "`BBX' too big" ) + FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, + "Font header corrupted or missing fields" ) + FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, + "Font glyphs corrupted or missing fields" ) + + /* */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/fterrors.h b/src_v2/libs/sloth/freetype/freetype2/freetype/fterrors.h new file mode 100644 index 0000000..f6ee5c2 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/fterrors.h @@ -0,0 +1,226 @@ +/***************************************************************************/ +/* */ +/* fterrors.h */ +/* */ +/* FreeType error code handling (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* error_enumerations */ + /* */ + /* <Title> */ + /* Error Enumerations */ + /* */ + /* <Abstract> */ + /* How to handle errors and error strings. */ + /* */ + /* <Description> */ + /* The header file `fterrors.h' (which is automatically included by */ + /* `freetype.h' defines the handling of FreeType's enumeration */ + /* constants. It can also be used to generate error message strings */ + /* with a small macro trick explained below. */ + /* */ + /* *Error* *Formats* */ + /* */ + /* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */ + /* defined in `ftoption.h' in order to make the higher byte indicate */ + /* the module where the error has happened (this is not compatible */ + /* with standard builds of FreeType~2, however). See the file */ + /* `ftmoderr.h' for more details. */ + /* */ + /* *Error* *Message* *Strings* */ + /* */ + /* Error definitions are set up with special macros that allow client */ + /* applications to build a table of error message strings. The */ + /* strings are not included in a normal build of FreeType~2 to save */ + /* space (most client applications do not use them). */ + /* */ + /* To do so, you have to define the following macros before including */ + /* this file. */ + /* */ + /* { */ + /* FT_ERROR_START_LIST */ + /* } */ + /* */ + /* This macro is called before anything else to define the start of */ + /* the error list. It is followed by several FT_ERROR_DEF calls. */ + /* */ + /* { */ + /* FT_ERROR_DEF( e, v, s ) */ + /* } */ + /* */ + /* This macro is called to define one single error. `e' is the error */ + /* code identifier (e.g., `Invalid_Argument'), `v' is the error's */ + /* numerical value, and `s' is the corresponding error string. */ + /* */ + /* { */ + /* FT_ERROR_END_LIST */ + /* } */ + /* */ + /* This macro ends the list. */ + /* */ + /* Additionally, you have to undefine `FTERRORS_H_' before #including */ + /* this file. */ + /* */ + /* Here is a simple example. */ + /* */ + /* { */ + /* #undef FTERRORS_H_ */ + /* #define FT_ERRORDEF( e, v, s ) { e, s }, */ + /* #define FT_ERROR_START_LIST { */ + /* #define FT_ERROR_END_LIST { 0, NULL } }; */ + /* */ + /* const struct */ + /* { */ + /* int err_code; */ + /* const char* err_msg; */ + /* } ft_errors[] = */ + /* */ + /* #include FT_ERRORS_H */ + /* } */ + /* */ + /* Note that `FT_Err_Ok' is _not_ defined with `FT_ERRORDEF' but with */ + /* `FT_NOERRORDEF'; it is always zero. */ + /* */ + /*************************************************************************/ + + /* */ + + /* In previous FreeType versions we used `__FTERRORS_H__'. However, */ + /* using two successive underscores in a non-system symbol name */ + /* violates the C (and C++) standard, so it was changed to the */ + /* current form. In spite of this, we have to make */ + /* */ + /* #undefine __FTERRORS_H__ */ + /* */ + /* work for backward compatibility. */ + /* */ +#if !( defined( FTERRORS_H_ ) && defined ( __FTERRORS_H__ ) ) +#define FTERRORS_H_ +#define __FTERRORS_H__ + + + /* include module base error codes */ +#include FT_MODULE_ERRORS_H + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** SETUP MACROS *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#undef FT_NEED_EXTERN_C + + + /* FT_ERR_PREFIX is used as a prefix for error identifiers. */ + /* By default, we use `FT_Err_'. */ + /* */ +#ifndef FT_ERR_PREFIX +#define FT_ERR_PREFIX FT_Err_ +#endif + + + /* FT_ERR_BASE is used as the base for module-specific errors. */ + /* */ +#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS + +#ifndef FT_ERR_BASE +#define FT_ERR_BASE FT_Mod_Err_Base +#endif + +#else + +#undef FT_ERR_BASE +#define FT_ERR_BASE 0 + +#endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */ + + + /* If FT_ERRORDEF is not defined, we need to define a simple */ + /* enumeration type. */ + /* */ +#ifndef FT_ERRORDEF + +#define FT_ERRORDEF( e, v, s ) e = v, +#define FT_ERROR_START_LIST enum { +#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) }; + +#ifdef __cplusplus +#define FT_NEED_EXTERN_C + extern "C" { +#endif + +#endif /* !FT_ERRORDEF */ + + + /* this macro is used to define an error */ +#define FT_ERRORDEF_( e, v, s ) \ + FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s ) + + /* this is only used for <module>_Err_Ok, which must be 0! */ +#define FT_NOERRORDEF_( e, v, s ) \ + FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s ) + + +#ifdef FT_ERROR_START_LIST + FT_ERROR_START_LIST +#endif + + + /* now include the error codes */ +#include FT_ERROR_DEFINITIONS_H + + +#ifdef FT_ERROR_END_LIST + FT_ERROR_END_LIST +#endif + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** SIMPLE CLEANUP *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + +#ifdef FT_NEED_EXTERN_C + } +#endif + +#undef FT_ERROR_START_LIST +#undef FT_ERROR_END_LIST + +#undef FT_ERRORDEF +#undef FT_ERRORDEF_ +#undef FT_NOERRORDEF_ + +#undef FT_NEED_EXTERN_C +#undef FT_ERR_BASE + + /* FT_ERR_PREFIX is needed internally */ +#ifndef FT2_BUILD_LIBRARY +#undef FT_ERR_PREFIX +#endif + +#endif /* !(FTERRORS_H_ && __FTERRORS_H__) */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftfntfmt.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftfntfmt.h new file mode 100644 index 0000000..cc86efa --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftfntfmt.h @@ -0,0 +1,95 @@ +/***************************************************************************/ +/* */ +/* ftfntfmt.h */ +/* */ +/* Support functions for font formats. */ +/* */ +/* Copyright 2002-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTFNTFMT_H_ +#define FTFNTFMT_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* font_formats */ + /* */ + /* <Title> */ + /* Font Formats */ + /* */ + /* <Abstract> */ + /* Getting the font format. */ + /* */ + /* <Description> */ + /* The single function in this section can be used to get the font */ + /* format. Note that this information is not needed normally; */ + /* however, there are special cases (like in PDF devices) where it is */ + /* important to differentiate, in spite of FreeType's uniform API. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Font_Format */ + /* */ + /* <Description> */ + /* Return a string describing the format of a given face. Possible */ + /* values are `TrueType', `Type~1', `BDF', `PCF', `Type~42', */ + /* `CID~Type~1', `CFF', `PFR', and `Windows~FNT'. */ + /* */ + /* The return value is suitable to be used as an X11 FONT_PROPERTY. */ + /* */ + /* <Input> */ + /* face :: */ + /* Input face handle. */ + /* */ + /* <Return> */ + /* Font format string. NULL in case of error. */ + /* */ + /* <Note> */ + /* A deprecated name for the same function is */ + /* `FT_Get_X11_Font_Format'. */ + /* */ + FT_EXPORT( const char* ) + FT_Get_Font_Format( FT_Face face ); + + + /* deprecated */ + FT_EXPORT( const char* ) + FT_Get_X11_Font_Format( FT_Face face ); + + + /* */ + + +FT_END_HEADER + +#endif /* FTFNTFMT_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftgasp.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftgasp.h new file mode 100644 index 0000000..9b54fc8 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftgasp.h @@ -0,0 +1,137 @@ +/***************************************************************************/ +/* */ +/* ftgasp.h */ +/* */ +/* Access of TrueType's `gasp' table (specification). */ +/* */ +/* Copyright 2007-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTGASP_H_ +#define FTGASP_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + + /*************************************************************************** + * + * @section: + * gasp_table + * + * @title: + * Gasp Table + * + * @abstract: + * Retrieving TrueType `gasp' table entries. + * + * @description: + * The function @FT_Get_Gasp can be used to query a TrueType or OpenType + * font for specific entries in its `gasp' table, if any. This is + * mainly useful when implementing native TrueType hinting with the + * bytecode interpreter to duplicate the Windows text rendering results. + */ + + /************************************************************************* + * + * @enum: + * FT_GASP_XXX + * + * @description: + * A list of values and/or bit-flags returned by the @FT_Get_Gasp + * function. + * + * @values: + * FT_GASP_NO_TABLE :: + * This special value means that there is no GASP table in this face. + * It is up to the client to decide what to do. + * + * FT_GASP_DO_GRIDFIT :: + * Grid-fitting and hinting should be performed at the specified ppem. + * This *really* means TrueType bytecode interpretation. If this bit + * is not set, no hinting gets applied. + * + * FT_GASP_DO_GRAY :: + * Anti-aliased rendering should be performed at the specified ppem. + * If not set, do monochrome rendering. + * + * FT_GASP_SYMMETRIC_SMOOTHING :: + * If set, smoothing along multiple axes must be used with ClearType. + * + * FT_GASP_SYMMETRIC_GRIDFIT :: + * Grid-fitting must be used with ClearType's symmetric smoothing. + * + * @note: + * The bit-flags `FT_GASP_DO_GRIDFIT' and `FT_GASP_DO_GRAY' are to be + * used for standard font rasterization only. Independently of that, + * `FT_GASP_SYMMETRIC_SMOOTHING' and `FT_GASP_SYMMETRIC_GRIDFIT' are to + * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT' and + * `FT_GASP_DO_GRAY' are consequently ignored). + * + * `ClearType' is Microsoft's implementation of LCD rendering, partly + * protected by patents. + * + * @since: + * 2.3.0 + */ +#define FT_GASP_NO_TABLE -1 +#define FT_GASP_DO_GRIDFIT 0x01 +#define FT_GASP_DO_GRAY 0x02 +#define FT_GASP_SYMMETRIC_GRIDFIT 0x04 +#define FT_GASP_SYMMETRIC_SMOOTHING 0x08 + + + /************************************************************************* + * + * @func: + * FT_Get_Gasp + * + * @description: + * For a TrueType or OpenType font file, return the rasterizer behaviour + * flags from the font's `gasp' table corresponding to a given + * character pixel size. + * + * @input: + * face :: The source face handle. + * + * ppem :: The vertical character pixel size. + * + * @return: + * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no + * `gasp' table in the face. + * + * @note: + * If you want to use the MM functionality of OpenType variation fonts + * (i.e., using @FT_Set_Var_Design_Coordinates and friends), call this + * function *after* setting an instance since the return values can + * change. + * + * @since: + * 2.3.0 + */ + FT_EXPORT( FT_Int ) + FT_Get_Gasp( FT_Face face, + FT_UInt ppem ); + + /* */ + + +#endif /* FTGASP_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftglyph.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftglyph.h new file mode 100644 index 0000000..5f3fc00 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftglyph.h @@ -0,0 +1,614 @@ +/***************************************************************************/ +/* */ +/* ftglyph.h */ +/* */ +/* FreeType convenience functions to handle glyphs (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file contains the definition of several convenience functions */ + /* that can be used by client applications to easily retrieve glyph */ + /* bitmaps and outlines from a given face. */ + /* */ + /* These functions should be optional if you are writing a font server */ + /* or text layout engine on top of FreeType. However, they are pretty */ + /* handy for many other simple uses of the library. */ + /* */ + /*************************************************************************/ + + +#ifndef FTGLYPH_H_ +#define FTGLYPH_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* glyph_management */ + /* */ + /* <Title> */ + /* Glyph Management */ + /* */ + /* <Abstract> */ + /* Generic interface to manage individual glyph data. */ + /* */ + /* <Description> */ + /* This section contains definitions used to manage glyph data */ + /* through generic FT_Glyph objects. Each of them can contain a */ + /* bitmap, a vector outline, or even images in other formats. */ + /* */ + /*************************************************************************/ + + + /* forward declaration to a private type */ + typedef struct FT_Glyph_Class_ FT_Glyph_Class; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Glyph */ + /* */ + /* <Description> */ + /* Handle to an object used to model generic glyph images. It is a */ + /* pointer to the @FT_GlyphRec structure and can contain a glyph */ + /* bitmap or pointer. */ + /* */ + /* <Note> */ + /* Glyph objects are not owned by the library. You must thus release */ + /* them manually (through @FT_Done_Glyph) _before_ calling */ + /* @FT_Done_FreeType. */ + /* */ + typedef struct FT_GlyphRec_* FT_Glyph; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_GlyphRec */ + /* */ + /* <Description> */ + /* The root glyph structure contains a given glyph image plus its */ + /* advance width in 16.16 fixed-point format. */ + /* */ + /* <Fields> */ + /* library :: A handle to the FreeType library object. */ + /* */ + /* clazz :: A pointer to the glyph's class. Private. */ + /* */ + /* format :: The format of the glyph's image. */ + /* */ + /* advance :: A 16.16 vector that gives the glyph's advance width. */ + /* */ + typedef struct FT_GlyphRec_ + { + FT_Library library; + const FT_Glyph_Class* clazz; + FT_Glyph_Format format; + FT_Vector advance; + + } FT_GlyphRec; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_BitmapGlyph */ + /* */ + /* <Description> */ + /* A handle to an object used to model a bitmap glyph image. This is */ + /* a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. */ + /* */ + typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_BitmapGlyphRec */ + /* */ + /* <Description> */ + /* A structure used for bitmap glyph images. This really is a */ + /* `sub-class' of @FT_GlyphRec. */ + /* */ + /* <Fields> */ + /* root :: The root @FT_Glyph fields. */ + /* */ + /* left :: The left-side bearing, i.e., the horizontal distance */ + /* from the current pen position to the left border of the */ + /* glyph bitmap. */ + /* */ + /* top :: The top-side bearing, i.e., the vertical distance from */ + /* the current pen position to the top border of the glyph */ + /* bitmap. This distance is positive for upwards~y! */ + /* */ + /* bitmap :: A descriptor for the bitmap. */ + /* */ + /* <Note> */ + /* You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have */ + /* `glyph->format == FT_GLYPH_FORMAT_BITMAP'. This lets you access */ + /* the bitmap's contents easily. */ + /* */ + /* The corresponding pixel buffer is always owned by @FT_BitmapGlyph */ + /* and is thus created and destroyed with it. */ + /* */ + typedef struct FT_BitmapGlyphRec_ + { + FT_GlyphRec root; + FT_Int left; + FT_Int top; + FT_Bitmap bitmap; + + } FT_BitmapGlyphRec; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_OutlineGlyph */ + /* */ + /* <Description> */ + /* A handle to an object used to model an outline glyph image. This */ + /* is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. */ + /* */ + typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_OutlineGlyphRec */ + /* */ + /* <Description> */ + /* A structure used for outline (vectorial) glyph images. This */ + /* really is a `sub-class' of @FT_GlyphRec. */ + /* */ + /* <Fields> */ + /* root :: The root @FT_Glyph fields. */ + /* */ + /* outline :: A descriptor for the outline. */ + /* */ + /* <Note> */ + /* You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have */ + /* `glyph->format == FT_GLYPH_FORMAT_OUTLINE'. This lets you access */ + /* the outline's content easily. */ + /* */ + /* As the outline is extracted from a glyph slot, its coordinates are */ + /* expressed normally in 26.6 pixels, unless the flag */ + /* @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */ + /* */ + /* The outline's tables are always owned by the object and are */ + /* destroyed with it. */ + /* */ + typedef struct FT_OutlineGlyphRec_ + { + FT_GlyphRec root; + FT_Outline outline; + + } FT_OutlineGlyphRec; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Glyph */ + /* */ + /* <Description> */ + /* A function used to extract a glyph image from a slot. Note that */ + /* the created @FT_Glyph object must be released with @FT_Done_Glyph. */ + /* */ + /* <Input> */ + /* slot :: A handle to the source glyph slot. */ + /* */ + /* <Output> */ + /* aglyph :: A handle to the glyph object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* Because `*aglyph->advance.x' and '*aglyph->advance.y' are 16.16 */ + /* fixed-point numbers, `slot->advance.x' and `slot->advance.y' */ + /* (which are in 26.6 fixed-point format) must be in the range */ + /* ]-32768;32768[. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Glyph( FT_GlyphSlot slot, + FT_Glyph *aglyph ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Glyph_Copy */ + /* */ + /* <Description> */ + /* A function used to copy a glyph image. Note that the created */ + /* @FT_Glyph object must be released with @FT_Done_Glyph. */ + /* */ + /* <Input> */ + /* source :: A handle to the source glyph object. */ + /* */ + /* <Output> */ + /* target :: A handle to the target glyph object. 0~in case of */ + /* error. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Glyph_Copy( FT_Glyph source, + FT_Glyph *target ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Glyph_Transform */ + /* */ + /* <Description> */ + /* Transform a glyph image if its format is scalable. */ + /* */ + /* <InOut> */ + /* glyph :: A handle to the target glyph object. */ + /* */ + /* <Input> */ + /* matrix :: A pointer to a 2x2 matrix to apply. */ + /* */ + /* delta :: A pointer to a 2d vector to apply. Coordinates are */ + /* expressed in 1/64th of a pixel. */ + /* */ + /* <Return> */ + /* FreeType error code (if not 0, the glyph format is not scalable). */ + /* */ + /* <Note> */ + /* The 2x2 transformation matrix is also applied to the glyph's */ + /* advance vector. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Glyph_Transform( FT_Glyph glyph, + FT_Matrix* matrix, + FT_Vector* delta ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Glyph_BBox_Mode */ + /* */ + /* <Description> */ + /* The mode how the values of @FT_Glyph_Get_CBox are returned. */ + /* */ + /* <Values> */ + /* FT_GLYPH_BBOX_UNSCALED :: */ + /* Return unscaled font units. */ + /* */ + /* FT_GLYPH_BBOX_SUBPIXELS :: */ + /* Return unfitted 26.6 coordinates. */ + /* */ + /* FT_GLYPH_BBOX_GRIDFIT :: */ + /* Return grid-fitted 26.6 coordinates. */ + /* */ + /* FT_GLYPH_BBOX_TRUNCATE :: */ + /* Return coordinates in integer pixels. */ + /* */ + /* FT_GLYPH_BBOX_PIXELS :: */ + /* Return grid-fitted pixel coordinates. */ + /* */ + typedef enum FT_Glyph_BBox_Mode_ + { + FT_GLYPH_BBOX_UNSCALED = 0, + FT_GLYPH_BBOX_SUBPIXELS = 0, + FT_GLYPH_BBOX_GRIDFIT = 1, + FT_GLYPH_BBOX_TRUNCATE = 2, + FT_GLYPH_BBOX_PIXELS = 3 + + } FT_Glyph_BBox_Mode; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Glyph_BBox_Mode' values instead */ +#define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED +#define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS +#define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT +#define ft_glyph_bbox_truncate FT_GLYPH_BBOX_TRUNCATE +#define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Glyph_Get_CBox */ + /* */ + /* <Description> */ + /* Return a glyph's `control box'. The control box encloses all the */ + /* outline's points, including Bezier control points. Though it */ + /* coincides with the exact bounding box for most glyphs, it can be */ + /* slightly larger in some situations (like when rotating an outline */ + /* that contains Bezier outside arcs). */ + /* */ + /* Computing the control box is very fast, while getting the bounding */ + /* box can take much more time as it needs to walk over all segments */ + /* and arcs in the outline. To get the latter, you can use the */ + /* `ftbbox' component, which is dedicated to this single task. */ + /* */ + /* <Input> */ + /* glyph :: A handle to the source glyph object. */ + /* */ + /* mode :: The mode that indicates how to interpret the returned */ + /* bounding box values. */ + /* */ + /* <Output> */ + /* acbox :: The glyph coordinate bounding box. Coordinates are */ + /* expressed in 1/64th of pixels if it is grid-fitted. */ + /* */ + /* <Note> */ + /* Coordinates are relative to the glyph origin, using the y~upwards */ + /* convention. */ + /* */ + /* If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode' */ + /* must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font */ + /* units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS */ + /* is another name for this constant. */ + /* */ + /* If the font is tricky and the glyph has been loaded with */ + /* @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get */ + /* reasonable values for the CBox it is necessary to load the glyph */ + /* at a large ppem value (so that the hinting instructions can */ + /* properly shift and scale the subglyphs), then extracting the CBox, */ + /* which can be eventually converted back to font units. */ + /* */ + /* Note that the maximum coordinates are exclusive, which means that */ + /* one can compute the width and height of the glyph image (be it in */ + /* integer or 26.6 pixels) as: */ + /* */ + /* { */ + /* width = bbox.xMax - bbox.xMin; */ + /* height = bbox.yMax - bbox.yMin; */ + /* } */ + /* */ + /* Note also that for 26.6 coordinates, if `bbox_mode' is set to */ + /* @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, */ + /* which corresponds to: */ + /* */ + /* { */ + /* bbox.xMin = FLOOR(bbox.xMin); */ + /* bbox.yMin = FLOOR(bbox.yMin); */ + /* bbox.xMax = CEILING(bbox.xMax); */ + /* bbox.yMax = CEILING(bbox.yMax); */ + /* } */ + /* */ + /* To get the bbox in pixel coordinates, set `bbox_mode' to */ + /* @FT_GLYPH_BBOX_TRUNCATE. */ + /* */ + /* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */ + /* to @FT_GLYPH_BBOX_PIXELS. */ + /* */ + FT_EXPORT( void ) + FT_Glyph_Get_CBox( FT_Glyph glyph, + FT_UInt bbox_mode, + FT_BBox *acbox ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Glyph_To_Bitmap */ + /* */ + /* <Description> */ + /* Convert a given glyph object to a bitmap glyph object. */ + /* */ + /* <InOut> */ + /* the_glyph :: A pointer to a handle to the target glyph. */ + /* */ + /* <Input> */ + /* render_mode :: An enumeration that describes how the data is */ + /* rendered. */ + /* */ + /* origin :: A pointer to a vector used to translate the glyph */ + /* image before rendering. Can be~0 (if no */ + /* translation). The origin is expressed in */ + /* 26.6 pixels. */ + /* */ + /* destroy :: A boolean that indicates that the original glyph */ + /* image should be destroyed by this function. It is */ + /* never destroyed in case of error. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function does nothing if the glyph format isn't scalable. */ + /* */ + /* The glyph image is translated with the `origin' vector before */ + /* rendering. */ + /* */ + /* The first parameter is a pointer to an @FT_Glyph handle, that will */ + /* be _replaced_ by this function (with newly allocated data). */ + /* Typically, you would use (omitting error handling): */ + /* */ + /* */ + /* { */ + /* FT_Glyph glyph; */ + /* FT_BitmapGlyph glyph_bitmap; */ + /* */ + /* */ + /* // load glyph */ + /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT ); */ + /* */ + /* // extract glyph image */ + /* error = FT_Get_Glyph( face->glyph, &glyph ); */ + /* */ + /* // convert to a bitmap (default render mode + destroying old) */ + /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */ + /* { */ + /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */ + /* 0, 1 ); */ + /* if ( error ) // `glyph' unchanged */ + /* ... */ + /* } */ + /* */ + /* // access bitmap content by typecasting */ + /* glyph_bitmap = (FT_BitmapGlyph)glyph; */ + /* */ + /* // do funny stuff with it, like blitting/drawing */ + /* ... */ + /* */ + /* // discard glyph image (bitmap or not) */ + /* FT_Done_Glyph( glyph ); */ + /* } */ + /* */ + /* */ + /* Here another example, again without error handling: */ + /* */ + /* */ + /* { */ + /* FT_Glyph glyphs[MAX_GLYPHS] */ + /* */ + /* */ + /* ... */ + /* */ + /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ + /* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */ + /* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */ + /* */ + /* ... */ + /* */ + /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ + /* { */ + /* FT_Glyph bitmap = glyphs[idx]; */ + /* */ + /* */ + /* ... */ + /* */ + /* // after this call, `bitmap' no longer points into */ + /* // the `glyphs' array (and the old value isn't destroyed) */ + /* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */ + /* */ + /* ... */ + /* */ + /* FT_Done_Glyph( bitmap ); */ + /* } */ + /* */ + /* ... */ + /* */ + /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ + /* FT_Done_Glyph( glyphs[idx] ); */ + /* } */ + /* */ + FT_EXPORT( FT_Error ) + FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, + FT_Render_Mode render_mode, + FT_Vector* origin, + FT_Bool destroy ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_Glyph */ + /* */ + /* <Description> */ + /* Destroy a given glyph. */ + /* */ + /* <Input> */ + /* glyph :: A handle to the target glyph object. */ + /* */ + FT_EXPORT( void ) + FT_Done_Glyph( FT_Glyph glyph ); + + /* */ + + + /* other helpful functions */ + + /*************************************************************************/ + /* */ + /* <Section> */ + /* computations */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Matrix_Multiply */ + /* */ + /* <Description> */ + /* Perform the matrix operation `b = a*b'. */ + /* */ + /* <Input> */ + /* a :: A pointer to matrix `a'. */ + /* */ + /* <InOut> */ + /* b :: A pointer to matrix `b'. */ + /* */ + /* <Note> */ + /* The result is undefined if either `a' or `b' is zero. */ + /* */ + /* Since the function uses wrap-around arithmetic, results become */ + /* meaningless if the arguments are very large. */ + /* */ + FT_EXPORT( void ) + FT_Matrix_Multiply( const FT_Matrix* a, + FT_Matrix* b ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Matrix_Invert */ + /* */ + /* <Description> */ + /* Invert a 2x2 matrix. Return an error if it can't be inverted. */ + /* */ + /* <InOut> */ + /* matrix :: A pointer to the target matrix. Remains untouched in */ + /* case of error. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Matrix_Invert( FT_Matrix* matrix ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGLYPH_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftgxval.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftgxval.h new file mode 100644 index 0000000..8382d59 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftgxval.h @@ -0,0 +1,357 @@ +/***************************************************************************/ +/* */ +/* ftgxval.h */ +/* */ +/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ +/* */ +/* Copyright 2004-2018 by */ +/* Masatake YAMATO, Redhat K.K, */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +/***************************************************************************/ +/* */ +/* gxvalid is derived from both gxlayout module and otvalid module. */ +/* Development of gxlayout is supported by the Information-technology */ +/* Promotion Agency(IPA), Japan. */ +/* */ +/***************************************************************************/ + + +#ifndef FTGXVAL_H_ +#define FTGXVAL_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* gx_validation */ + /* */ + /* <Title> */ + /* TrueTypeGX/AAT Validation */ + /* */ + /* <Abstract> */ + /* An API to validate TrueTypeGX/AAT tables. */ + /* */ + /* <Description> */ + /* This section contains the declaration of functions to validate */ + /* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */ + /* trak, prop, lcar). */ + /* */ + /* <Order> */ + /* FT_TrueTypeGX_Validate */ + /* FT_TrueTypeGX_Free */ + /* */ + /* FT_ClassicKern_Validate */ + /* FT_ClassicKern_Free */ + /* */ + /* FT_VALIDATE_GX_LENGTH */ + /* FT_VALIDATE_GXXXX */ + /* FT_VALIDATE_CKERNXXX */ + /* */ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* */ + /* Warning: Use FT_VALIDATE_XXX to validate a table. */ + /* Following definitions are for gxvalid developers. */ + /* */ + /* */ + /*************************************************************************/ + +#define FT_VALIDATE_feat_INDEX 0 +#define FT_VALIDATE_mort_INDEX 1 +#define FT_VALIDATE_morx_INDEX 2 +#define FT_VALIDATE_bsln_INDEX 3 +#define FT_VALIDATE_just_INDEX 4 +#define FT_VALIDATE_kern_INDEX 5 +#define FT_VALIDATE_opbd_INDEX 6 +#define FT_VALIDATE_trak_INDEX 7 +#define FT_VALIDATE_prop_INDEX 8 +#define FT_VALIDATE_lcar_INDEX 9 +#define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX + + + /************************************************************************* + * + * @macro: + * FT_VALIDATE_GX_LENGTH + * + * @description: + * The number of tables checked in this module. Use it as a parameter + * for the `table-length' argument of function @FT_TrueTypeGX_Validate. + */ +#define FT_VALIDATE_GX_LENGTH ( FT_VALIDATE_GX_LAST_INDEX + 1 ) + + /* */ + + /* Up to 0x1000 is used by otvalid. + Ox2xxx is reserved for feature OT extension. */ +#define FT_VALIDATE_GX_START 0x4000 +#define FT_VALIDATE_GX_BITFIELD( tag ) \ + ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX ) + + + /********************************************************************** + * + * @enum: + * FT_VALIDATE_GXXXX + * + * @description: + * A list of bit-field constants used with @FT_TrueTypeGX_Validate to + * indicate which TrueTypeGX/AAT Type tables should be validated. + * + * @values: + * FT_VALIDATE_feat :: + * Validate `feat' table. + * + * FT_VALIDATE_mort :: + * Validate `mort' table. + * + * FT_VALIDATE_morx :: + * Validate `morx' table. + * + * FT_VALIDATE_bsln :: + * Validate `bsln' table. + * + * FT_VALIDATE_just :: + * Validate `just' table. + * + * FT_VALIDATE_kern :: + * Validate `kern' table. + * + * FT_VALIDATE_opbd :: + * Validate `opbd' table. + * + * FT_VALIDATE_trak :: + * Validate `trak' table. + * + * FT_VALIDATE_prop :: + * Validate `prop' table. + * + * FT_VALIDATE_lcar :: + * Validate `lcar' table. + * + * FT_VALIDATE_GX :: + * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern, + * opbd, trak, prop and lcar). + * + */ + +#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat ) +#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort ) +#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx ) +#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln ) +#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just ) +#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern ) +#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd ) +#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak ) +#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop ) +#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar ) + +#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \ + FT_VALIDATE_mort | \ + FT_VALIDATE_morx | \ + FT_VALIDATE_bsln | \ + FT_VALIDATE_just | \ + FT_VALIDATE_kern | \ + FT_VALIDATE_opbd | \ + FT_VALIDATE_trak | \ + FT_VALIDATE_prop | \ + FT_VALIDATE_lcar ) + + + /********************************************************************** + * + * @function: + * FT_TrueTypeGX_Validate + * + * @description: + * Validate various TrueTypeGX tables to assure that all offsets and + * indices are valid. The idea is that a higher-level library that + * actually does the text layout can access those tables without + * error checking (which can be quite time consuming). + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the tables to be validated. See + * @FT_VALIDATE_GXXXX for possible values. + * + * table_length :: + * The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH + * should be passed. + * + * @output: + * tables :: + * The array where all validated sfnt tables are stored. + * The array itself must be allocated by a client. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with TrueTypeGX fonts, returning an error + * otherwise. + * + * After use, the application should deallocate the buffers pointed to by + * each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value + * indicates that the table either doesn't exist in the font, the + * application hasn't asked for validation, or the validator doesn't have + * the ability to validate the sfnt table. + */ + FT_EXPORT( FT_Error ) + FT_TrueTypeGX_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes tables[FT_VALIDATE_GX_LENGTH], + FT_UInt table_length ); + + + /********************************************************************** + * + * @function: + * FT_TrueTypeGX_Free + * + * @description: + * Free the buffer allocated by TrueTypeGX validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer allocated by + * @FT_TrueTypeGX_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_TrueTypeGX_Validate only. + */ + FT_EXPORT( void ) + FT_TrueTypeGX_Free( FT_Face face, + FT_Bytes table ); + + + /********************************************************************** + * + * @enum: + * FT_VALIDATE_CKERNXXX + * + * @description: + * A list of bit-field constants used with @FT_ClassicKern_Validate + * to indicate the classic kern dialect or dialects. If the selected + * type doesn't fit, @FT_ClassicKern_Validate regards the table as + * invalid. + * + * @values: + * FT_VALIDATE_MS :: + * Handle the `kern' table as a classic Microsoft kern table. + * + * FT_VALIDATE_APPLE :: + * Handle the `kern' table as a classic Apple kern table. + * + * FT_VALIDATE_CKERN :: + * Handle the `kern' as either classic Apple or Microsoft kern table. + */ +#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 ) +#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 ) + +#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE ) + + + /********************************************************************** + * + * @function: + * FT_ClassicKern_Validate + * + * @description: + * Validate classic (16-bit format) kern table to assure that the offsets + * and indices are valid. The idea is that a higher-level library that + * actually does the text layout can access those tables without error + * checking (which can be quite time consuming). + * + * The `kern' table validator in @FT_TrueTypeGX_Validate deals with both + * the new 32-bit format and the classic 16-bit format, while + * FT_ClassicKern_Validate only supports the classic 16-bit format. + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the dialect to be validated. See + * @FT_VALIDATE_CKERNXXX for possible values. + * + * @output: + * ckern_table :: + * A pointer to the kern table. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * After use, the application should deallocate the buffers pointed to by + * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value + * indicates that the table doesn't exist in the font. + */ + FT_EXPORT( FT_Error ) + FT_ClassicKern_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes *ckern_table ); + + + /********************************************************************** + * + * @function: + * FT_ClassicKern_Free + * + * @description: + * Free the buffer allocated by classic Kern validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer that is allocated by + * @FT_ClassicKern_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_ClassicKern_Validate only. + */ + FT_EXPORT( void ) + FT_ClassicKern_Free( FT_Face face, + FT_Bytes table ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGXVAL_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftgzip.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftgzip.h new file mode 100644 index 0000000..db033da --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftgzip.h @@ -0,0 +1,151 @@ +/***************************************************************************/ +/* */ +/* ftgzip.h */ +/* */ +/* Gzip-compressed stream support. */ +/* */ +/* Copyright 2002-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTGZIP_H_ +#define FTGZIP_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* <Section> */ + /* gzip */ + /* */ + /* <Title> */ + /* GZIP Streams */ + /* */ + /* <Abstract> */ + /* Using gzip-compressed font files. */ + /* */ + /* <Description> */ + /* This section contains the declaration of Gzip-specific functions. */ + /* */ + /*************************************************************************/ + + + /************************************************************************ + * + * @function: + * FT_Stream_OpenGzip + * + * @description: + * Open a new stream to parse gzip-compressed font files. This is + * mainly used to support the compressed `*.pcf.gz' fonts that come + * with XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close' on the new stream will + * *not* call `FT_Stream_Close' on the source stream. None of the stream + * objects will be released to the heap. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream. + * + * In certain builds of the library, gzip compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a gzipped stream from + * it and re-open the face with it. + * + * This function may return `FT_Err_Unimplemented_Feature' if your build + * of FreeType was not compiled with zlib support. + */ + FT_EXPORT( FT_Error ) + FT_Stream_OpenGzip( FT_Stream stream, + FT_Stream source ); + + + /************************************************************************ + * + * @function: + * FT_Gzip_Uncompress + * + * @description: + * Decompress a zipped input buffer into an output buffer. This function + * is modeled after zlib's `uncompress' function. + * + * @input: + * memory :: + * A FreeType memory handle. + * + * input :: + * The input buffer. + * + * input_len :: + * The length of the input buffer. + * + * @output: + * output:: + * The output buffer. + * + * @inout: + * output_len :: + * Before calling the function, this is the total size of the output + * buffer, which must be large enough to hold the entire uncompressed + * data (so the size of the uncompressed data must be known in + * advance). After calling the function, `output_len' is the size of + * the used data in `output'. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function may return `FT_Err_Unimplemented_Feature' if your build + * of FreeType was not compiled with zlib support. + * + * @since: + * 2.5.1 + */ + FT_EXPORT( FT_Error ) + FT_Gzip_Uncompress( FT_Memory memory, + FT_Byte* output, + FT_ULong* output_len, + const FT_Byte* input, + FT_ULong input_len ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGZIP_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftimage.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftimage.h new file mode 100644 index 0000000..79ede19 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftimage.h @@ -0,0 +1,1205 @@ +/***************************************************************************/ +/* */ +/* ftimage.h */ +/* */ +/* FreeType glyph image formats and default raster interface */ +/* (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + /*************************************************************************/ + /* */ + /* Note: A `raster' is simply a scan-line converter, used to render */ + /* FT_Outlines into FT_Bitmaps. */ + /* */ + /*************************************************************************/ + + +#ifndef FTIMAGE_H_ +#define FTIMAGE_H_ + + + /* STANDALONE_ is from ftgrays.c */ +#ifndef STANDALONE_ +#include <ft2build.h> +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* basic_types */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Pos */ + /* */ + /* <Description> */ + /* The type FT_Pos is used to store vectorial coordinates. Depending */ + /* on the context, these can represent distances in integer font */ + /* units, or 16.16, or 26.6 fixed-point pixel coordinates. */ + /* */ + typedef signed long FT_Pos; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Vector */ + /* */ + /* <Description> */ + /* A simple structure used to store a 2D vector; coordinates are of */ + /* the FT_Pos type. */ + /* */ + /* <Fields> */ + /* x :: The horizontal coordinate. */ + /* y :: The vertical coordinate. */ + /* */ + typedef struct FT_Vector_ + { + FT_Pos x; + FT_Pos y; + + } FT_Vector; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_BBox */ + /* */ + /* <Description> */ + /* A structure used to hold an outline's bounding box, i.e., the */ + /* coordinates of its extrema in the horizontal and vertical */ + /* directions. */ + /* */ + /* <Fields> */ + /* xMin :: The horizontal minimum (left-most). */ + /* */ + /* yMin :: The vertical minimum (bottom-most). */ + /* */ + /* xMax :: The horizontal maximum (right-most). */ + /* */ + /* yMax :: The vertical maximum (top-most). */ + /* */ + /* <Note> */ + /* The bounding box is specified with the coordinates of the lower */ + /* left and the upper right corner. In PostScript, those values are */ + /* often called (llx,lly) and (urx,ury), respectively. */ + /* */ + /* If `yMin' is negative, this value gives the glyph's descender. */ + /* Otherwise, the glyph doesn't descend below the baseline. */ + /* Similarly, if `ymax' is positive, this value gives the glyph's */ + /* ascender. */ + /* */ + /* `xMin' gives the horizontal distance from the glyph's origin to */ + /* the left edge of the glyph's bounding box. If `xMin' is negative, */ + /* the glyph extends to the left of the origin. */ + /* */ + typedef struct FT_BBox_ + { + FT_Pos xMin, yMin; + FT_Pos xMax, yMax; + + } FT_BBox; + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Pixel_Mode */ + /* */ + /* <Description> */ + /* An enumeration type used to describe the format of pixels in a */ + /* given bitmap. Note that additional formats may be added in the */ + /* future. */ + /* */ + /* <Values> */ + /* FT_PIXEL_MODE_NONE :: */ + /* Value~0 is reserved. */ + /* */ + /* FT_PIXEL_MODE_MONO :: */ + /* A monochrome bitmap, using 1~bit per pixel. Note that pixels */ + /* are stored in most-significant order (MSB), which means that */ + /* the left-most pixel in a byte has value 128. */ + /* */ + /* FT_PIXEL_MODE_GRAY :: */ + /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ + /* images. Each pixel is stored in one byte. Note that the number */ + /* of `gray' levels is stored in the `num_grays' field of the */ + /* @FT_Bitmap structure (it generally is 256). */ + /* */ + /* FT_PIXEL_MODE_GRAY2 :: */ + /* A 2-bit per pixel bitmap, used to represent embedded */ + /* anti-aliased bitmaps in font files according to the OpenType */ + /* specification. We haven't found a single font using this */ + /* format, however. */ + /* */ + /* FT_PIXEL_MODE_GRAY4 :: */ + /* A 4-bit per pixel bitmap, representing embedded anti-aliased */ + /* bitmaps in font files according to the OpenType specification. */ + /* We haven't found a single font using this format, however. */ + /* */ + /* FT_PIXEL_MODE_LCD :: */ + /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ + /* used for display on LCD displays; the bitmap is three times */ + /* wider than the original glyph image. See also */ + /* @FT_RENDER_MODE_LCD. */ + /* */ + /* FT_PIXEL_MODE_LCD_V :: */ + /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ + /* used for display on rotated LCD displays; the bitmap is three */ + /* times taller than the original glyph image. See also */ + /* @FT_RENDER_MODE_LCD_V. */ + /* */ + /* FT_PIXEL_MODE_BGRA :: */ + /* [Since 2.5] An image with four 8-bit channels per pixel, */ + /* representing a color image (such as emoticons) with alpha */ + /* channel. For each pixel, the format is BGRA, which means, the */ + /* blue channel comes first in memory. The color channels are */ + /* pre-multiplied and in the sRGB colorspace. For example, full */ + /* red at half-translucent opacity will be represented as */ + /* `00,00,80,80', not `00,00,FF,80'. See also @FT_LOAD_COLOR. */ + /* */ + typedef enum FT_Pixel_Mode_ + { + FT_PIXEL_MODE_NONE = 0, + FT_PIXEL_MODE_MONO, + FT_PIXEL_MODE_GRAY, + FT_PIXEL_MODE_GRAY2, + FT_PIXEL_MODE_GRAY4, + FT_PIXEL_MODE_LCD, + FT_PIXEL_MODE_LCD_V, + FT_PIXEL_MODE_BGRA, + + FT_PIXEL_MODE_MAX /* do not remove */ + + } FT_Pixel_Mode; + + + /* these constants are deprecated; use the corresponding `FT_Pixel_Mode' */ + /* values instead. */ +#define ft_pixel_mode_none FT_PIXEL_MODE_NONE +#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO +#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY +#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2 +#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4 + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Bitmap */ + /* */ + /* <Description> */ + /* A structure used to describe a bitmap or pixmap to the raster. */ + /* Note that we now manage pixmaps of various depths through the */ + /* `pixel_mode' field. */ + /* */ + /* <Fields> */ + /* rows :: The number of bitmap rows. */ + /* */ + /* width :: The number of pixels in bitmap row. */ + /* */ + /* pitch :: The pitch's absolute value is the number of bytes */ + /* taken by one bitmap row, including padding. */ + /* However, the pitch is positive when the bitmap has */ + /* a `down' flow, and negative when it has an `up' */ + /* flow. In all cases, the pitch is an offset to add */ + /* to a bitmap pointer in order to go down one row. */ + /* */ + /* Note that `padding' means the alignment of a */ + /* bitmap to a byte border, and FreeType functions */ + /* normally align to the smallest possible integer */ + /* value. */ + /* */ + /* For the B/W rasterizer, `pitch' is always an even */ + /* number. */ + /* */ + /* To change the pitch of a bitmap (say, to make it a */ + /* multiple of 4), use @FT_Bitmap_Convert. */ + /* Alternatively, you might use callback functions to */ + /* directly render to the application's surface; see */ + /* the file `example2.cpp' in the tutorial for a */ + /* demonstration. */ + /* */ + /* buffer :: A typeless pointer to the bitmap buffer. This */ + /* value should be aligned on 32-bit boundaries in */ + /* most cases. */ + /* */ + /* num_grays :: This field is only used with */ + /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */ + /* levels used in the bitmap. */ + /* */ + /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */ + /* See @FT_Pixel_Mode for possible values. */ + /* */ + /* palette_mode :: This field is intended for paletted pixel modes; */ + /* it indicates how the palette is stored. Not */ + /* used currently. */ + /* */ + /* palette :: A typeless pointer to the bitmap palette; this */ + /* field is intended for paletted pixel modes. Not */ + /* used currently. */ + /* */ + typedef struct FT_Bitmap_ + { + unsigned int rows; + unsigned int width; + int pitch; + unsigned char* buffer; + unsigned short num_grays; + unsigned char pixel_mode; + unsigned char palette_mode; + void* palette; + + } FT_Bitmap; + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* outline_processing */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Outline */ + /* */ + /* <Description> */ + /* This structure is used to describe an outline to the scan-line */ + /* converter. */ + /* */ + /* <Fields> */ + /* n_contours :: The number of contours in the outline. */ + /* */ + /* n_points :: The number of points in the outline. */ + /* */ + /* points :: A pointer to an array of `n_points' @FT_Vector */ + /* elements, giving the outline's point coordinates. */ + /* */ + /* tags :: A pointer to an array of `n_points' chars, giving */ + /* each outline point's type. */ + /* */ + /* If bit~0 is unset, the point is `off' the curve, */ + /* i.e., a Bezier control point, while it is `on' if */ + /* set. */ + /* */ + /* Bit~1 is meaningful for `off' points only. If set, */ + /* it indicates a third-order Bezier arc control point; */ + /* and a second-order control point if unset. */ + /* */ + /* If bit~2 is set, bits 5-7 contain the drop-out mode */ + /* (as defined in the OpenType specification; the value */ + /* is the same as the argument to the SCANMODE */ + /* instruction). */ + /* */ + /* Bits 3 and~4 are reserved for internal purposes. */ + /* */ + /* contours :: An array of `n_contours' shorts, giving the end */ + /* point of each contour within the outline. For */ + /* example, the first contour is defined by the points */ + /* `0' to `contours[0]', the second one is defined by */ + /* the points `contours[0]+1' to `contours[1]', etc. */ + /* */ + /* flags :: A set of bit flags used to characterize the outline */ + /* and give hints to the scan-converter and hinter on */ + /* how to convert/grid-fit it. See @FT_OUTLINE_XXX. */ + /* */ + /* <Note> */ + /* The B/W rasterizer only checks bit~2 in the `tags' array for the */ + /* first point of each contour. The drop-out mode as given with */ + /* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */ + /* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */ + /* */ + typedef struct FT_Outline_ + { + short n_contours; /* number of contours in glyph */ + short n_points; /* number of points in the glyph */ + + FT_Vector* points; /* the outline's points */ + char* tags; /* the points flags */ + short* contours; /* the contour end points */ + + int flags; /* outline masks */ + + } FT_Outline; + + /* */ + + /* Following limits must be consistent with */ + /* FT_Outline.{n_contours,n_points} */ +#define FT_OUTLINE_CONTOURS_MAX SHRT_MAX +#define FT_OUTLINE_POINTS_MAX SHRT_MAX + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_OUTLINE_XXX */ + /* */ + /* <Description> */ + /* A list of bit-field constants use for the flags in an outline's */ + /* `flags' field. */ + /* */ + /* <Values> */ + /* FT_OUTLINE_NONE :: */ + /* Value~0 is reserved. */ + /* */ + /* FT_OUTLINE_OWNER :: */ + /* If set, this flag indicates that the outline's field arrays */ + /* (i.e., `points', `flags', and `contours') are `owned' by the */ + /* outline object, and should thus be freed when it is destroyed. */ + /* */ + /* FT_OUTLINE_EVEN_ODD_FILL :: */ + /* By default, outlines are filled using the non-zero winding rule. */ + /* If set to 1, the outline will be filled using the even-odd fill */ + /* rule (only works with the smooth rasterizer). */ + /* */ + /* FT_OUTLINE_REVERSE_FILL :: */ + /* By default, outside contours of an outline are oriented in */ + /* clock-wise direction, as defined in the TrueType specification. */ + /* This flag is set if the outline uses the opposite direction */ + /* (typically for Type~1 fonts). This flag is ignored by the scan */ + /* converter. */ + /* */ + /* FT_OUTLINE_IGNORE_DROPOUTS :: */ + /* By default, the scan converter will try to detect drop-outs in */ + /* an outline and correct the glyph bitmap to ensure consistent */ + /* shape continuity. If set, this flag hints the scan-line */ + /* converter to ignore such cases. See below for more information. */ + /* */ + /* FT_OUTLINE_SMART_DROPOUTS :: */ + /* Select smart dropout control. If unset, use simple dropout */ + /* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */ + /* below for more information. */ + /* */ + /* FT_OUTLINE_INCLUDE_STUBS :: */ + /* If set, turn pixels on for `stubs', otherwise exclude them. */ + /* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */ + /* more information. */ + /* */ + /* FT_OUTLINE_HIGH_PRECISION :: */ + /* This flag indicates that the scan-line converter should try to */ + /* convert this outline to bitmaps with the highest possible */ + /* quality. It is typically set for small character sizes. Note */ + /* that this is only a hint that might be completely ignored by a */ + /* given scan-converter. */ + /* */ + /* FT_OUTLINE_SINGLE_PASS :: */ + /* This flag is set to force a given scan-converter to only use a */ + /* single pass over the outline to render a bitmap glyph image. */ + /* Normally, it is set for very large character sizes. It is only */ + /* a hint that might be completely ignored by a given */ + /* scan-converter. */ + /* */ + /* <Note> */ + /* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */ + /* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */ + /* rasterizer. */ + /* */ + /* There exists a second mechanism to pass the drop-out mode to the */ + /* B/W rasterizer; see the `tags' field in @FT_Outline. */ + /* */ + /* Please refer to the description of the `SCANTYPE' instruction in */ + /* the OpenType specification (in file `ttinst1.doc') how simple */ + /* drop-outs, smart drop-outs, and stubs are defined. */ + /* */ +#define FT_OUTLINE_NONE 0x0 +#define FT_OUTLINE_OWNER 0x1 +#define FT_OUTLINE_EVEN_ODD_FILL 0x2 +#define FT_OUTLINE_REVERSE_FILL 0x4 +#define FT_OUTLINE_IGNORE_DROPOUTS 0x8 +#define FT_OUTLINE_SMART_DROPOUTS 0x10 +#define FT_OUTLINE_INCLUDE_STUBS 0x20 + +#define FT_OUTLINE_HIGH_PRECISION 0x100 +#define FT_OUTLINE_SINGLE_PASS 0x200 + + + /* these constants are deprecated; use the corresponding */ + /* `FT_OUTLINE_XXX' values instead */ +#define ft_outline_none FT_OUTLINE_NONE +#define ft_outline_owner FT_OUTLINE_OWNER +#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL +#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL +#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS +#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION +#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS + + /* */ + +#define FT_CURVE_TAG( flag ) ( flag & 3 ) + +#define FT_CURVE_TAG_ON 1 +#define FT_CURVE_TAG_CONIC 0 +#define FT_CURVE_TAG_CUBIC 2 + +#define FT_CURVE_TAG_HAS_SCANMODE 4 + +#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ +#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ + +#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \ + FT_CURVE_TAG_TOUCH_Y ) + +#define FT_Curve_Tag_On FT_CURVE_TAG_ON +#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC +#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC +#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X +#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Outline_MoveToFunc */ + /* */ + /* <Description> */ + /* A function pointer type used to describe the signature of a `move */ + /* to' function during outline walking/decomposition. */ + /* */ + /* A `move to' is emitted to start a new contour in an outline. */ + /* */ + /* <Input> */ + /* to :: A pointer to the target point of the `move to'. */ + /* */ + /* user :: A typeless pointer, which is passed from the caller of the */ + /* decomposition function. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + typedef int + (*FT_Outline_MoveToFunc)( const FT_Vector* to, + void* user ); + +#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Outline_LineToFunc */ + /* */ + /* <Description> */ + /* A function pointer type used to describe the signature of a `line */ + /* to' function during outline walking/decomposition. */ + /* */ + /* A `line to' is emitted to indicate a segment in the outline. */ + /* */ + /* <Input> */ + /* to :: A pointer to the target point of the `line to'. */ + /* */ + /* user :: A typeless pointer, which is passed from the caller of the */ + /* decomposition function. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + typedef int + (*FT_Outline_LineToFunc)( const FT_Vector* to, + void* user ); + +#define FT_Outline_LineTo_Func FT_Outline_LineToFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Outline_ConicToFunc */ + /* */ + /* <Description> */ + /* A function pointer type used to describe the signature of a `conic */ + /* to' function during outline walking or decomposition. */ + /* */ + /* A `conic to' is emitted to indicate a second-order Bezier arc in */ + /* the outline. */ + /* */ + /* <Input> */ + /* control :: An intermediate control point between the last position */ + /* and the new target in `to'. */ + /* */ + /* to :: A pointer to the target end point of the conic arc. */ + /* */ + /* user :: A typeless pointer, which is passed from the caller of */ + /* the decomposition function. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + typedef int + (*FT_Outline_ConicToFunc)( const FT_Vector* control, + const FT_Vector* to, + void* user ); + +#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Outline_CubicToFunc */ + /* */ + /* <Description> */ + /* A function pointer type used to describe the signature of a `cubic */ + /* to' function during outline walking or decomposition. */ + /* */ + /* A `cubic to' is emitted to indicate a third-order Bezier arc. */ + /* */ + /* <Input> */ + /* control1 :: A pointer to the first Bezier control point. */ + /* */ + /* control2 :: A pointer to the second Bezier control point. */ + /* */ + /* to :: A pointer to the target end point. */ + /* */ + /* user :: A typeless pointer, which is passed from the caller of */ + /* the decomposition function. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + typedef int + (*FT_Outline_CubicToFunc)( const FT_Vector* control1, + const FT_Vector* control2, + const FT_Vector* to, + void* user ); + +#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Outline_Funcs */ + /* */ + /* <Description> */ + /* A structure to hold various function pointers used during outline */ + /* decomposition in order to emit segments, conic, and cubic Beziers. */ + /* */ + /* <Fields> */ + /* move_to :: The `move to' emitter. */ + /* */ + /* line_to :: The segment emitter. */ + /* */ + /* conic_to :: The second-order Bezier arc emitter. */ + /* */ + /* cubic_to :: The third-order Bezier arc emitter. */ + /* */ + /* shift :: The shift that is applied to coordinates before they */ + /* are sent to the emitter. */ + /* */ + /* delta :: The delta that is applied to coordinates before they */ + /* are sent to the emitter, but after the shift. */ + /* */ + /* <Note> */ + /* The point coordinates sent to the emitters are the transformed */ + /* version of the original coordinates (this is important for high */ + /* accuracy during scan-conversion). The transformation is simple: */ + /* */ + /* { */ + /* x' = (x << shift) - delta */ + /* y' = (y << shift) - delta */ + /* } */ + /* */ + /* Set the values of `shift' and `delta' to~0 to get the original */ + /* point coordinates. */ + /* */ + typedef struct FT_Outline_Funcs_ + { + FT_Outline_MoveToFunc move_to; + FT_Outline_LineToFunc line_to; + FT_Outline_ConicToFunc conic_to; + FT_Outline_CubicToFunc cubic_to; + + int shift; + FT_Pos delta; + + } FT_Outline_Funcs; + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* basic_types */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_IMAGE_TAG */ + /* */ + /* <Description> */ + /* This macro converts four-letter tags to an unsigned long type. */ + /* */ + /* <Note> */ + /* Since many 16-bit compilers don't like 32-bit enumerations, you */ + /* should redefine this macro in case of problems to something like */ + /* this: */ + /* */ + /* { */ + /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */ + /* } */ + /* */ + /* to get a simple enumeration without assigning special numbers. */ + /* */ +#ifndef FT_IMAGE_TAG +#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ + value = ( ( (unsigned long)_x1 << 24 ) | \ + ( (unsigned long)_x2 << 16 ) | \ + ( (unsigned long)_x3 << 8 ) | \ + (unsigned long)_x4 ) +#endif /* FT_IMAGE_TAG */ + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Glyph_Format */ + /* */ + /* <Description> */ + /* An enumeration type used to describe the format of a given glyph */ + /* image. Note that this version of FreeType only supports two image */ + /* formats, even though future font drivers will be able to register */ + /* their own format. */ + /* */ + /* <Values> */ + /* FT_GLYPH_FORMAT_NONE :: */ + /* The value~0 is reserved. */ + /* */ + /* FT_GLYPH_FORMAT_COMPOSITE :: */ + /* The glyph image is a composite of several other images. This */ + /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */ + /* report compound glyphs (like accented characters). */ + /* */ + /* FT_GLYPH_FORMAT_BITMAP :: */ + /* The glyph image is a bitmap, and can be described as an */ + /* @FT_Bitmap. You generally need to access the `bitmap' field of */ + /* the @FT_GlyphSlotRec structure to read it. */ + /* */ + /* FT_GLYPH_FORMAT_OUTLINE :: */ + /* The glyph image is a vectorial outline made of line segments */ + /* and Bezier arcs; it can be described as an @FT_Outline; you */ + /* generally want to access the `outline' field of the */ + /* @FT_GlyphSlotRec structure to read it. */ + /* */ + /* FT_GLYPH_FORMAT_PLOTTER :: */ + /* The glyph image is a vectorial path with no inside and outside */ + /* contours. Some Type~1 fonts, like those in the Hershey family, */ + /* contain glyphs in this format. These are described as */ + /* @FT_Outline, but FreeType isn't currently capable of rendering */ + /* them correctly. */ + /* */ + typedef enum FT_Glyph_Format_ + { + FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), + + FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ) + + } FT_Glyph_Format; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Glyph_Format' values instead. */ +#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE +#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE +#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP +#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE +#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** R A S T E R D E F I N I T I O N S *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* A raster is a scan converter, in charge of rendering an outline into */ + /* a bitmap. This section contains the public API for rasters. */ + /* */ + /* Note that in FreeType 2, all rasters are now encapsulated within */ + /* specific modules called `renderers'. See `ftrender.h' for more */ + /* details on renderers. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* raster */ + /* */ + /* <Title> */ + /* Scanline Converter */ + /* */ + /* <Abstract> */ + /* How vectorial outlines are converted into bitmaps and pixmaps. */ + /* */ + /* <Description> */ + /* This section contains technical definitions. */ + /* */ + /* <Order> */ + /* FT_Raster */ + /* FT_Span */ + /* FT_SpanFunc */ + /* */ + /* FT_Raster_Params */ + /* FT_RASTER_FLAG_XXX */ + /* */ + /* FT_Raster_NewFunc */ + /* FT_Raster_DoneFunc */ + /* FT_Raster_ResetFunc */ + /* FT_Raster_SetModeFunc */ + /* FT_Raster_RenderFunc */ + /* FT_Raster_Funcs */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Raster */ + /* */ + /* <Description> */ + /* An opaque handle (pointer) to a raster object. Each object can be */ + /* used independently to convert an outline into a bitmap or pixmap. */ + /* */ + typedef struct FT_RasterRec_* FT_Raster; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Span */ + /* */ + /* <Description> */ + /* A structure used to model a single span of gray pixels when */ + /* rendering an anti-aliased bitmap. */ + /* */ + /* <Fields> */ + /* x :: The span's horizontal start position. */ + /* */ + /* len :: The span's length in pixels. */ + /* */ + /* coverage :: The span color/coverage, ranging from 0 (background) */ + /* to 255 (foreground). */ + /* */ + /* <Note> */ + /* This structure is used by the span drawing callback type named */ + /* @FT_SpanFunc that takes the y~coordinate of the span as a */ + /* parameter. */ + /* */ + /* The coverage value is always between 0 and 255. If you want less */ + /* gray values, the callback function has to reduce them. */ + /* */ + typedef struct FT_Span_ + { + short x; + unsigned short len; + unsigned char coverage; + + } FT_Span; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_SpanFunc */ + /* */ + /* <Description> */ + /* A function used as a call-back by the anti-aliased renderer in */ + /* order to let client applications draw themselves the gray pixel */ + /* spans on each scan line. */ + /* */ + /* <Input> */ + /* y :: The scanline's y~coordinate. */ + /* */ + /* count :: The number of spans to draw on this scanline. */ + /* */ + /* spans :: A table of `count' spans to draw on the scanline. */ + /* */ + /* user :: User-supplied data that is passed to the callback. */ + /* */ + /* <Note> */ + /* This callback allows client applications to directly render the */ + /* gray spans of the anti-aliased bitmap to any kind of surfaces. */ + /* */ + /* This can be used to write anti-aliased outlines directly to a */ + /* given background bitmap, and even perform translucency. */ + /* */ + typedef void + (*FT_SpanFunc)( int y, + int count, + const FT_Span* spans, + void* user ); + +#define FT_Raster_Span_Func FT_SpanFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_BitTest_Func */ + /* */ + /* <Description> */ + /* Deprecated, unimplemented. */ + /* */ + typedef int + (*FT_Raster_BitTest_Func)( int y, + int x, + void* user ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_BitSet_Func */ + /* */ + /* <Description> */ + /* Deprecated, unimplemented. */ + /* */ + typedef void + (*FT_Raster_BitSet_Func)( int y, + int x, + void* user ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_RASTER_FLAG_XXX */ + /* */ + /* <Description> */ + /* A list of bit flag constants as used in the `flags' field of a */ + /* @FT_Raster_Params structure. */ + /* */ + /* <Values> */ + /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */ + /* */ + /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */ + /* anti-aliased glyph image should be */ + /* generated. Otherwise, it will be */ + /* monochrome (1-bit). */ + /* */ + /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */ + /* rendering. In this mode, client */ + /* applications must provide their own span */ + /* callback. This lets them directly */ + /* draw or compose over an existing bitmap. */ + /* If this bit is not set, the target */ + /* pixmap's buffer _must_ be zeroed before */ + /* rendering. */ + /* */ + /* Direct rendering is only possible with */ + /* anti-aliased glyphs. */ + /* */ + /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ + /* rendering mode. If set, the output will */ + /* be clipped to a box specified in the */ + /* `clip_box' field of the */ + /* @FT_Raster_Params structure. */ + /* */ + /* Note that by default, the glyph bitmap */ + /* is clipped to the target pixmap, except */ + /* in direct rendering mode where all spans */ + /* are generated if no clipping box is set. */ + /* */ +#define FT_RASTER_FLAG_DEFAULT 0x0 +#define FT_RASTER_FLAG_AA 0x1 +#define FT_RASTER_FLAG_DIRECT 0x2 +#define FT_RASTER_FLAG_CLIP 0x4 + + /* these constants are deprecated; use the corresponding */ + /* `FT_RASTER_FLAG_XXX' values instead */ +#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT +#define ft_raster_flag_aa FT_RASTER_FLAG_AA +#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT +#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Raster_Params */ + /* */ + /* <Description> */ + /* A structure to hold the arguments used by a raster's render */ + /* function. */ + /* */ + /* <Fields> */ + /* target :: The target bitmap. */ + /* */ + /* source :: A pointer to the source glyph image (e.g., an */ + /* @FT_Outline). */ + /* */ + /* flags :: The rendering flags. */ + /* */ + /* gray_spans :: The gray span drawing callback. */ + /* */ + /* black_spans :: Unused. */ + /* */ + /* bit_test :: Unused. */ + /* */ + /* bit_set :: Unused. */ + /* */ + /* user :: User-supplied data that is passed to each drawing */ + /* callback. */ + /* */ + /* clip_box :: An optional clipping box. It is only used in */ + /* direct rendering mode. Note that coordinates here */ + /* should be expressed in _integer_ pixels (and not in */ + /* 26.6 fixed-point units). */ + /* */ + /* <Note> */ + /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */ + /* bit flag is set in the `flags' field, otherwise a monochrome */ + /* bitmap is generated. */ + /* */ + /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ + /* raster will call the `gray_spans' callback to draw gray pixel */ + /* spans. This allows direct composition over a pre-existing bitmap */ + /* through user-provided callbacks to perform the span drawing and */ + /* composition. Not supported by the monochrome rasterizer. */ + /* */ + typedef struct FT_Raster_Params_ + { + const FT_Bitmap* target; + const void* source; + int flags; + FT_SpanFunc gray_spans; + FT_SpanFunc black_spans; /* unused */ + FT_Raster_BitTest_Func bit_test; /* unused */ + FT_Raster_BitSet_Func bit_set; /* unused */ + void* user; + FT_BBox clip_box; + + } FT_Raster_Params; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_NewFunc */ + /* */ + /* <Description> */ + /* A function used to create a new raster object. */ + /* */ + /* <Input> */ + /* memory :: A handle to the memory allocator. */ + /* */ + /* <Output> */ + /* raster :: A handle to the new raster object. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + /* <Note> */ + /* The `memory' parameter is a typeless pointer in order to avoid */ + /* un-wanted dependencies on the rest of the FreeType code. In */ + /* practice, it is an @FT_Memory object, i.e., a handle to the */ + /* standard FreeType memory allocator. However, this field can be */ + /* completely ignored by a given raster implementation. */ + /* */ + typedef int + (*FT_Raster_NewFunc)( void* memory, + FT_Raster* raster ); + +#define FT_Raster_New_Func FT_Raster_NewFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_DoneFunc */ + /* */ + /* <Description> */ + /* A function used to destroy a given raster object. */ + /* */ + /* <Input> */ + /* raster :: A handle to the raster object. */ + /* */ + typedef void + (*FT_Raster_DoneFunc)( FT_Raster raster ); + +#define FT_Raster_Done_Func FT_Raster_DoneFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_ResetFunc */ + /* */ + /* <Description> */ + /* FreeType used to provide an area of memory called the `render */ + /* pool' available to all registered rasterizers. This was not */ + /* thread safe, however, and now FreeType never allocates this pool. */ + /* */ + /* This function is called after a new raster object is created. */ + /* */ + /* <Input> */ + /* raster :: A handle to the new raster object. */ + /* */ + /* pool_base :: Previously, the address in memory of the render pool. */ + /* Set this to NULL. */ + /* */ + /* pool_size :: Previously, the size in bytes of the render pool. */ + /* Set this to 0. */ + /* */ + /* <Note> */ + /* Rasterizers should rely on dynamic or stack allocation if they */ + /* want to (a handle to the memory allocator is passed to the */ + /* rasterizer constructor). */ + /* */ + typedef void + (*FT_Raster_ResetFunc)( FT_Raster raster, + unsigned char* pool_base, + unsigned long pool_size ); + +#define FT_Raster_Reset_Func FT_Raster_ResetFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_SetModeFunc */ + /* */ + /* <Description> */ + /* This function is a generic facility to change modes or attributes */ + /* in a given raster. This can be used for debugging purposes, or */ + /* simply to allow implementation-specific `features' in a given */ + /* raster module. */ + /* */ + /* <Input> */ + /* raster :: A handle to the new raster object. */ + /* */ + /* mode :: A 4-byte tag used to name the mode or property. */ + /* */ + /* args :: A pointer to the new mode/property to use. */ + /* */ + typedef int + (*FT_Raster_SetModeFunc)( FT_Raster raster, + unsigned long mode, + void* args ); + +#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Raster_RenderFunc */ + /* */ + /* <Description> */ + /* Invoke a given raster to scan-convert a given glyph image into a */ + /* target bitmap. */ + /* */ + /* <Input> */ + /* raster :: A handle to the raster object. */ + /* */ + /* params :: A pointer to an @FT_Raster_Params structure used to */ + /* store the rendering parameters. */ + /* */ + /* <Return> */ + /* Error code. 0~means success. */ + /* */ + /* <Note> */ + /* The exact format of the source image depends on the raster's glyph */ + /* format defined in its @FT_Raster_Funcs structure. It can be an */ + /* @FT_Outline or anything else in order to support a large array of */ + /* glyph formats. */ + /* */ + /* Note also that the render function can fail and return a */ + /* `FT_Err_Unimplemented_Feature' error code if the raster used does */ + /* not support direct composition. */ + /* */ + /* XXX: For now, the standard raster doesn't support direct */ + /* composition but this should change for the final release (see */ + /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */ + /* for examples of distinct implementations that support direct */ + /* composition). */ + /* */ + typedef int + (*FT_Raster_RenderFunc)( FT_Raster raster, + const FT_Raster_Params* params ); + +#define FT_Raster_Render_Func FT_Raster_RenderFunc + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Raster_Funcs */ + /* */ + /* <Description> */ + /* A structure used to describe a given raster class to the library. */ + /* */ + /* <Fields> */ + /* glyph_format :: The supported glyph format for this raster. */ + /* */ + /* raster_new :: The raster constructor. */ + /* */ + /* raster_reset :: Used to reset the render pool within the raster. */ + /* */ + /* raster_render :: A function to render a glyph into a given bitmap. */ + /* */ + /* raster_done :: The raster destructor. */ + /* */ + typedef struct FT_Raster_Funcs_ + { + FT_Glyph_Format glyph_format; + + FT_Raster_NewFunc raster_new; + FT_Raster_ResetFunc raster_reset; + FT_Raster_SetModeFunc raster_set_mode; + FT_Raster_RenderFunc raster_render; + FT_Raster_DoneFunc raster_done; + + } FT_Raster_Funcs; + + /* */ + + +FT_END_HEADER + +#endif /* FTIMAGE_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftincrem.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftincrem.h new file mode 100644 index 0000000..44619f9 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftincrem.h @@ -0,0 +1,343 @@ +/***************************************************************************/ +/* */ +/* ftincrem.h */ +/* */ +/* FreeType incremental loading (specification). */ +/* */ +/* Copyright 2002-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTINCREM_H_ +#define FTINCREM_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_PARAMETER_TAGS_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************** + * + * @section: + * incremental + * + * @title: + * Incremental Loading + * + * @abstract: + * Custom Glyph Loading. + * + * @description: + * This section contains various functions used to perform so-called + * `incremental' glyph loading. This is a mode where all glyphs loaded + * from a given @FT_Face are provided by the client application. + * + * Apart from that, all other tables are loaded normally from the font + * file. This mode is useful when FreeType is used within another + * engine, e.g., a PostScript Imaging Processor. + * + * To enable this mode, you must use @FT_Open_Face, passing an + * @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an + * @FT_Incremental_Interface value. See the comments for + * @FT_Incremental_InterfaceRec for an example. + * + */ + + + /*************************************************************************** + * + * @type: + * FT_Incremental + * + * @description: + * An opaque type describing a user-provided object used to implement + * `incremental' glyph loading within FreeType. This is used to support + * embedded fonts in certain environments (e.g., PostScript interpreters), + * where the glyph data isn't in the font file, or must be overridden by + * different values. + * + * @note: + * It is up to client applications to create and implement @FT_Incremental + * objects, as long as they provide implementations for the methods + * @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc + * and @FT_Incremental_GetGlyphMetricsFunc. + * + * See the description of @FT_Incremental_InterfaceRec to understand how + * to use incremental objects with FreeType. + * + */ + typedef struct FT_IncrementalRec_* FT_Incremental; + + + /*************************************************************************** + * + * @struct: + * FT_Incremental_MetricsRec + * + * @description: + * A small structure used to contain the basic glyph metrics returned + * by the @FT_Incremental_GetGlyphMetricsFunc method. + * + * @fields: + * bearing_x :: + * Left bearing, in font units. + * + * bearing_y :: + * Top bearing, in font units. + * + * advance :: + * Horizontal component of glyph advance, in font units. + * + * advance_v :: + * Vertical component of glyph advance, in font units. + * + * @note: + * These correspond to horizontal or vertical metrics depending on the + * value of the `vertical' argument to the function + * @FT_Incremental_GetGlyphMetricsFunc. + * + */ + typedef struct FT_Incremental_MetricsRec_ + { + FT_Long bearing_x; + FT_Long bearing_y; + FT_Long advance; + FT_Long advance_v; /* since 2.3.12 */ + + } FT_Incremental_MetricsRec; + + + /*************************************************************************** + * + * @struct: + * FT_Incremental_Metrics + * + * @description: + * A handle to an @FT_Incremental_MetricsRec structure. + * + */ + typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics; + + + /*************************************************************************** + * + * @type: + * FT_Incremental_GetGlyphDataFunc + * + * @description: + * A function called by FreeType to access a given glyph's data bytes + * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is + * enabled. + * + * Note that the format of the glyph's data bytes depends on the font + * file format. For TrueType, it must correspond to the raw bytes within + * the `glyf' table. For PostScript formats, it must correspond to the + * *unencrypted* charstring bytes, without any `lenIV' header. It is + * undefined for any other format. + * + * @input: + * incremental :: + * Handle to an opaque @FT_Incremental handle provided by the client + * application. + * + * glyph_index :: + * Index of relevant glyph. + * + * @output: + * adata :: + * A structure describing the returned glyph data bytes (which will be + * accessed as a read-only byte block). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If this function returns successfully the method + * @FT_Incremental_FreeGlyphDataFunc will be called later to release + * the data bytes. + * + * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for + * compound glyphs. + * + */ + typedef FT_Error + (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental, + FT_UInt glyph_index, + FT_Data* adata ); + + + /*************************************************************************** + * + * @type: + * FT_Incremental_FreeGlyphDataFunc + * + * @description: + * A function used to release the glyph data bytes returned by a + * successful call to @FT_Incremental_GetGlyphDataFunc. + * + * @input: + * incremental :: + * A handle to an opaque @FT_Incremental handle provided by the client + * application. + * + * data :: + * A structure describing the glyph data bytes (which will be accessed + * as a read-only byte block). + * + */ + typedef void + (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental, + FT_Data* data ); + + + /*************************************************************************** + * + * @type: + * FT_Incremental_GetGlyphMetricsFunc + * + * @description: + * A function used to retrieve the basic metrics of a given glyph index + * before accessing its data. This is necessary because, in certain + * formats like TrueType, the metrics are stored in a different place from + * the glyph images proper. + * + * @input: + * incremental :: + * A handle to an opaque @FT_Incremental handle provided by the client + * application. + * + * glyph_index :: + * Index of relevant glyph. + * + * vertical :: + * If true, return vertical metrics. + * + * ametrics :: + * This parameter is used for both input and output. + * The original glyph metrics, if any, in font units. If metrics are + * not available all the values must be set to zero. + * + * @output: + * ametrics :: + * The replacement glyph metrics in font units. + * + */ + typedef FT_Error + (*FT_Incremental_GetGlyphMetricsFunc) + ( FT_Incremental incremental, + FT_UInt glyph_index, + FT_Bool vertical, + FT_Incremental_MetricsRec *ametrics ); + + + /************************************************************************** + * + * @struct: + * FT_Incremental_FuncsRec + * + * @description: + * A table of functions for accessing fonts that load data + * incrementally. Used in @FT_Incremental_InterfaceRec. + * + * @fields: + * get_glyph_data :: + * The function to get glyph data. Must not be null. + * + * free_glyph_data :: + * The function to release glyph data. Must not be null. + * + * get_glyph_metrics :: + * The function to get glyph metrics. May be null if the font does + * not provide overriding glyph metrics. + * + */ + typedef struct FT_Incremental_FuncsRec_ + { + FT_Incremental_GetGlyphDataFunc get_glyph_data; + FT_Incremental_FreeGlyphDataFunc free_glyph_data; + FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics; + + } FT_Incremental_FuncsRec; + + + /*************************************************************************** + * + * @struct: + * FT_Incremental_InterfaceRec + * + * @description: + * A structure to be used with @FT_Open_Face to indicate that the user + * wants to support incremental glyph loading. You should use it with + * @FT_PARAM_TAG_INCREMENTAL as in the following example: + * + * { + * FT_Incremental_InterfaceRec inc_int; + * FT_Parameter parameter; + * FT_Open_Args open_args; + * + * + * // set up incremental descriptor + * inc_int.funcs = my_funcs; + * inc_int.object = my_object; + * + * // set up optional parameter + * parameter.tag = FT_PARAM_TAG_INCREMENTAL; + * parameter.data = &inc_int; + * + * // set up FT_Open_Args structure + * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; + * open_args.pathname = my_font_pathname; + * open_args.num_params = 1; + * open_args.params = ¶meter; // we use one optional argument + * + * // open the font + * error = FT_Open_Face( library, &open_args, index, &face ); + * ... + * } + * + */ + typedef struct FT_Incremental_InterfaceRec_ + { + const FT_Incremental_FuncsRec* funcs; + FT_Incremental object; + + } FT_Incremental_InterfaceRec; + + + /*************************************************************************** + * + * @type: + * FT_Incremental_Interface + * + * @description: + * A pointer to an @FT_Incremental_InterfaceRec structure. + * + */ + typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface; + + + /* */ + + +FT_END_HEADER + +#endif /* FTINCREM_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftlcdfil.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftlcdfil.h new file mode 100644 index 0000000..2a27196 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftlcdfil.h @@ -0,0 +1,309 @@ +/***************************************************************************/ +/* */ +/* ftlcdfil.h */ +/* */ +/* FreeType API for color filtering of subpixel bitmap glyphs */ +/* (specification). */ +/* */ +/* Copyright 2006-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTLCDFIL_H_ +#define FTLCDFIL_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_PARAMETER_TAGS_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************** + * + * @section: + * lcd_filtering + * + * @title: + * LCD Filtering + * + * @abstract: + * Reduce color fringes of subpixel-rendered bitmaps. + * + * @description: + * Should you #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your + * `ftoption.h', which enables patented ClearType-style rendering, + * the LCD-optimized glyph bitmaps should be filtered to reduce color + * fringes inherent to this technology. The default FreeType LCD + * rendering uses different technology, and API described below, + * although available, does nothing. + * + * ClearType-style LCD rendering exploits the color-striped structure of + * LCD pixels, increasing the available resolution in the direction of + * the stripe (usually horizontal RGB) by a factor of~3. Since these + * subpixels are color pixels, using them unfiltered creates severe + * color fringes. Use the @FT_Library_SetLcdFilter API to specify a + * low-pass filter, which is then applied to subpixel-rendered bitmaps + * generated through @FT_Render_Glyph. The filter sacrifices some of + * the higher resolution to reduce color fringes, making the glyph image + * slightly blurrier. Positional improvements will remain. + * + * A filter should have two properties: + * + * 1) It should be normalized, meaning the sum of the 5~components + * should be 256 (0x100). It is possible to go above or under this + * target sum, however: going under means tossing out contrast, going + * over means invoking clamping and thereby non-linearities that + * increase contrast somewhat at the expense of greater distortion + * and color-fringing. Contrast is better enhanced through stem + * darkening. + * + * 2) It should be color-balanced, meaning a filter `{~a, b, c, b, a~}' + * where a~+ b~=~c. It distributes the computed coverage for one + * subpixel to all subpixels equally, sacrificing some won resolution + * but drastically reducing color-fringing. Positioning improvements + * remain! Note that color-fringing can only really be minimized + * when using a color-balanced filter and alpha-blending the glyph + * onto a surface in linear space; see @FT_Render_Glyph. + * + * Regarding the form, a filter can be a `boxy' filter or a `beveled' + * filter. Boxy filters are sharper but are less forgiving of non-ideal + * gamma curves of a screen (viewing angles!), beveled filters are + * fuzzier but more tolerant. + * + * Examples: + * + * - [0x10 0x40 0x70 0x40 0x10] is beveled and neither balanced nor + * normalized. + * + * - [0x1A 0x33 0x4D 0x33 0x1A] is beveled and balanced but not + * normalized. + * + * - [0x19 0x33 0x66 0x4c 0x19] is beveled and normalized but not + * balanced. + * + * - [0x00 0x4c 0x66 0x4c 0x00] is boxily beveled and normalized but not + * balanced. + * + * - [0x00 0x55 0x56 0x55 0x00] is boxy, normalized, and almost + * balanced. + * + * - [0x08 0x4D 0x56 0x4D 0x08] is beveled, normalized and, almost + * balanced. + * + * The filter affects glyph bitmaps rendered through @FT_Render_Glyph, + * @FT_Load_Glyph, and @FT_Load_Char. It does _not_ affect the output + * of @FT_Outline_Render and @FT_Outline_Get_Bitmap. + * + * If this feature is activated, the dimensions of LCD glyph bitmaps are + * either wider or taller than the dimensions of the corresponding + * outline with regard to the pixel grid. For example, for + * @FT_RENDER_MODE_LCD, the filter adds 3~subpixels to the left, and + * 3~subpixels to the right. The bitmap offset values are adjusted + * accordingly, so clients shouldn't need to modify their layout and + * glyph positioning code when enabling the filter. + * + * It is important to understand that linear alpha blending and gamma + * correction is critical for correctly rendering glyphs onto surfaces + * without artifacts and even more critical when subpixel rendering is + * involved. + * + * Each of the 3~alpha values (subpixels) is independently used to blend + * one color channel. That is, red alpha blends the red channel of the + * text color with the red channel of the background pixel. The + * distribution of density values by the color-balanced filter assumes + * alpha blending is done in linear space; only then color artifacts + * cancel out. + */ + + + /**************************************************************************** + * + * @enum: + * FT_LcdFilter + * + * @description: + * A list of values to identify various types of LCD filters. + * + * @values: + * FT_LCD_FILTER_NONE :: + * Do not perform filtering. When used with subpixel rendering, this + * results in sometimes severe color fringes. + * + * FT_LCD_FILTER_DEFAULT :: + * The default filter reduces color fringes considerably, at the cost + * of a slight blurriness in the output. + * + * It is a beveled, normalized, and color-balanced five-tap filter + * that is more forgiving to screens with non-ideal gamma curves and + * viewing angles. Note that while color-fringing is reduced, it can + * only be minimized by using linear alpha blending and gamma + * correction to render glyphs onto surfaces. The default filter + * weights are [0x08 0x4D 0x56 0x4D 0x08]. + * + * FT_LCD_FILTER_LIGHT :: + * The light filter is a variant that is sharper at the cost of + * slightly more color fringes than the default one. + * + * It is a boxy, normalized, and color-balanced three-tap filter that + * is less forgiving to screens with non-ideal gamma curves and + * viewing angles. This filter works best when the rendering system + * uses linear alpha blending and gamma correction to render glyphs + * onto surfaces. The light filter weights are + * [0x00 0x55 0x56 0x55 0x00]. + * + * FT_LCD_FILTER_LEGACY :: + * This filter corresponds to the original libXft color filter. It + * provides high contrast output but can exhibit really bad color + * fringes if glyphs are not extremely well hinted to the pixel grid. + * In other words, it only works well if the TrueType bytecode + * interpreter is enabled *and* high-quality hinted fonts are used. + * + * This filter is only provided for comparison purposes, and might be + * disabled or stay unsupported in the future. + * + * FT_LCD_FILTER_LEGACY1 :: + * For historical reasons, the FontConfig library returns a different + * enumeration value for legacy LCD filtering. To make code work that + * (incorrectly) forwards FontConfig's enumeration value to + * @FT_Library_SetLcdFilter without proper mapping, it is thus easiest + * to have another enumeration value, which is completely equal to + * `FT_LCD_FILTER_LEGACY'. + * + * @since: + * 2.3.0 (`FT_LCD_FILTER_LEGACY1' since 2.6.2) + */ + typedef enum FT_LcdFilter_ + { + FT_LCD_FILTER_NONE = 0, + FT_LCD_FILTER_DEFAULT = 1, + FT_LCD_FILTER_LIGHT = 2, + FT_LCD_FILTER_LEGACY1 = 3, + FT_LCD_FILTER_LEGACY = 16, + + FT_LCD_FILTER_MAX /* do not remove */ + + } FT_LcdFilter; + + + /************************************************************************** + * + * @func: + * FT_Library_SetLcdFilter + * + * @description: + * This function is used to apply color filtering to LCD decimated + * bitmaps, like the ones used when calling @FT_Render_Glyph with + * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V. + * + * @input: + * library :: + * A handle to the target library instance. + * + * filter :: + * The filter type. + * + * You can use @FT_LCD_FILTER_NONE here to disable this feature, or + * @FT_LCD_FILTER_DEFAULT to use a default filter that should work + * well on most LCD screens. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This feature is always disabled by default. Clients must make an + * explicit call to this function with a `filter' value other than + * @FT_LCD_FILTER_NONE in order to enable it. + * + * Due to *PATENTS* covering subpixel rendering, this function doesn't + * do anything except returning `FT_Err_Unimplemented_Feature' if the + * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not + * defined in your build of the library, which should correspond to all + * default builds of FreeType. + * + * @since: + * 2.3.0 + */ + FT_EXPORT( FT_Error ) + FT_Library_SetLcdFilter( FT_Library library, + FT_LcdFilter filter ); + + + /************************************************************************** + * + * @func: + * FT_Library_SetLcdFilterWeights + * + * @description: + * This function can be used to enable LCD filter with custom weights, + * instead of using presets in @FT_Library_SetLcdFilter. + * + * @input: + * library :: + * A handle to the target library instance. + * + * weights :: + * A pointer to an array; the function copies the first five bytes and + * uses them to specify the filter weights. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Due to *PATENTS* covering subpixel rendering, this function doesn't + * do anything except returning `FT_Err_Unimplemented_Feature' if the + * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not + * defined in your build of the library, which should correspond to all + * default builds of FreeType. + * + * LCD filter weights can also be set per face using @FT_Face_Properties + * with @FT_PARAM_TAG_LCD_FILTER_WEIGHTS. + * + * @since: + * 2.4.0 + */ + FT_EXPORT( FT_Error ) + FT_Library_SetLcdFilterWeights( FT_Library library, + unsigned char *weights ); + + + /* + * @type: + * FT_LcdFiveTapFilter + * + * @description: + * A typedef for passing the five LCD filter weights to + * @FT_Face_Properties within an @FT_Parameter structure. + * + * @since: + * 2.8 + * + */ +#define FT_LCD_FILTER_FIVE_TAPS 5 + + typedef FT_Byte FT_LcdFiveTapFilter[FT_LCD_FILTER_FIVE_TAPS]; + + + /* */ + + +FT_END_HEADER + +#endif /* FTLCDFIL_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftlist.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftlist.h new file mode 100644 index 0000000..117473b --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftlist.h @@ -0,0 +1,276 @@ +/***************************************************************************/ +/* */ +/* ftlist.h */ +/* */ +/* Generic list support for FreeType (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file implements functions relative to list processing. Its */ + /* data structures are defined in `freetype.h'. */ + /* */ + /*************************************************************************/ + + +#ifndef FTLIST_H_ +#define FTLIST_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* list_processing */ + /* */ + /* <Title> */ + /* List Processing */ + /* */ + /* <Abstract> */ + /* Simple management of lists. */ + /* */ + /* <Description> */ + /* This section contains various definitions related to list */ + /* processing using doubly-linked nodes. */ + /* */ + /* <Order> */ + /* FT_List */ + /* FT_ListNode */ + /* FT_ListRec */ + /* FT_ListNodeRec */ + /* */ + /* FT_List_Add */ + /* FT_List_Insert */ + /* FT_List_Find */ + /* FT_List_Remove */ + /* FT_List_Up */ + /* FT_List_Iterate */ + /* FT_List_Iterator */ + /* FT_List_Finalize */ + /* FT_List_Destructor */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Find */ + /* */ + /* <Description> */ + /* Find the list node for a given listed object. */ + /* */ + /* <Input> */ + /* list :: A pointer to the parent list. */ + /* data :: The address of the listed object. */ + /* */ + /* <Return> */ + /* List node. NULL if it wasn't found. */ + /* */ + FT_EXPORT( FT_ListNode ) + FT_List_Find( FT_List list, + void* data ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Add */ + /* */ + /* <Description> */ + /* Append an element to the end of a list. */ + /* */ + /* <InOut> */ + /* list :: A pointer to the parent list. */ + /* node :: The node to append. */ + /* */ + FT_EXPORT( void ) + FT_List_Add( FT_List list, + FT_ListNode node ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Insert */ + /* */ + /* <Description> */ + /* Insert an element at the head of a list. */ + /* */ + /* <InOut> */ + /* list :: A pointer to parent list. */ + /* node :: The node to insert. */ + /* */ + FT_EXPORT( void ) + FT_List_Insert( FT_List list, + FT_ListNode node ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Remove */ + /* */ + /* <Description> */ + /* Remove a node from a list. This function doesn't check whether */ + /* the node is in the list! */ + /* */ + /* <Input> */ + /* node :: The node to remove. */ + /* */ + /* <InOut> */ + /* list :: A pointer to the parent list. */ + /* */ + FT_EXPORT( void ) + FT_List_Remove( FT_List list, + FT_ListNode node ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Up */ + /* */ + /* <Description> */ + /* Move a node to the head/top of a list. Used to maintain LRU */ + /* lists. */ + /* */ + /* <InOut> */ + /* list :: A pointer to the parent list. */ + /* node :: The node to move. */ + /* */ + FT_EXPORT( void ) + FT_List_Up( FT_List list, + FT_ListNode node ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_List_Iterator */ + /* */ + /* <Description> */ + /* An FT_List iterator function that is called during a list parse */ + /* by @FT_List_Iterate. */ + /* */ + /* <Input> */ + /* node :: The current iteration list node. */ + /* */ + /* user :: A typeless pointer passed to @FT_List_Iterate. */ + /* Can be used to point to the iteration's state. */ + /* */ + typedef FT_Error + (*FT_List_Iterator)( FT_ListNode node, + void* user ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Iterate */ + /* */ + /* <Description> */ + /* Parse a list and calls a given iterator function on each element. */ + /* Note that parsing is stopped as soon as one of the iterator calls */ + /* returns a non-zero value. */ + /* */ + /* <Input> */ + /* list :: A handle to the list. */ + /* iterator :: An iterator function, called on each node of the list. */ + /* user :: A user-supplied field that is passed as the second */ + /* argument to the iterator. */ + /* */ + /* <Return> */ + /* The result (a FreeType error code) of the last iterator call. */ + /* */ + FT_EXPORT( FT_Error ) + FT_List_Iterate( FT_List list, + FT_List_Iterator iterator, + void* user ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_List_Destructor */ + /* */ + /* <Description> */ + /* An @FT_List iterator function that is called during a list */ + /* finalization by @FT_List_Finalize to destroy all elements in a */ + /* given list. */ + /* */ + /* <Input> */ + /* system :: The current system object. */ + /* */ + /* data :: The current object to destroy. */ + /* */ + /* user :: A typeless pointer passed to @FT_List_Iterate. It can */ + /* be used to point to the iteration's state. */ + /* */ + typedef void + (*FT_List_Destructor)( FT_Memory memory, + void* data, + void* user ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_List_Finalize */ + /* */ + /* <Description> */ + /* Destroy all elements in the list as well as the list itself. */ + /* */ + /* <Input> */ + /* list :: A handle to the list. */ + /* */ + /* destroy :: A list destructor that will be applied to each element */ + /* of the list. Set this to NULL if not needed. */ + /* */ + /* memory :: The current memory object that handles deallocation. */ + /* */ + /* user :: A user-supplied field that is passed as the last */ + /* argument to the destructor. */ + /* */ + /* <Note> */ + /* This function expects that all nodes added by @FT_List_Add or */ + /* @FT_List_Insert have been dynamically allocated. */ + /* */ + FT_EXPORT( void ) + FT_List_Finalize( FT_List list, + FT_List_Destructor destroy, + FT_Memory memory, + void* user ); + + /* */ + + +FT_END_HEADER + +#endif /* FTLIST_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftlzw.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftlzw.h new file mode 100644 index 0000000..1615912 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftlzw.h @@ -0,0 +1,99 @@ +/***************************************************************************/ +/* */ +/* ftlzw.h */ +/* */ +/* LZW-compressed stream support. */ +/* */ +/* Copyright 2004-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTLZW_H_ +#define FTLZW_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* <Section> */ + /* lzw */ + /* */ + /* <Title> */ + /* LZW Streams */ + /* */ + /* <Abstract> */ + /* Using LZW-compressed font files. */ + /* */ + /* <Description> */ + /* This section contains the declaration of LZW-specific functions. */ + /* */ + /*************************************************************************/ + + /************************************************************************ + * + * @function: + * FT_Stream_OpenLZW + * + * @description: + * Open a new stream to parse LZW-compressed font files. This is + * mainly used to support the compressed `*.pcf.Z' fonts that come + * with XFree86. + * + * @input: + * stream :: The target embedding stream. + * + * source :: The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close' on the new stream will + * *not* call `FT_Stream_Close' on the source stream. None of the stream + * objects will be released to the heap. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream + * + * In certain builds of the library, LZW compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a LZW stream from it + * and re-open the face with it. + * + * This function may return `FT_Err_Unimplemented_Feature' if your build + * of FreeType was not compiled with LZW support. + */ + FT_EXPORT( FT_Error ) + FT_Stream_OpenLZW( FT_Stream stream, + FT_Stream source ); + + /* */ + + +FT_END_HEADER + +#endif /* FTLZW_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftmac.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftmac.h new file mode 100644 index 0000000..c1e497c --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftmac.h @@ -0,0 +1,275 @@ +/***************************************************************************/ +/* */ +/* ftmac.h */ +/* */ +/* Additional Mac-specific API. */ +/* */ +/* Copyright 1996-2018 by */ +/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* NOTE: Include this file after FT_FREETYPE_H and after any */ +/* Mac-specific headers (because this header uses Mac types such as */ +/* Handle, FSSpec, FSRef, etc.) */ +/* */ +/***************************************************************************/ + + +#ifndef FTMAC_H_ +#define FTMAC_H_ + + +#include <ft2build.h> + + +FT_BEGIN_HEADER + + + /* gcc-3.1 and later can warn about functions tagged as deprecated */ +#ifndef FT_DEPRECATED_ATTRIBUTE +#if defined( __GNUC__ ) && \ + ( ( __GNUC__ >= 4 ) || \ + ( ( __GNUC__ == 3 ) && ( __GNUC_MINOR__ >= 1 ) ) ) +#define FT_DEPRECATED_ATTRIBUTE __attribute__(( deprecated )) +#else +#define FT_DEPRECATED_ATTRIBUTE +#endif +#endif + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* mac_specific */ + /* */ + /* <Title> */ + /* Mac Specific Interface */ + /* */ + /* <Abstract> */ + /* Only available on the Macintosh. */ + /* */ + /* <Description> */ + /* The following definitions are only available if FreeType is */ + /* compiled on a Macintosh. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Face_From_FOND */ + /* */ + /* <Description> */ + /* Create a new face object from a FOND resource. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* fond :: A FOND resource. */ + /* */ + /* face_index :: Only supported for the -1 `sanity check' special */ + /* case. */ + /* */ + /* <Output> */ + /* aface :: A handle to a new face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Notes> */ + /* This function can be used to create @FT_Face objects from fonts */ + /* that are installed in the system as follows. */ + /* */ + /* { */ + /* fond = GetResource( 'FOND', fontName ); */ + /* error = FT_New_Face_From_FOND( library, fond, 0, &face ); */ + /* } */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Face_From_FOND( FT_Library library, + Handle fond, + FT_Long face_index, + FT_Face *aface ) + FT_DEPRECATED_ATTRIBUTE; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_GetFile_From_Mac_Name */ + /* */ + /* <Description> */ + /* Return an FSSpec for the disk file containing the named font. */ + /* */ + /* <Input> */ + /* fontName :: Mac OS name of the font (e.g., Times New Roman */ + /* Bold). */ + /* */ + /* <Output> */ + /* pathSpec :: FSSpec to the file. For passing to */ + /* @FT_New_Face_From_FSSpec. */ + /* */ + /* face_index :: Index of the face. For passing to */ + /* @FT_New_Face_From_FSSpec. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_GetFile_From_Mac_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ) + FT_DEPRECATED_ATTRIBUTE; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_GetFile_From_Mac_ATS_Name */ + /* */ + /* <Description> */ + /* Return an FSSpec for the disk file containing the named font. */ + /* */ + /* <Input> */ + /* fontName :: Mac OS name of the font in ATS framework. */ + /* */ + /* <Output> */ + /* pathSpec :: FSSpec to the file. For passing to */ + /* @FT_New_Face_From_FSSpec. */ + /* */ + /* face_index :: Index of the face. For passing to */ + /* @FT_New_Face_From_FSSpec. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_GetFile_From_Mac_ATS_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ) + FT_DEPRECATED_ATTRIBUTE; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_GetFilePath_From_Mac_ATS_Name */ + /* */ + /* <Description> */ + /* Return a pathname of the disk file and face index for given font */ + /* name that is handled by ATS framework. */ + /* */ + /* <Input> */ + /* fontName :: Mac OS name of the font in ATS framework. */ + /* */ + /* <Output> */ + /* path :: Buffer to store pathname of the file. For passing */ + /* to @FT_New_Face. The client must allocate this */ + /* buffer before calling this function. */ + /* */ + /* maxPathSize :: Lengths of the buffer `path' that client allocated. */ + /* */ + /* face_index :: Index of the face. For passing to @FT_New_Face. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_GetFilePath_From_Mac_ATS_Name( const char* fontName, + UInt8* path, + UInt32 maxPathSize, + FT_Long* face_index ) + FT_DEPRECATED_ATTRIBUTE; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Face_From_FSSpec */ + /* */ + /* <Description> */ + /* Create a new face object from a given resource and typeface index */ + /* using an FSSpec to the font file. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* spec :: FSSpec to the font file. */ + /* */ + /* face_index :: The index of the face within the resource. The */ + /* first face has index~0. */ + /* <Output> */ + /* aface :: A handle to a new face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* @FT_New_Face_From_FSSpec is identical to @FT_New_Face except */ + /* it accepts an FSSpec instead of a path. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Face_From_FSSpec( FT_Library library, + const FSSpec *spec, + FT_Long face_index, + FT_Face *aface ) + FT_DEPRECATED_ATTRIBUTE; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Face_From_FSRef */ + /* */ + /* <Description> */ + /* Create a new face object from a given resource and typeface index */ + /* using an FSRef to the font file. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library resource. */ + /* */ + /* <Input> */ + /* spec :: FSRef to the font file. */ + /* */ + /* face_index :: The index of the face within the resource. The */ + /* first face has index~0. */ + /* <Output> */ + /* aface :: A handle to a new face object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */ + /* it accepts an FSRef instead of a path. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Face_From_FSRef( FT_Library library, + const FSRef *ref, + FT_Long face_index, + FT_Face *aface ) + FT_DEPRECATED_ATTRIBUTE; + + /* */ + + +FT_END_HEADER + + +#endif /* FTMAC_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftmm.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftmm.h new file mode 100644 index 0000000..9948102 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftmm.h @@ -0,0 +1,638 @@ +/***************************************************************************/ +/* */ +/* ftmm.h */ +/* */ +/* FreeType Multiple Master font interface (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTMM_H_ +#define FTMM_H_ + + +#include <ft2build.h> +#include FT_TYPE1_TABLES_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* multiple_masters */ + /* */ + /* <Title> */ + /* Multiple Masters */ + /* */ + /* <Abstract> */ + /* How to manage Multiple Masters fonts. */ + /* */ + /* <Description> */ + /* The following types and functions are used to manage Multiple */ + /* Master fonts, i.e., the selection of specific design instances by */ + /* setting design axis coordinates. */ + /* */ + /* Besides Adobe MM fonts, the interface supports Apple's TrueType GX */ + /* and OpenType variation fonts. Some of the routines only work with */ + /* Adobe MM fonts, others will work with all three types. They are */ + /* similar enough that a consistent interface makes sense. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_MM_Axis */ + /* */ + /* <Description> */ + /* A structure to model a given axis in design space for Multiple */ + /* Masters fonts. */ + /* */ + /* This structure can't be used for TrueType GX or OpenType variation */ + /* fonts. */ + /* */ + /* <Fields> */ + /* name :: The axis's name. */ + /* */ + /* minimum :: The axis's minimum design coordinate. */ + /* */ + /* maximum :: The axis's maximum design coordinate. */ + /* */ + typedef struct FT_MM_Axis_ + { + FT_String* name; + FT_Long minimum; + FT_Long maximum; + + } FT_MM_Axis; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Multi_Master */ + /* */ + /* <Description> */ + /* A structure to model the axes and space of a Multiple Masters */ + /* font. */ + /* */ + /* This structure can't be used for TrueType GX or OpenType variation */ + /* fonts. */ + /* */ + /* <Fields> */ + /* num_axis :: Number of axes. Cannot exceed~4. */ + /* */ + /* num_designs :: Number of designs; should be normally 2^num_axis */ + /* even though the Type~1 specification strangely */ + /* allows for intermediate designs to be present. */ + /* This number cannot exceed~16. */ + /* */ + /* axis :: A table of axis descriptors. */ + /* */ + typedef struct FT_Multi_Master_ + { + FT_UInt num_axis; + FT_UInt num_designs; + FT_MM_Axis axis[T1_MAX_MM_AXIS]; + + } FT_Multi_Master; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Var_Axis */ + /* */ + /* <Description> */ + /* A structure to model a given axis in design space for Multiple */ + /* Masters, TrueType GX, and OpenType variation fonts. */ + /* */ + /* <Fields> */ + /* name :: The axis's name. */ + /* Not always meaningful for TrueType GX or OpenType */ + /* variation fonts. */ + /* */ + /* minimum :: The axis's minimum design coordinate. */ + /* */ + /* def :: The axis's default design coordinate. */ + /* FreeType computes meaningful default values for Adobe */ + /* MM fonts. */ + /* */ + /* maximum :: The axis's maximum design coordinate. */ + /* */ + /* tag :: The axis's tag (the equivalent to `name' for TrueType */ + /* GX and OpenType variation fonts). FreeType provides */ + /* default values for Adobe MM fonts if possible. */ + /* */ + /* strid :: The axis name entry in the font's `name' table. This */ + /* is another (and often better) version of the `name' */ + /* field for TrueType GX or OpenType variation fonts. Not */ + /* meaningful for Adobe MM fonts. */ + /* */ + /* <Note> */ + /* The fields `minimum', `def', and `maximum' are 16.16 fractional */ + /* values for TrueType GX and OpenType variation fonts. For Adobe MM */ + /* fonts, the values are integers. */ + /* */ + typedef struct FT_Var_Axis_ + { + FT_String* name; + + FT_Fixed minimum; + FT_Fixed def; + FT_Fixed maximum; + + FT_ULong tag; + FT_UInt strid; + + } FT_Var_Axis; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Var_Named_Style */ + /* */ + /* <Description> */ + /* A structure to model a named instance in a TrueType GX or OpenType */ + /* variation font. */ + /* */ + /* This structure can't be used for Adobe MM fonts. */ + /* */ + /* <Fields> */ + /* coords :: The design coordinates for this instance. */ + /* This is an array with one entry for each axis. */ + /* */ + /* strid :: The entry in `name' table identifying this instance. */ + /* */ + /* psid :: The entry in `name' table identifying a PostScript name */ + /* for this instance. Value 0xFFFF indicates a missing */ + /* entry. */ + /* */ + typedef struct FT_Var_Named_Style_ + { + FT_Fixed* coords; + FT_UInt strid; + FT_UInt psid; /* since 2.7.1 */ + + } FT_Var_Named_Style; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_MM_Var */ + /* */ + /* <Description> */ + /* A structure to model the axes and space of an Adobe MM, TrueType */ + /* GX, or OpenType variation font. */ + /* */ + /* Some fields are specific to one format and not to the others. */ + /* */ + /* <Fields> */ + /* num_axis :: The number of axes. The maximum value is~4 for */ + /* Adobe MM fonts; no limit in TrueType GX or */ + /* OpenType variation fonts. */ + /* */ + /* num_designs :: The number of designs; should be normally */ + /* 2^num_axis for Adobe MM fonts. Not meaningful */ + /* for TrueType GX or OpenType variation fonts */ + /* (where every glyph could have a different */ + /* number of designs). */ + /* */ + /* num_namedstyles :: The number of named styles; a `named style' is */ + /* a tuple of design coordinates that has a string */ + /* ID (in the `name' table) associated with it. */ + /* The font can tell the user that, for example, */ + /* [Weight=1.5,Width=1.1] is `Bold'. Another name */ + /* for `named style' is `named instance'. */ + /* */ + /* For Adobe Multiple Masters fonts, this value is */ + /* always zero because the format does not support */ + /* named styles. */ + /* */ + /* axis :: An axis descriptor table. */ + /* TrueType GX and OpenType variation fonts */ + /* contain slightly more data than Adobe MM fonts. */ + /* Memory management of this pointer is done */ + /* internally by FreeType. */ + /* */ + /* namedstyle :: A named style (instance) table. */ + /* Only meaningful for TrueType GX and OpenType */ + /* variation fonts. Memory management of this */ + /* pointer is done internally by FreeType. */ + /* */ + typedef struct FT_MM_Var_ + { + FT_UInt num_axis; + FT_UInt num_designs; + FT_UInt num_namedstyles; + FT_Var_Axis* axis; + FT_Var_Named_Style* namedstyle; + + } FT_MM_Var; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Multi_Master */ + /* */ + /* <Description> */ + /* Retrieve a variation descriptor of a given Adobe MM font. */ + /* */ + /* This function can't be used with TrueType GX or OpenType variation */ + /* fonts. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* <Output> */ + /* amaster :: The Multiple Masters descriptor. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Multi_Master( FT_Face face, + FT_Multi_Master *amaster ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_MM_Var */ + /* */ + /* <Description> */ + /* Retrieve a variation descriptor for a given font. */ + /* */ + /* This function works with all supported variation formats. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* <Output> */ + /* amaster :: The variation descriptor. */ + /* Allocates a data structure, which the user must */ + /* deallocate with a call to @FT_Done_MM_Var after use. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_MM_Var( FT_Face face, + FT_MM_Var* *amaster ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_MM_Var */ + /* */ + /* <Description> */ + /* Free the memory allocated by @FT_Get_MM_Var. */ + /* */ + /* <Input> */ + /* library :: A handle of the face's parent library object that was */ + /* used in the call to @FT_Get_MM_Var to create `amaster'. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Done_MM_Var( FT_Library library, + FT_MM_Var *amaster ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_MM_Design_Coordinates */ + /* */ + /* <Description> */ + /* For Adobe MM fonts, choose an interpolated font design through */ + /* design coordinates. */ + /* */ + /* This function can't be used with TrueType GX or OpenType variation */ + /* fonts. */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face. */ + /* */ + /* <Input> */ + /* num_coords :: The number of available design coordinates. If it */ + /* is larger than the number of axes, ignore the excess */ + /* values. If it is smaller than the number of axes, */ + /* use default values for the remaining axes. */ + /* */ + /* coords :: An array of design coordinates. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* [Since 2.8.1] To reset all axes to the default values, call the */ + /* function with `num_coords' set to zero and `coords' set to NULL. */ + /* */ + /* [Since 2.9] If `num_coords' is larger than zero, this function */ + /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */ + /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */ + /* is zero, this bit flag gets unset. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_MM_Design_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Long* coords ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Var_Design_Coordinates */ + /* */ + /* <Description> */ + /* Choose an interpolated font design through design coordinates. */ + /* */ + /* This function works with all supported variation formats. */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face. */ + /* */ + /* <Input> */ + /* num_coords :: The number of available design coordinates. If it */ + /* is larger than the number of axes, ignore the excess */ + /* values. If it is smaller than the number of axes, */ + /* use default values for the remaining axes. */ + /* */ + /* coords :: An array of design coordinates. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* [Since 2.8.1] To reset all axes to the default values, call the */ + /* function with `num_coords' set to zero and `coords' set to NULL. */ + /* [Since 2.9] `Default values' means the currently selected named */ + /* instance (or the base font if no named instance is selected). */ + /* */ + /* [Since 2.9] If `num_coords' is larger than zero, this function */ + /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */ + /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */ + /* is zero, this bit flag gets unset. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Var_Design_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Var_Design_Coordinates */ + /* */ + /* <Description> */ + /* Get the design coordinates of the currently selected interpolated */ + /* font. */ + /* */ + /* This function works with all supported variation formats. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* num_coords :: The number of design coordinates to retrieve. If it */ + /* is larger than the number of axes, set the excess */ + /* values to~0. */ + /* */ + /* <Output> */ + /* coords :: The design coordinates array. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Since> */ + /* 2.7.1 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Var_Design_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_MM_Blend_Coordinates */ + /* */ + /* <Description> */ + /* Choose an interpolated font design through normalized blend */ + /* coordinates. */ + /* */ + /* This function works with all supported variation formats. */ + /* */ + /* <InOut> */ + /* face :: A handle to the source face. */ + /* */ + /* <Input> */ + /* num_coords :: The number of available design coordinates. If it */ + /* is larger than the number of axes, ignore the excess */ + /* values. If it is smaller than the number of axes, */ + /* use default values for the remaining axes. */ + /* */ + /* coords :: The design coordinates array (each element must be */ + /* between 0 and 1.0 for Adobe MM fonts, and between */ + /* -1.0 and 1.0 for TrueType GX and OpenType variation */ + /* fonts). */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* [Since 2.8.1] To reset all axes to the default values, call the */ + /* function with `num_coords' set to zero and `coords' set to NULL. */ + /* [Since 2.9] `Default values' means the currently selected named */ + /* instance (or the base font if no named instance is selected). */ + /* */ + /* [Since 2.9] If `num_coords' is larger than zero, this function */ + /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */ + /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */ + /* is zero, this bit flag gets unset. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_MM_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_MM_Blend_Coordinates */ + /* */ + /* <Description> */ + /* Get the normalized blend coordinates of the currently selected */ + /* interpolated font. */ + /* */ + /* This function works with all supported variation formats. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* num_coords :: The number of normalized blend coordinates to */ + /* retrieve. If it is larger than the number of axes, */ + /* set the excess values to~0.5 for Adobe MM fonts, and */ + /* to~0 for TrueType GX and OpenType variation fonts. */ + /* */ + /* <Output> */ + /* coords :: The normalized blend coordinates array. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Since> */ + /* 2.7.1 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_MM_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Var_Blend_Coordinates */ + /* */ + /* <Description> */ + /* This is another name of @FT_Set_MM_Blend_Coordinates. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Var_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Var_Blend_Coordinates */ + /* */ + /* <Description> */ + /* This is another name of @FT_Get_MM_Blend_Coordinates. */ + /* */ + /* <Since> */ + /* 2.7.1 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Var_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_VAR_AXIS_FLAG_XXX */ + /* */ + /* <Description> */ + /* A list of bit flags used in the return value of */ + /* @FT_Get_Var_Axis_Flags. */ + /* */ + /* <Values> */ + /* FT_VAR_AXIS_FLAG_HIDDEN :: */ + /* The variation axis should not be exposed to user interfaces. */ + /* */ + /* <Since> */ + /* 2.8.1 */ + /* */ +#define FT_VAR_AXIS_FLAG_HIDDEN 1 + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Var_Axis_Flags */ + /* */ + /* <Description> */ + /* Get the `flags' field of an OpenType Variation Axis Record. */ + /* */ + /* Not meaningful for Adobe MM fonts (`*flags' is always zero). */ + /* */ + /* <Input> */ + /* master :: The variation descriptor. */ + /* */ + /* axis_index :: The index of the requested variation axis. */ + /* */ + /* <Output> */ + /* flags :: The `flags' field. See @FT_VAR_AXIS_FLAG_XXX for */ + /* possible values. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Since> */ + /* 2.8.1 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Var_Axis_Flags( FT_MM_Var* master, + FT_UInt axis_index, + FT_UInt* flags ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Named_Instance */ + /* */ + /* <Description> */ + /* Set or change the current named instance. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* instance_index :: The index of the requested instance, starting */ + /* with value 1. If set to value 0, FreeType */ + /* switches to font access without a named */ + /* instance. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The function uses the value of `instance_index' to set bits 16-30 */ + /* of the face's `face_index' field. It also resets any variation */ + /* applied to the font, and the @FT_FACE_FLAG_VARIATION bit of the */ + /* face's `face_flags' field gets reset to zero (i.e., */ + /* @FT_IS_VARIATION will return false). */ + /* */ + /* For Adobe MM fonts (which don't have named instances) this */ + /* function simply resets the current face to the default instance. */ + /* */ + /* <Since> */ + /* 2.9 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Named_Instance( FT_Face face, + FT_UInt instance_index ); + + /* */ + + +FT_END_HEADER + +#endif /* FTMM_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftmodapi.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftmodapi.h new file mode 100644 index 0000000..a6eb876 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftmodapi.h @@ -0,0 +1,711 @@ +/***************************************************************************/ +/* */ +/* ftmodapi.h */ +/* */ +/* FreeType modules public interface (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTMODAPI_H_ +#define FTMODAPI_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* module_management */ + /* */ + /* <Title> */ + /* Module Management */ + /* */ + /* <Abstract> */ + /* How to add, upgrade, remove, and control modules from FreeType. */ + /* */ + /* <Description> */ + /* The definitions below are used to manage modules within FreeType. */ + /* Modules can be added, upgraded, and removed at runtime. */ + /* Additionally, some module properties can be controlled also. */ + /* */ + /* Here is a list of possible values of the `module_name' field in */ + /* the @FT_Module_Class structure. */ + /* */ + /* { */ + /* autofitter */ + /* bdf */ + /* cff */ + /* gxvalid */ + /* otvalid */ + /* pcf */ + /* pfr */ + /* psaux */ + /* pshinter */ + /* psnames */ + /* raster1 */ + /* sfnt */ + /* smooth, smooth-lcd, smooth-lcdv */ + /* truetype */ + /* type1 */ + /* type42 */ + /* t1cid */ + /* winfonts */ + /* } */ + /* */ + /* Note that the FreeType Cache sub-system is not a FreeType module. */ + /* */ + /* <Order> */ + /* FT_Module */ + /* FT_Module_Constructor */ + /* FT_Module_Destructor */ + /* FT_Module_Requester */ + /* FT_Module_Class */ + /* */ + /* FT_Add_Module */ + /* FT_Get_Module */ + /* FT_Remove_Module */ + /* FT_Add_Default_Modules */ + /* */ + /* FT_Property_Set */ + /* FT_Property_Get */ + /* FT_Set_Default_Properties */ + /* */ + /* FT_New_Library */ + /* FT_Done_Library */ + /* FT_Reference_Library */ + /* */ + /* FT_Renderer */ + /* FT_Renderer_Class */ + /* */ + /* FT_Get_Renderer */ + /* FT_Set_Renderer */ + /* */ + /* FT_Set_Debug_Hook */ + /* */ + /*************************************************************************/ + + + /* module bit flags */ +#define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */ +#define FT_MODULE_RENDERER 2 /* this module is a renderer */ +#define FT_MODULE_HINTER 4 /* this module is a glyph hinter */ +#define FT_MODULE_STYLER 8 /* this module is a styler */ + +#define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */ + /* scalable fonts */ +#define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */ + /* support vector outlines */ +#define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */ + /* own hinter */ +#define FT_MODULE_DRIVER_HINTS_LIGHTLY 0x800 /* the driver's hinter */ + /* produces LIGHT hints */ + + + /* deprecated values */ +#define ft_module_font_driver FT_MODULE_FONT_DRIVER +#define ft_module_renderer FT_MODULE_RENDERER +#define ft_module_hinter FT_MODULE_HINTER +#define ft_module_styler FT_MODULE_STYLER + +#define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE +#define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES +#define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER +#define ft_module_driver_hints_lightly FT_MODULE_DRIVER_HINTS_LIGHTLY + + + typedef FT_Pointer FT_Module_Interface; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Module_Constructor */ + /* */ + /* <Description> */ + /* A function used to initialize (not create) a new module object. */ + /* */ + /* <Input> */ + /* module :: The module to initialize. */ + /* */ + typedef FT_Error + (*FT_Module_Constructor)( FT_Module module ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Module_Destructor */ + /* */ + /* <Description> */ + /* A function used to finalize (not destroy) a given module object. */ + /* */ + /* <Input> */ + /* module :: The module to finalize. */ + /* */ + typedef void + (*FT_Module_Destructor)( FT_Module module ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Module_Requester */ + /* */ + /* <Description> */ + /* A function used to query a given module for a specific interface. */ + /* */ + /* <Input> */ + /* module :: The module to be searched. */ + /* */ + /* name :: The name of the interface in the module. */ + /* */ + typedef FT_Module_Interface + (*FT_Module_Requester)( FT_Module module, + const char* name ); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Module_Class */ + /* */ + /* <Description> */ + /* The module class descriptor. */ + /* */ + /* <Fields> */ + /* module_flags :: Bit flags describing the module. */ + /* */ + /* module_size :: The size of one module object/instance in */ + /* bytes. */ + /* */ + /* module_name :: The name of the module. */ + /* */ + /* module_version :: The version, as a 16.16 fixed number */ + /* (major.minor). */ + /* */ + /* module_requires :: The version of FreeType this module requires, */ + /* as a 16.16 fixed number (major.minor). Starts */ + /* at version 2.0, i.e., 0x20000. */ + /* */ + /* module_init :: The initializing function. */ + /* */ + /* module_done :: The finalizing function. */ + /* */ + /* get_interface :: The interface requesting function. */ + /* */ + typedef struct FT_Module_Class_ + { + FT_ULong module_flags; + FT_Long module_size; + const FT_String* module_name; + FT_Fixed module_version; + FT_Fixed module_requires; + + const void* module_interface; + + FT_Module_Constructor module_init; + FT_Module_Destructor module_done; + FT_Module_Requester get_interface; + + } FT_Module_Class; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Add_Module */ + /* */ + /* <Description> */ + /* Add a new module to a given library instance. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library object. */ + /* */ + /* <Input> */ + /* clazz :: A pointer to class descriptor for the module. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* An error will be returned if a module already exists by that name, */ + /* or if the module requires a version of FreeType that is too great. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Add_Module( FT_Library library, + const FT_Module_Class* clazz ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Module */ + /* */ + /* <Description> */ + /* Find a module by its name. */ + /* */ + /* <Input> */ + /* library :: A handle to the library object. */ + /* */ + /* module_name :: The module's name (as an ASCII string). */ + /* */ + /* <Return> */ + /* A module handle. 0~if none was found. */ + /* */ + /* <Note> */ + /* FreeType's internal modules aren't documented very well, and you */ + /* should look up the source code for details. */ + /* */ + FT_EXPORT( FT_Module ) + FT_Get_Module( FT_Library library, + const char* module_name ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Remove_Module */ + /* */ + /* <Description> */ + /* Remove a given module from a library instance. */ + /* */ + /* <InOut> */ + /* library :: A handle to a library object. */ + /* */ + /* <Input> */ + /* module :: A handle to a module object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The module object is destroyed by the function in case of success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Remove_Module( FT_Library library, + FT_Module module ); + + + /********************************************************************** + * + * @function: + * FT_Property_Set + * + * @description: + * Set a property for a given module. + * + * @input: + * library :: + * A handle to the library the module is part of. + * + * module_name :: + * The module name. + * + * property_name :: + * The property name. Properties are described in section + * @properties. + * + * Note that only a few modules have properties. + * + * value :: + * A generic pointer to a variable or structure that gives the new + * value of the property. The exact definition of `value' is + * dependent on the property; see section @properties. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `module_name' isn't a valid module name, or `property_name' + * doesn't specify a valid property, or if `value' doesn't represent a + * valid value for the given property, an error is returned. + * + * The following example sets property `bar' (a simple integer) in + * module `foo' to value~1. + * + * { + * FT_UInt bar; + * + * + * bar = 1; + * FT_Property_Set( library, "foo", "bar", &bar ); + * } + * + * Note that the FreeType Cache sub-system doesn't recognize module + * property changes. To avoid glyph lookup confusion within the cache + * you should call @FTC_Manager_Reset to completely flush the cache if + * a module property gets changed after @FTC_Manager_New has been + * called. + * + * It is not possible to set properties of the FreeType Cache + * sub-system itself with FT_Property_Set; use @FTC_Property_Set + * instead. + * + * @since: + * 2.4.11 + * + */ + FT_EXPORT( FT_Error ) + FT_Property_Set( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + const void* value ); + + + /********************************************************************** + * + * @function: + * FT_Property_Get + * + * @description: + * Get a module's property value. + * + * @input: + * library :: + * A handle to the library the module is part of. + * + * module_name :: + * The module name. + * + * property_name :: + * The property name. Properties are described in section + * @properties. + * + * @inout: + * value :: + * A generic pointer to a variable or structure that gives the + * value of the property. The exact definition of `value' is + * dependent on the property; see section @properties. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `module_name' isn't a valid module name, or `property_name' + * doesn't specify a valid property, or if `value' doesn't represent a + * valid value for the given property, an error is returned. + * + * The following example gets property `baz' (a range) in module `foo'. + * + * { + * typedef range_ + * { + * FT_Int32 min; + * FT_Int32 max; + * + * } range; + * + * range baz; + * + * + * FT_Property_Get( library, "foo", "baz", &baz ); + * } + * + * It is not possible to retrieve properties of the FreeType Cache + * sub-system with FT_Property_Get; use @FTC_Property_Get instead. + * + * @since: + * 2.4.11 + * + */ + FT_EXPORT( FT_Error ) + FT_Property_Get( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + void* value ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Default_Properties */ + /* */ + /* <Description> */ + /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */ + /* set, this function reads the `FREETYPE_PROPERTIES' environment */ + /* variable to control driver properties. See section @properties */ + /* for more. */ + /* */ + /* If the compilation option is not set, this function does nothing. */ + /* */ + /* `FREETYPE_PROPERTIES' has the following syntax form (broken here */ + /* into multiple lines for better readability). */ + /* */ + /* { */ + /* <optional whitespace> */ + /* <module-name1> ':' */ + /* <property-name1> '=' <property-value1> */ + /* <whitespace> */ + /* <module-name2> ':' */ + /* <property-name2> '=' <property-value2> */ + /* ... */ + /* } */ + /* */ + /* Example: */ + /* */ + /* { */ + /* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */ + /* cff:no-stem-darkening=1 \ */ + /* autofitter:warping=1 */ + /* } */ + /* */ + /* <InOut> */ + /* library :: A handle to a new library object. */ + /* */ + /* <Since> */ + /* 2.8 */ + /* */ + FT_EXPORT( void ) + FT_Set_Default_Properties( FT_Library library ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Reference_Library */ + /* */ + /* <Description> */ + /* A counter gets initialized to~1 at the time an @FT_Library */ + /* structure is created. This function increments the counter. */ + /* @FT_Done_Library then only destroys a library if the counter is~1, */ + /* otherwise it simply decrements the counter. */ + /* */ + /* This function helps in managing life-cycles of structures that */ + /* reference @FT_Library objects. */ + /* */ + /* <Input> */ + /* library :: A handle to a target library object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Since> */ + /* 2.4.2 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Reference_Library( FT_Library library ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Library */ + /* */ + /* <Description> */ + /* This function is used to create a new FreeType library instance */ + /* from a given memory object. It is thus possible to use libraries */ + /* with distinct memory allocators within the same program. Note, */ + /* however, that the used @FT_Memory structure is expected to remain */ + /* valid for the life of the @FT_Library object. */ + /* */ + /* Normally, you would call this function (followed by a call to */ + /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, */ + /* and a call to @FT_Set_Default_Properties) instead of */ + /* @FT_Init_FreeType to initialize the FreeType library. */ + /* */ + /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */ + /* library instance. */ + /* */ + /* <Input> */ + /* memory :: A handle to the original memory object. */ + /* */ + /* <Output> */ + /* alibrary :: A pointer to handle of a new library object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* See the discussion of reference counters in the description of */ + /* @FT_Reference_Library. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Library( FT_Memory memory, + FT_Library *alibrary ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_Library */ + /* */ + /* <Description> */ + /* Discard a given library object. This closes all drivers and */ + /* discards all resource objects. */ + /* */ + /* <Input> */ + /* library :: A handle to the target library. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* See the discussion of reference counters in the description of */ + /* @FT_Reference_Library. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Done_Library( FT_Library library ); + + /* */ + + typedef void + (*FT_DebugHook_Func)( void* arg ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Debug_Hook */ + /* */ + /* <Description> */ + /* Set a debug hook function for debugging the interpreter of a font */ + /* format. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library object. */ + /* */ + /* <Input> */ + /* hook_index :: The index of the debug hook. You should use the */ + /* values defined in `ftobjs.h', e.g., */ + /* `FT_DEBUG_HOOK_TRUETYPE'. */ + /* */ + /* debug_hook :: The function used to debug the interpreter. */ + /* */ + /* <Note> */ + /* Currently, four debug hook slots are available, but only two (for */ + /* the TrueType and the Type~1 interpreter) are defined. */ + /* */ + /* Since the internal headers of FreeType are no longer installed, */ + /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */ + /* This is a bug and will be fixed in a forthcoming release. */ + /* */ + FT_EXPORT( void ) + FT_Set_Debug_Hook( FT_Library library, + FT_UInt hook_index, + FT_DebugHook_Func debug_hook ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Add_Default_Modules */ + /* */ + /* <Description> */ + /* Add the set of default drivers to a given library object. */ + /* This is only useful when you create a library object with */ + /* @FT_New_Library (usually to plug a custom memory manager). */ + /* */ + /* <InOut> */ + /* library :: A handle to a new library object. */ + /* */ + FT_EXPORT( void ) + FT_Add_Default_Modules( FT_Library library ); + + + + /************************************************************************** + * + * @section: + * truetype_engine + * + * @title: + * The TrueType Engine + * + * @abstract: + * TrueType bytecode support. + * + * @description: + * This section contains a function used to query the level of TrueType + * bytecode support compiled in this version of the library. + * + */ + + + /************************************************************************** + * + * @enum: + * FT_TrueTypeEngineType + * + * @description: + * A list of values describing which kind of TrueType bytecode + * engine is implemented in a given FT_Library instance. It is used + * by the @FT_Get_TrueType_Engine_Type function. + * + * @values: + * FT_TRUETYPE_ENGINE_TYPE_NONE :: + * The library doesn't implement any kind of bytecode interpreter. + * + * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED :: + * Deprecated and removed. + * + * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: + * The library implements a bytecode interpreter that covers + * the full instruction set of the TrueType virtual machine (this + * was governed by patents until May 2010, hence the name). + * + * @since: + * 2.2 + * + */ + typedef enum FT_TrueTypeEngineType_ + { + FT_TRUETYPE_ENGINE_TYPE_NONE = 0, + FT_TRUETYPE_ENGINE_TYPE_UNPATENTED, + FT_TRUETYPE_ENGINE_TYPE_PATENTED + + } FT_TrueTypeEngineType; + + + /************************************************************************** + * + * @func: + * FT_Get_TrueType_Engine_Type + * + * @description: + * Return an @FT_TrueTypeEngineType value to indicate which level of + * the TrueType virtual machine a given library instance supports. + * + * @input: + * library :: + * A library instance. + * + * @return: + * A value indicating which level is supported. + * + * @since: + * 2.2 + * + */ + FT_EXPORT( FT_TrueTypeEngineType ) + FT_Get_TrueType_Engine_Type( FT_Library library ); + + /* */ + + +FT_END_HEADER + +#endif /* FTMODAPI_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftmoderr.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftmoderr.h new file mode 100644 index 0000000..e0fc131 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftmoderr.h @@ -0,0 +1,194 @@ +/***************************************************************************/ +/* */ +/* ftmoderr.h */ +/* */ +/* FreeType module error offsets (specification). */ +/* */ +/* Copyright 2001-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file is used to define the FreeType module error codes. */ + /* */ + /* If the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in `ftoption.h' is */ + /* set, the lower byte of an error value identifies the error code as */ + /* usual. In addition, the higher byte identifies the module. For */ + /* example, the error `FT_Err_Invalid_File_Format' has value 0x0003, the */ + /* error `TT_Err_Invalid_File_Format' has value 0x1303, the error */ + /* `T1_Err_Invalid_File_Format' has value 0x1403, etc. */ + /* */ + /* Note that `FT_Err_Ok', `TT_Err_Ok', etc. are always equal to zero, */ + /* including the high byte. */ + /* */ + /* If FT_CONFIG_OPTION_USE_MODULE_ERRORS isn't set, the higher byte of */ + /* an error value is set to zero. */ + /* */ + /* To hide the various `XXX_Err_' prefixes in the source code, FreeType */ + /* provides some macros in `fttypes.h'. */ + /* */ + /* FT_ERR( err ) */ + /* Add current error module prefix (as defined with the */ + /* `FT_ERR_PREFIX' macro) to `err'. For example, in the BDF module */ + /* the line */ + /* */ + /* error = FT_ERR( Invalid_Outline ); */ + /* */ + /* expands to */ + /* */ + /* error = BDF_Err_Invalid_Outline; */ + /* */ + /* For simplicity, you can always use `FT_Err_Ok' directly instead */ + /* of `FT_ERR( Ok )'. */ + /* */ + /* FT_ERR_EQ( errcode, err ) */ + /* FT_ERR_NEQ( errcode, err ) */ + /* Compare error code `errcode' with the error `err' for equality */ + /* and inequality, respectively. Example: */ + /* */ + /* if ( FT_ERR_EQ( error, Invalid_Outline ) ) */ + /* ... */ + /* */ + /* Using this macro you don't have to think about error prefixes. */ + /* Of course, if module errors are not active, the above example is */ + /* the same as */ + /* */ + /* if ( error == FT_Err_Invalid_Outline ) */ + /* ... */ + /* */ + /* FT_ERROR_BASE( errcode ) */ + /* FT_ERROR_MODULE( errcode ) */ + /* Get base error and module error code, respectively. */ + /* */ + /* */ + /* It can also be used to create a module error message table easily */ + /* with something like */ + /* */ + /* { */ + /* #undef FTMODERR_H_ */ + /* #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, */ + /* #define FT_MODERR_START_LIST { */ + /* #define FT_MODERR_END_LIST { 0, 0 } }; */ + /* */ + /* const struct */ + /* { */ + /* int mod_err_offset; */ + /* const char* mod_err_msg */ + /* } ft_mod_errors[] = */ + /* */ + /* #include FT_MODULE_ERRORS_H */ + /* } */ + /* */ + /*************************************************************************/ + + +#ifndef FTMODERR_H_ +#define FTMODERR_H_ + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** SETUP MACROS *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#undef FT_NEED_EXTERN_C + +#ifndef FT_MODERRDEF + +#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS +#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v, +#else +#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0, +#endif + +#define FT_MODERR_START_LIST enum { +#define FT_MODERR_END_LIST FT_Mod_Err_Max }; + +#ifdef __cplusplus +#define FT_NEED_EXTERN_C + extern "C" { +#endif + +#endif /* !FT_MODERRDEF */ + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** LIST MODULE ERROR BASES *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#ifdef FT_MODERR_START_LIST + FT_MODERR_START_LIST +#endif + + + FT_MODERRDEF( Base, 0x000, "base module" ) + FT_MODERRDEF( Autofit, 0x100, "autofitter module" ) + FT_MODERRDEF( BDF, 0x200, "BDF module" ) + FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" ) + FT_MODERRDEF( Cache, 0x400, "cache module" ) + FT_MODERRDEF( CFF, 0x500, "CFF module" ) + FT_MODERRDEF( CID, 0x600, "CID module" ) + FT_MODERRDEF( Gzip, 0x700, "Gzip module" ) + FT_MODERRDEF( LZW, 0x800, "LZW module" ) + FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" ) + FT_MODERRDEF( PCF, 0xA00, "PCF module" ) + FT_MODERRDEF( PFR, 0xB00, "PFR module" ) + FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" ) + FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" ) + FT_MODERRDEF( PSnames, 0xE00, "PS names module" ) + FT_MODERRDEF( Raster, 0xF00, "raster module" ) + FT_MODERRDEF( SFNT, 0x1000, "SFNT module" ) + FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" ) + FT_MODERRDEF( TrueType, 0x1200, "TrueType module" ) + FT_MODERRDEF( Type1, 0x1300, "Type 1 module" ) + FT_MODERRDEF( Type42, 0x1400, "Type 42 module" ) + FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" ) + FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" ) + + +#ifdef FT_MODERR_END_LIST + FT_MODERR_END_LIST +#endif + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** CLEANUP *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#ifdef FT_NEED_EXTERN_C + } +#endif + +#undef FT_MODERR_START_LIST +#undef FT_MODERR_END_LIST +#undef FT_MODERRDEF +#undef FT_NEED_EXTERN_C + + +#endif /* FTMODERR_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftotval.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftotval.h new file mode 100644 index 0000000..26731c2 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftotval.h @@ -0,0 +1,204 @@ +/***************************************************************************/ +/* */ +/* ftotval.h */ +/* */ +/* FreeType API for validating OpenType tables (specification). */ +/* */ +/* Copyright 2004-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +/***************************************************************************/ +/* */ +/* */ +/* Warning: This module might be moved to a different library in the */ +/* future to avoid a tight dependency between FreeType and the */ +/* OpenType specification. */ +/* */ +/* */ +/***************************************************************************/ + + +#ifndef FTOTVAL_H_ +#define FTOTVAL_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* ot_validation */ + /* */ + /* <Title> */ + /* OpenType Validation */ + /* */ + /* <Abstract> */ + /* An API to validate OpenType tables. */ + /* */ + /* <Description> */ + /* This section contains the declaration of functions to validate */ + /* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */ + /* */ + /* <Order> */ + /* FT_OpenType_Validate */ + /* FT_OpenType_Free */ + /* */ + /* FT_VALIDATE_OTXXX */ + /* */ + /*************************************************************************/ + + + /********************************************************************** + * + * @enum: + * FT_VALIDATE_OTXXX + * + * @description: + * A list of bit-field constants used with @FT_OpenType_Validate to + * indicate which OpenType tables should be validated. + * + * @values: + * FT_VALIDATE_BASE :: + * Validate BASE table. + * + * FT_VALIDATE_GDEF :: + * Validate GDEF table. + * + * FT_VALIDATE_GPOS :: + * Validate GPOS table. + * + * FT_VALIDATE_GSUB :: + * Validate GSUB table. + * + * FT_VALIDATE_JSTF :: + * Validate JSTF table. + * + * FT_VALIDATE_MATH :: + * Validate MATH table. + * + * FT_VALIDATE_OT :: + * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). + * + */ +#define FT_VALIDATE_BASE 0x0100 +#define FT_VALIDATE_GDEF 0x0200 +#define FT_VALIDATE_GPOS 0x0400 +#define FT_VALIDATE_GSUB 0x0800 +#define FT_VALIDATE_JSTF 0x1000 +#define FT_VALIDATE_MATH 0x2000 + +#define FT_VALIDATE_OT ( FT_VALIDATE_BASE | \ + FT_VALIDATE_GDEF | \ + FT_VALIDATE_GPOS | \ + FT_VALIDATE_GSUB | \ + FT_VALIDATE_JSTF | \ + FT_VALIDATE_MATH ) + + /********************************************************************** + * + * @function: + * FT_OpenType_Validate + * + * @description: + * Validate various OpenType tables to assure that all offsets and + * indices are valid. The idea is that a higher-level library that + * actually does the text layout can access those tables without + * error checking (which can be quite time consuming). + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the tables to be validated. See + * @FT_VALIDATE_OTXXX for possible values. + * + * @output: + * BASE_table :: + * A pointer to the BASE table. + * + * GDEF_table :: + * A pointer to the GDEF table. + * + * GPOS_table :: + * A pointer to the GPOS table. + * + * GSUB_table :: + * A pointer to the GSUB table. + * + * JSTF_table :: + * A pointer to the JSTF table. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with OpenType fonts, returning an error + * otherwise. + * + * After use, the application should deallocate the five tables with + * @FT_OpenType_Free. A NULL value indicates that the table either + * doesn't exist in the font, or the application hasn't asked for + * validation. + */ + FT_EXPORT( FT_Error ) + FT_OpenType_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes *BASE_table, + FT_Bytes *GDEF_table, + FT_Bytes *GPOS_table, + FT_Bytes *GSUB_table, + FT_Bytes *JSTF_table ); + + /********************************************************************** + * + * @function: + * FT_OpenType_Free + * + * @description: + * Free the buffer allocated by OpenType validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer that is allocated by + * @FT_OpenType_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_OpenType_Validate only. + */ + FT_EXPORT( void ) + FT_OpenType_Free( FT_Face face, + FT_Bytes table ); + + /* */ + + +FT_END_HEADER + +#endif /* FTOTVAL_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftoutln.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftoutln.h new file mode 100644 index 0000000..89389a4 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftoutln.h @@ -0,0 +1,582 @@ +/***************************************************************************/ +/* */ +/* ftoutln.h */ +/* */ +/* Support for the FT_Outline type used to store glyph shapes of */ +/* most scalable font formats (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTOUTLN_H_ +#define FTOUTLN_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* outline_processing */ + /* */ + /* <Title> */ + /* Outline Processing */ + /* */ + /* <Abstract> */ + /* Functions to create, transform, and render vectorial glyph images. */ + /* */ + /* <Description> */ + /* This section contains routines used to create and destroy scalable */ + /* glyph images known as `outlines'. These can also be measured, */ + /* transformed, and converted into bitmaps and pixmaps. */ + /* */ + /* <Order> */ + /* FT_Outline */ + /* FT_Outline_New */ + /* FT_Outline_Done */ + /* FT_Outline_Copy */ + /* FT_Outline_Translate */ + /* FT_Outline_Transform */ + /* FT_Outline_Embolden */ + /* FT_Outline_EmboldenXY */ + /* FT_Outline_Reverse */ + /* FT_Outline_Check */ + /* */ + /* FT_Outline_Get_CBox */ + /* FT_Outline_Get_BBox */ + /* */ + /* FT_Outline_Get_Bitmap */ + /* FT_Outline_Render */ + /* FT_Outline_Decompose */ + /* FT_Outline_Funcs */ + /* FT_Outline_MoveToFunc */ + /* FT_Outline_LineToFunc */ + /* FT_Outline_ConicToFunc */ + /* FT_Outline_CubicToFunc */ + /* */ + /* FT_Orientation */ + /* FT_Outline_Get_Orientation */ + /* */ + /* FT_OUTLINE_XXX */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Decompose */ + /* */ + /* <Description> */ + /* Walk over an outline's structure to decompose it into individual */ + /* segments and Bezier arcs. This function also emits `move to' */ + /* operations to indicate the start of new contours in the outline. */ + /* */ + /* <Input> */ + /* outline :: A pointer to the source target. */ + /* */ + /* func_interface :: A table of `emitters', i.e., function pointers */ + /* called during decomposition to indicate path */ + /* operations. */ + /* */ + /* <InOut> */ + /* user :: A typeless pointer that is passed to each */ + /* emitter during the decomposition. It can be */ + /* used to store the state during the */ + /* decomposition. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* A contour that contains a single point only is represented by a */ + /* `move to' operation followed by `line to' to the same point. In */ + /* most cases, it is best to filter this out before using the */ + /* outline for stroking purposes (otherwise it would result in a */ + /* visible dot when round caps are used). */ + /* */ + /* Similarly, the function returns success for an empty outline also */ + /* (doing nothing, this is, not calling any emitter); if necessary, */ + /* you should filter this out, too. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Decompose( FT_Outline* outline, + const FT_Outline_Funcs* func_interface, + void* user ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_New */ + /* */ + /* <Description> */ + /* Create a new outline of a given size. */ + /* */ + /* <Input> */ + /* library :: A handle to the library object from where the */ + /* outline is allocated. Note however that the new */ + /* outline will *not* necessarily be *freed*, when */ + /* destroying the library, by @FT_Done_FreeType. */ + /* */ + /* numPoints :: The maximum number of points within the outline. */ + /* Must be smaller than or equal to 0xFFFF (65535). */ + /* */ + /* numContours :: The maximum number of contours within the outline. */ + /* This value must be in the range 0 to `numPoints'. */ + /* */ + /* <Output> */ + /* anoutline :: A handle to the new outline. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The reason why this function takes a `library' parameter is simply */ + /* to use the library's memory allocator. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_New( FT_Library library, + FT_UInt numPoints, + FT_Int numContours, + FT_Outline *anoutline ); + + + FT_EXPORT( FT_Error ) + FT_Outline_New_Internal( FT_Memory memory, + FT_UInt numPoints, + FT_Int numContours, + FT_Outline *anoutline ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Done */ + /* */ + /* <Description> */ + /* Destroy an outline created with @FT_Outline_New. */ + /* */ + /* <Input> */ + /* library :: A handle of the library object used to allocate the */ + /* outline. */ + /* */ + /* outline :: A pointer to the outline object to be discarded. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* If the outline's `owner' field is not set, only the outline */ + /* descriptor will be released. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Done( FT_Library library, + FT_Outline* outline ); + + + FT_EXPORT( FT_Error ) + FT_Outline_Done_Internal( FT_Memory memory, + FT_Outline* outline ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Check */ + /* */ + /* <Description> */ + /* Check the contents of an outline descriptor. */ + /* */ + /* <Input> */ + /* outline :: A handle to a source outline. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* An empty outline, or an outline with a single point only is also */ + /* valid. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Check( FT_Outline* outline ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Get_CBox */ + /* */ + /* <Description> */ + /* Return an outline's `control box'. The control box encloses all */ + /* the outline's points, including Bezier control points. Though it */ + /* coincides with the exact bounding box for most glyphs, it can be */ + /* slightly larger in some situations (like when rotating an outline */ + /* that contains Bezier outside arcs). */ + /* */ + /* Computing the control box is very fast, while getting the bounding */ + /* box can take much more time as it needs to walk over all segments */ + /* and arcs in the outline. To get the latter, you can use the */ + /* `ftbbox' component, which is dedicated to this single task. */ + /* */ + /* <Input> */ + /* outline :: A pointer to the source outline descriptor. */ + /* */ + /* <Output> */ + /* acbox :: The outline's control box. */ + /* */ + /* <Note> */ + /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */ + /* */ + FT_EXPORT( void ) + FT_Outline_Get_CBox( const FT_Outline* outline, + FT_BBox *acbox ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Translate */ + /* */ + /* <Description> */ + /* Apply a simple translation to the points of an outline. */ + /* */ + /* <InOut> */ + /* outline :: A pointer to the target outline descriptor. */ + /* */ + /* <Input> */ + /* xOffset :: The horizontal offset. */ + /* */ + /* yOffset :: The vertical offset. */ + /* */ + FT_EXPORT( void ) + FT_Outline_Translate( const FT_Outline* outline, + FT_Pos xOffset, + FT_Pos yOffset ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Copy */ + /* */ + /* <Description> */ + /* Copy an outline into another one. Both objects must have the */ + /* same sizes (number of points & number of contours) when this */ + /* function is called. */ + /* */ + /* <Input> */ + /* source :: A handle to the source outline. */ + /* */ + /* <Output> */ + /* target :: A handle to the target outline. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Copy( const FT_Outline* source, + FT_Outline *target ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Transform */ + /* */ + /* <Description> */ + /* Apply a simple 2x2 matrix to all of an outline's points. Useful */ + /* for applying rotations, slanting, flipping, etc. */ + /* */ + /* <InOut> */ + /* outline :: A pointer to the target outline descriptor. */ + /* */ + /* <Input> */ + /* matrix :: A pointer to the transformation matrix. */ + /* */ + /* <Note> */ + /* You can use @FT_Outline_Translate if you need to translate the */ + /* outline's points. */ + /* */ + FT_EXPORT( void ) + FT_Outline_Transform( const FT_Outline* outline, + const FT_Matrix* matrix ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Embolden */ + /* */ + /* <Description> */ + /* Embolden an outline. The new outline will be at most 4~times */ + /* `strength' pixels wider and higher. You may think of the left and */ + /* bottom borders as unchanged. */ + /* */ + /* Negative `strength' values to reduce the outline thickness are */ + /* possible also. */ + /* */ + /* <InOut> */ + /* outline :: A handle to the target outline. */ + /* */ + /* <Input> */ + /* strength :: How strong the glyph is emboldened. Expressed in */ + /* 26.6 pixel format. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The used algorithm to increase or decrease the thickness of the */ + /* glyph doesn't change the number of points; this means that certain */ + /* situations like acute angles or intersections are sometimes */ + /* handled incorrectly. */ + /* */ + /* If you need `better' metrics values you should call */ + /* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */ + /* */ + /* Example call: */ + /* */ + /* { */ + /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */ + /* if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) */ + /* FT_Outline_Embolden( &face->glyph->outline, strength ); */ + /* } */ + /* */ + /* To get meaningful results, font scaling values must be set with */ + /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Embolden( FT_Outline* outline, + FT_Pos strength ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_EmboldenXY */ + /* */ + /* <Description> */ + /* Embolden an outline. The new outline will be `xstrength' pixels */ + /* wider and `ystrength' pixels higher. Otherwise, it is similar to */ + /* @FT_Outline_Embolden, which uses the same strength in both */ + /* directions. */ + /* */ + /* <Since> */ + /* 2.4.10 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_EmboldenXY( FT_Outline* outline, + FT_Pos xstrength, + FT_Pos ystrength ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Reverse */ + /* */ + /* <Description> */ + /* Reverse the drawing direction of an outline. This is used to */ + /* ensure consistent fill conventions for mirrored glyphs. */ + /* */ + /* <InOut> */ + /* outline :: A pointer to the target outline descriptor. */ + /* */ + /* <Note> */ + /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */ + /* the outline's `flags' field. */ + /* */ + /* It shouldn't be used by a normal client application, unless it */ + /* knows what it is doing. */ + /* */ + FT_EXPORT( void ) + FT_Outline_Reverse( FT_Outline* outline ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Get_Bitmap */ + /* */ + /* <Description> */ + /* Render an outline within a bitmap. The outline's image is simply */ + /* OR-ed to the target bitmap. */ + /* */ + /* <Input> */ + /* library :: A handle to a FreeType library object. */ + /* */ + /* outline :: A pointer to the source outline descriptor. */ + /* */ + /* <InOut> */ + /* abitmap :: A pointer to the target bitmap descriptor. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* This function does NOT CREATE the bitmap, it only renders an */ + /* outline image within the one you pass to it! Consequently, the */ + /* various fields in `abitmap' should be set accordingly. */ + /* */ + /* It will use the raster corresponding to the default glyph format. */ + /* */ + /* The value of the `num_grays' field in `abitmap' is ignored. If */ + /* you select the gray-level rasterizer, and you want less than 256 */ + /* gray levels, you have to use @FT_Outline_Render directly. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Get_Bitmap( FT_Library library, + FT_Outline* outline, + const FT_Bitmap *abitmap ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Outline_Render */ + /* */ + /* <Description> */ + /* Render an outline within a bitmap using the current scan-convert. */ + /* This function uses an @FT_Raster_Params structure as an argument, */ + /* allowing advanced features like direct composition, translucency, */ + /* etc. */ + /* */ + /* <Input> */ + /* library :: A handle to a FreeType library object. */ + /* */ + /* outline :: A pointer to the source outline descriptor. */ + /* */ + /* <InOut> */ + /* params :: A pointer to an @FT_Raster_Params structure used to */ + /* describe the rendering operation. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* You should know what you are doing and how @FT_Raster_Params works */ + /* to use this function. */ + /* */ + /* The field `params.source' will be set to `outline' before the scan */ + /* converter is called, which means that the value you give to it is */ + /* actually ignored. */ + /* */ + /* The gray-level rasterizer always uses 256 gray levels. If you */ + /* want less gray levels, you have to provide your own span callback. */ + /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */ + /* @FT_Raster_Params structure for more details. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Outline_Render( FT_Library library, + FT_Outline* outline, + FT_Raster_Params* params ); + + + /************************************************************************** + * + * @enum: + * FT_Orientation + * + * @description: + * A list of values used to describe an outline's contour orientation. + * + * The TrueType and PostScript specifications use different conventions + * to determine whether outline contours should be filled or unfilled. + * + * @values: + * FT_ORIENTATION_TRUETYPE :: + * According to the TrueType specification, clockwise contours must + * be filled, and counter-clockwise ones must be unfilled. + * + * FT_ORIENTATION_POSTSCRIPT :: + * According to the PostScript specification, counter-clockwise contours + * must be filled, and clockwise ones must be unfilled. + * + * FT_ORIENTATION_FILL_RIGHT :: + * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to + * remember that in TrueType, everything that is to the right of + * the drawing direction of a contour must be filled. + * + * FT_ORIENTATION_FILL_LEFT :: + * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to + * remember that in PostScript, everything that is to the left of + * the drawing direction of a contour must be filled. + * + * FT_ORIENTATION_NONE :: + * The orientation cannot be determined. That is, different parts of + * the glyph have different orientation. + * + */ + typedef enum FT_Orientation_ + { + FT_ORIENTATION_TRUETYPE = 0, + FT_ORIENTATION_POSTSCRIPT = 1, + FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE, + FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT, + FT_ORIENTATION_NONE + + } FT_Orientation; + + + /************************************************************************** + * + * @function: + * FT_Outline_Get_Orientation + * + * @description: + * This function analyzes a glyph outline and tries to compute its + * fill orientation (see @FT_Orientation). This is done by integrating + * the total area covered by the outline. The positive integral + * corresponds to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT + * is returned. The negative integral corresponds to the counter-clockwise + * orientation and @FT_ORIENTATION_TRUETYPE is returned. + * + * Note that this will return @FT_ORIENTATION_TRUETYPE for empty + * outlines. + * + * @input: + * outline :: + * A handle to the source outline. + * + * @return: + * The orientation. + * + */ + FT_EXPORT( FT_Orientation ) + FT_Outline_Get_Orientation( FT_Outline* outline ); + + /* */ + + +FT_END_HEADER + +#endif /* FTOUTLN_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftparams.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftparams.h new file mode 100644 index 0000000..5a9006c --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftparams.h @@ -0,0 +1,205 @@ +/***************************************************************************/ +/* */ +/* ftparams.h */ +/* */ +/* FreeType API for possible FT_Parameter tags (specification only). */ +/* */ +/* Copyright 2017-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTPARAMS_H_ +#define FTPARAMS_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * parameter_tags + * + * @title: + * Parameter Tags + * + * @abstract: + * Macros for driver property and font loading parameter tags. + * + * @description: + * This section contains macros for the @FT_Parameter structure that are + * used with various functions to activate some special functionality or + * different behaviour of various components of FreeType. + * + */ + + + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY + * + * @description: + * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic + * family names in the `name' table (introduced in OpenType version + * 1.4). Use this for backward compatibility with legacy systems that + * have a four-faces-per-family restriction. + * + * @since: + * 2.8 + * + */ +#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY \ + FT_MAKE_TAG( 'i', 'g', 'p', 'f' ) + + + /* this constant is deprecated */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY \ + FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY + + + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY + * + * @description: + * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic + * subfamily names in the `name' table (introduced in OpenType version + * 1.4). Use this for backward compatibility with legacy systems that + * have a four-faces-per-family restriction. + * + * @since: + * 2.8 + * + */ +#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY \ + FT_MAKE_TAG( 'i', 'g', 'p', 's' ) + + + /* this constant is deprecated */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY \ + FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY + + + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_INCREMENTAL + * + * @description: + * An @FT_Parameter tag to be used with @FT_Open_Face to indicate + * incremental glyph loading. + * + */ +#define FT_PARAM_TAG_INCREMENTAL \ + FT_MAKE_TAG( 'i', 'n', 'c', 'r' ) + + + /************************************************************************** + * + * @constant: + * FT_PARAM_TAG_LCD_FILTER_WEIGHTS + * + * @description: + * An @FT_Parameter tag to be used with @FT_Face_Properties. The + * corresponding argument specifies the five LCD filter weights for a + * given face (if using @FT_LOAD_TARGET_LCD, for example), overriding + * the global default values or the values set up with + * @FT_Library_SetLcdFilterWeights. + * + * @since: + * 2.8 + * + */ +#define FT_PARAM_TAG_LCD_FILTER_WEIGHTS \ + FT_MAKE_TAG( 'l', 'c', 'd', 'f' ) + + + /************************************************************************** + * + * @constant: + * FT_PARAM_TAG_RANDOM_SEED + * + * @description: + * An @FT_Parameter tag to be used with @FT_Face_Properties. The + * corresponding 32bit signed integer argument overrides the font + * driver's random seed value with a face-specific one; see + * @random-seed. + * + * @since: + * 2.8 + * + */ +#define FT_PARAM_TAG_RANDOM_SEED \ + FT_MAKE_TAG( 's', 'e', 'e', 'd' ) + + + /************************************************************************** + * + * @constant: + * FT_PARAM_TAG_STEM_DARKENING + * + * @description: + * An @FT_Parameter tag to be used with @FT_Face_Properties. The + * corresponding Boolean argument specifies whether to apply stem + * darkening, overriding the global default values or the values set up + * with @FT_Property_Set (see @no-stem-darkening). + * + * This is a passive setting that only takes effect if the font driver + * or autohinter honors it, which the CFF, Type~1, and CID drivers + * always do, but the autohinter only in `light' hinting mode (as of + * version 2.9). + * + * @since: + * 2.8 + * + */ +#define FT_PARAM_TAG_STEM_DARKENING \ + FT_MAKE_TAG( 'd', 'a', 'r', 'k' ) + + + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_UNPATENTED_HINTING + * + * @description: + * Deprecated, no effect. + * + * Previously: A constant used as the tag of an @FT_Parameter structure to + * indicate that unpatented methods only should be used by the TrueType + * bytecode interpreter for a typeface opened by @FT_Open_Face. + * + */ +#define FT_PARAM_TAG_UNPATENTED_HINTING \ + FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) + + + /* */ + + +FT_END_HEADER + + +#endif /* FTPARAMS_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftpfr.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftpfr.h new file mode 100644 index 0000000..ce60eb4 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftpfr.h @@ -0,0 +1,172 @@ +/***************************************************************************/ +/* */ +/* ftpfr.h */ +/* */ +/* FreeType API for accessing PFR-specific data (specification only). */ +/* */ +/* Copyright 2002-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTPFR_H_ +#define FTPFR_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* pfr_fonts */ + /* */ + /* <Title> */ + /* PFR Fonts */ + /* */ + /* <Abstract> */ + /* PFR/TrueDoc specific API. */ + /* */ + /* <Description> */ + /* This section contains the declaration of PFR-specific functions. */ + /* */ + /*************************************************************************/ + + + /********************************************************************** + * + * @function: + * FT_Get_PFR_Metrics + * + * @description: + * Return the outline and metrics resolutions of a given PFR face. + * + * @input: + * face :: Handle to the input face. It can be a non-PFR face. + * + * @output: + * aoutline_resolution :: + * Outline resolution. This is equivalent to `face->units_per_EM' + * for non-PFR fonts. Optional (parameter can be NULL). + * + * ametrics_resolution :: + * Metrics resolution. This is equivalent to `outline_resolution' + * for non-PFR fonts. Optional (parameter can be NULL). + * + * ametrics_x_scale :: + * A 16.16 fixed-point number used to scale distance expressed + * in metrics units to device sub-pixels. This is equivalent to + * `face->size->x_scale', but for metrics only. Optional (parameter + * can be NULL). + * + * ametrics_y_scale :: + * Same as `ametrics_x_scale' but for the vertical direction. + * optional (parameter can be NULL). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If the input face is not a PFR, this function will return an error. + * However, in all cases, it will return valid values. + */ + FT_EXPORT( FT_Error ) + FT_Get_PFR_Metrics( FT_Face face, + FT_UInt *aoutline_resolution, + FT_UInt *ametrics_resolution, + FT_Fixed *ametrics_x_scale, + FT_Fixed *ametrics_y_scale ); + + + /********************************************************************** + * + * @function: + * FT_Get_PFR_Kerning + * + * @description: + * Return the kerning pair corresponding to two glyphs in a PFR face. + * The distance is expressed in metrics units, unlike the result of + * @FT_Get_Kerning. + * + * @input: + * face :: A handle to the input face. + * + * left :: Index of the left glyph. + * + * right :: Index of the right glyph. + * + * @output: + * avector :: A kerning vector. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function always return distances in original PFR metrics + * units. This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED + * mode, which always returns distances converted to outline units. + * + * You can use the value of the `x_scale' and `y_scale' parameters + * returned by @FT_Get_PFR_Metrics to scale these to device sub-pixels. + */ + FT_EXPORT( FT_Error ) + FT_Get_PFR_Kerning( FT_Face face, + FT_UInt left, + FT_UInt right, + FT_Vector *avector ); + + + /********************************************************************** + * + * @function: + * FT_Get_PFR_Advance + * + * @description: + * Return a given glyph advance, expressed in original metrics units, + * from a PFR font. + * + * @input: + * face :: A handle to the input face. + * + * gindex :: The glyph index. + * + * @output: + * aadvance :: The glyph advance in metrics units. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics + * to convert the advance to device sub-pixels (i.e., 1/64th of pixels). + */ + FT_EXPORT( FT_Error ) + FT_Get_PFR_Advance( FT_Face face, + FT_UInt gindex, + FT_Pos *aadvance ); + + /* */ + + +FT_END_HEADER + +#endif /* FTPFR_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftrender.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftrender.h new file mode 100644 index 0000000..fa8ad22 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftrender.h @@ -0,0 +1,233 @@ +/***************************************************************************/ +/* */ +/* ftrender.h */ +/* */ +/* FreeType renderer modules public interface (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTRENDER_H_ +#define FTRENDER_H_ + + +#include <ft2build.h> +#include FT_MODULE_H +#include FT_GLYPH_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* module_management */ + /* */ + /*************************************************************************/ + + + /* create a new glyph object */ + typedef FT_Error + (*FT_Glyph_InitFunc)( FT_Glyph glyph, + FT_GlyphSlot slot ); + + /* destroys a given glyph object */ + typedef void + (*FT_Glyph_DoneFunc)( FT_Glyph glyph ); + + typedef void + (*FT_Glyph_TransformFunc)( FT_Glyph glyph, + const FT_Matrix* matrix, + const FT_Vector* delta ); + + typedef void + (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph, + FT_BBox* abbox ); + + typedef FT_Error + (*FT_Glyph_CopyFunc)( FT_Glyph source, + FT_Glyph target ); + + typedef FT_Error + (*FT_Glyph_PrepareFunc)( FT_Glyph glyph, + FT_GlyphSlot slot ); + +/* deprecated */ +#define FT_Glyph_Init_Func FT_Glyph_InitFunc +#define FT_Glyph_Done_Func FT_Glyph_DoneFunc +#define FT_Glyph_Transform_Func FT_Glyph_TransformFunc +#define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc +#define FT_Glyph_Copy_Func FT_Glyph_CopyFunc +#define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc + + + struct FT_Glyph_Class_ + { + FT_Long glyph_size; + FT_Glyph_Format glyph_format; + + FT_Glyph_InitFunc glyph_init; + FT_Glyph_DoneFunc glyph_done; + FT_Glyph_CopyFunc glyph_copy; + FT_Glyph_TransformFunc glyph_transform; + FT_Glyph_GetBBoxFunc glyph_bbox; + FT_Glyph_PrepareFunc glyph_prepare; + }; + + + typedef FT_Error + (*FT_Renderer_RenderFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + FT_Render_Mode mode, + const FT_Vector* origin ); + + typedef FT_Error + (*FT_Renderer_TransformFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + const FT_Matrix* matrix, + const FT_Vector* delta ); + + + typedef void + (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + FT_BBox* cbox ); + + + typedef FT_Error + (*FT_Renderer_SetModeFunc)( FT_Renderer renderer, + FT_ULong mode_tag, + FT_Pointer mode_ptr ); + +/* deprecated identifiers */ +#define FTRenderer_render FT_Renderer_RenderFunc +#define FTRenderer_transform FT_Renderer_TransformFunc +#define FTRenderer_getCBox FT_Renderer_GetCBoxFunc +#define FTRenderer_setMode FT_Renderer_SetModeFunc + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Renderer_Class */ + /* */ + /* <Description> */ + /* The renderer module class descriptor. */ + /* */ + /* <Fields> */ + /* root :: The root @FT_Module_Class fields. */ + /* */ + /* glyph_format :: The glyph image format this renderer handles. */ + /* */ + /* render_glyph :: A method used to render the image that is in a */ + /* given glyph slot into a bitmap. */ + /* */ + /* transform_glyph :: A method used to transform the image that is in */ + /* a given glyph slot. */ + /* */ + /* get_glyph_cbox :: A method used to access the glyph's cbox. */ + /* */ + /* set_mode :: A method used to pass additional parameters. */ + /* */ + /* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */ + /* This is a pointer to its raster's class. */ + /* */ + typedef struct FT_Renderer_Class_ + { + FT_Module_Class root; + + FT_Glyph_Format glyph_format; + + FT_Renderer_RenderFunc render_glyph; + FT_Renderer_TransformFunc transform_glyph; + FT_Renderer_GetCBoxFunc get_glyph_cbox; + FT_Renderer_SetModeFunc set_mode; + + FT_Raster_Funcs* raster_class; + + } FT_Renderer_Class; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Renderer */ + /* */ + /* <Description> */ + /* Retrieve the current renderer for a given glyph format. */ + /* */ + /* <Input> */ + /* library :: A handle to the library object. */ + /* */ + /* format :: The glyph format. */ + /* */ + /* <Return> */ + /* A renderer handle. 0~if none found. */ + /* */ + /* <Note> */ + /* An error will be returned if a module already exists by that name, */ + /* or if the module requires a version of FreeType that is too great. */ + /* */ + /* To add a new renderer, simply use @FT_Add_Module. To retrieve a */ + /* renderer by its name, use @FT_Get_Module. */ + /* */ + FT_EXPORT( FT_Renderer ) + FT_Get_Renderer( FT_Library library, + FT_Glyph_Format format ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Renderer */ + /* */ + /* <Description> */ + /* Set the current renderer to use, and set additional mode. */ + /* */ + /* <InOut> */ + /* library :: A handle to the library object. */ + /* */ + /* <Input> */ + /* renderer :: A handle to the renderer object. */ + /* */ + /* num_params :: The number of additional parameters. */ + /* */ + /* parameters :: Additional parameters. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* In case of success, the renderer will be used to convert glyph */ + /* images in the renderer's known format into bitmaps. */ + /* */ + /* This doesn't change the current renderer for other formats. */ + /* */ + /* Currently, no FreeType renderer module uses `parameters'; you */ + /* should thus always pass NULL as the value. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Renderer( FT_Library library, + FT_Renderer renderer, + FT_UInt num_params, + FT_Parameter* parameters ); + + /* */ + + +FT_END_HEADER + +#endif /* FTRENDER_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftsizes.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftsizes.h new file mode 100644 index 0000000..72cb08b --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftsizes.h @@ -0,0 +1,159 @@ +/***************************************************************************/ +/* */ +/* ftsizes.h */ +/* */ +/* FreeType size objects management (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Typical application would normally not need to use these functions. */ + /* However, they have been placed in a public API for the rare cases */ + /* where they are needed. */ + /* */ + /*************************************************************************/ + + +#ifndef FTSIZES_H_ +#define FTSIZES_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* sizes_management */ + /* */ + /* <Title> */ + /* Size Management */ + /* */ + /* <Abstract> */ + /* Managing multiple sizes per face. */ + /* */ + /* <Description> */ + /* When creating a new face object (e.g., with @FT_New_Face), an */ + /* @FT_Size object is automatically created and used to store all */ + /* pixel-size dependent information, available in the `face->size' */ + /* field. */ + /* */ + /* It is however possible to create more sizes for a given face, */ + /* mostly in order to manage several character pixel sizes of the */ + /* same font family and style. See @FT_New_Size and @FT_Done_Size. */ + /* */ + /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */ + /* modify the contents of the current `active' size; you thus need */ + /* to use @FT_Activate_Size to change it. */ + /* */ + /* 99% of applications won't need the functions provided here, */ + /* especially if they use the caching sub-system, so be cautious */ + /* when using these. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Size */ + /* */ + /* <Description> */ + /* Create a new size object from a given face object. */ + /* */ + /* <Input> */ + /* face :: A handle to a parent face object. */ + /* */ + /* <Output> */ + /* asize :: A handle to a new size object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* You need to call @FT_Activate_Size in order to select the new size */ + /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */ + /* @FT_Load_Glyph, @FT_Load_Char, etc. */ + /* */ + FT_EXPORT( FT_Error ) + FT_New_Size( FT_Face face, + FT_Size* size ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_Size */ + /* */ + /* <Description> */ + /* Discard a given size object. Note that @FT_Done_Face */ + /* automatically discards all size objects allocated with */ + /* @FT_New_Size. */ + /* */ + /* <Input> */ + /* size :: A handle to a target size object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Done_Size( FT_Size size ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Activate_Size */ + /* */ + /* <Description> */ + /* Even though it is possible to create several size objects for a */ + /* given face (see @FT_New_Size for details), functions like */ + /* @FT_Load_Glyph or @FT_Load_Char only use the one that has been */ + /* activated last to determine the `current character pixel size'. */ + /* */ + /* This function can be used to `activate' a previously created size */ + /* object. */ + /* */ + /* <Input> */ + /* size :: A handle to a target size object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* If `face' is the size's parent face object, this function changes */ + /* the value of `face->size' to the input size handle. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Activate_Size( FT_Size size ); + + /* */ + + +FT_END_HEADER + +#endif /* FTSIZES_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftsnames.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftsnames.h new file mode 100644 index 0000000..8eb8d70 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftsnames.h @@ -0,0 +1,253 @@ +/***************************************************************************/ +/* */ +/* ftsnames.h */ +/* */ +/* Simple interface to access SFNT `name' tables (which are used */ +/* to hold font names, copyright info, notices, etc.) (specification). */ +/* */ +/* This is _not_ used to retrieve glyph names! */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTSNAMES_H_ +#define FTSNAMES_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_PARAMETER_TAGS_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* sfnt_names */ + /* */ + /* <Title> */ + /* SFNT Names */ + /* */ + /* <Abstract> */ + /* Access the names embedded in TrueType and OpenType files. */ + /* */ + /* <Description> */ + /* The TrueType and OpenType specifications allow the inclusion of */ + /* a special names table (`name') in font files. This table contains */ + /* textual (and internationalized) information regarding the font, */ + /* like family name, copyright, version, etc. */ + /* */ + /* The definitions below are used to access them if available. */ + /* */ + /* Note that this has nothing to do with glyph names! */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_SfntName */ + /* */ + /* <Description> */ + /* A structure used to model an SFNT `name' table entry. */ + /* */ + /* <Fields> */ + /* platform_id :: The platform ID for `string'. */ + /* See @TT_PLATFORM_XXX for possible values. */ + /* */ + /* encoding_id :: The encoding ID for `string'. */ + /* See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */ + /* @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX */ + /* for possible values. */ + /* */ + /* language_id :: The language ID for `string'. */ + /* See @TT_MAC_LANGID_XXX and @TT_MS_LANGID_XXX for */ + /* possible values. */ + /* */ + /* Registered OpenType values for `language_id' are */ + /* always smaller than 0x8000; values equal or larger */ + /* than 0x8000 usually indicate a language tag string */ + /* (introduced in OpenType version 1.6). Use function */ + /* @FT_Get_Sfnt_LangTag with `language_id' as its */ + /* argument to retrieve the associated language tag. */ + /* */ + /* name_id :: An identifier for `string'. */ + /* See @TT_NAME_ID_XXX for possible values. */ + /* */ + /* string :: The `name' string. Note that its format differs */ + /* depending on the (platform,encoding) pair, being */ + /* either a string of bytes (without a terminating */ + /* NULL byte) or containing UTF-16BE entities. */ + /* */ + /* string_len :: The length of `string' in bytes. */ + /* */ + /* <Note> */ + /* Please refer to the TrueType or OpenType specification for more */ + /* details. */ + /* */ + typedef struct FT_SfntName_ + { + FT_UShort platform_id; + FT_UShort encoding_id; + FT_UShort language_id; + FT_UShort name_id; + + FT_Byte* string; /* this string is *not* null-terminated! */ + FT_UInt string_len; /* in bytes */ + + } FT_SfntName; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Sfnt_Name_Count */ + /* */ + /* <Description> */ + /* Retrieve the number of name strings in the SFNT `name' table. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* <Return> */ + /* The number of strings in the `name' table. */ + /* */ + FT_EXPORT( FT_UInt ) + FT_Get_Sfnt_Name_Count( FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Sfnt_Name */ + /* */ + /* <Description> */ + /* Retrieve a string of the SFNT `name' table for a given index. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* idx :: The index of the `name' string. */ + /* */ + /* <Output> */ + /* aname :: The indexed @FT_SfntName structure. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The `string' array returned in the `aname' structure is not */ + /* null-terminated. Note that you don't have to deallocate `string' */ + /* by yourself; FreeType takes care of it if you call @FT_Done_Face. */ + /* */ + /* Use @FT_Get_Sfnt_Name_Count to get the total number of available */ + /* `name' table entries, then do a loop until you get the right */ + /* platform, encoding, and name ID. */ + /* */ + /* `name' table format~1 entries can use language tags also, see */ + /* @FT_Get_Sfnt_LangTag. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Sfnt_Name( FT_Face face, + FT_UInt idx, + FT_SfntName *aname ); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_SfntLangTag */ + /* */ + /* <Description> */ + /* A structure to model a language tag entry from an SFNT `name' */ + /* table. */ + /* */ + /* <Fields> */ + /* string :: The language tag string, encoded in UTF-16BE */ + /* (without trailing NULL bytes). */ + /* */ + /* string_len :: The length of `string' in *bytes*. */ + /* */ + /* <Note> */ + /* Please refer to the TrueType or OpenType specification for more */ + /* details. */ + /* */ + /* <Since> */ + /* 2.8 */ + /* */ + typedef struct FT_SfntLangTag_ + { + FT_Byte* string; /* this string is *not* null-terminated! */ + FT_UInt string_len; /* in bytes */ + + } FT_SfntLangTag; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Sfnt_LangTag */ + /* */ + /* <Description> */ + /* Retrieve the language tag associated with a language ID of an SFNT */ + /* `name' table entry. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* langID :: The language ID, as returned by @FT_Get_Sfnt_Name. */ + /* This is always a value larger than 0x8000. */ + /* */ + /* <Output> */ + /* alangTag :: The language tag associated with the `name' table */ + /* entry's language ID. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The `string' array returned in the `alangTag' structure is not */ + /* null-terminated. Note that you don't have to deallocate `string' */ + /* by yourself; FreeType takes care of it if you call @FT_Done_Face. */ + /* */ + /* Only `name' table format~1 supports language tags. For format~0 */ + /* tables, this function always returns FT_Err_Invalid_Table. For */ + /* invalid format~1 language ID values, FT_Err_Invalid_Argument is */ + /* returned. */ + /* */ + /* <Since> */ + /* 2.8 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Sfnt_LangTag( FT_Face face, + FT_UInt langID, + FT_SfntLangTag *alangTag ); + + + /* */ + + +FT_END_HEADER + +#endif /* FTSNAMES_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftstroke.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftstroke.h new file mode 100644 index 0000000..44b6fbe --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftstroke.h @@ -0,0 +1,785 @@ +/***************************************************************************/ +/* */ +/* ftstroke.h */ +/* */ +/* FreeType path stroker (specification). */ +/* */ +/* Copyright 2002-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTSTROKE_H_ +#define FTSTROKE_H_ + +#include <ft2build.h> +#include FT_OUTLINE_H +#include FT_GLYPH_H + + +FT_BEGIN_HEADER + + + /************************************************************************ + * + * @section: + * glyph_stroker + * + * @title: + * Glyph Stroker + * + * @abstract: + * Generating bordered and stroked glyphs. + * + * @description: + * This component generates stroked outlines of a given vectorial + * glyph. It also allows you to retrieve the `outside' and/or the + * `inside' borders of the stroke. + * + * This can be useful to generate `bordered' glyph, i.e., glyphs + * displayed with a coloured (and anti-aliased) border around their + * shape. + * + * @order: + * FT_Stroker + * + * FT_Stroker_LineJoin + * FT_Stroker_LineCap + * FT_StrokerBorder + * + * FT_Outline_GetInsideBorder + * FT_Outline_GetOutsideBorder + * + * FT_Glyph_Stroke + * FT_Glyph_StrokeBorder + * + * FT_Stroker_New + * FT_Stroker_Set + * FT_Stroker_Rewind + * FT_Stroker_ParseOutline + * FT_Stroker_Done + * + * FT_Stroker_BeginSubPath + * FT_Stroker_EndSubPath + * + * FT_Stroker_LineTo + * FT_Stroker_ConicTo + * FT_Stroker_CubicTo + * + * FT_Stroker_GetBorderCounts + * FT_Stroker_ExportBorder + * FT_Stroker_GetCounts + * FT_Stroker_Export + * + */ + + + /************************************************************** + * + * @type: + * FT_Stroker + * + * @description: + * Opaque handle to a path stroker object. + */ + typedef struct FT_StrokerRec_* FT_Stroker; + + + /************************************************************** + * + * @enum: + * FT_Stroker_LineJoin + * + * @description: + * These values determine how two joining lines are rendered + * in a stroker. + * + * @values: + * FT_STROKER_LINEJOIN_ROUND :: + * Used to render rounded line joins. Circular arcs are used + * to join two lines smoothly. + * + * FT_STROKER_LINEJOIN_BEVEL :: + * Used to render beveled line joins. The outer corner of + * the joined lines is filled by enclosing the triangular + * region of the corner with a straight line between the + * outer corners of each stroke. + * + * FT_STROKER_LINEJOIN_MITER_FIXED :: + * Used to render mitered line joins, with fixed bevels if the + * miter limit is exceeded. The outer edges of the strokes + * for the two segments are extended until they meet at an + * angle. If the segments meet at too sharp an angle (such + * that the miter would extend from the intersection of the + * segments a distance greater than the product of the miter + * limit value and the border radius), then a bevel join (see + * above) is used instead. This prevents long spikes being + * created. FT_STROKER_LINEJOIN_MITER_FIXED generates a miter + * line join as used in PostScript and PDF. + * + * FT_STROKER_LINEJOIN_MITER_VARIABLE :: + * FT_STROKER_LINEJOIN_MITER :: + * Used to render mitered line joins, with variable bevels if + * the miter limit is exceeded. The intersection of the + * strokes is clipped at a line perpendicular to the bisector + * of the angle between the strokes, at the distance from the + * intersection of the segments equal to the product of the + * miter limit value and the border radius. This prevents + * long spikes being created. + * FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line + * join as used in XPS. FT_STROKER_LINEJOIN_MITER is an alias + * for FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for + * backward compatibility. + */ + typedef enum FT_Stroker_LineJoin_ + { + FT_STROKER_LINEJOIN_ROUND = 0, + FT_STROKER_LINEJOIN_BEVEL = 1, + FT_STROKER_LINEJOIN_MITER_VARIABLE = 2, + FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE, + FT_STROKER_LINEJOIN_MITER_FIXED = 3 + + } FT_Stroker_LineJoin; + + + /************************************************************** + * + * @enum: + * FT_Stroker_LineCap + * + * @description: + * These values determine how the end of opened sub-paths are + * rendered in a stroke. + * + * @values: + * FT_STROKER_LINECAP_BUTT :: + * The end of lines is rendered as a full stop on the last + * point itself. + * + * FT_STROKER_LINECAP_ROUND :: + * The end of lines is rendered as a half-circle around the + * last point. + * + * FT_STROKER_LINECAP_SQUARE :: + * The end of lines is rendered as a square around the + * last point. + */ + typedef enum FT_Stroker_LineCap_ + { + FT_STROKER_LINECAP_BUTT = 0, + FT_STROKER_LINECAP_ROUND, + FT_STROKER_LINECAP_SQUARE + + } FT_Stroker_LineCap; + + + /************************************************************** + * + * @enum: + * FT_StrokerBorder + * + * @description: + * These values are used to select a given stroke border + * in @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder. + * + * @values: + * FT_STROKER_BORDER_LEFT :: + * Select the left border, relative to the drawing direction. + * + * FT_STROKER_BORDER_RIGHT :: + * Select the right border, relative to the drawing direction. + * + * @note: + * Applications are generally interested in the `inside' and `outside' + * borders. However, there is no direct mapping between these and the + * `left' and `right' ones, since this really depends on the glyph's + * drawing orientation, which varies between font formats. + * + * You can however use @FT_Outline_GetInsideBorder and + * @FT_Outline_GetOutsideBorder to get these. + */ + typedef enum FT_StrokerBorder_ + { + FT_STROKER_BORDER_LEFT = 0, + FT_STROKER_BORDER_RIGHT + + } FT_StrokerBorder; + + + /************************************************************** + * + * @function: + * FT_Outline_GetInsideBorder + * + * @description: + * Retrieve the @FT_StrokerBorder value corresponding to the + * `inside' borders of a given outline. + * + * @input: + * outline :: + * The source outline handle. + * + * @return: + * The border index. @FT_STROKER_BORDER_RIGHT for empty or invalid + * outlines. + */ + FT_EXPORT( FT_StrokerBorder ) + FT_Outline_GetInsideBorder( FT_Outline* outline ); + + + /************************************************************** + * + * @function: + * FT_Outline_GetOutsideBorder + * + * @description: + * Retrieve the @FT_StrokerBorder value corresponding to the + * `outside' borders of a given outline. + * + * @input: + * outline :: + * The source outline handle. + * + * @return: + * The border index. @FT_STROKER_BORDER_LEFT for empty or invalid + * outlines. + */ + FT_EXPORT( FT_StrokerBorder ) + FT_Outline_GetOutsideBorder( FT_Outline* outline ); + + + /************************************************************** + * + * @function: + * FT_Stroker_New + * + * @description: + * Create a new stroker object. + * + * @input: + * library :: + * FreeType library handle. + * + * @output: + * astroker :: + * A new stroker object handle. NULL in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_New( FT_Library library, + FT_Stroker *astroker ); + + + /************************************************************** + * + * @function: + * FT_Stroker_Set + * + * @description: + * Reset a stroker object's attributes. + * + * @input: + * stroker :: + * The target stroker handle. + * + * radius :: + * The border radius. + * + * line_cap :: + * The line cap style. + * + * line_join :: + * The line join style. + * + * miter_limit :: + * The miter limit for the FT_STROKER_LINEJOIN_MITER_FIXED and + * FT_STROKER_LINEJOIN_MITER_VARIABLE line join styles, + * expressed as 16.16 fixed-point value. + * + * @note: + * The radius is expressed in the same units as the outline + * coordinates. + * + * This function calls @FT_Stroker_Rewind automatically. + */ + FT_EXPORT( void ) + FT_Stroker_Set( FT_Stroker stroker, + FT_Fixed radius, + FT_Stroker_LineCap line_cap, + FT_Stroker_LineJoin line_join, + FT_Fixed miter_limit ); + + + /************************************************************** + * + * @function: + * FT_Stroker_Rewind + * + * @description: + * Reset a stroker object without changing its attributes. + * You should call this function before beginning a new + * series of calls to @FT_Stroker_BeginSubPath or + * @FT_Stroker_EndSubPath. + * + * @input: + * stroker :: + * The target stroker handle. + */ + FT_EXPORT( void ) + FT_Stroker_Rewind( FT_Stroker stroker ); + + + /************************************************************** + * + * @function: + * FT_Stroker_ParseOutline + * + * @description: + * A convenience function used to parse a whole outline with + * the stroker. The resulting outline(s) can be retrieved + * later by functions like @FT_Stroker_GetCounts and @FT_Stroker_Export. + * + * @input: + * stroker :: + * The target stroker handle. + * + * outline :: + * The source outline. + * + * opened :: + * A boolean. If~1, the outline is treated as an open path instead + * of a closed one. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `opened' is~0 (the default), the outline is treated as a closed + * path, and the stroker generates two distinct `border' outlines. + * + * If `opened' is~1, the outline is processed as an open path, and the + * stroker generates a single `stroke' outline. + * + * This function calls @FT_Stroker_Rewind automatically. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_ParseOutline( FT_Stroker stroker, + FT_Outline* outline, + FT_Bool opened ); + + + /************************************************************** + * + * @function: + * FT_Stroker_BeginSubPath + * + * @description: + * Start a new sub-path in the stroker. + * + * @input: + * stroker :: + * The target stroker handle. + * + * to :: + * A pointer to the start vector. + * + * open :: + * A boolean. If~1, the sub-path is treated as an open one. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function is useful when you need to stroke a path that is + * not stored as an @FT_Outline object. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_BeginSubPath( FT_Stroker stroker, + FT_Vector* to, + FT_Bool open ); + + + /************************************************************** + * + * @function: + * FT_Stroker_EndSubPath + * + * @description: + * Close the current sub-path in the stroker. + * + * @input: + * stroker :: + * The target stroker handle. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function after @FT_Stroker_BeginSubPath. + * If the subpath was not `opened', this function `draws' a + * single line segment to the start position when needed. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_EndSubPath( FT_Stroker stroker ); + + + /************************************************************** + * + * @function: + * FT_Stroker_LineTo + * + * @description: + * `Draw' a single line segment in the stroker's current sub-path, + * from the last position. + * + * @input: + * stroker :: + * The target stroker handle. + * + * to :: + * A pointer to the destination point. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function between @FT_Stroker_BeginSubPath and + * @FT_Stroker_EndSubPath. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_LineTo( FT_Stroker stroker, + FT_Vector* to ); + + + /************************************************************** + * + * @function: + * FT_Stroker_ConicTo + * + * @description: + * `Draw' a single quadratic Bezier in the stroker's current sub-path, + * from the last position. + * + * @input: + * stroker :: + * The target stroker handle. + * + * control :: + * A pointer to a Bezier control point. + * + * to :: + * A pointer to the destination point. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function between @FT_Stroker_BeginSubPath and + * @FT_Stroker_EndSubPath. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_ConicTo( FT_Stroker stroker, + FT_Vector* control, + FT_Vector* to ); + + + /************************************************************** + * + * @function: + * FT_Stroker_CubicTo + * + * @description: + * `Draw' a single cubic Bezier in the stroker's current sub-path, + * from the last position. + * + * @input: + * stroker :: + * The target stroker handle. + * + * control1 :: + * A pointer to the first Bezier control point. + * + * control2 :: + * A pointer to second Bezier control point. + * + * to :: + * A pointer to the destination point. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function between @FT_Stroker_BeginSubPath and + * @FT_Stroker_EndSubPath. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_CubicTo( FT_Stroker stroker, + FT_Vector* control1, + FT_Vector* control2, + FT_Vector* to ); + + + /************************************************************** + * + * @function: + * FT_Stroker_GetBorderCounts + * + * @description: + * Call this function once you have finished parsing your paths + * with the stroker. It returns the number of points and + * contours necessary to export one of the `border' or `stroke' + * outlines generated by the stroker. + * + * @input: + * stroker :: + * The target stroker handle. + * + * border :: + * The border index. + * + * @output: + * anum_points :: + * The number of points. + * + * anum_contours :: + * The number of contours. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * When an outline, or a sub-path, is `closed', the stroker generates + * two independent `border' outlines, named `left' and `right'. + * + * When the outline, or a sub-path, is `opened', the stroker merges + * the `border' outlines with caps. The `left' border receives all + * points, while the `right' border becomes empty. + * + * Use the function @FT_Stroker_GetCounts instead if you want to + * retrieve the counts associated to both borders. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_GetBorderCounts( FT_Stroker stroker, + FT_StrokerBorder border, + FT_UInt *anum_points, + FT_UInt *anum_contours ); + + + /************************************************************** + * + * @function: + * FT_Stroker_ExportBorder + * + * @description: + * Call this function after @FT_Stroker_GetBorderCounts to + * export the corresponding border to your own @FT_Outline + * structure. + * + * Note that this function appends the border points and + * contours to your outline, but does not try to resize its + * arrays. + * + * @input: + * stroker :: + * The target stroker handle. + * + * border :: + * The border index. + * + * outline :: + * The target outline handle. + * + * @note: + * Always call this function after @FT_Stroker_GetBorderCounts to + * get sure that there is enough room in your @FT_Outline object to + * receive all new data. + * + * When an outline, or a sub-path, is `closed', the stroker generates + * two independent `border' outlines, named `left' and `right'. + * + * When the outline, or a sub-path, is `opened', the stroker merges + * the `border' outlines with caps. The `left' border receives all + * points, while the `right' border becomes empty. + * + * Use the function @FT_Stroker_Export instead if you want to + * retrieve all borders at once. + */ + FT_EXPORT( void ) + FT_Stroker_ExportBorder( FT_Stroker stroker, + FT_StrokerBorder border, + FT_Outline* outline ); + + + /************************************************************** + * + * @function: + * FT_Stroker_GetCounts + * + * @description: + * Call this function once you have finished parsing your paths + * with the stroker. It returns the number of points and + * contours necessary to export all points/borders from the stroked + * outline/path. + * + * @input: + * stroker :: + * The target stroker handle. + * + * @output: + * anum_points :: + * The number of points. + * + * anum_contours :: + * The number of contours. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_GetCounts( FT_Stroker stroker, + FT_UInt *anum_points, + FT_UInt *anum_contours ); + + + /************************************************************** + * + * @function: + * FT_Stroker_Export + * + * @description: + * Call this function after @FT_Stroker_GetBorderCounts to + * export all borders to your own @FT_Outline structure. + * + * Note that this function appends the border points and + * contours to your outline, but does not try to resize its + * arrays. + * + * @input: + * stroker :: + * The target stroker handle. + * + * outline :: + * The target outline handle. + */ + FT_EXPORT( void ) + FT_Stroker_Export( FT_Stroker stroker, + FT_Outline* outline ); + + + /************************************************************** + * + * @function: + * FT_Stroker_Done + * + * @description: + * Destroy a stroker object. + * + * @input: + * stroker :: + * A stroker handle. Can be NULL. + */ + FT_EXPORT( void ) + FT_Stroker_Done( FT_Stroker stroker ); + + + /************************************************************** + * + * @function: + * FT_Glyph_Stroke + * + * @description: + * Stroke a given outline glyph object with a given stroker. + * + * @inout: + * pglyph :: + * Source glyph handle on input, new glyph handle on output. + * + * @input: + * stroker :: + * A stroker handle. + * + * destroy :: + * A Boolean. If~1, the source glyph object is destroyed + * on success. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source glyph is untouched in case of error. + * + * Adding stroke may yield a significantly wider and taller glyph + * depending on how large of a radius was used to stroke the glyph. You + * may need to manually adjust horizontal and vertical advance amounts + * to account for this added size. + */ + FT_EXPORT( FT_Error ) + FT_Glyph_Stroke( FT_Glyph *pglyph, + FT_Stroker stroker, + FT_Bool destroy ); + + + /************************************************************** + * + * @function: + * FT_Glyph_StrokeBorder + * + * @description: + * Stroke a given outline glyph object with a given stroker, but + * only return either its inside or outside border. + * + * @inout: + * pglyph :: + * Source glyph handle on input, new glyph handle on output. + * + * @input: + * stroker :: + * A stroker handle. + * + * inside :: + * A Boolean. If~1, return the inside border, otherwise + * the outside border. + * + * destroy :: + * A Boolean. If~1, the source glyph object is destroyed + * on success. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source glyph is untouched in case of error. + * + * Adding stroke may yield a significantly wider and taller glyph + * depending on how large of a radius was used to stroke the glyph. You + * may need to manually adjust horizontal and vertical advance amounts + * to account for this added size. + */ + FT_EXPORT( FT_Error ) + FT_Glyph_StrokeBorder( FT_Glyph *pglyph, + FT_Stroker stroker, + FT_Bool inside, + FT_Bool destroy ); + + /* */ + +FT_END_HEADER + +#endif /* FTSTROKE_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftsynth.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftsynth.h new file mode 100644 index 0000000..ff9fb43 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftsynth.h @@ -0,0 +1,84 @@ +/***************************************************************************/ +/* */ +/* ftsynth.h */ +/* */ +/* FreeType synthesizing code for emboldening and slanting */ +/* (specification). */ +/* */ +/* Copyright 2000-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /********* *********/ + /********* WARNING, THIS IS ALPHA CODE! THIS API *********/ + /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/ + /********* FREETYPE DEVELOPMENT TEAM *********/ + /********* *********/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /* Main reason for not lifting the functions in this module to a */ + /* `standard' API is that the used parameters for emboldening and */ + /* slanting are not configurable. Consider the functions as a */ + /* code resource that should be copied into the application and */ + /* adapted to the particular needs. */ + + +#ifndef FTSYNTH_H_ +#define FTSYNTH_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /* Embolden a glyph by a `reasonable' value (which is highly a matter of */ + /* taste). This function is actually a convenience function, providing */ + /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */ + /* */ + /* For emboldened outlines the height, width, and advance metrics are */ + /* increased by the strength of the emboldening -- this even affects */ + /* mono-width fonts! */ + /* */ + /* You can also call @FT_Outline_Get_CBox to get precise values. */ + FT_EXPORT( void ) + FT_GlyphSlot_Embolden( FT_GlyphSlot slot ); + + /* Slant an outline glyph to the right by about 12 degrees. */ + FT_EXPORT( void ) + FT_GlyphSlot_Oblique( FT_GlyphSlot slot ); + + /* */ + + +FT_END_HEADER + +#endif /* FTSYNTH_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftsystem.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftsystem.h new file mode 100644 index 0000000..f6b1629 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftsystem.h @@ -0,0 +1,355 @@ +/***************************************************************************/ +/* */ +/* ftsystem.h */ +/* */ +/* FreeType low-level system interface definition (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTSYSTEM_H_ +#define FTSYSTEM_H_ + + +#include <ft2build.h> + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* system_interface */ + /* */ + /* <Title> */ + /* System Interface */ + /* */ + /* <Abstract> */ + /* How FreeType manages memory and i/o. */ + /* */ + /* <Description> */ + /* This section contains various definitions related to memory */ + /* management and i/o access. You need to understand this */ + /* information if you want to use a custom memory manager or you own */ + /* i/o streams. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* M E M O R Y M A N A G E M E N T */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @type: + * FT_Memory + * + * @description: + * A handle to a given memory manager object, defined with an + * @FT_MemoryRec structure. + * + */ + typedef struct FT_MemoryRec_* FT_Memory; + + + /************************************************************************* + * + * @functype: + * FT_Alloc_Func + * + * @description: + * A function used to allocate `size' bytes from `memory'. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * size :: + * The size in bytes to allocate. + * + * @return: + * Address of new memory block. 0~in case of failure. + * + */ + typedef void* + (*FT_Alloc_Func)( FT_Memory memory, + long size ); + + + /************************************************************************* + * + * @functype: + * FT_Free_Func + * + * @description: + * A function used to release a given block of memory. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * block :: + * The address of the target memory block. + * + */ + typedef void + (*FT_Free_Func)( FT_Memory memory, + void* block ); + + + /************************************************************************* + * + * @functype: + * FT_Realloc_Func + * + * @description: + * A function used to re-allocate a given block of memory. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * cur_size :: + * The block's current size in bytes. + * + * new_size :: + * The block's requested new size. + * + * block :: + * The block's current address. + * + * @return: + * New block address. 0~in case of memory shortage. + * + * @note: + * In case of error, the old block must still be available. + * + */ + typedef void* + (*FT_Realloc_Func)( FT_Memory memory, + long cur_size, + long new_size, + void* block ); + + + /************************************************************************* + * + * @struct: + * FT_MemoryRec + * + * @description: + * A structure used to describe a given memory manager to FreeType~2. + * + * @fields: + * user :: + * A generic typeless pointer for user data. + * + * alloc :: + * A pointer type to an allocation function. + * + * free :: + * A pointer type to an memory freeing function. + * + * realloc :: + * A pointer type to a reallocation function. + * + */ + struct FT_MemoryRec_ + { + void* user; + FT_Alloc_Func alloc; + FT_Free_Func free; + FT_Realloc_Func realloc; + }; + + + /*************************************************************************/ + /* */ + /* I / O M A N A G E M E N T */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @type: + * FT_Stream + * + * @description: + * A handle to an input stream. + * + * @also: + * See @FT_StreamRec for the publicly accessible fields of a given + * stream object. + * + */ + typedef struct FT_StreamRec_* FT_Stream; + + + /************************************************************************* + * + * @struct: + * FT_StreamDesc + * + * @description: + * A union type used to store either a long or a pointer. This is used + * to store a file descriptor or a `FILE*' in an input stream. + * + */ + typedef union FT_StreamDesc_ + { + long value; + void* pointer; + + } FT_StreamDesc; + + + /************************************************************************* + * + * @functype: + * FT_Stream_IoFunc + * + * @description: + * A function used to seek and read data from a given input stream. + * + * @input: + * stream :: + * A handle to the source stream. + * + * offset :: + * The offset of read in stream (always from start). + * + * buffer :: + * The address of the read buffer. + * + * count :: + * The number of bytes to read from the stream. + * + * @return: + * The number of bytes effectively read by the stream. + * + * @note: + * This function might be called to perform a seek or skip operation + * with a `count' of~0. A non-zero return value then indicates an + * error. + * + */ + typedef unsigned long + (*FT_Stream_IoFunc)( FT_Stream stream, + unsigned long offset, + unsigned char* buffer, + unsigned long count ); + + + /************************************************************************* + * + * @functype: + * FT_Stream_CloseFunc + * + * @description: + * A function used to close a given input stream. + * + * @input: + * stream :: + * A handle to the target stream. + * + */ + typedef void + (*FT_Stream_CloseFunc)( FT_Stream stream ); + + + /************************************************************************* + * + * @struct: + * FT_StreamRec + * + * @description: + * A structure used to describe an input stream. + * + * @input: + * base :: + * For memory-based streams, this is the address of the first stream + * byte in memory. This field should always be set to NULL for + * disk-based streams. + * + * size :: + * The stream size in bytes. + * + * In case of compressed streams where the size is unknown before + * actually doing the decompression, the value is set to 0x7FFFFFFF. + * (Note that this size value can occur for normal streams also; it is + * thus just a hint.) + * + * pos :: + * The current position within the stream. + * + * descriptor :: + * This field is a union that can hold an integer or a pointer. It is + * used by stream implementations to store file descriptors or `FILE*' + * pointers. + * + * pathname :: + * This field is completely ignored by FreeType. However, it is often + * useful during debugging to use it to store the stream's filename + * (where available). + * + * read :: + * The stream's input function. + * + * close :: + * The stream's close function. + * + * memory :: + * The memory manager to use to preload frames. This is set + * internally by FreeType and shouldn't be touched by stream + * implementations. + * + * cursor :: + * This field is set and used internally by FreeType when parsing + * frames. + * + * limit :: + * This field is set and used internally by FreeType when parsing + * frames. + * + */ + typedef struct FT_StreamRec_ + { + unsigned char* base; + unsigned long size; + unsigned long pos; + + FT_StreamDesc descriptor; + FT_StreamDesc pathname; + FT_Stream_IoFunc read; + FT_Stream_CloseFunc close; + + FT_Memory memory; + unsigned char* cursor; + unsigned char* limit; + + } FT_StreamRec; + + /* */ + + +FT_END_HEADER + +#endif /* FTSYSTEM_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/fttrigon.h b/src_v2/libs/sloth/freetype/freetype2/freetype/fttrigon.h new file mode 100644 index 0000000..2e3f3f1 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/fttrigon.h @@ -0,0 +1,350 @@ +/***************************************************************************/ +/* */ +/* fttrigon.h */ +/* */ +/* FreeType trigonometric functions (specification). */ +/* */ +/* Copyright 2001-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTTRIGON_H_ +#define FTTRIGON_H_ + +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* computations */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @type: + * FT_Angle + * + * @description: + * This type is used to model angle values in FreeType. Note that the + * angle is a 16.16 fixed-point value expressed in degrees. + * + */ + typedef FT_Fixed FT_Angle; + + + /************************************************************************* + * + * @macro: + * FT_ANGLE_PI + * + * @description: + * The angle pi expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_PI ( 180L << 16 ) + + + /************************************************************************* + * + * @macro: + * FT_ANGLE_2PI + * + * @description: + * The angle 2*pi expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) + + + /************************************************************************* + * + * @macro: + * FT_ANGLE_PI2 + * + * @description: + * The angle pi/2 expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) + + + /************************************************************************* + * + * @macro: + * FT_ANGLE_PI4 + * + * @description: + * The angle pi/4 expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) + + + /************************************************************************* + * + * @function: + * FT_Sin + * + * @description: + * Return the sinus of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The sinus value. + * + * @note: + * If you need both the sinus and cosinus for a given angle, use the + * function @FT_Vector_Unit. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Sin( FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * FT_Cos + * + * @description: + * Return the cosinus of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The cosinus value. + * + * @note: + * If you need both the sinus and cosinus for a given angle, use the + * function @FT_Vector_Unit. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Cos( FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * FT_Tan + * + * @description: + * Return the tangent of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The tangent value. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Tan( FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * FT_Atan2 + * + * @description: + * Return the arc-tangent corresponding to a given vector (x,y) in + * the 2d plane. + * + * @input: + * x :: + * The horizontal vector coordinate. + * + * y :: + * The vertical vector coordinate. + * + * @return: + * The arc-tangent value (i.e. angle). + * + */ + FT_EXPORT( FT_Angle ) + FT_Atan2( FT_Fixed x, + FT_Fixed y ); + + + /************************************************************************* + * + * @function: + * FT_Angle_Diff + * + * @description: + * Return the difference between two angles. The result is always + * constrained to the ]-PI..PI] interval. + * + * @input: + * angle1 :: + * First angle. + * + * angle2 :: + * Second angle. + * + * @return: + * Constrained value of `value2-value1'. + * + */ + FT_EXPORT( FT_Angle ) + FT_Angle_Diff( FT_Angle angle1, + FT_Angle angle2 ); + + + /************************************************************************* + * + * @function: + * FT_Vector_Unit + * + * @description: + * Return the unit vector corresponding to a given angle. After the + * call, the value of `vec.x' will be `cos(angle)', and the value of + * `vec.y' will be `sin(angle)'. + * + * This function is useful to retrieve both the sinus and cosinus of a + * given angle quickly. + * + * @output: + * vec :: + * The address of target vector. + * + * @input: + * angle :: + * The input angle. + * + */ + FT_EXPORT( void ) + FT_Vector_Unit( FT_Vector* vec, + FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * FT_Vector_Rotate + * + * @description: + * Rotate a vector by a given angle. + * + * @inout: + * vec :: + * The address of target vector. + * + * @input: + * angle :: + * The input angle. + * + */ + FT_EXPORT( void ) + FT_Vector_Rotate( FT_Vector* vec, + FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * FT_Vector_Length + * + * @description: + * Return the length of a given vector. + * + * @input: + * vec :: + * The address of target vector. + * + * @return: + * The vector length, expressed in the same units that the original + * vector coordinates. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Vector_Length( FT_Vector* vec ); + + + /************************************************************************* + * + * @function: + * FT_Vector_Polarize + * + * @description: + * Compute both the length and angle of a given vector. + * + * @input: + * vec :: + * The address of source vector. + * + * @output: + * length :: + * The vector length. + * + * angle :: + * The vector angle. + * + */ + FT_EXPORT( void ) + FT_Vector_Polarize( FT_Vector* vec, + FT_Fixed *length, + FT_Angle *angle ); + + + /************************************************************************* + * + * @function: + * FT_Vector_From_Polar + * + * @description: + * Compute vector coordinates from a length and angle. + * + * @output: + * vec :: + * The address of source vector. + * + * @input: + * length :: + * The vector length. + * + * angle :: + * The vector angle. + * + */ + FT_EXPORT( void ) + FT_Vector_From_Polar( FT_Vector* vec, + FT_Fixed length, + FT_Angle angle ); + + /* */ + + +FT_END_HEADER + +#endif /* FTTRIGON_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/fttypes.h b/src_v2/libs/sloth/freetype/freetype2/freetype/fttypes.h new file mode 100644 index 0000000..f638c2e --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/fttypes.h @@ -0,0 +1,602 @@ +/***************************************************************************/ +/* */ +/* fttypes.h */ +/* */ +/* FreeType simple types definitions (specification only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTTYPES_H_ +#define FTTYPES_H_ + + +#include <ft2build.h> +#include FT_CONFIG_CONFIG_H +#include FT_SYSTEM_H +#include FT_IMAGE_H + +#include <stddef.h> + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* basic_types */ + /* */ + /* <Title> */ + /* Basic Data Types */ + /* */ + /* <Abstract> */ + /* The basic data types defined by the library. */ + /* */ + /* <Description> */ + /* This section contains the basic data types defined by FreeType~2, */ + /* ranging from simple scalar types to bitmap descriptors. More */ + /* font-specific structures are defined in a different section. */ + /* */ + /* <Order> */ + /* FT_Byte */ + /* FT_Bytes */ + /* FT_Char */ + /* FT_Int */ + /* FT_UInt */ + /* FT_Int16 */ + /* FT_UInt16 */ + /* FT_Int32 */ + /* FT_UInt32 */ + /* FT_Int64 */ + /* FT_UInt64 */ + /* FT_Short */ + /* FT_UShort */ + /* FT_Long */ + /* FT_ULong */ + /* FT_Bool */ + /* FT_Offset */ + /* FT_PtrDist */ + /* FT_String */ + /* FT_Tag */ + /* FT_Error */ + /* FT_Fixed */ + /* FT_Pointer */ + /* FT_Pos */ + /* FT_Vector */ + /* FT_BBox */ + /* FT_Matrix */ + /* FT_FWord */ + /* FT_UFWord */ + /* FT_F2Dot14 */ + /* FT_UnitVector */ + /* FT_F26Dot6 */ + /* FT_Data */ + /* */ + /* FT_MAKE_TAG */ + /* */ + /* FT_Generic */ + /* FT_Generic_Finalizer */ + /* */ + /* FT_Bitmap */ + /* FT_Pixel_Mode */ + /* FT_Palette_Mode */ + /* FT_Glyph_Format */ + /* FT_IMAGE_TAG */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Bool */ + /* */ + /* <Description> */ + /* A typedef of unsigned char, used for simple booleans. As usual, */ + /* values 1 and~0 represent true and false, respectively. */ + /* */ + typedef unsigned char FT_Bool; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_FWord */ + /* */ + /* <Description> */ + /* A signed 16-bit integer used to store a distance in original font */ + /* units. */ + /* */ + typedef signed short FT_FWord; /* distance in FUnits */ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_UFWord */ + /* */ + /* <Description> */ + /* An unsigned 16-bit integer used to store a distance in original */ + /* font units. */ + /* */ + typedef unsigned short FT_UFWord; /* unsigned distance */ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Char */ + /* */ + /* <Description> */ + /* A simple typedef for the _signed_ char type. */ + /* */ + typedef signed char FT_Char; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Byte */ + /* */ + /* <Description> */ + /* A simple typedef for the _unsigned_ char type. */ + /* */ + typedef unsigned char FT_Byte; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Bytes */ + /* */ + /* <Description> */ + /* A typedef for constant memory areas. */ + /* */ + typedef const FT_Byte* FT_Bytes; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Tag */ + /* */ + /* <Description> */ + /* A typedef for 32-bit tags (as used in the SFNT format). */ + /* */ + typedef FT_UInt32 FT_Tag; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_String */ + /* */ + /* <Description> */ + /* A simple typedef for the char type, usually used for strings. */ + /* */ + typedef char FT_String; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Short */ + /* */ + /* <Description> */ + /* A typedef for signed short. */ + /* */ + typedef signed short FT_Short; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_UShort */ + /* */ + /* <Description> */ + /* A typedef for unsigned short. */ + /* */ + typedef unsigned short FT_UShort; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Int */ + /* */ + /* <Description> */ + /* A typedef for the int type. */ + /* */ + typedef signed int FT_Int; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_UInt */ + /* */ + /* <Description> */ + /* A typedef for the unsigned int type. */ + /* */ + typedef unsigned int FT_UInt; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Long */ + /* */ + /* <Description> */ + /* A typedef for signed long. */ + /* */ + typedef signed long FT_Long; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_ULong */ + /* */ + /* <Description> */ + /* A typedef for unsigned long. */ + /* */ + typedef unsigned long FT_ULong; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_F2Dot14 */ + /* */ + /* <Description> */ + /* A signed 2.14 fixed-point type used for unit vectors. */ + /* */ + typedef signed short FT_F2Dot14; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_F26Dot6 */ + /* */ + /* <Description> */ + /* A signed 26.6 fixed-point type used for vectorial pixel */ + /* coordinates. */ + /* */ + typedef signed long FT_F26Dot6; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Fixed */ + /* */ + /* <Description> */ + /* This type is used to store 16.16 fixed-point values, like scaling */ + /* values or matrix coefficients. */ + /* */ + typedef signed long FT_Fixed; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Error */ + /* */ + /* <Description> */ + /* The FreeType error code type. A value of~0 is always interpreted */ + /* as a successful operation. */ + /* */ + typedef int FT_Error; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Pointer */ + /* */ + /* <Description> */ + /* A simple typedef for a typeless pointer. */ + /* */ + typedef void* FT_Pointer; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_Offset */ + /* */ + /* <Description> */ + /* This is equivalent to the ANSI~C `size_t' type, i.e., the largest */ + /* _unsigned_ integer type used to express a file size or position, */ + /* or a memory block size. */ + /* */ + typedef size_t FT_Offset; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_PtrDist */ + /* */ + /* <Description> */ + /* This is equivalent to the ANSI~C `ptrdiff_t' type, i.e., the */ + /* largest _signed_ integer type used to express the distance */ + /* between two pointers. */ + /* */ + typedef ft_ptrdiff_t FT_PtrDist; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_UnitVector */ + /* */ + /* <Description> */ + /* A simple structure used to store a 2D vector unit vector. Uses */ + /* FT_F2Dot14 types. */ + /* */ + /* <Fields> */ + /* x :: Horizontal coordinate. */ + /* */ + /* y :: Vertical coordinate. */ + /* */ + typedef struct FT_UnitVector_ + { + FT_F2Dot14 x; + FT_F2Dot14 y; + + } FT_UnitVector; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Matrix */ + /* */ + /* <Description> */ + /* A simple structure used to store a 2x2 matrix. Coefficients are */ + /* in 16.16 fixed-point format. The computation performed is: */ + /* */ + /* { */ + /* x' = x*xx + y*xy */ + /* y' = x*yx + y*yy */ + /* } */ + /* */ + /* <Fields> */ + /* xx :: Matrix coefficient. */ + /* */ + /* xy :: Matrix coefficient. */ + /* */ + /* yx :: Matrix coefficient. */ + /* */ + /* yy :: Matrix coefficient. */ + /* */ + typedef struct FT_Matrix_ + { + FT_Fixed xx, xy; + FT_Fixed yx, yy; + + } FT_Matrix; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Data */ + /* */ + /* <Description> */ + /* Read-only binary data represented as a pointer and a length. */ + /* */ + /* <Fields> */ + /* pointer :: The data. */ + /* */ + /* length :: The length of the data in bytes. */ + /* */ + typedef struct FT_Data_ + { + const FT_Byte* pointer; + FT_Int length; + + } FT_Data; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Generic_Finalizer */ + /* */ + /* <Description> */ + /* Describe a function used to destroy the `client' data of any */ + /* FreeType object. See the description of the @FT_Generic type for */ + /* details of usage. */ + /* */ + /* <Input> */ + /* The address of the FreeType object that is under finalization. */ + /* Its client data is accessed through its `generic' field. */ + /* */ + typedef void (*FT_Generic_Finalizer)( void* object ); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Generic */ + /* */ + /* <Description> */ + /* Client applications often need to associate their own data to a */ + /* variety of FreeType core objects. For example, a text layout API */ + /* might want to associate a glyph cache to a given size object. */ + /* */ + /* Some FreeType object contains a `generic' field, of type */ + /* FT_Generic, which usage is left to client applications and font */ + /* servers. */ + /* */ + /* It can be used to store a pointer to client-specific data, as well */ + /* as the address of a `finalizer' function, which will be called by */ + /* FreeType when the object is destroyed (for example, the previous */ + /* client example would put the address of the glyph cache destructor */ + /* in the `finalizer' field). */ + /* */ + /* <Fields> */ + /* data :: A typeless pointer to any client-specified data. This */ + /* field is completely ignored by the FreeType library. */ + /* */ + /* finalizer :: A pointer to a `generic finalizer' function, which */ + /* will be called when the object is destroyed. If this */ + /* field is set to NULL, no code will be called. */ + /* */ + typedef struct FT_Generic_ + { + void* data; + FT_Generic_Finalizer finalizer; + + } FT_Generic; + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_MAKE_TAG */ + /* */ + /* <Description> */ + /* This macro converts four-letter tags that are used to label */ + /* TrueType tables into an unsigned long, to be used within FreeType. */ + /* */ + /* <Note> */ + /* The produced values *must* be 32-bit integers. Don't redefine */ + /* this macro. */ + /* */ +#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ + (FT_Tag) \ + ( ( (FT_ULong)_x1 << 24 ) | \ + ( (FT_ULong)_x2 << 16 ) | \ + ( (FT_ULong)_x3 << 8 ) | \ + (FT_ULong)_x4 ) + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* L I S T M A N A G E M E N T */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* list_processing */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_ListNode */ + /* */ + /* <Description> */ + /* Many elements and objects in FreeType are listed through an */ + /* @FT_List record (see @FT_ListRec). As its name suggests, an */ + /* FT_ListNode is a handle to a single list element. */ + /* */ + typedef struct FT_ListNodeRec_* FT_ListNode; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* FT_List */ + /* */ + /* <Description> */ + /* A handle to a list record (see @FT_ListRec). */ + /* */ + typedef struct FT_ListRec_* FT_List; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_ListNodeRec */ + /* */ + /* <Description> */ + /* A structure used to hold a single list element. */ + /* */ + /* <Fields> */ + /* prev :: The previous element in the list. NULL if first. */ + /* */ + /* next :: The next element in the list. NULL if last. */ + /* */ + /* data :: A typeless pointer to the listed object. */ + /* */ + typedef struct FT_ListNodeRec_ + { + FT_ListNode prev; + FT_ListNode next; + void* data; + + } FT_ListNodeRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_ListRec */ + /* */ + /* <Description> */ + /* A structure used to hold a simple doubly-linked list. These are */ + /* used in many parts of FreeType. */ + /* */ + /* <Fields> */ + /* head :: The head (first element) of doubly-linked list. */ + /* */ + /* tail :: The tail (last element) of doubly-linked list. */ + /* */ + typedef struct FT_ListRec_ + { + FT_ListNode head; + FT_ListNode tail; + + } FT_ListRec; + + /* */ + + +#define FT_IS_EMPTY( list ) ( (list).head == 0 ) +#define FT_BOOL( x ) ( (FT_Bool)( x ) ) + + /* concatenate C tokens */ +#define FT_ERR_XCAT( x, y ) x ## y +#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) + + /* see `ftmoderr.h' for descriptions of the following macros */ + +#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) + +#define FT_ERROR_BASE( x ) ( (x) & 0xFF ) +#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U ) + +#define FT_ERR_EQ( x, e ) \ + ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) ) +#define FT_ERR_NEQ( x, e ) \ + ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) ) + + +FT_END_HEADER + +#endif /* FTTYPES_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ftwinfnt.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ftwinfnt.h new file mode 100644 index 0000000..461c65b --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ftwinfnt.h @@ -0,0 +1,275 @@ +/***************************************************************************/ +/* */ +/* ftwinfnt.h */ +/* */ +/* FreeType API for accessing Windows fnt-specific data. */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTWINFNT_H_ +#define FTWINFNT_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* winfnt_fonts */ + /* */ + /* <Title> */ + /* Window FNT Files */ + /* */ + /* <Abstract> */ + /* Windows FNT specific API. */ + /* */ + /* <Description> */ + /* This section contains the declaration of Windows FNT specific */ + /* functions. */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @enum: + * FT_WinFNT_ID_XXX + * + * @description: + * A list of valid values for the `charset' byte in + * @FT_WinFNT_HeaderRec. Exact mapping tables for the various cpXXXX + * encodings (except for cp1361) can be found at + * ftp://ftp.unicode.org/Public in the MAPPINGS/VENDORS/MICSFT/WINDOWS + * subdirectory. cp1361 is roughly a superset of + * MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT. + * + * @values: + * FT_WinFNT_ID_DEFAULT :: + * This is used for font enumeration and font creation as a + * `don't care' value. Valid font files don't contain this value. + * When querying for information about the character set of the font + * that is currently selected into a specified device context, this + * return value (of the related Windows API) simply denotes failure. + * + * FT_WinFNT_ID_SYMBOL :: + * There is no known mapping table available. + * + * FT_WinFNT_ID_MAC :: + * Mac Roman encoding. + * + * FT_WinFNT_ID_OEM :: + * From Michael Poettgen <michael@poettgen.de>: + * + * The `Windows Font Mapping' article says that FT_WinFNT_ID_OEM + * is used for the charset of vector fonts, like `modern.fon', + * `roman.fon', and `script.fon' on Windows. + * + * The `CreateFont' documentation says: The FT_WinFNT_ID_OEM value + * specifies a character set that is operating-system dependent. + * + * The `IFIMETRICS' documentation from the `Windows Driver + * Development Kit' says: This font supports an OEM-specific + * character set. The OEM character set is system dependent. + * + * In general OEM, as opposed to ANSI (i.e., cp1252), denotes the + * second default codepage that most international versions of + * Windows have. It is one of the OEM codepages from + * + * https://msdn.microsoft.com/en-us/goglobal/bb964655, + * + * and is used for the `DOS boxes', to support legacy applications. + * A German Windows version for example usually uses ANSI codepage + * 1252 and OEM codepage 850. + * + * FT_WinFNT_ID_CP874 :: + * A superset of Thai TIS 620 and ISO 8859-11. + * + * FT_WinFNT_ID_CP932 :: + * A superset of Japanese Shift-JIS (with minor deviations). + * + * FT_WinFNT_ID_CP936 :: + * A superset of simplified Chinese GB 2312-1980 (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP949 :: + * A superset of Korean Hangul KS~C 5601-1987 (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP950 :: + * A superset of traditional Chinese Big~5 ETen (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP1250 :: + * A superset of East European ISO 8859-2 (with slightly different + * ordering). + * + * FT_WinFNT_ID_CP1251 :: + * A superset of Russian ISO 8859-5 (with different ordering). + * + * FT_WinFNT_ID_CP1252 :: + * ANSI encoding. A superset of ISO 8859-1. + * + * FT_WinFNT_ID_CP1253 :: + * A superset of Greek ISO 8859-7 (with minor modifications). + * + * FT_WinFNT_ID_CP1254 :: + * A superset of Turkish ISO 8859-9. + * + * FT_WinFNT_ID_CP1255 :: + * A superset of Hebrew ISO 8859-8 (with some modifications). + * + * FT_WinFNT_ID_CP1256 :: + * A superset of Arabic ISO 8859-6 (with different ordering). + * + * FT_WinFNT_ID_CP1257 :: + * A superset of Baltic ISO 8859-13 (with some deviations). + * + * FT_WinFNT_ID_CP1258 :: + * For Vietnamese. This encoding doesn't cover all necessary + * characters. + * + * FT_WinFNT_ID_CP1361 :: + * Korean (Johab). + */ + +#define FT_WinFNT_ID_CP1252 0 +#define FT_WinFNT_ID_DEFAULT 1 +#define FT_WinFNT_ID_SYMBOL 2 +#define FT_WinFNT_ID_MAC 77 +#define FT_WinFNT_ID_CP932 128 +#define FT_WinFNT_ID_CP949 129 +#define FT_WinFNT_ID_CP1361 130 +#define FT_WinFNT_ID_CP936 134 +#define FT_WinFNT_ID_CP950 136 +#define FT_WinFNT_ID_CP1253 161 +#define FT_WinFNT_ID_CP1254 162 +#define FT_WinFNT_ID_CP1258 163 +#define FT_WinFNT_ID_CP1255 177 +#define FT_WinFNT_ID_CP1256 178 +#define FT_WinFNT_ID_CP1257 186 +#define FT_WinFNT_ID_CP1251 204 +#define FT_WinFNT_ID_CP874 222 +#define FT_WinFNT_ID_CP1250 238 +#define FT_WinFNT_ID_OEM 255 + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_WinFNT_HeaderRec */ + /* */ + /* <Description> */ + /* Windows FNT Header info. */ + /* */ + typedef struct FT_WinFNT_HeaderRec_ + { + FT_UShort version; + FT_ULong file_size; + FT_Byte copyright[60]; + FT_UShort file_type; + FT_UShort nominal_point_size; + FT_UShort vertical_resolution; + FT_UShort horizontal_resolution; + FT_UShort ascent; + FT_UShort internal_leading; + FT_UShort external_leading; + FT_Byte italic; + FT_Byte underline; + FT_Byte strike_out; + FT_UShort weight; + FT_Byte charset; + FT_UShort pixel_width; + FT_UShort pixel_height; + FT_Byte pitch_and_family; + FT_UShort avg_width; + FT_UShort max_width; + FT_Byte first_char; + FT_Byte last_char; + FT_Byte default_char; + FT_Byte break_char; + FT_UShort bytes_per_row; + FT_ULong device_offset; + FT_ULong face_name_offset; + FT_ULong bits_pointer; + FT_ULong bits_offset; + FT_Byte reserved; + FT_ULong flags; + FT_UShort A_space; + FT_UShort B_space; + FT_UShort C_space; + FT_UShort color_table_offset; + FT_ULong reserved1[4]; + + } FT_WinFNT_HeaderRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_WinFNT_Header */ + /* */ + /* <Description> */ + /* A handle to an @FT_WinFNT_HeaderRec structure. */ + /* */ + typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header; + + + /********************************************************************** + * + * @function: + * FT_Get_WinFNT_Header + * + * @description: + * Retrieve a Windows FNT font info header. + * + * @input: + * face :: A handle to the input face. + * + * @output: + * aheader :: The WinFNT header. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with Windows FNT faces, returning an error + * otherwise. + */ + FT_EXPORT( FT_Error ) + FT_Get_WinFNT_Header( FT_Face face, + FT_WinFNT_HeaderRec *aheader ); + + /* */ + + +FT_END_HEADER + +#endif /* FTWINFNT_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/autohint.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/autohint.h new file mode 100644 index 0000000..f4d308f --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/autohint.h @@ -0,0 +1,244 @@ +/***************************************************************************/ +/* */ +/* autohint.h */ +/* */ +/* High-level `autohint' module-specific interface (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* The auto-hinter is used to load and automatically hint glyphs if a */ + /* format-specific hinter isn't available. */ + /* */ + /*************************************************************************/ + + +#ifndef AUTOHINT_H_ +#define AUTOHINT_H_ + + + /*************************************************************************/ + /* */ + /* A small technical note regarding automatic hinting in order to */ + /* clarify this module interface. */ + /* */ + /* An automatic hinter might compute two kinds of data for a given face: */ + /* */ + /* - global hints: Usually some metrics that describe global properties */ + /* of the face. It is computed by scanning more or less */ + /* aggressively the glyphs in the face, and thus can be */ + /* very slow to compute (even if the size of global */ + /* hints is really small). */ + /* */ + /* - glyph hints: These describe some important features of the glyph */ + /* outline, as well as how to align them. They are */ + /* generally much faster to compute than global hints. */ + /* */ + /* The current FreeType auto-hinter does a pretty good job while */ + /* performing fast computations for both global and glyph hints. */ + /* However, we might be interested in introducing more complex and */ + /* powerful algorithms in the future, like the one described in the John */ + /* D. Hobby paper, which unfortunately requires a lot more horsepower. */ + /* */ + /* Because a sufficiently sophisticated font management system would */ + /* typically implement an LRU cache of opened face objects to reduce */ + /* memory usage, it is a good idea to be able to avoid recomputing */ + /* global hints every time the same face is re-opened. */ + /* */ + /* We thus provide the ability to cache global hints outside of the face */ + /* object, in order to speed up font re-opening time. Of course, this */ + /* feature is purely optional, so most client programs won't even notice */ + /* it. */ + /* */ + /* I initially thought that it would be a good idea to cache the glyph */ + /* hints too. However, my general idea now is that if you really need */ + /* to cache these too, you are simply in need of a new font format, */ + /* where all this information could be stored within the font file and */ + /* decoded on the fly. */ + /* */ + /*************************************************************************/ + + +#include <ft2build.h> +#include FT_FREETYPE_H + + +FT_BEGIN_HEADER + + + typedef struct FT_AutoHinterRec_ *FT_AutoHinter; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_AutoHinter_GlobalGetFunc */ + /* */ + /* <Description> */ + /* Retrieve the global hints computed for a given face object. The */ + /* resulting data is dissociated from the face and will survive a */ + /* call to FT_Done_Face(). It must be discarded through the API */ + /* FT_AutoHinter_GlobalDoneFunc(). */ + /* */ + /* <Input> */ + /* hinter :: A handle to the source auto-hinter. */ + /* */ + /* face :: A handle to the source face object. */ + /* */ + /* <Output> */ + /* global_hints :: A typeless pointer to the global hints. */ + /* */ + /* global_len :: The size in bytes of the global hints. */ + /* */ + typedef void + (*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter hinter, + FT_Face face, + void** global_hints, + long* global_len ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_AutoHinter_GlobalDoneFunc */ + /* */ + /* <Description> */ + /* Discard the global hints retrieved through */ + /* FT_AutoHinter_GlobalGetFunc(). This is the only way these hints */ + /* are freed from memory. */ + /* */ + /* <Input> */ + /* hinter :: A handle to the auto-hinter module. */ + /* */ + /* global :: A pointer to retrieved global hints to discard. */ + /* */ + typedef void + (*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter hinter, + void* global ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_AutoHinter_GlobalResetFunc */ + /* */ + /* <Description> */ + /* This function is used to recompute the global metrics in a given */ + /* font. This is useful when global font data changes (e.g. Multiple */ + /* Masters fonts where blend coordinates change). */ + /* */ + /* <Input> */ + /* hinter :: A handle to the source auto-hinter. */ + /* */ + /* face :: A handle to the face. */ + /* */ + typedef void + (*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter hinter, + FT_Face face ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_AutoHinter_GlyphLoadFunc */ + /* */ + /* <Description> */ + /* This function is used to load, scale, and automatically hint a */ + /* glyph from a given face. */ + /* */ + /* <Input> */ + /* face :: A handle to the face. */ + /* */ + /* glyph_index :: The glyph index. */ + /* */ + /* load_flags :: The load flags. */ + /* */ + /* <Note> */ + /* This function is capable of loading composite glyphs by hinting */ + /* each sub-glyph independently (which improves quality). */ + /* */ + /* It will call the font driver with @FT_Load_Glyph, with */ + /* @FT_LOAD_NO_SCALE set. */ + /* */ + typedef FT_Error + (*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter hinter, + FT_GlyphSlot slot, + FT_Size size, + FT_UInt glyph_index, + FT_Int32 load_flags ); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_AutoHinter_InterfaceRec */ + /* */ + /* <Description> */ + /* The auto-hinter module's interface. */ + /* */ + typedef struct FT_AutoHinter_InterfaceRec_ + { + FT_AutoHinter_GlobalResetFunc reset_face; + FT_AutoHinter_GlobalGetFunc get_global_hints; + FT_AutoHinter_GlobalDoneFunc done_global_hints; + FT_AutoHinter_GlyphLoadFunc load_glyph; + + } FT_AutoHinter_InterfaceRec, *FT_AutoHinter_Interface; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_AUTOHINTER_INTERFACE( \ + class_, \ + reset_face_, \ + get_global_hints_, \ + done_global_hints_, \ + load_glyph_ ) \ + FT_CALLBACK_TABLE_DEF \ + const FT_AutoHinter_InterfaceRec class_ = \ + { \ + reset_face_, \ + get_global_hints_, \ + done_global_hints_, \ + load_glyph_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_AUTOHINTER_INTERFACE( \ + class_, \ + reset_face_, \ + get_global_hints_, \ + done_global_hints_, \ + load_glyph_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + FT_AutoHinter_InterfaceRec* clazz ) \ + { \ + FT_UNUSED( library ); \ + \ + clazz->reset_face = reset_face_; \ + clazz->get_global_hints = get_global_hints_; \ + clazz->done_global_hints = done_global_hints_; \ + clazz->load_glyph = load_glyph_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + +FT_END_HEADER + +#endif /* AUTOHINT_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/cffotypes.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/cffotypes.h new file mode 100644 index 0000000..57e7591 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/cffotypes.h @@ -0,0 +1,108 @@ +/***************************************************************************/ +/* */ +/* cffotypes.h */ +/* */ +/* Basic OpenType/CFF object type definitions (specification). */ +/* */ +/* Copyright 2017-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef CFFOTYPES_H_ +#define CFFOTYPES_H_ + +#include <ft2build.h> +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_CFF_TYPES_H +#include FT_INTERNAL_TRUETYPE_TYPES_H +#include FT_SERVICE_POSTSCRIPT_CMAPS_H +#include FT_INTERNAL_POSTSCRIPT_HINTS_H + + +FT_BEGIN_HEADER + + + typedef TT_Face CFF_Face; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* CFF_Size */ + /* */ + /* <Description> */ + /* A handle to an OpenType size object. */ + /* */ + typedef struct CFF_SizeRec_ + { + FT_SizeRec root; + FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */ + + } CFF_SizeRec, *CFF_Size; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* CFF_GlyphSlot */ + /* */ + /* <Description> */ + /* A handle to an OpenType glyph slot object. */ + /* */ + typedef struct CFF_GlyphSlotRec_ + { + FT_GlyphSlotRec root; + + FT_Bool hint; + FT_Bool scaled; + + FT_Fixed x_scale; + FT_Fixed y_scale; + + } CFF_GlyphSlotRec, *CFF_GlyphSlot; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* CFF_Internal */ + /* */ + /* <Description> */ + /* The interface to the `internal' field of `FT_Size'. */ + /* */ + typedef struct CFF_InternalRec_ + { + PSH_Globals topfont; + PSH_Globals subfonts[CFF_MAX_CID_FONTS]; + + } CFF_InternalRec, *CFF_Internal; + + + /*************************************************************************/ + /* */ + /* Subglyph transformation record. */ + /* */ + typedef struct CFF_Transform_ + { + FT_Fixed xx, xy; /* transformation matrix coefficients */ + FT_Fixed yx, yy; + FT_F26Dot6 ox, oy; /* offsets */ + + } CFF_Transform; + + +FT_END_HEADER + + +#endif /* CFFOTYPES_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/cfftypes.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/cfftypes.h new file mode 100644 index 0000000..7c07e1a --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/cfftypes.h @@ -0,0 +1,412 @@ +/***************************************************************************/ +/* */ +/* cfftypes.h */ +/* */ +/* Basic OpenType/CFF type definitions and interface (specification */ +/* only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef CFFTYPES_H_ +#define CFFTYPES_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_TYPE1_TABLES_H +#include FT_INTERNAL_SERVICE_H +#include FT_SERVICE_POSTSCRIPT_CMAPS_H +#include FT_INTERNAL_POSTSCRIPT_HINTS_H +#include FT_INTERNAL_TYPE1_TYPES_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CFF_IndexRec */ + /* */ + /* <Description> */ + /* A structure used to model a CFF Index table. */ + /* */ + /* <Fields> */ + /* stream :: The source input stream. */ + /* */ + /* start :: The position of the first index byte in the */ + /* input stream. */ + /* */ + /* count :: The number of elements in the index. */ + /* */ + /* off_size :: The size in bytes of object offsets in index. */ + /* */ + /* data_offset :: The position of first data byte in the index's */ + /* bytes. */ + /* */ + /* data_size :: The size of the data table in this index. */ + /* */ + /* offsets :: A table of element offsets in the index. Must be */ + /* loaded explicitly. */ + /* */ + /* bytes :: If the index is loaded in memory, its bytes. */ + /* */ + typedef struct CFF_IndexRec_ + { + FT_Stream stream; + FT_ULong start; + FT_UInt hdr_size; + FT_UInt count; + FT_Byte off_size; + FT_ULong data_offset; + FT_ULong data_size; + + FT_ULong* offsets; + FT_Byte* bytes; + + } CFF_IndexRec, *CFF_Index; + + + typedef struct CFF_EncodingRec_ + { + FT_UInt format; + FT_ULong offset; + + FT_UInt count; + FT_UShort sids [256]; /* avoid dynamic allocations */ + FT_UShort codes[256]; + + } CFF_EncodingRec, *CFF_Encoding; + + + typedef struct CFF_CharsetRec_ + { + + FT_UInt format; + FT_ULong offset; + + FT_UShort* sids; + FT_UShort* cids; /* the inverse mapping of `sids'; only needed */ + /* for CID-keyed fonts */ + FT_UInt max_cid; + FT_UInt num_glyphs; + + } CFF_CharsetRec, *CFF_Charset; + + + /* cf. similar fields in file `ttgxvar.h' from the `truetype' module */ + + typedef struct CFF_VarData_ + { +#if 0 + FT_UInt itemCount; /* not used; always zero */ + FT_UInt shortDeltaCount; /* not used; always zero */ +#endif + + FT_UInt regionIdxCount; /* number of region indexes */ + FT_UInt* regionIndices; /* array of `regionIdxCount' indices; */ + /* these index `varRegionList' */ + } CFF_VarData; + + + /* contribution of one axis to a region */ + typedef struct CFF_AxisCoords_ + { + FT_Fixed startCoord; + FT_Fixed peakCoord; /* zero peak means no effect (factor = 1) */ + FT_Fixed endCoord; + + } CFF_AxisCoords; + + + typedef struct CFF_VarRegion_ + { + CFF_AxisCoords* axisList; /* array of axisCount records */ + + } CFF_VarRegion; + + + typedef struct CFF_VStoreRec_ + { + FT_UInt dataCount; + CFF_VarData* varData; /* array of dataCount records */ + /* vsindex indexes this array */ + FT_UShort axisCount; + FT_UInt regionCount; /* total number of regions defined */ + CFF_VarRegion* varRegionList; + + } CFF_VStoreRec, *CFF_VStore; + + + /* forward reference */ + typedef struct CFF_FontRec_* CFF_Font; + + + /* This object manages one cached blend vector. */ + /* */ + /* There is a BlendRec for Private DICT parsing in each subfont */ + /* and a BlendRec for charstrings in CF2_Font instance data. */ + /* A cached BV may be used across DICTs or Charstrings if inputs */ + /* have not changed. */ + /* */ + /* `usedBV' is reset at the start of each parse or charstring. */ + /* vsindex cannot be changed after a BV is used. */ + /* */ + /* Note: NDV is long (32/64 bit), while BV is 16.16 (FT_Int32). */ + typedef struct CFF_BlendRec_ + { + FT_Bool builtBV; /* blendV has been built */ + FT_Bool usedBV; /* blendV has been used */ + CFF_Font font; /* top level font struct */ + FT_UInt lastVsindex; /* last vsindex used */ + FT_UInt lenNDV; /* normDV length (aka numAxes) */ + FT_Fixed* lastNDV; /* last NDV used */ + FT_UInt lenBV; /* BlendV length (aka numMasters) */ + FT_Int32* BV; /* current blendV (per DICT/glyph) */ + + } CFF_BlendRec, *CFF_Blend; + + + typedef struct CFF_FontRecDictRec_ + { + FT_UInt version; + FT_UInt notice; + FT_UInt copyright; + FT_UInt full_name; + FT_UInt family_name; + FT_UInt weight; + FT_Bool is_fixed_pitch; + FT_Fixed italic_angle; + FT_Fixed underline_position; + FT_Fixed underline_thickness; + FT_Int paint_type; + FT_Int charstring_type; + FT_Matrix font_matrix; + FT_Bool has_font_matrix; + FT_ULong units_per_em; /* temporarily used as scaling value also */ + FT_Vector font_offset; + FT_ULong unique_id; + FT_BBox font_bbox; + FT_Pos stroke_width; + FT_ULong charset_offset; + FT_ULong encoding_offset; + FT_ULong charstrings_offset; + FT_ULong private_offset; + FT_ULong private_size; + FT_Long synthetic_base; + FT_UInt embedded_postscript; + + /* these should only be used for the top-level font dictionary */ + FT_UInt cid_registry; + FT_UInt cid_ordering; + FT_Long cid_supplement; + + FT_Long cid_font_version; + FT_Long cid_font_revision; + FT_Long cid_font_type; + FT_ULong cid_count; + FT_ULong cid_uid_base; + FT_ULong cid_fd_array_offset; + FT_ULong cid_fd_select_offset; + FT_UInt cid_font_name; + + /* the next fields come from the data of the deprecated */ + /* `MultipleMaster' operator; they are needed to parse the (also */ + /* deprecated) `blend' operator in Type 2 charstrings */ + FT_UShort num_designs; + FT_UShort num_axes; + + /* fields for CFF2 */ + FT_ULong vstore_offset; + FT_UInt maxstack; + + } CFF_FontRecDictRec, *CFF_FontRecDict; + + + /* forward reference */ + typedef struct CFF_SubFontRec_* CFF_SubFont; + + + typedef struct CFF_PrivateRec_ + { + FT_Byte num_blue_values; + FT_Byte num_other_blues; + FT_Byte num_family_blues; + FT_Byte num_family_other_blues; + + FT_Pos blue_values[14]; + FT_Pos other_blues[10]; + FT_Pos family_blues[14]; + FT_Pos family_other_blues[10]; + + FT_Fixed blue_scale; + FT_Pos blue_shift; + FT_Pos blue_fuzz; + FT_Pos standard_width; + FT_Pos standard_height; + + FT_Byte num_snap_widths; + FT_Byte num_snap_heights; + FT_Pos snap_widths[13]; + FT_Pos snap_heights[13]; + FT_Bool force_bold; + FT_Fixed force_bold_threshold; + FT_Int lenIV; + FT_Int language_group; + FT_Fixed expansion_factor; + FT_Long initial_random_seed; + FT_ULong local_subrs_offset; + FT_Pos default_width; + FT_Pos nominal_width; + + /* fields for CFF2 */ + FT_UInt vsindex; + CFF_SubFont subfont; + + } CFF_PrivateRec, *CFF_Private; + + + typedef struct CFF_FDSelectRec_ + { + FT_Byte format; + FT_UInt range_count; + + /* that's the table, taken from the file `as is' */ + FT_Byte* data; + FT_UInt data_size; + + /* small cache for format 3 only */ + FT_UInt cache_first; + FT_UInt cache_count; + FT_Byte cache_fd; + + } CFF_FDSelectRec, *CFF_FDSelect; + + + /* A SubFont packs a font dict and a private dict together. They are */ + /* needed to support CID-keyed CFF fonts. */ + typedef struct CFF_SubFontRec_ + { + CFF_FontRecDictRec font_dict; + CFF_PrivateRec private_dict; + + /* fields for CFF2 */ + CFF_BlendRec blend; /* current blend vector */ + FT_UInt lenNDV; /* current length NDV or zero */ + FT_Fixed* NDV; /* ptr to current NDV or NULL */ + + /* `blend_stack' is a writable buffer to hold blend results. */ + /* This buffer is to the side of the normal cff parser stack; */ + /* `cff_parse_blend' and `cff_blend_doBlend' push blend results here. */ + /* The normal stack then points to these values instead of the DICT */ + /* because all other operators in Private DICT clear the stack. */ + /* `blend_stack' could be cleared at each operator other than blend. */ + /* Blended values are stored as 5-byte fixed point values. */ + + FT_Byte* blend_stack; /* base of stack allocation */ + FT_Byte* blend_top; /* first empty slot */ + FT_UInt blend_used; /* number of bytes in use */ + FT_UInt blend_alloc; /* number of bytes allocated */ + + CFF_IndexRec local_subrs_index; + FT_Byte** local_subrs; /* array of pointers */ + /* into Local Subrs INDEX data */ + + FT_UInt32 random; + + } CFF_SubFontRec; + + +#define CFF_MAX_CID_FONTS 256 + + + typedef struct CFF_FontRec_ + { + FT_Library library; + FT_Stream stream; + FT_Memory memory; /* TODO: take this from stream->memory? */ + FT_ULong base_offset; /* offset to start of CFF */ + FT_UInt num_faces; + FT_UInt num_glyphs; + + FT_Byte version_major; + FT_Byte version_minor; + FT_Byte header_size; + + FT_UInt top_dict_length; /* cff2 only */ + + FT_Bool cff2; + + CFF_IndexRec name_index; + CFF_IndexRec top_dict_index; + CFF_IndexRec global_subrs_index; + + CFF_EncodingRec encoding; + CFF_CharsetRec charset; + + CFF_IndexRec charstrings_index; + CFF_IndexRec font_dict_index; + CFF_IndexRec private_index; + CFF_IndexRec local_subrs_index; + + FT_String* font_name; + + /* array of pointers into Global Subrs INDEX data */ + FT_Byte** global_subrs; + + /* array of pointers into String INDEX data stored at string_pool */ + FT_UInt num_strings; + FT_Byte** strings; + FT_Byte* string_pool; + FT_ULong string_pool_size; + + CFF_SubFontRec top_font; + FT_UInt num_subfonts; + CFF_SubFont subfonts[CFF_MAX_CID_FONTS]; + + CFF_FDSelectRec fd_select; + + /* interface to PostScript hinter */ + PSHinter_Service pshinter; + + /* interface to Postscript Names service */ + FT_Service_PsCMaps psnames; + + /* interface to CFFLoad service */ + const void* cffload; + + /* since version 2.3.0 */ + PS_FontInfoRec* font_info; /* font info dictionary */ + + /* since version 2.3.6 */ + FT_String* registry; + FT_String* ordering; + + /* since version 2.4.12 */ + FT_Generic cf2_instance; + + /* since version 2.7.1 */ + CFF_VStoreRec vstore; /* parsed vstore structure */ + + /* since version 2.9 */ + PS_FontExtraRec* font_extra; + + } CFF_FontRec; + + +FT_END_HEADER + +#endif /* CFFTYPES_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftcalc.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftcalc.h new file mode 100644 index 0000000..818a812 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftcalc.h @@ -0,0 +1,444 @@ +/***************************************************************************/ +/* */ +/* ftcalc.h */ +/* */ +/* Arithmetic computations (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTCALC_H_ +#define FTCALC_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */ + /* */ + /*************************************************************************/ + +#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER + /* Provide assembler fragments for performance-critical functions. */ + /* These must be defined `static __inline__' with GCC. */ + +#if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */ + +#define FT_MULFIX_ASSEMBLER FT_MulFix_arm + + /* documentation is in freetype.h */ + + static __inline FT_Int32 + FT_MulFix_arm( FT_Int32 a, + FT_Int32 b ) + { + FT_Int32 t, t2; + + + __asm + { + smull t2, t, b, a /* (lo=t2,hi=t) = a*b */ + mov a, t, asr #31 /* a = (hi >> 31) */ + add a, a, #0x8000 /* a += 0x8000 */ + adds t2, t2, a /* t2 += a */ + adc t, t, #0 /* t += carry */ + mov a, t2, lsr #16 /* a = t2 >> 16 */ + orr a, a, t, lsl #16 /* a |= t << 16 */ + } + return a; + } + +#endif /* __CC_ARM || __ARMCC__ */ + + +#ifdef __GNUC__ + +#if defined( __arm__ ) && \ + ( !defined( __thumb__ ) || defined( __thumb2__ ) ) && \ + !( defined( __CC_ARM ) || defined( __ARMCC__ ) ) + +#define FT_MULFIX_ASSEMBLER FT_MulFix_arm + + /* documentation is in freetype.h */ + + static __inline__ FT_Int32 + FT_MulFix_arm( FT_Int32 a, + FT_Int32 b ) + { + FT_Int32 t, t2; + + + __asm__ __volatile__ ( + "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */ + "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */ +#if defined( __clang__ ) && defined( __thumb2__ ) + "add.w %0, %0, #0x8000\n\t" /* %0 += 0x8000 */ +#else + "add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */ +#endif + "adds %1, %1, %0\n\t" /* %1 += %0 */ + "adc %2, %2, #0\n\t" /* %2 += carry */ + "mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */ + "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */ + : "=r"(a), "=&r"(t2), "=&r"(t) + : "r"(a), "r"(b) + : "cc" ); + return a; + } + +#endif /* __arm__ && */ + /* ( __thumb2__ || !__thumb__ ) && */ + /* !( __CC_ARM || __ARMCC__ ) */ + + +#if defined( __i386__ ) + +#define FT_MULFIX_ASSEMBLER FT_MulFix_i386 + + /* documentation is in freetype.h */ + + static __inline__ FT_Int32 + FT_MulFix_i386( FT_Int32 a, + FT_Int32 b ) + { + FT_Int32 result; + + + __asm__ __volatile__ ( + "imul %%edx\n" + "movl %%edx, %%ecx\n" + "sarl $31, %%ecx\n" + "addl $0x8000, %%ecx\n" + "addl %%ecx, %%eax\n" + "adcl $0, %%edx\n" + "shrl $16, %%eax\n" + "shll $16, %%edx\n" + "addl %%edx, %%eax\n" + : "=a"(result), "=d"(b) + : "a"(a), "d"(b) + : "%ecx", "cc" ); + return result; + } + +#endif /* i386 */ + +#endif /* __GNUC__ */ + + +#ifdef _MSC_VER /* Visual C++ */ + +#ifdef _M_IX86 + +#define FT_MULFIX_ASSEMBLER FT_MulFix_i386 + + /* documentation is in freetype.h */ + + static __inline FT_Int32 + FT_MulFix_i386( FT_Int32 a, + FT_Int32 b ) + { + FT_Int32 result; + + __asm + { + mov eax, a + mov edx, b + imul edx + mov ecx, edx + sar ecx, 31 + add ecx, 8000h + add eax, ecx + adc edx, 0 + shr eax, 16 + shl edx, 16 + add eax, edx + mov result, eax + } + return result; + } + +#endif /* _M_IX86 */ + +#endif /* _MSC_VER */ + + +#if defined( __GNUC__ ) && defined( __x86_64__ ) + +#define FT_MULFIX_ASSEMBLER FT_MulFix_x86_64 + + static __inline__ FT_Int32 + FT_MulFix_x86_64( FT_Int32 a, + FT_Int32 b ) + { + /* Temporarily disable the warning that C90 doesn't support */ + /* `long long'. */ +#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wlong-long" +#endif + +#if 1 + /* Technically not an assembly fragment, but GCC does a really good */ + /* job at inlining it and generating good machine code for it. */ + long long ret, tmp; + + + ret = (long long)a * b; + tmp = ret >> 63; + ret += 0x8000 + tmp; + + return (FT_Int32)( ret >> 16 ); +#else + + /* For some reason, GCC 4.6 on Ubuntu 12.04 generates invalid machine */ + /* code from the lines below. The main issue is that `wide_a' is not */ + /* properly initialized by sign-extending `a'. Instead, the generated */ + /* machine code assumes that the register that contains `a' on input */ + /* can be used directly as a 64-bit value, which is wrong most of the */ + /* time. */ + long long wide_a = (long long)a; + long long wide_b = (long long)b; + long long result; + + + __asm__ __volatile__ ( + "imul %2, %1\n" + "mov %1, %0\n" + "sar $63, %0\n" + "lea 0x8000(%1, %0), %0\n" + "sar $16, %0\n" + : "=&r"(result), "=&r"(wide_a) + : "r"(wide_b) + : "cc" ); + + return (FT_Int32)result; +#endif + +#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 ) +#pragma GCC diagnostic pop +#endif + } + +#endif /* __GNUC__ && __x86_64__ */ + +#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */ + + +#ifdef FT_CONFIG_OPTION_INLINE_MULFIX +#ifdef FT_MULFIX_ASSEMBLER +#define FT_MulFix( a, b ) FT_MULFIX_ASSEMBLER( (FT_Int32)(a), (FT_Int32)(b) ) +#endif +#endif + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_MulDiv_No_Round */ + /* */ + /* <Description> */ + /* A very simple function used to perform the computation `(a*b)/c' */ + /* (without rounding) with maximum accuracy (it uses a 64-bit */ + /* intermediate integer whenever necessary). */ + /* */ + /* This function isn't necessarily as fast as some processor specific */ + /* operations, but is at least completely portable. */ + /* */ + /* <Input> */ + /* a :: The first multiplier. */ + /* b :: The second multiplier. */ + /* c :: The divisor. */ + /* */ + /* <Return> */ + /* The result of `(a*b)/c'. This function never traps when trying to */ + /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ + /* on the signs of `a' and `b'. */ + /* */ + FT_BASE( FT_Long ) + FT_MulDiv_No_Round( FT_Long a, + FT_Long b, + FT_Long c ); + + + /* + * A variant of FT_Matrix_Multiply which scales its result afterwards. + * The idea is that both `a' and `b' are scaled by factors of 10 so that + * the values are as precise as possible to get a correct result during + * the 64bit multiplication. Let `sa' and `sb' be the scaling factors of + * `a' and `b', respectively, then the scaling factor of the result is + * `sa*sb'. + */ + FT_BASE( void ) + FT_Matrix_Multiply_Scaled( const FT_Matrix* a, + FT_Matrix *b, + FT_Long scaling ); + + + /* + * A variant of FT_Vector_Transform. See comments for + * FT_Matrix_Multiply_Scaled. + */ + FT_BASE( void ) + FT_Vector_Transform_Scaled( FT_Vector* vector, + const FT_Matrix* matrix, + FT_Long scaling ); + + + /* + * This function normalizes a vector and returns its original length. + * The normalized vector is a 16.16 fixed-point unit vector with length + * close to 0x10000. The accuracy of the returned length is limited to + * 16 bits also. The function utilizes quick inverse square root + * approximation without divisions and square roots relying on Newton's + * iterations instead. + */ + FT_BASE( FT_UInt32 ) + FT_Vector_NormLen( FT_Vector* vector ); + + + /* + * Return -1, 0, or +1, depending on the orientation of a given corner. + * We use the Cartesian coordinate system, with positive vertical values + * going upwards. The function returns +1 if the corner turns to the + * left, -1 to the right, and 0 for undecidable cases. + */ + FT_BASE( FT_Int ) + ft_corner_orientation( FT_Pos in_x, + FT_Pos in_y, + FT_Pos out_x, + FT_Pos out_y ); + + + /* + * Return TRUE if a corner is flat or nearly flat. This is equivalent to + * saying that the corner point is close to its neighbors, or inside an + * ellipse defined by the neighbor focal points to be more precise. + */ + FT_BASE( FT_Int ) + ft_corner_is_flat( FT_Pos in_x, + FT_Pos in_y, + FT_Pos out_x, + FT_Pos out_y ); + + + /* + * Return the most significant bit index. + */ + +#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER +#if defined( __GNUC__ ) && \ + ( __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4 ) ) + +#if FT_SIZEOF_INT == 4 + +#define FT_MSB( x ) ( 31 - __builtin_clz( x ) ) + +#elif FT_SIZEOF_LONG == 4 + +#define FT_MSB( x ) ( 31 - __builtin_clzl( x ) ) + +#endif + +#endif /* __GNUC__ */ +#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */ + +#ifndef FT_MSB + + FT_BASE( FT_Int ) + FT_MSB( FT_UInt32 z ); + +#endif + + + /* + * Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses + * two fixed-point arguments instead. + */ + FT_BASE( FT_Fixed ) + FT_Hypot( FT_Fixed x, + FT_Fixed y ); + + +#if 0 + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_SqrtFixed */ + /* */ + /* <Description> */ + /* Computes the square root of a 16.16 fixed-point value. */ + /* */ + /* <Input> */ + /* x :: The value to compute the root for. */ + /* */ + /* <Return> */ + /* The result of `sqrt(x)'. */ + /* */ + /* <Note> */ + /* This function is not very fast. */ + /* */ + FT_BASE( FT_Int32 ) + FT_SqrtFixed( FT_Int32 x ); + +#endif /* 0 */ + + +#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) * 64 ) /* << 6 */ +#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) * 16384 ) /* << 14 */ +#define INT_TO_FIXED( x ) ( (FT_Long)(x) * 65536 ) /* << 16 */ +#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) * 4 ) /* << 2 */ +#define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 ) + +#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \ + : ( -( ( 32 - (x) ) & -64 ) ) ) + + /* + * The following macros have two purposes. + * + * . Tag places where overflow is expected and harmless. + * + * . Avoid run-time sanitizer errors. + * + * Use with care! + */ +#define ADD_LONG( a, b ) \ + (FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) ) +#define SUB_LONG( a, b ) \ + (FT_Long)( (FT_ULong)(a) - (FT_ULong)(b) ) +#define MUL_LONG( a, b ) \ + (FT_Long)( (FT_ULong)(a) * (FT_ULong)(b) ) +#define NEG_LONG( a ) \ + (FT_Long)( (FT_ULong)0 - (FT_ULong)(a) ) + +#define ADD_INT32( a, b ) \ + (FT_Int32)( (FT_UInt32)(a) + (FT_UInt32)(b) ) +#define SUB_INT32( a, b ) \ + (FT_Int32)( (FT_UInt32)(a) - (FT_UInt32)(b) ) +#define MUL_INT32( a, b ) \ + (FT_Int32)( (FT_UInt32)(a) * (FT_UInt32)(b) ) +#define NEG_INT32( a ) \ + (FT_Int32)( (FT_UInt32)0 - (FT_UInt32)(a) ) + + +FT_END_HEADER + +#endif /* FTCALC_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftdebug.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftdebug.h new file mode 100644 index 0000000..292a4ee --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftdebug.h @@ -0,0 +1,255 @@ +/***************************************************************************/ +/* */ +/* ftdebug.h */ +/* */ +/* Debugging and logging component (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/* */ +/* IMPORTANT: A description of FreeType's debugging support can be */ +/* found in `docs/DEBUG.TXT'. Read it if you need to use or */ +/* understand this code. */ +/* */ +/***************************************************************************/ + + +#ifndef FTDEBUG_H_ +#define FTDEBUG_H_ + + +#include <ft2build.h> +#include FT_CONFIG_CONFIG_H +#include FT_FREETYPE_H + + +FT_BEGIN_HEADER + + + /* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */ + /* is already defined; this simplifies the following #ifdefs */ + /* */ +#ifdef FT_DEBUG_LEVEL_TRACE +#undef FT_DEBUG_LEVEL_ERROR +#define FT_DEBUG_LEVEL_ERROR +#endif + + + /*************************************************************************/ + /* */ + /* Define the trace enums as well as the trace levels array when they */ + /* are needed. */ + /* */ + /*************************************************************************/ + +#ifdef FT_DEBUG_LEVEL_TRACE + +#define FT_TRACE_DEF( x ) trace_ ## x , + + /* defining the enumeration */ + typedef enum FT_Trace_ + { +#include FT_INTERNAL_TRACE_H + trace_count + + } FT_Trace; + + + /* defining the array of trace levels, provided by `src/base/ftdebug.c' */ + extern int ft_trace_levels[trace_count]; + +#undef FT_TRACE_DEF + +#endif /* FT_DEBUG_LEVEL_TRACE */ + + + /*************************************************************************/ + /* */ + /* Define the FT_TRACE macro */ + /* */ + /* IMPORTANT! */ + /* */ + /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */ + /* value before using any TRACE macro. */ + /* */ + /*************************************************************************/ + +#ifdef FT_DEBUG_LEVEL_TRACE + +#define FT_TRACE( level, varformat ) \ + do \ + { \ + if ( ft_trace_levels[FT_COMPONENT] >= level ) \ + FT_Message varformat; \ + } while ( 0 ) + +#else /* !FT_DEBUG_LEVEL_TRACE */ + +#define FT_TRACE( level, varformat ) do { } while ( 0 ) /* nothing */ + +#endif /* !FT_DEBUG_LEVEL_TRACE */ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Trace_Get_Count */ + /* */ + /* <Description> */ + /* Return the number of available trace components. */ + /* */ + /* <Return> */ + /* The number of trace components. 0 if FreeType 2 is not built with */ + /* FT_DEBUG_LEVEL_TRACE definition. */ + /* */ + /* <Note> */ + /* This function may be useful if you want to access elements of */ + /* the internal `ft_trace_levels' array by an index. */ + /* */ + FT_BASE( FT_Int ) + FT_Trace_Get_Count( void ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Trace_Get_Name */ + /* */ + /* <Description> */ + /* Return the name of a trace component. */ + /* */ + /* <Input> */ + /* The index of the trace component. */ + /* */ + /* <Return> */ + /* The name of the trace component. This is a statically allocated */ + /* C string, so do not free it after use. NULL if FreeType 2 is not */ + /* built with FT_DEBUG_LEVEL_TRACE definition. */ + /* */ + /* <Note> */ + /* Use @FT_Trace_Get_Count to get the number of available trace */ + /* components. */ + /* */ + /* This function may be useful if you want to control FreeType 2's */ + /* debug level in your application. */ + /* */ + FT_BASE( const char* ) + FT_Trace_Get_Name( FT_Int idx ); + + + /*************************************************************************/ + /* */ + /* You need two opening and closing parentheses! */ + /* */ + /* Example: FT_TRACE0(( "Value is %i", foo )) */ + /* */ + /* Output of the FT_TRACEX macros is sent to stderr. */ + /* */ + /*************************************************************************/ + +#define FT_TRACE0( varformat ) FT_TRACE( 0, varformat ) +#define FT_TRACE1( varformat ) FT_TRACE( 1, varformat ) +#define FT_TRACE2( varformat ) FT_TRACE( 2, varformat ) +#define FT_TRACE3( varformat ) FT_TRACE( 3, varformat ) +#define FT_TRACE4( varformat ) FT_TRACE( 4, varformat ) +#define FT_TRACE5( varformat ) FT_TRACE( 5, varformat ) +#define FT_TRACE6( varformat ) FT_TRACE( 6, varformat ) +#define FT_TRACE7( varformat ) FT_TRACE( 7, varformat ) + + + /*************************************************************************/ + /* */ + /* Define the FT_ERROR macro. */ + /* */ + /* Output of this macro is sent to stderr. */ + /* */ + /*************************************************************************/ + +#ifdef FT_DEBUG_LEVEL_ERROR + +#define FT_ERROR( varformat ) FT_Message varformat + +#else /* !FT_DEBUG_LEVEL_ERROR */ + +#define FT_ERROR( varformat ) do { } while ( 0 ) /* nothing */ + +#endif /* !FT_DEBUG_LEVEL_ERROR */ + + + /*************************************************************************/ + /* */ + /* Define the FT_ASSERT and FT_THROW macros. The call to `FT_Throw' */ + /* makes it possible to easily set a breakpoint at this function. */ + /* */ + /*************************************************************************/ + +#ifdef FT_DEBUG_LEVEL_ERROR + +#define FT_ASSERT( condition ) \ + do \ + { \ + if ( !( condition ) ) \ + FT_Panic( "assertion failed on line %d of file %s\n", \ + __LINE__, __FILE__ ); \ + } while ( 0 ) + +#define FT_THROW( e ) \ + ( FT_Throw( FT_ERR_CAT( FT_ERR_PREFIX, e ), \ + __LINE__, \ + __FILE__ ) | \ + FT_ERR_CAT( FT_ERR_PREFIX, e ) ) + +#else /* !FT_DEBUG_LEVEL_ERROR */ + +#define FT_ASSERT( condition ) do { } while ( 0 ) + +#define FT_THROW( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) + +#endif /* !FT_DEBUG_LEVEL_ERROR */ + + + /*************************************************************************/ + /* */ + /* Define `FT_Message' and `FT_Panic' when needed. */ + /* */ + /*************************************************************************/ + +#ifdef FT_DEBUG_LEVEL_ERROR + +#include "stdio.h" /* for vfprintf() */ + + /* print a message */ + FT_BASE( void ) + FT_Message( const char* fmt, + ... ); + + /* print a message and exit */ + FT_BASE( void ) + FT_Panic( const char* fmt, + ... ); + + /* report file name and line number of an error */ + FT_BASE( int ) + FT_Throw( FT_Error error, + int line, + const char* file ); + +#endif /* FT_DEBUG_LEVEL_ERROR */ + + + FT_BASE( void ) + ft_debug_init( void ); + +FT_END_HEADER + +#endif /* FTDEBUG_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftdrv.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftdrv.h new file mode 100644 index 0000000..58dd35a --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftdrv.h @@ -0,0 +1,400 @@ +/***************************************************************************/ +/* */ +/* ftdrv.h */ +/* */ +/* FreeType internal font driver interface (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTDRV_H_ +#define FTDRV_H_ + + +#include <ft2build.h> +#include FT_MODULE_H + + +FT_BEGIN_HEADER + + + typedef FT_Error + (*FT_Face_InitFunc)( FT_Stream stream, + FT_Face face, + FT_Int typeface_index, + FT_Int num_params, + FT_Parameter* parameters ); + + typedef void + (*FT_Face_DoneFunc)( FT_Face face ); + + + typedef FT_Error + (*FT_Size_InitFunc)( FT_Size size ); + + typedef void + (*FT_Size_DoneFunc)( FT_Size size ); + + + typedef FT_Error + (*FT_Slot_InitFunc)( FT_GlyphSlot slot ); + + typedef void + (*FT_Slot_DoneFunc)( FT_GlyphSlot slot ); + + + typedef FT_Error + (*FT_Size_RequestFunc)( FT_Size size, + FT_Size_Request req ); + + typedef FT_Error + (*FT_Size_SelectFunc)( FT_Size size, + FT_ULong size_index ); + + typedef FT_Error + (*FT_Slot_LoadFunc)( FT_GlyphSlot slot, + FT_Size size, + FT_UInt glyph_index, + FT_Int32 load_flags ); + + + typedef FT_Error + (*FT_Face_GetKerningFunc)( FT_Face face, + FT_UInt left_glyph, + FT_UInt right_glyph, + FT_Vector* kerning ); + + + typedef FT_Error + (*FT_Face_AttachFunc)( FT_Face face, + FT_Stream stream ); + + + typedef FT_Error + (*FT_Face_GetAdvancesFunc)( FT_Face face, + FT_UInt first, + FT_UInt count, + FT_Int32 flags, + FT_Fixed* advances ); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Driver_ClassRec */ + /* */ + /* <Description> */ + /* The font driver class. This structure mostly contains pointers to */ + /* driver methods. */ + /* */ + /* <Fields> */ + /* root :: The parent module. */ + /* */ + /* face_object_size :: The size of a face object in bytes. */ + /* */ + /* size_object_size :: The size of a size object in bytes. */ + /* */ + /* slot_object_size :: The size of a glyph object in bytes. */ + /* */ + /* init_face :: The format-specific face constructor. */ + /* */ + /* done_face :: The format-specific face destructor. */ + /* */ + /* init_size :: The format-specific size constructor. */ + /* */ + /* done_size :: The format-specific size destructor. */ + /* */ + /* init_slot :: The format-specific slot constructor. */ + /* */ + /* done_slot :: The format-specific slot destructor. */ + /* */ + /* */ + /* load_glyph :: A function handle to load a glyph to a slot. */ + /* This field is mandatory! */ + /* */ + /* get_kerning :: A function handle to return the unscaled */ + /* kerning for a given pair of glyphs. Can be */ + /* set to 0 if the format doesn't support */ + /* kerning. */ + /* */ + /* attach_file :: This function handle is used to read */ + /* additional data for a face from another */ + /* file/stream. For example, this can be used to */ + /* add data from AFM or PFM files on a Type 1 */ + /* face, or a CIDMap on a CID-keyed face. */ + /* */ + /* get_advances :: A function handle used to return advance */ + /* widths of `count' glyphs (in font units), */ + /* starting at `first'. The `vertical' flag must */ + /* be set to get vertical advance heights. The */ + /* `advances' buffer is caller-allocated. */ + /* The idea of this function is to be able to */ + /* perform device-independent text layout without */ + /* loading a single glyph image. */ + /* */ + /* request_size :: A handle to a function used to request the new */ + /* character size. Can be set to 0 if the */ + /* scaling done in the base layer suffices. */ + /* */ + /* select_size :: A handle to a function used to select a new */ + /* fixed size. It is used only if */ + /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */ + /* to 0 if the scaling done in the base layer */ + /* suffices. */ + /* <Note> */ + /* Most function pointers, with the exception of `load_glyph', can be */ + /* set to 0 to indicate a default behaviour. */ + /* */ + typedef struct FT_Driver_ClassRec_ + { + FT_Module_Class root; + + FT_Long face_object_size; + FT_Long size_object_size; + FT_Long slot_object_size; + + FT_Face_InitFunc init_face; + FT_Face_DoneFunc done_face; + + FT_Size_InitFunc init_size; + FT_Size_DoneFunc done_size; + + FT_Slot_InitFunc init_slot; + FT_Slot_DoneFunc done_slot; + + FT_Slot_LoadFunc load_glyph; + + FT_Face_GetKerningFunc get_kerning; + FT_Face_AttachFunc attach_file; + FT_Face_GetAdvancesFunc get_advances; + + /* since version 2.2 */ + FT_Size_RequestFunc request_size; + FT_Size_SelectFunc select_size; + + } FT_Driver_ClassRec, *FT_Driver_Class; + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_DECLARE_DRIVER */ + /* */ + /* <Description> */ + /* Used to create a forward declaration of an FT_Driver_ClassRec */ + /* struct instance. */ + /* */ + /* <Macro> */ + /* FT_DEFINE_DRIVER */ + /* */ + /* <Description> */ + /* Used to initialize an instance of FT_Driver_ClassRec struct. */ + /* */ + /* When FT_CONFIG_OPTION_PIC is defined a `create' function has to be */ + /* called with a pointer where the allocated structure is returned. */ + /* And when it is no longer needed a `destroy' function needs to be */ + /* called to release that allocation. */ + /* */ + /* `ftinit.c' (ft_create_default_module_classes) already contains a */ + /* mechanism to call these functions for the default modules */ + /* described in `ftmodule.h'. */ + /* */ + /* Notice that the created `create' and `destroy' functions call */ + /* `pic_init' and `pic_free' to allow you to manually allocate and */ + /* initialize any additional global data, like a module specific */ + /* interface, and put them in the global pic container defined in */ + /* `ftpic.h'. If you don't need them just implement the functions as */ + /* empty to resolve the link error. Also the `pic_init' and */ + /* `pic_free' functions should be declared in `pic.h', to be referred */ + /* by driver definition calling `FT_DEFINE_DRIVER' in following. */ + /* */ + /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ + /* allocated in the global scope (or the scope where the macro is */ + /* used). */ + /* */ +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DECLARE_DRIVER( class_ ) \ + FT_CALLBACK_TABLE \ + const FT_Driver_ClassRec class_; + +#define FT_DEFINE_DRIVER( \ + class_, \ + flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_, \ + face_object_size_, \ + size_object_size_, \ + slot_object_size_, \ + init_face_, \ + done_face_, \ + init_size_, \ + done_size_, \ + init_slot_, \ + done_slot_, \ + load_glyph_, \ + get_kerning_, \ + attach_file_, \ + get_advances_, \ + request_size_, \ + select_size_ ) \ + FT_CALLBACK_TABLE_DEF \ + const FT_Driver_ClassRec class_ = \ + { \ + FT_DEFINE_ROOT_MODULE( flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_ ) \ + \ + face_object_size_, \ + size_object_size_, \ + slot_object_size_, \ + \ + init_face_, \ + done_face_, \ + \ + init_size_, \ + done_size_, \ + \ + init_slot_, \ + done_slot_, \ + \ + load_glyph_, \ + \ + get_kerning_, \ + attach_file_, \ + get_advances_, \ + \ + request_size_, \ + select_size_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DECLARE_DRIVER( class_ ) FT_DECLARE_MODULE( class_ ) + +#define FT_DEFINE_DRIVER( \ + class_, \ + flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_, \ + face_object_size_, \ + size_object_size_, \ + slot_object_size_, \ + init_face_, \ + done_face_, \ + init_size_, \ + done_size_, \ + init_slot_, \ + done_slot_, \ + load_glyph_, \ + get_kerning_, \ + attach_file_, \ + get_advances_, \ + request_size_, \ + select_size_ ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_Module_Class* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \ + \ + \ + class_ ## _pic_free( library ); \ + if ( dclazz ) \ + FT_FREE( dclazz ); \ + } \ + \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_Module_Class** output_class ) \ + { \ + FT_Driver_Class clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ + return error; \ + \ + error = class_ ## _pic_init( library ); \ + if ( error ) \ + { \ + FT_FREE( clazz ); \ + return error; \ + } \ + \ + FT_DEFINE_ROOT_MODULE( flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_ ) \ + \ + clazz->face_object_size = face_object_size_; \ + clazz->size_object_size = size_object_size_; \ + clazz->slot_object_size = slot_object_size_; \ + \ + clazz->init_face = init_face_; \ + clazz->done_face = done_face_; \ + \ + clazz->init_size = init_size_; \ + clazz->done_size = done_size_; \ + \ + clazz->init_slot = init_slot_; \ + clazz->done_slot = done_slot_; \ + \ + clazz->load_glyph = load_glyph_; \ + \ + clazz->get_kerning = get_kerning_; \ + clazz->attach_file = attach_file_; \ + clazz->get_advances = get_advances_; \ + \ + clazz->request_size = request_size_; \ + clazz->select_size = select_size_; \ + \ + *output_class = (FT_Module_Class*)clazz; \ + \ + return FT_Err_Ok; \ + } + + +#endif /* FT_CONFIG_OPTION_PIC */ + +FT_END_HEADER + +#endif /* FTDRV_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftgloadr.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftgloadr.h new file mode 100644 index 0000000..a002fdb --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftgloadr.h @@ -0,0 +1,154 @@ +/***************************************************************************/ +/* */ +/* ftgloadr.h */ +/* */ +/* The FreeType glyph loader (specification). */ +/* */ +/* Copyright 2002-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTGLOADR_H_ +#define FTGLOADR_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_GlyphLoader */ + /* */ + /* <Description> */ + /* The glyph loader is an internal object used to load several glyphs */ + /* together (for example, in the case of composites). */ + /* */ + typedef struct FT_SubGlyphRec_ + { + FT_Int index; + FT_UShort flags; + FT_Int arg1; + FT_Int arg2; + FT_Matrix transform; + + } FT_SubGlyphRec; + + + typedef struct FT_GlyphLoadRec_ + { + FT_Outline outline; /* outline */ + FT_Vector* extra_points; /* extra points table */ + FT_Vector* extra_points2; /* second extra points table */ + FT_UInt num_subglyphs; /* number of subglyphs */ + FT_SubGlyph subglyphs; /* subglyphs */ + + } FT_GlyphLoadRec, *FT_GlyphLoad; + + + typedef struct FT_GlyphLoaderRec_ + { + FT_Memory memory; + FT_UInt max_points; + FT_UInt max_contours; + FT_UInt max_subglyphs; + FT_Bool use_extra; + + FT_GlyphLoadRec base; + FT_GlyphLoadRec current; + + void* other; /* for possible future extension? */ + + } FT_GlyphLoaderRec, *FT_GlyphLoader; + + + /* create new empty glyph loader */ + FT_BASE( FT_Error ) + FT_GlyphLoader_New( FT_Memory memory, + FT_GlyphLoader *aloader ); + + /* add an extra points table to a glyph loader */ + FT_BASE( FT_Error ) + FT_GlyphLoader_CreateExtra( FT_GlyphLoader loader ); + + /* destroy a glyph loader */ + FT_BASE( void ) + FT_GlyphLoader_Done( FT_GlyphLoader loader ); + + /* reset a glyph loader (frees everything int it) */ + FT_BASE( void ) + FT_GlyphLoader_Reset( FT_GlyphLoader loader ); + + /* rewind a glyph loader */ + FT_BASE( void ) + FT_GlyphLoader_Rewind( FT_GlyphLoader loader ); + + /* check that there is enough space to add `n_points' and `n_contours' */ + /* to the glyph loader */ + FT_BASE( FT_Error ) + FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader, + FT_UInt n_points, + FT_UInt n_contours ); + + +#define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \ + ( (_count) == 0 || \ + ( (FT_UInt)(_loader)->base.outline.n_points + \ + (FT_UInt)(_loader)->current.outline.n_points + \ + (FT_UInt)(_count) ) <= (_loader)->max_points ) + +#define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \ + ( (_count) == 0 || \ + ( (FT_UInt)(_loader)->base.outline.n_contours + \ + (FT_UInt)(_loader)->current.outline.n_contours + \ + (FT_UInt)(_count) ) <= (_loader)->max_contours ) + +#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points, _contours ) \ + ( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \ + FT_GLYPHLOADER_CHECK_C( _loader, _contours ) ) \ + ? 0 \ + : FT_GlyphLoader_CheckPoints( (_loader), \ + (FT_UInt)(_points), \ + (FT_UInt)(_contours) ) ) + + + /* check that there is enough space to add `n_subs' sub-glyphs to */ + /* a glyph loader */ + FT_BASE( FT_Error ) + FT_GlyphLoader_CheckSubGlyphs( FT_GlyphLoader loader, + FT_UInt n_subs ); + + /* prepare a glyph loader, i.e. empty the current glyph */ + FT_BASE( void ) + FT_GlyphLoader_Prepare( FT_GlyphLoader loader ); + + /* add the current glyph to the base glyph */ + FT_BASE( void ) + FT_GlyphLoader_Add( FT_GlyphLoader loader ); + + /* copy points from one glyph loader to another */ + FT_BASE( FT_Error ) + FT_GlyphLoader_CopyPoints( FT_GlyphLoader target, + FT_GlyphLoader source ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGLOADR_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/fthash.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/fthash.h new file mode 100644 index 0000000..f22f9d5 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/fthash.h @@ -0,0 +1,136 @@ +/***************************************************************************/ +/* */ +/* fthash.h */ +/* */ +/* Hashing functions (specification). */ +/* */ +/***************************************************************************/ + +/* + * Copyright 2000 Computing Research Labs, New Mexico State University + * Copyright 2001-2015 + * Francesco Zappa Nardelli + * + * 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 COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY 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. + */ + + /*************************************************************************/ + /* */ + /* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 */ + /* */ + /* taken from Mark Leisher's xmbdfed package */ + /* */ + /*************************************************************************/ + + +#ifndef FTHASH_H_ +#define FTHASH_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + + +FT_BEGIN_HEADER + + + typedef union FT_Hashkey_ + { + FT_Int num; + const char* str; + + } FT_Hashkey; + + + typedef struct FT_HashnodeRec_ + { + FT_Hashkey key; + size_t data; + + } FT_HashnodeRec; + + typedef struct FT_HashnodeRec_ *FT_Hashnode; + + + typedef FT_ULong + (*FT_Hash_LookupFunc)( FT_Hashkey* key ); + + typedef FT_Bool + (*FT_Hash_CompareFunc)( FT_Hashkey* a, + FT_Hashkey* b ); + + + typedef struct FT_HashRec_ + { + FT_UInt limit; + FT_UInt size; + FT_UInt used; + + FT_Hash_LookupFunc lookup; + FT_Hash_CompareFunc compare; + + FT_Hashnode* table; + + } FT_HashRec; + + typedef struct FT_HashRec_ *FT_Hash; + + + FT_Error + ft_hash_str_init( FT_Hash hash, + FT_Memory memory ); + + FT_Error + ft_hash_num_init( FT_Hash hash, + FT_Memory memory ); + + void + ft_hash_str_free( FT_Hash hash, + FT_Memory memory ); + +#define ft_hash_num_free ft_hash_str_free + + FT_Error + ft_hash_str_insert( const char* key, + size_t data, + FT_Hash hash, + FT_Memory memory ); + + FT_Error + ft_hash_num_insert( FT_Int num, + size_t data, + FT_Hash hash, + FT_Memory memory ); + + size_t* + ft_hash_str_lookup( const char* key, + FT_Hash hash ); + + size_t* + ft_hash_num_lookup( FT_Int num, + FT_Hash hash ); + + +FT_END_HEADER + + +#endif /* FTHASH_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftmemory.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftmemory.h new file mode 100644 index 0000000..054eaec --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftmemory.h @@ -0,0 +1,393 @@ +/***************************************************************************/ +/* */ +/* ftmemory.h */ +/* */ +/* The FreeType memory management macros (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTMEMORY_H_ +#define FTMEMORY_H_ + + +#include <ft2build.h> +#include FT_CONFIG_CONFIG_H +#include FT_TYPES_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_SET_ERROR */ + /* */ + /* <Description> */ + /* This macro is used to set an implicit `error' variable to a given */ + /* expression's value (usually a function call), and convert it to a */ + /* boolean which is set whenever the value is != 0. */ + /* */ +#undef FT_SET_ERROR +#define FT_SET_ERROR( expression ) \ + ( ( error = (expression) ) != 0 ) + + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** M E M O R Y ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /* + * C++ refuses to handle statements like p = (void*)anything, with `p' a + * typed pointer. Since we don't have a `typeof' operator in standard + * C++, we have to use a template to emulate it. + */ + +#ifdef __cplusplus + +extern "C++" +{ + template <typename T> inline T* + cplusplus_typeof( T*, + void *v ) + { + return static_cast <T*> ( v ); + } +} + +#define FT_ASSIGNP( p, val ) (p) = cplusplus_typeof( (p), (val) ) + +#else + +#define FT_ASSIGNP( p, val ) (p) = (val) + +#endif + + + +#ifdef FT_DEBUG_MEMORY + + FT_BASE( const char* ) _ft_debug_file; + FT_BASE( long ) _ft_debug_lineno; + +#define FT_DEBUG_INNER( exp ) ( _ft_debug_file = __FILE__, \ + _ft_debug_lineno = __LINE__, \ + (exp) ) + +#define FT_ASSIGNP_INNER( p, exp ) ( _ft_debug_file = __FILE__, \ + _ft_debug_lineno = __LINE__, \ + FT_ASSIGNP( p, exp ) ) + +#else /* !FT_DEBUG_MEMORY */ + +#define FT_DEBUG_INNER( exp ) (exp) +#define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp ) + +#endif /* !FT_DEBUG_MEMORY */ + + + /* + * The allocation functions return a pointer, and the error code + * is written to through the `p_error' parameter. + */ + + /* The `q' variants of the functions below (`q' for `quick') don't fill */ + /* the allocated or reallocated memory with zero bytes. */ + + FT_BASE( FT_Pointer ) + ft_mem_alloc( FT_Memory memory, + FT_Long size, + FT_Error *p_error ); + + FT_BASE( FT_Pointer ) + ft_mem_qalloc( FT_Memory memory, + FT_Long size, + FT_Error *p_error ); + + FT_BASE( FT_Pointer ) + ft_mem_realloc( FT_Memory memory, + FT_Long item_size, + FT_Long cur_count, + FT_Long new_count, + void* block, + FT_Error *p_error ); + + FT_BASE( FT_Pointer ) + ft_mem_qrealloc( FT_Memory memory, + FT_Long item_size, + FT_Long cur_count, + FT_Long new_count, + void* block, + FT_Error *p_error ); + + FT_BASE( void ) + ft_mem_free( FT_Memory memory, + const void* P ); + + + /* The `Q' variants of the macros below (`Q' for `quick') don't fill */ + /* the allocated or reallocated memory with zero bytes. */ + +#define FT_MEM_ALLOC( ptr, size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, \ + (FT_Long)(size), \ + &error ) ) + +#define FT_MEM_FREE( ptr ) \ + FT_BEGIN_STMNT \ + ft_mem_free( memory, (ptr) ); \ + (ptr) = NULL; \ + FT_END_STMNT + +#define FT_MEM_NEW( ptr ) \ + FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) ) + +#define FT_MEM_REALLOC( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ + 1, \ + (FT_Long)(cursz), \ + (FT_Long)(newsz), \ + (ptr), \ + &error ) ) + +#define FT_MEM_QALLOC( ptr, size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, \ + (FT_Long)(size), \ + &error ) ) + +#define FT_MEM_QNEW( ptr ) \ + FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) ) + +#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + 1, \ + (FT_Long)(cursz), \ + (FT_Long)(newsz), \ + (ptr), \ + &error ) ) + +#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ + (FT_Long)(item_size), \ + 0, \ + (FT_Long)(count), \ + NULL, \ + &error ) ) + +#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ + (FT_Long)(itmsz), \ + (FT_Long)(oldcnt), \ + (FT_Long)(newcnt), \ + (ptr), \ + &error ) ) + +#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + (FT_Long)(item_size), \ + 0, \ + (FT_Long)(count), \ + NULL, \ + &error ) ) + +#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + (FT_Long)(itmsz), \ + (FT_Long)(oldcnt), \ + (FT_Long)(newcnt), \ + (ptr), \ + &error ) ) + + +#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) + + +#define FT_MEM_SET( dest, byte, count ) \ + ft_memset( dest, byte, (FT_Offset)(count) ) + +#define FT_MEM_COPY( dest, source, count ) \ + ft_memcpy( dest, source, (FT_Offset)(count) ) + +#define FT_MEM_MOVE( dest, source, count ) \ + ft_memmove( dest, source, (FT_Offset)(count) ) + + +#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) + +#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) ) + + +#define FT_ARRAY_ZERO( dest, count ) \ + FT_MEM_ZERO( dest, \ + (FT_Offset)(count) * sizeof ( *(dest) ) ) + +#define FT_ARRAY_COPY( dest, source, count ) \ + FT_MEM_COPY( dest, \ + source, \ + (FT_Offset)(count) * sizeof ( *(dest) ) ) + +#define FT_ARRAY_MOVE( dest, source, count ) \ + FT_MEM_MOVE( dest, \ + source, \ + (FT_Offset)(count) * sizeof ( *(dest) ) ) + + + /* + * Return the maximum number of addressable elements in an array. + * We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid + * any problems. + */ +#define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) ) + +#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) + + + /*************************************************************************/ + /* */ + /* The following functions macros expect that their pointer argument is */ + /* _typed_ in order to automatically compute array element sizes. */ + /* */ + +#define FT_MEM_NEW_ARRAY( ptr, count ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ + sizeof ( *(ptr) ), \ + 0, \ + (FT_Long)(count), \ + NULL, \ + &error ) ) + +#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ + sizeof ( *(ptr) ), \ + (FT_Long)(cursz), \ + (FT_Long)(newsz), \ + (ptr), \ + &error ) ) + +#define FT_MEM_QNEW_ARRAY( ptr, count ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + sizeof ( *(ptr) ), \ + 0, \ + (FT_Long)(count), \ + NULL, \ + &error ) ) + +#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + sizeof ( *(ptr) ), \ + (FT_Long)(cursz), \ + (FT_Long)(newsz), \ + (ptr), \ + &error ) ) + +#define FT_ALLOC( ptr, size ) \ + FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) ) + +#define FT_REALLOC( ptr, cursz, newsz ) \ + FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) ) + +#define FT_ALLOC_MULT( ptr, count, item_size ) \ + FT_MEM_SET_ERROR( FT_MEM_ALLOC_MULT( ptr, count, item_size ) ) + +#define FT_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_MEM_SET_ERROR( FT_MEM_REALLOC_MULT( ptr, oldcnt, \ + newcnt, itmsz ) ) + +#define FT_QALLOC( ptr, size ) \ + FT_MEM_SET_ERROR( FT_MEM_QALLOC( ptr, size ) ) + +#define FT_QREALLOC( ptr, cursz, newsz ) \ + FT_MEM_SET_ERROR( FT_MEM_QREALLOC( ptr, cursz, newsz ) ) + +#define FT_QALLOC_MULT( ptr, count, item_size ) \ + FT_MEM_SET_ERROR( FT_MEM_QALLOC_MULT( ptr, count, item_size ) ) + +#define FT_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_MEM_SET_ERROR( FT_MEM_QREALLOC_MULT( ptr, oldcnt, \ + newcnt, itmsz ) ) + +#define FT_FREE( ptr ) FT_MEM_FREE( ptr ) + +#define FT_NEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_NEW( ptr ) ) + +#define FT_NEW_ARRAY( ptr, count ) \ + FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) + +#define FT_RENEW_ARRAY( ptr, curcnt, newcnt ) \ + FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) + +#define FT_QNEW( ptr ) \ + FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) ) + +#define FT_QNEW_ARRAY( ptr, count ) \ + FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) + +#define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \ + FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) + + + FT_BASE( FT_Pointer ) + ft_mem_strdup( FT_Memory memory, + const char* str, + FT_Error *p_error ); + + FT_BASE( FT_Pointer ) + ft_mem_dup( FT_Memory memory, + const void* address, + FT_ULong size, + FT_Error *p_error ); + + +#define FT_MEM_STRDUP( dst, str ) \ + (dst) = (char*)ft_mem_strdup( memory, (const char*)(str), &error ) + +#define FT_STRDUP( dst, str ) \ + FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) ) + +#define FT_MEM_DUP( dst, address, size ) \ + (dst) = ft_mem_dup( memory, (address), (FT_ULong)(size), &error ) + +#define FT_DUP( dst, address, size ) \ + FT_MEM_SET_ERROR( FT_MEM_DUP( dst, address, size ) ) + + + /* Return >= 1 if a truncation occurs. */ + /* Return 0 if the source string fits the buffer. */ + /* This is *not* the same as strlcpy(). */ + FT_BASE( FT_Int ) + ft_mem_strcpyn( char* dst, + const char* src, + FT_ULong size ); + +#define FT_STRCPYN( dst, src, size ) \ + ft_mem_strcpyn( (char*)dst, (const char*)(src), (FT_ULong)(size) ) + + /* */ + + +FT_END_HEADER + +#endif /* FTMEMORY_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftobjs.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftobjs.h new file mode 100644 index 0000000..37c6baf --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftobjs.h @@ -0,0 +1,1625 @@ +/***************************************************************************/ +/* */ +/* ftobjs.h */ +/* */ +/* The FreeType private base classes (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file contains the definition of all internal FreeType classes. */ + /* */ + /*************************************************************************/ + + +#ifndef FTOBJS_H_ +#define FTOBJS_H_ + +#include <ft2build.h> +#include FT_RENDER_H +#include FT_SIZES_H +#include FT_LCD_FILTER_H +#include FT_INTERNAL_MEMORY_H +#include FT_INTERNAL_GLYPH_LOADER_H +#include FT_INTERNAL_DRIVER_H +#include FT_INTERNAL_AUTOHINT_H +#include FT_INTERNAL_SERVICE_H +#include FT_INTERNAL_PIC_H +#include FT_INTERNAL_CALC_H + +#ifdef FT_CONFIG_OPTION_INCREMENTAL +#include FT_INCREMENTAL_H +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* Some generic definitions. */ + /* */ +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL (void*)0 +#endif + + + /*************************************************************************/ + /* */ + /* The min and max functions missing in C. As usual, be careful not to */ + /* write things like FT_MIN( a++, b++ ) to avoid side effects. */ + /* */ +#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) ) +#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) ) + +#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) ) + + /* + * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' + * algorithm. We use alpha = 1, beta = 3/8, giving us results with a + * largest error less than 7% compared to the exact value. + */ +#define FT_HYPOT( x, y ) \ + ( x = FT_ABS( x ), \ + y = FT_ABS( y ), \ + x > y ? x + ( 3 * y >> 3 ) \ + : y + ( 3 * x >> 3 ) ) + + /* we use FT_TYPEOF to suppress signedness compilation warnings */ +#define FT_PAD_FLOOR( x, n ) ( (x) & ~FT_TYPEOF( x )( (n) - 1 ) ) +#define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x) + (n) / 2, n ) +#define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x) + (n) - 1, n ) + +#define FT_PIX_FLOOR( x ) ( (x) & ~FT_TYPEOF( x )63 ) +#define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 ) +#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 ) + + /* specialized versions (for signed values) */ + /* that don't produce run-time errors due to integer overflow */ +#define FT_PAD_ROUND_LONG( x, n ) FT_PAD_FLOOR( ADD_LONG( (x), (n) / 2 ), \ + n ) +#define FT_PAD_CEIL_LONG( x, n ) FT_PAD_FLOOR( ADD_LONG( (x), (n) - 1 ), \ + n ) +#define FT_PIX_ROUND_LONG( x ) FT_PIX_FLOOR( ADD_LONG( (x), 32 ) ) +#define FT_PIX_CEIL_LONG( x ) FT_PIX_FLOOR( ADD_LONG( (x), 63 ) ) + +#define FT_PAD_ROUND_INT32( x, n ) FT_PAD_FLOOR( ADD_INT32( (x), (n) / 2 ), \ + n ) +#define FT_PAD_CEIL_INT32( x, n ) FT_PAD_FLOOR( ADD_INT32( (x), (n) - 1 ), \ + n ) +#define FT_PIX_ROUND_INT32( x ) FT_PIX_FLOOR( ADD_INT32( (x), 32 ) ) +#define FT_PIX_CEIL_INT32( x ) FT_PIX_FLOOR( ADD_INT32( (x), 63 ) ) + + + /* + * character classification functions -- since these are used to parse + * font files, we must not use those in <ctypes.h> which are + * locale-dependent + */ +#define ft_isdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U ) + +#define ft_isxdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U || \ + ( (unsigned)(x) - 'a' ) < 6U || \ + ( (unsigned)(x) - 'A' ) < 6U ) + + /* the next two macros assume ASCII representation */ +#define ft_isupper( x ) ( ( (unsigned)(x) - 'A' ) < 26U ) +#define ft_islower( x ) ( ( (unsigned)(x) - 'a' ) < 26U ) + +#define ft_isalpha( x ) ( ft_isupper( x ) || ft_islower( x ) ) +#define ft_isalnum( x ) ( ft_isdigit( x ) || ft_isalpha( x ) ) + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** C H A R M A P S ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + /* handle to internal charmap object */ + typedef struct FT_CMapRec_* FT_CMap; + + /* handle to charmap class structure */ + typedef const struct FT_CMap_ClassRec_* FT_CMap_Class; + + /* internal charmap object structure */ + typedef struct FT_CMapRec_ + { + FT_CharMapRec charmap; + FT_CMap_Class clazz; + + } FT_CMapRec; + + /* typecase any pointer to a charmap handle */ +#define FT_CMAP( x ) ( (FT_CMap)( x ) ) + + /* obvious macros */ +#define FT_CMAP_PLATFORM_ID( x ) FT_CMAP( x )->charmap.platform_id +#define FT_CMAP_ENCODING_ID( x ) FT_CMAP( x )->charmap.encoding_id +#define FT_CMAP_ENCODING( x ) FT_CMAP( x )->charmap.encoding +#define FT_CMAP_FACE( x ) FT_CMAP( x )->charmap.face + + + /* class method definitions */ + typedef FT_Error + (*FT_CMap_InitFunc)( FT_CMap cmap, + FT_Pointer init_data ); + + typedef void + (*FT_CMap_DoneFunc)( FT_CMap cmap ); + + typedef FT_UInt + (*FT_CMap_CharIndexFunc)( FT_CMap cmap, + FT_UInt32 char_code ); + + typedef FT_UInt + (*FT_CMap_CharNextFunc)( FT_CMap cmap, + FT_UInt32 *achar_code ); + + typedef FT_UInt + (*FT_CMap_CharVarIndexFunc)( FT_CMap cmap, + FT_CMap unicode_cmap, + FT_UInt32 char_code, + FT_UInt32 variant_selector ); + + typedef FT_Bool + (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap cmap, + FT_UInt32 char_code, + FT_UInt32 variant_selector ); + + typedef FT_UInt32 * + (*FT_CMap_VariantListFunc)( FT_CMap cmap, + FT_Memory mem ); + + typedef FT_UInt32 * + (*FT_CMap_CharVariantListFunc)( FT_CMap cmap, + FT_Memory mem, + FT_UInt32 char_code ); + + typedef FT_UInt32 * + (*FT_CMap_VariantCharListFunc)( FT_CMap cmap, + FT_Memory mem, + FT_UInt32 variant_selector ); + + + typedef struct FT_CMap_ClassRec_ + { + FT_ULong size; + + FT_CMap_InitFunc init; + FT_CMap_DoneFunc done; + FT_CMap_CharIndexFunc char_index; + FT_CMap_CharNextFunc char_next; + + /* Subsequent entries are special ones for format 14 -- the variant */ + /* selector subtable which behaves like no other */ + + FT_CMap_CharVarIndexFunc char_var_index; + FT_CMap_CharVarIsDefaultFunc char_var_default; + FT_CMap_VariantListFunc variant_list; + FT_CMap_CharVariantListFunc charvariant_list; + FT_CMap_VariantCharListFunc variantchar_list; + + } FT_CMap_ClassRec; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DECLARE_CMAP_CLASS( class_ ) \ + FT_CALLBACK_TABLE const FT_CMap_ClassRec class_; + +#define FT_DEFINE_CMAP_CLASS( \ + class_, \ + size_, \ + init_, \ + done_, \ + char_index_, \ + char_next_, \ + char_var_index_, \ + char_var_default_, \ + variant_list_, \ + charvariant_list_, \ + variantchar_list_ ) \ + FT_CALLBACK_TABLE_DEF \ + const FT_CMap_ClassRec class_ = \ + { \ + size_, \ + init_, \ + done_, \ + char_index_, \ + char_next_, \ + char_var_index_, \ + char_var_default_, \ + variant_list_, \ + charvariant_list_, \ + variantchar_list_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DECLARE_CMAP_CLASS( class_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + FT_CMap_ClassRec* clazz ); + +#define FT_DEFINE_CMAP_CLASS( \ + class_, \ + size_, \ + init_, \ + done_, \ + char_index_, \ + char_next_, \ + char_var_index_, \ + char_var_default_, \ + variant_list_, \ + charvariant_list_, \ + variantchar_list_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + FT_CMap_ClassRec* clazz ) \ + { \ + FT_UNUSED( library ); \ + \ + clazz->size = size_; \ + clazz->init = init_; \ + clazz->done = done_; \ + clazz->char_index = char_index_; \ + clazz->char_next = char_next_; \ + clazz->char_var_index = char_var_index_; \ + clazz->char_var_default = char_var_default_; \ + clazz->variant_list = variant_list_; \ + clazz->charvariant_list = charvariant_list_; \ + clazz->variantchar_list = variantchar_list_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + + /* create a new charmap and add it to charmap->face */ + FT_BASE( FT_Error ) + FT_CMap_New( FT_CMap_Class clazz, + FT_Pointer init_data, + FT_CharMap charmap, + FT_CMap *acmap ); + + /* destroy a charmap and remove it from face's list */ + FT_BASE( void ) + FT_CMap_Done( FT_CMap cmap ); + + + /* adds LCD padding to Min and Max boundaries */ + FT_BASE( void ) + ft_lcd_padding( FT_Pos* Min, + FT_Pos* Max, + FT_GlyphSlot slot ); + +#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + + typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap, + FT_Render_Mode render_mode, + FT_Byte* weights ); + + + /* This is the default LCD filter, an in-place, 5-tap FIR filter. */ + FT_BASE( void ) + ft_lcd_filter_fir( FT_Bitmap* bitmap, + FT_Render_Mode mode, + FT_LcdFiveTapFilter weights ); + +#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Face_InternalRec */ + /* */ + /* <Description> */ + /* This structure contains the internal fields of each FT_Face */ + /* object. These fields may change between different releases of */ + /* FreeType. */ + /* */ + /* <Fields> */ + /* max_points :: */ + /* The maximum number of points used to store the vectorial outline */ + /* of any glyph in this face. If this value cannot be known in */ + /* advance, or if the face isn't scalable, this should be set to 0. */ + /* Only relevant for scalable formats. */ + /* */ + /* max_contours :: */ + /* The maximum number of contours used to store the vectorial */ + /* outline of any glyph in this face. If this value cannot be */ + /* known in advance, or if the face isn't scalable, this should be */ + /* set to 0. Only relevant for scalable formats. */ + /* */ + /* transform_matrix :: */ + /* A 2x2 matrix of 16.16 coefficients used to transform glyph */ + /* outlines after they are loaded from the font. Only used by the */ + /* convenience functions. */ + /* */ + /* transform_delta :: */ + /* A translation vector used to transform glyph outlines after they */ + /* are loaded from the font. Only used by the convenience */ + /* functions. */ + /* */ + /* transform_flags :: */ + /* Some flags used to classify the transform. Only used by the */ + /* convenience functions. */ + /* */ + /* services :: */ + /* A cache for frequently used services. It should be only */ + /* accessed with the macro `FT_FACE_LOOKUP_SERVICE'. */ + /* */ + /* incremental_interface :: */ + /* If non-null, the interface through which glyph data and metrics */ + /* are loaded incrementally for faces that do not provide all of */ + /* this data when first opened. This field exists only if */ + /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */ + /* */ + /* no_stem_darkening :: */ + /* Overrides the module-level default, see @stem-darkening[cff], */ + /* for example. FALSE and TRUE toggle stem darkening on and off, */ + /* respectively, value~-1 means to use the module/driver default. */ + /* */ + /* random_seed :: */ + /* If positive, override the seed value for the CFF `random' */ + /* operator. Value~0 means to use the font's value. Value~-1 */ + /* means to use the CFF driver's default. */ + /* */ + /* lcd_weights :: */ + /* lcd_filter_func :: */ + /* If subpixel rendering is activated, the LCD filtering weights */ + /* and callback function. */ + /* */ + /* refcount :: */ + /* A counter initialized to~1 at the time an @FT_Face structure is */ + /* created. @FT_Reference_Face increments this counter, and */ + /* @FT_Done_Face only destroys a face if the counter is~1, */ + /* otherwise it simply decrements it. */ + /* */ + typedef struct FT_Face_InternalRec_ + { + FT_Matrix transform_matrix; + FT_Vector transform_delta; + FT_Int transform_flags; + + FT_ServiceCacheRec services; + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + FT_Incremental_InterfaceRec* incremental_interface; +#endif + + FT_Char no_stem_darkening; + FT_Int32 random_seed; + +#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */ + FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */ +#endif + + FT_Int refcount; + + } FT_Face_InternalRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Slot_InternalRec */ + /* */ + /* <Description> */ + /* This structure contains the internal fields of each FT_GlyphSlot */ + /* object. These fields may change between different releases of */ + /* FreeType. */ + /* */ + /* <Fields> */ + /* loader :: The glyph loader object used to load outlines */ + /* into the glyph slot. */ + /* */ + /* flags :: Possible values are zero or */ + /* FT_GLYPH_OWN_BITMAP. The latter indicates */ + /* that the FT_GlyphSlot structure owns the */ + /* bitmap buffer. */ + /* */ + /* glyph_transformed :: Boolean. Set to TRUE when the loaded glyph */ + /* must be transformed through a specific */ + /* font transformation. This is _not_ the same */ + /* as the face transform set through */ + /* FT_Set_Transform(). */ + /* */ + /* glyph_matrix :: The 2x2 matrix corresponding to the glyph */ + /* transformation, if necessary. */ + /* */ + /* glyph_delta :: The 2d translation vector corresponding to */ + /* the glyph transformation, if necessary. */ + /* */ + /* glyph_hints :: Format-specific glyph hints management. */ + /* */ + +#define FT_GLYPH_OWN_BITMAP 0x1U + + typedef struct FT_Slot_InternalRec_ + { + FT_GlyphLoader loader; + FT_UInt flags; + FT_Bool glyph_transformed; + FT_Matrix glyph_matrix; + FT_Vector glyph_delta; + void* glyph_hints; + + } FT_GlyphSlot_InternalRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Size_InternalRec */ + /* */ + /* <Description> */ + /* This structure contains the internal fields of each FT_Size */ + /* object. */ + /* */ + /* <Fields> */ + /* module_data :: Data specific to a driver module. */ + /* */ + /* autohint_mode :: The used auto-hinting mode. */ + /* */ + /* autohint_metrics :: Metrics used by the auto-hinter. */ + /* */ + /*************************************************************************/ + + typedef struct FT_Size_InternalRec_ + { + void* module_data; + + FT_Render_Mode autohint_mode; + FT_Size_Metrics autohint_metrics; + + } FT_Size_InternalRec; + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** M O D U L E S ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_ModuleRec */ + /* */ + /* <Description> */ + /* A module object instance. */ + /* */ + /* <Fields> */ + /* clazz :: A pointer to the module's class. */ + /* */ + /* library :: A handle to the parent library object. */ + /* */ + /* memory :: A handle to the memory manager. */ + /* */ + typedef struct FT_ModuleRec_ + { + FT_Module_Class* clazz; + FT_Library library; + FT_Memory memory; + + } FT_ModuleRec; + + + /* typecast an object to an FT_Module */ +#define FT_MODULE( x ) ( (FT_Module)(x) ) + +#define FT_MODULE_CLASS( x ) FT_MODULE( x )->clazz +#define FT_MODULE_LIBRARY( x ) FT_MODULE( x )->library +#define FT_MODULE_MEMORY( x ) FT_MODULE( x )->memory + + +#define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ + FT_MODULE_FONT_DRIVER ) + +#define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ + FT_MODULE_RENDERER ) + +#define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ + FT_MODULE_HINTER ) + +#define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ + FT_MODULE_STYLER ) + +#define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS( x )->module_flags & \ + FT_MODULE_DRIVER_SCALABLE ) + +#define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS( x )->module_flags & \ + FT_MODULE_DRIVER_NO_OUTLINES ) + +#define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ + FT_MODULE_DRIVER_HAS_HINTER ) + +#define FT_DRIVER_HINTS_LIGHTLY( x ) ( FT_MODULE_CLASS( x )->module_flags & \ + FT_MODULE_DRIVER_HINTS_LIGHTLY ) + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Module_Interface */ + /* */ + /* <Description> */ + /* Finds a module and returns its specific interface as a typeless */ + /* pointer. */ + /* */ + /* <Input> */ + /* library :: A handle to the library object. */ + /* */ + /* module_name :: The module's name (as an ASCII string). */ + /* */ + /* <Return> */ + /* A module-specific interface if available, 0 otherwise. */ + /* */ + /* <Note> */ + /* You should better be familiar with FreeType internals to know */ + /* which module to look for, and what its interface is :-) */ + /* */ + FT_BASE( const void* ) + FT_Get_Module_Interface( FT_Library library, + const char* mod_name ); + + FT_BASE( FT_Pointer ) + ft_module_get_service( FT_Module module, + const char* service_id, + FT_Bool global ); + +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_BASE( FT_Error ) + ft_property_string_set( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + FT_String* value ); +#endif + + /* */ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** F A C E, S I Z E & G L Y P H S L O T O B J E C T S ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + /* a few macros used to perform easy typecasts with minimal brain damage */ + +#define FT_FACE( x ) ( (FT_Face)(x) ) +#define FT_SIZE( x ) ( (FT_Size)(x) ) +#define FT_SLOT( x ) ( (FT_GlyphSlot)(x) ) + +#define FT_FACE_DRIVER( x ) FT_FACE( x )->driver +#define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library +#define FT_FACE_MEMORY( x ) FT_FACE( x )->memory +#define FT_FACE_STREAM( x ) FT_FACE( x )->stream + +#define FT_SIZE_FACE( x ) FT_SIZE( x )->face +#define FT_SLOT_FACE( x ) FT_SLOT( x )->face + +#define FT_FACE_SLOT( x ) FT_FACE( x )->glyph +#define FT_FACE_SIZE( x ) FT_FACE( x )->size + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_GlyphSlot */ + /* */ + /* <Description> */ + /* It is sometimes useful to have more than one glyph slot for a */ + /* given face object. This function is used to create additional */ + /* slots. All of them are automatically discarded when the face is */ + /* destroyed. */ + /* */ + /* <Input> */ + /* face :: A handle to a parent face object. */ + /* */ + /* <Output> */ + /* aslot :: A handle to a new glyph slot object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + FT_BASE( FT_Error ) + FT_New_GlyphSlot( FT_Face face, + FT_GlyphSlot *aslot ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_GlyphSlot */ + /* */ + /* <Description> */ + /* Destroys a given glyph slot. Remember however that all slots are */ + /* automatically destroyed with its parent. Using this function is */ + /* not always mandatory. */ + /* */ + /* <Input> */ + /* slot :: A handle to a target glyph slot. */ + /* */ + FT_BASE( void ) + FT_Done_GlyphSlot( FT_GlyphSlot slot ); + + /* */ + +#define FT_REQUEST_WIDTH( req ) \ + ( (req)->horiResolution \ + ? ( (req)->width * (FT_Pos)(req)->horiResolution + 36 ) / 72 \ + : (req)->width ) + +#define FT_REQUEST_HEIGHT( req ) \ + ( (req)->vertResolution \ + ? ( (req)->height * (FT_Pos)(req)->vertResolution + 36 ) / 72 \ + : (req)->height ) + + + /* Set the metrics according to a bitmap strike. */ + FT_BASE( void ) + FT_Select_Metrics( FT_Face face, + FT_ULong strike_index ); + + + /* Set the metrics according to a size request. */ + FT_BASE( void ) + FT_Request_Metrics( FT_Face face, + FT_Size_Request req ); + + + /* Match a size request against `available_sizes'. */ + FT_BASE( FT_Error ) + FT_Match_Size( FT_Face face, + FT_Size_Request req, + FT_Bool ignore_width, + FT_ULong* size_index ); + + + /* Use the horizontal metrics to synthesize the vertical metrics. */ + /* If `advance' is zero, it is also synthesized. */ + FT_BASE( void ) + ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics, + FT_Pos advance ); + + + /* Free the bitmap of a given glyphslot when needed (i.e., only when it */ + /* was allocated with ft_glyphslot_alloc_bitmap). */ + FT_BASE( void ) + ft_glyphslot_free_bitmap( FT_GlyphSlot slot ); + + + /* Preset bitmap metrics of an outline glyphslot prior to rendering. */ + FT_BASE( void ) + ft_glyphslot_preset_bitmap( FT_GlyphSlot slot, + FT_Render_Mode mode, + const FT_Vector* origin ); + + /* Allocate a new bitmap buffer in a glyph slot. */ + FT_BASE( FT_Error ) + ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot, + FT_ULong size ); + + + /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */ + /* will not be freed by a later call to ft_glyphslot_free_bitmap. */ + FT_BASE( void ) + ft_glyphslot_set_bitmap( FT_GlyphSlot slot, + FT_Byte* buffer ); + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** R E N D E R E R S ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + +#define FT_RENDERER( x ) ( (FT_Renderer)(x) ) +#define FT_GLYPH( x ) ( (FT_Glyph)(x) ) +#define FT_BITMAP_GLYPH( x ) ( (FT_BitmapGlyph)(x) ) +#define FT_OUTLINE_GLYPH( x ) ( (FT_OutlineGlyph)(x) ) + + + typedef struct FT_RendererRec_ + { + FT_ModuleRec root; + FT_Renderer_Class* clazz; + FT_Glyph_Format glyph_format; + FT_Glyph_Class glyph_class; + + FT_Raster raster; + FT_Raster_Render_Func raster_render; + FT_Renderer_RenderFunc render; + + } FT_RendererRec; + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** F O N T D R I V E R S ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /* typecast a module into a driver easily */ +#define FT_DRIVER( x ) ( (FT_Driver)(x) ) + + /* typecast a module as a driver, and get its driver class */ +#define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_DriverRec */ + /* */ + /* <Description> */ + /* The root font driver class. A font driver is responsible for */ + /* managing and loading font files of a given format. */ + /* */ + /* <Fields> */ + /* root :: Contains the fields of the root module class. */ + /* */ + /* clazz :: A pointer to the font driver's class. Note that */ + /* this is NOT root.clazz. `class' wasn't used */ + /* as it is a reserved word in C++. */ + /* */ + /* faces_list :: The list of faces currently opened by this */ + /* driver. */ + /* */ + /* glyph_loader :: Unused. Used to be glyph loader for all faces */ + /* managed by this driver. */ + /* */ + typedef struct FT_DriverRec_ + { + FT_ModuleRec root; + FT_Driver_Class clazz; + FT_ListRec faces_list; + FT_GlyphLoader glyph_loader; + + } FT_DriverRec; + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** L I B R A R I E S ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /* This hook is used by the TrueType debugger. It must be set to an */ + /* alternate truetype bytecode interpreter function. */ +#define FT_DEBUG_HOOK_TRUETYPE 0 + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_LibraryRec */ + /* */ + /* <Description> */ + /* The FreeType library class. This is the root of all FreeType */ + /* data. Use FT_New_Library() to create a library object, and */ + /* FT_Done_Library() to discard it and all child objects. */ + /* */ + /* <Fields> */ + /* memory :: The library's memory object. Manages memory */ + /* allocation. */ + /* */ + /* version_major :: The major version number of the library. */ + /* */ + /* version_minor :: The minor version number of the library. */ + /* */ + /* version_patch :: The current patch level of the library. */ + /* */ + /* num_modules :: The number of modules currently registered */ + /* within this library. This is set to 0 for new */ + /* libraries. New modules are added through the */ + /* FT_Add_Module() API function. */ + /* */ + /* modules :: A table used to store handles to the currently */ + /* registered modules. Note that each font driver */ + /* contains a list of its opened faces. */ + /* */ + /* renderers :: The list of renderers currently registered */ + /* within the library. */ + /* */ + /* cur_renderer :: The current outline renderer. This is a */ + /* shortcut used to avoid parsing the list on */ + /* each call to FT_Outline_Render(). It is a */ + /* handle to the current renderer for the */ + /* FT_GLYPH_FORMAT_OUTLINE format. */ + /* */ + /* auto_hinter :: The auto-hinter module interface. */ + /* */ + /* debug_hooks :: An array of four function pointers that allow */ + /* debuggers to hook into a font format's */ + /* interpreter. Currently, only the TrueType */ + /* bytecode debugger uses this. */ + /* */ + /* lcd_weights :: If subpixel rendering is activated, the LCD */ + /* filter weights, if any. */ + /* */ + /* lcd_filter_func :: If subpixel rendering is activated, the LCD */ + /* filtering callback function. */ + /* */ + /* pic_container :: Contains global structs and tables, instead */ + /* of defining them globally. */ + /* */ + /* refcount :: A counter initialized to~1 at the time an */ + /* @FT_Library structure is created. */ + /* @FT_Reference_Library increments this counter, */ + /* and @FT_Done_Library only destroys a library */ + /* if the counter is~1, otherwise it simply */ + /* decrements it. */ + /* */ + typedef struct FT_LibraryRec_ + { + FT_Memory memory; /* library's memory manager */ + + FT_Int version_major; + FT_Int version_minor; + FT_Int version_patch; + + FT_UInt num_modules; + FT_Module modules[FT_MAX_MODULES]; /* module objects */ + + FT_ListRec renderers; /* list of renderers */ + FT_Renderer cur_renderer; /* current outline renderer */ + FT_Module auto_hinter; + + FT_DebugHook_Func debug_hooks[4]; + +#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */ + FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */ +#endif + +#ifdef FT_CONFIG_OPTION_PIC + FT_PIC_Container pic_container; +#endif + + FT_Int refcount; + + } FT_LibraryRec; + + + FT_BASE( FT_Renderer ) + FT_Lookup_Renderer( FT_Library library, + FT_Glyph_Format format, + FT_ListNode* node ); + + FT_BASE( FT_Error ) + FT_Render_Glyph_Internal( FT_Library library, + FT_GlyphSlot slot, + FT_Render_Mode render_mode ); + + typedef const char* + (*FT_Face_GetPostscriptNameFunc)( FT_Face face ); + + typedef FT_Error + (*FT_Face_GetGlyphNameFunc)( FT_Face face, + FT_UInt glyph_index, + FT_Pointer buffer, + FT_UInt buffer_max ); + + typedef FT_UInt + (*FT_Face_GetGlyphNameIndexFunc)( FT_Face face, + FT_String* glyph_name ); + + +#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_New_Memory */ + /* */ + /* <Description> */ + /* Creates a new memory object. */ + /* */ + /* <Return> */ + /* A pointer to the new memory object. 0 in case of error. */ + /* */ + FT_BASE( FT_Memory ) + FT_New_Memory( void ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Done_Memory */ + /* */ + /* <Description> */ + /* Discards memory manager. */ + /* */ + /* <Input> */ + /* memory :: A handle to the memory manager. */ + /* */ + FT_BASE( void ) + FT_Done_Memory( FT_Memory memory ); + +#endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */ + + + /* Define default raster's interface. The default raster is located in */ + /* `src/base/ftraster.c'. */ + /* */ + /* Client applications can register new rasters through the */ + /* FT_Set_Raster() API. */ + +#ifndef FT_NO_DEFAULT_RASTER + FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster; +#endif + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** P I C S U P P O R T ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /* PIC support macros for ftimage.h */ + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_DEFINE_OUTLINE_FUNCS */ + /* */ + /* <Description> */ + /* Used to initialize an instance of FT_Outline_Funcs struct. */ + /* When FT_CONFIG_OPTION_PIC is defined an init function will need */ + /* to be called with a pre-allocated structure to be filled. */ + /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ + /* allocated in the global scope (or the scope where the macro */ + /* is used). */ + /* */ +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_OUTLINE_FUNCS( \ + class_, \ + move_to_, \ + line_to_, \ + conic_to_, \ + cubic_to_, \ + shift_, \ + delta_ ) \ + static const FT_Outline_Funcs class_ = \ + { \ + move_to_, \ + line_to_, \ + conic_to_, \ + cubic_to_, \ + shift_, \ + delta_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_OUTLINE_FUNCS( \ + class_, \ + move_to_, \ + line_to_, \ + conic_to_, \ + cubic_to_, \ + shift_, \ + delta_ ) \ + static FT_Error \ + Init_Class_ ## class_( FT_Outline_Funcs* clazz ) \ + { \ + clazz->move_to = move_to_; \ + clazz->line_to = line_to_; \ + clazz->conic_to = conic_to_; \ + clazz->cubic_to = cubic_to_; \ + clazz->shift = shift_; \ + clazz->delta = delta_; \ + \ + return FT_Err_Ok; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_DEFINE_RASTER_FUNCS */ + /* */ + /* <Description> */ + /* Used to initialize an instance of FT_Raster_Funcs struct. */ + /* When FT_CONFIG_OPTION_PIC is defined an init function will need */ + /* to be called with a pre-allocated structure to be filled. */ + /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ + /* allocated in the global scope (or the scope where the macro */ + /* is used). */ + /* */ +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_RASTER_FUNCS( \ + class_, \ + glyph_format_, \ + raster_new_, \ + raster_reset_, \ + raster_set_mode_, \ + raster_render_, \ + raster_done_ ) \ + const FT_Raster_Funcs class_ = \ + { \ + glyph_format_, \ + raster_new_, \ + raster_reset_, \ + raster_set_mode_, \ + raster_render_, \ + raster_done_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_RASTER_FUNCS( \ + class_, \ + glyph_format_, \ + raster_new_, \ + raster_reset_, \ + raster_set_mode_, \ + raster_render_, \ + raster_done_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Raster_Funcs* clazz ) \ + { \ + clazz->glyph_format = glyph_format_; \ + clazz->raster_new = raster_new_; \ + clazz->raster_reset = raster_reset_; \ + clazz->raster_set_mode = raster_set_mode_; \ + clazz->raster_render = raster_render_; \ + clazz->raster_done = raster_done_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + + /* PIC support macros for ftrender.h */ + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_DEFINE_GLYPH */ + /* */ + /* <Description> */ + /* Used to initialize an instance of FT_Glyph_Class struct. */ + /* When FT_CONFIG_OPTION_PIC is defined an init function will need */ + /* to be called with a pre-allocated structure to be filled. */ + /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ + /* allocated in the global scope (or the scope where the macro */ + /* is used). */ + /* */ +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_GLYPH( \ + class_, \ + size_, \ + format_, \ + init_, \ + done_, \ + copy_, \ + transform_, \ + bbox_, \ + prepare_ ) \ + FT_CALLBACK_TABLE_DEF \ + const FT_Glyph_Class class_ = \ + { \ + size_, \ + format_, \ + init_, \ + done_, \ + copy_, \ + transform_, \ + bbox_, \ + prepare_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_GLYPH( \ + class_, \ + size_, \ + format_, \ + init_, \ + done_, \ + copy_, \ + transform_, \ + bbox_, \ + prepare_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Glyph_Class* clazz ) \ + { \ + clazz->glyph_size = size_; \ + clazz->glyph_format = format_; \ + clazz->glyph_init = init_; \ + clazz->glyph_done = done_; \ + clazz->glyph_copy = copy_; \ + clazz->glyph_transform = transform_; \ + clazz->glyph_bbox = bbox_; \ + clazz->glyph_prepare = prepare_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_DECLARE_RENDERER */ + /* */ + /* <Description> */ + /* Used to create a forward declaration of a */ + /* FT_Renderer_Class struct instance. */ + /* */ + /* <Macro> */ + /* FT_DEFINE_RENDERER */ + /* */ + /* <Description> */ + /* Used to initialize an instance of FT_Renderer_Class struct. */ + /* */ + /* When FT_CONFIG_OPTION_PIC is defined a `create' function will */ + /* need to be called with a pointer where the allocated structure is */ + /* returned. And when it is no longer needed a `destroy' function */ + /* needs to be called to release that allocation. */ + /* `ftinit.c' (ft_create_default_module_classes) already contains */ + /* a mechanism to call these functions for the default modules */ + /* described in `ftmodule.h'. */ + /* */ + /* Notice that the created `create' and `destroy' functions call */ + /* `pic_init' and `pic_free' to allow you to manually allocate and */ + /* initialize any additional global data, like a module specific */ + /* interface, and put them in the global pic container defined in */ + /* `ftpic.h'. If you don't need them just implement the functions as */ + /* empty to resolve the link error. Also the `pic_init' and */ + /* `pic_free' functions should be declared in `pic.h', to be referred */ + /* by the renderer definition calling `FT_DEFINE_RENDERER' in the */ + /* following. */ + /* */ + /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ + /* allocated in the global scope (or the scope where the macro */ + /* is used). */ + /* */ +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DECLARE_RENDERER( class_ ) \ + FT_EXPORT_VAR( const FT_Renderer_Class ) class_; + +#define FT_DEFINE_RENDERER( \ + class_, \ + flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_, \ + glyph_format_, \ + render_glyph_, \ + transform_glyph_, \ + get_glyph_cbox_, \ + set_mode_, \ + raster_class_ ) \ + FT_CALLBACK_TABLE_DEF \ + const FT_Renderer_Class class_ = \ + { \ + FT_DEFINE_ROOT_MODULE( flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_ ) \ + glyph_format_, \ + \ + render_glyph_, \ + transform_glyph_, \ + get_glyph_cbox_, \ + set_mode_, \ + \ + raster_class_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DECLARE_RENDERER( class_ ) FT_DECLARE_MODULE( class_ ) + +#define FT_DEFINE_RENDERER( \ + class_, \ + flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_, \ + glyph_format_, \ + render_glyph_, \ + transform_glyph_, \ + get_glyph_cbox_, \ + set_mode_, \ + raster_class_ ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_Module_Class* clazz ) \ + { \ + FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \ + FT_Memory memory = library->memory; \ + \ + \ + class_ ## _pic_free( library ); \ + if ( rclazz ) \ + FT_FREE( rclazz ); \ + } \ + \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_Module_Class** output_class ) \ + { \ + FT_Renderer_Class* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ + return error; \ + \ + error = class_ ## _pic_init( library ); \ + if ( error ) \ + { \ + FT_FREE( clazz ); \ + return error; \ + } \ + \ + FT_DEFINE_ROOT_MODULE( flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_ ) \ + \ + clazz->glyph_format = glyph_format_; \ + \ + clazz->render_glyph = render_glyph_; \ + clazz->transform_glyph = transform_glyph_; \ + clazz->get_glyph_cbox = get_glyph_cbox_; \ + clazz->set_mode = set_mode_; \ + \ + clazz->raster_class = raster_class_; \ + \ + *output_class = (FT_Module_Class*)clazz; \ + \ + return FT_Err_Ok; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + + /* PIC support macros for ftmodapi.h **/ + + +#ifdef FT_CONFIG_OPTION_PIC + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Module_Creator */ + /* */ + /* <Description> */ + /* A function used to create (allocate) a new module class object. */ + /* The object's members are initialized, but the module itself is */ + /* not. */ + /* */ + /* <Input> */ + /* memory :: A handle to the memory manager. */ + /* output_class :: Initialized with the newly allocated class. */ + /* */ + typedef FT_Error + (*FT_Module_Creator)( FT_Memory memory, + FT_Module_Class** output_class ); + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* FT_Module_Destroyer */ + /* */ + /* <Description> */ + /* A function used to destroy (deallocate) a module class object. */ + /* */ + /* <Input> */ + /* memory :: A handle to the memory manager. */ + /* clazz :: Module class to destroy. */ + /* */ + typedef void + (*FT_Module_Destroyer)( FT_Memory memory, + FT_Module_Class* clazz ); + +#endif + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_DECLARE_MODULE */ + /* */ + /* <Description> */ + /* Used to create a forward declaration of a */ + /* FT_Module_Class struct instance. */ + /* */ + /* <Macro> */ + /* FT_DEFINE_MODULE */ + /* */ + /* <Description> */ + /* Used to initialize an instance of an FT_Module_Class struct. */ + /* */ + /* When FT_CONFIG_OPTION_PIC is defined a `create' function needs */ + /* to be called with a pointer where the allocated structure is */ + /* returned. And when it is no longer needed a `destroy' function */ + /* needs to be called to release that allocation. */ + /* `ftinit.c' (ft_create_default_module_classes) already contains */ + /* a mechanism to call these functions for the default modules */ + /* described in `ftmodule.h'. */ + /* */ + /* Notice that the created `create' and `destroy' functions call */ + /* `pic_init' and `pic_free' to allow you to manually allocate and */ + /* initialize any additional global data, like a module specific */ + /* interface, and put them in the global pic container defined in */ + /* `ftpic.h'. If you don't need them just implement the functions as */ + /* empty to resolve the link error. Also the `pic_init' and */ + /* `pic_free' functions should be declared in `pic.h', to be referred */ + /* by the module definition calling `FT_DEFINE_MODULE' in the */ + /* following. */ + /* */ + /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ + /* allocated in the global scope (or the scope where the macro */ + /* is used). */ + /* */ + /* <Macro> */ + /* FT_DEFINE_ROOT_MODULE */ + /* */ + /* <Description> */ + /* Used to initialize an instance of an FT_Module_Class struct inside */ + /* another struct that contains it or in a function that initializes */ + /* that containing struct. */ + /* */ +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DECLARE_MODULE( class_ ) \ + FT_CALLBACK_TABLE \ + const FT_Module_Class class_; + +#define FT_DEFINE_ROOT_MODULE( \ + flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_ ) \ + { \ + flags_, \ + size_, \ + \ + name_, \ + version_, \ + requires_, \ + \ + interface_, \ + \ + init_, \ + done_, \ + get_interface_, \ + }, + +#define FT_DEFINE_MODULE( \ + class_, \ + flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_ ) \ + FT_CALLBACK_TABLE_DEF \ + const FT_Module_Class class_ = \ + { \ + flags_, \ + size_, \ + \ + name_, \ + version_, \ + requires_, \ + \ + interface_, \ + \ + init_, \ + done_, \ + get_interface_, \ + }; + + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DECLARE_MODULE( class_ ) \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_Module_Class** output_class ); \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_Module_Class* clazz ); + +#define FT_DEFINE_ROOT_MODULE( \ + flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_ ) \ + clazz->root.module_flags = flags_; \ + clazz->root.module_size = size_; \ + clazz->root.module_name = name_; \ + clazz->root.module_version = version_; \ + clazz->root.module_requires = requires_; \ + \ + clazz->root.module_interface = interface_; \ + \ + clazz->root.module_init = init_; \ + clazz->root.module_done = done_; \ + clazz->root.get_interface = get_interface_; + +#define FT_DEFINE_MODULE( \ + class_, \ + flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_ ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_Module_Class* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + class_ ## _pic_free( library ); \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_Module_Class** output_class ) \ + { \ + FT_Memory memory = library->memory; \ + FT_Module_Class* clazz = NULL; \ + FT_Error error; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ + return error; \ + error = class_ ## _pic_init( library ); \ + if ( error ) \ + { \ + FT_FREE( clazz ); \ + return error; \ + } \ + \ + clazz->module_flags = flags_; \ + clazz->module_size = size_; \ + clazz->module_name = name_; \ + clazz->module_version = version_; \ + clazz->module_requires = requires_; \ + \ + clazz->module_interface = interface_; \ + \ + clazz->module_init = init_; \ + clazz->module_done = done_; \ + clazz->get_interface = get_interface_; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + +FT_END_HEADER + +#endif /* FTOBJS_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftpic.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftpic.h new file mode 100644 index 0000000..5214f05 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftpic.h @@ -0,0 +1,71 @@ +/***************************************************************************/ +/* */ +/* ftpic.h */ +/* */ +/* The FreeType position independent code services (declaration). */ +/* */ +/* Copyright 2009-2018 by */ +/* Oran Agra and Mickey Gabel. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + /*************************************************************************/ + /* */ + /* Modules that ordinarily have const global data that need address */ + /* can instead define pointers here. */ + /* */ + /*************************************************************************/ + + +#ifndef FTPIC_H_ +#define FTPIC_H_ + + +FT_BEGIN_HEADER + +#ifdef FT_CONFIG_OPTION_PIC + + typedef struct FT_PIC_Container_ + { + /* pic containers for base */ + void* base; + + /* pic containers for modules */ + void* autofit; + void* cff; + void* pshinter; + void* psnames; + void* raster; + void* sfnt; + void* smooth; + void* truetype; + + } FT_PIC_Container; + + + /* Initialize the various function tables, structs, etc. */ + /* stored in the container. */ + FT_BASE( FT_Error ) + ft_pic_container_init( FT_Library library ); + + + /* Destroy the contents of the container. */ + FT_BASE( void ) + ft_pic_container_destroy( FT_Library library ); + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + +FT_END_HEADER + +#endif /* FTPIC_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftpsprop.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftpsprop.h new file mode 100644 index 0000000..abbb628 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftpsprop.h @@ -0,0 +1,48 @@ +/***************************************************************************/ +/* */ +/* ftpsprop.h */ +/* */ +/* Get and set properties of PostScript drivers (specification). */ +/* */ +/* Copyright 2017-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTPSPROP_H_ +#define FTPSPROP_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + + +FT_BEGIN_HEADER + + + FT_BASE_CALLBACK( FT_Error ) + ps_property_set( FT_Module module, /* PS_Driver */ + const char* property_name, + const void* value, + FT_Bool value_is_string ); + + FT_BASE_CALLBACK( FT_Error ) + ps_property_get( FT_Module module, /* PS_Driver */ + const char* property_name, + void* value ); + + +FT_END_HEADER + + +#endif /* FTPSPROP_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftrfork.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftrfork.h new file mode 100644 index 0000000..1aca48a --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftrfork.h @@ -0,0 +1,267 @@ +/***************************************************************************/ +/* */ +/* ftrfork.h */ +/* */ +/* Embedded resource forks accessor (specification). */ +/* */ +/* Copyright 2004-2018 by */ +/* Masatake YAMATO and Redhat K.K. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +/***************************************************************************/ +/* Development of the code in this file is support of */ +/* Information-technology Promotion Agency, Japan. */ +/***************************************************************************/ + + +#ifndef FTRFORK_H_ +#define FTRFORK_H_ + + +#include <ft2build.h> +#include FT_INTERNAL_OBJECTS_H + + +FT_BEGIN_HEADER + + + /* Number of guessing rules supported in `FT_Raccess_Guess'. */ + /* Don't forget to increment the number if you add a new guessing rule. */ +#define FT_RACCESS_N_RULES 9 + + + /* A structure to describe a reference in a resource by its resource ID */ + /* and internal offset. The `POST' resource expects to be concatenated */ + /* by the order of resource IDs instead of its appearance in the file. */ + + typedef struct FT_RFork_Ref_ + { + FT_Short res_id; + FT_Long offset; + + } FT_RFork_Ref; + + +#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK + typedef FT_Error + (*ft_raccess_guess_func)( FT_Library library, + FT_Stream stream, + char *base_file_name, + char **result_file_name, + FT_Long *result_offset ); + + typedef enum FT_RFork_Rule_ { + FT_RFork_Rule_invalid = -2, + FT_RFork_Rule_uknown, /* -1 */ + FT_RFork_Rule_apple_double, + FT_RFork_Rule_apple_single, + FT_RFork_Rule_darwin_ufs_export, + FT_RFork_Rule_darwin_newvfs, + FT_RFork_Rule_darwin_hfsplus, + FT_RFork_Rule_vfat, + FT_RFork_Rule_linux_cap, + FT_RFork_Rule_linux_double, + FT_RFork_Rule_linux_netatalk + } FT_RFork_Rule; + + /* For fast translation between rule index and rule type, + * the macros FT_RFORK_xxx should be kept consistent with + * the raccess_guess_funcs table + */ + typedef struct ft_raccess_guess_rec_ { + ft_raccess_guess_func func; + FT_RFork_Rule type; + } ft_raccess_guess_rec; + +#ifndef FT_CONFIG_OPTION_PIC + + /* this array is a storage in non-PIC mode, so ; is needed in END */ +#define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \ + static const type name[] = { +#define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \ + { raccess_guess_ ## func_suffix, \ + FT_RFork_Rule_ ## type_suffix }, +#define CONST_FT_RFORK_RULE_ARRAY_END }; + +#else /* FT_CONFIG_OPTION_PIC */ + + /* this array is a function in PIC mode, so no ; is needed in END */ +#define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \ + void \ + FT_Init_Table_ ## name( type* storage ) \ + { \ + type* local = storage; \ + \ + \ + int i = 0; +#define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \ + local[i].func = raccess_guess_ ## func_suffix; \ + local[i].type = FT_RFork_Rule_ ## type_suffix; \ + i++; +#define CONST_FT_RFORK_RULE_ARRAY_END } + +#endif /* FT_CONFIG_OPTION_PIC */ + +#endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Raccess_Guess */ + /* */ + /* <Description> */ + /* Guess a file name and offset where the actual resource fork is */ + /* stored. The macro FT_RACCESS_N_RULES holds the number of */ + /* guessing rules; the guessed result for the Nth rule is */ + /* represented as a triplet: a new file name (new_names[N]), a file */ + /* offset (offsets[N]), and an error code (errors[N]). */ + /* */ + /* <Input> */ + /* library :: */ + /* A FreeType library instance. */ + /* */ + /* stream :: */ + /* A file stream containing the resource fork. */ + /* */ + /* base_name :: */ + /* The (base) file name of the resource fork used for some */ + /* guessing rules. */ + /* */ + /* <Output> */ + /* new_names :: */ + /* An array of guessed file names in which the resource forks may */ + /* exist. If `new_names[N]' is NULL, the guessed file name is */ + /* equal to `base_name'. */ + /* */ + /* offsets :: */ + /* An array of guessed file offsets. `offsets[N]' holds the file */ + /* offset of the possible start of the resource fork in file */ + /* `new_names[N]'. */ + /* */ + /* errors :: */ + /* An array of FreeType error codes. `errors[N]' is the error */ + /* code of Nth guessing rule function. If `errors[N]' is not */ + /* FT_Err_Ok, `new_names[N]' and `offsets[N]' are meaningless. */ + /* */ + FT_BASE( void ) + FT_Raccess_Guess( FT_Library library, + FT_Stream stream, + char* base_name, + char** new_names, + FT_Long* offsets, + FT_Error* errors ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Raccess_Get_HeaderInfo */ + /* */ + /* <Description> */ + /* Get the information from the header of resource fork. The */ + /* information includes the file offset where the resource map */ + /* starts, and the file offset where the resource data starts. */ + /* `FT_Raccess_Get_DataOffsets' requires these two data. */ + /* */ + /* <Input> */ + /* library :: */ + /* A FreeType library instance. */ + /* */ + /* stream :: */ + /* A file stream containing the resource fork. */ + /* */ + /* rfork_offset :: */ + /* The file offset where the resource fork starts. */ + /* */ + /* <Output> */ + /* map_offset :: */ + /* The file offset where the resource map starts. */ + /* */ + /* rdata_pos :: */ + /* The file offset where the resource data starts. */ + /* */ + /* <Return> */ + /* FreeType error code. FT_Err_Ok means success. */ + /* */ + FT_BASE( FT_Error ) + FT_Raccess_Get_HeaderInfo( FT_Library library, + FT_Stream stream, + FT_Long rfork_offset, + FT_Long *map_offset, + FT_Long *rdata_pos ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Raccess_Get_DataOffsets */ + /* */ + /* <Description> */ + /* Get the data offsets for a tag in a resource fork. Offsets are */ + /* stored in an array because, in some cases, resources in a resource */ + /* fork have the same tag. */ + /* */ + /* <Input> */ + /* library :: */ + /* A FreeType library instance. */ + /* */ + /* stream :: */ + /* A file stream containing the resource fork. */ + /* */ + /* map_offset :: */ + /* The file offset where the resource map starts. */ + /* */ + /* rdata_pos :: */ + /* The file offset where the resource data starts. */ + /* */ + /* tag :: */ + /* The resource tag. */ + /* */ + /* sort_by_res_id :: */ + /* A Boolean to sort the fragmented resource by their ids. */ + /* The fragmented resources for `POST' resource should be sorted */ + /* to restore Type1 font properly. For `sfnt' resources, sorting */ + /* may induce a different order of the faces in comparison to that */ + /* by QuickDraw API. */ + /* */ + /* <Output> */ + /* offsets :: */ + /* The stream offsets for the resource data specified by `tag'. */ + /* This array is allocated by the function, so you have to call */ + /* @ft_mem_free after use. */ + /* */ + /* count :: */ + /* The length of offsets array. */ + /* */ + /* <Return> */ + /* FreeType error code. FT_Err_Ok means success. */ + /* */ + /* <Note> */ + /* Normally you should use `FT_Raccess_Get_HeaderInfo' to get the */ + /* value for `map_offset' and `rdata_pos'. */ + /* */ + FT_BASE( FT_Error ) + FT_Raccess_Get_DataOffsets( FT_Library library, + FT_Stream stream, + FT_Long map_offset, + FT_Long rdata_pos, + FT_Long tag, + FT_Bool sort_by_res_id, + FT_Long **offsets, + FT_Long *count ); + + +FT_END_HEADER + +#endif /* FTRFORK_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftserv.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftserv.h new file mode 100644 index 0000000..e01c167 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftserv.h @@ -0,0 +1,1016 @@ +/***************************************************************************/ +/* */ +/* ftserv.h */ +/* */ +/* The FreeType services (specification only). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + /*************************************************************************/ + /* */ + /* Each module can export one or more `services'. Each service is */ + /* identified by a constant string and modeled by a pointer; the latter */ + /* generally corresponds to a structure containing function pointers. */ + /* */ + /* Note that a service's data cannot be a mere function pointer because */ + /* in C it is possible that function pointers might be implemented */ + /* differently than data pointers (e.g. 48 bits instead of 32). */ + /* */ + /*************************************************************************/ + + +#ifndef FTSERV_H_ +#define FTSERV_H_ + + +FT_BEGIN_HEADER + + /* + * @macro: + * FT_FACE_FIND_SERVICE + * + * @description: + * This macro is used to look up a service from a face's driver module. + * + * @input: + * face :: + * The source face handle. + * + * id :: + * A string describing the service as defined in the service's + * header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to + * `multi-masters'). It is automatically prefixed with + * `FT_SERVICE_ID_'. + * + * @output: + * ptr :: + * A variable that receives the service pointer. Will be NULL + * if not found. + */ +#ifdef __cplusplus + +#define FT_FACE_FIND_SERVICE( face, ptr, id ) \ + FT_BEGIN_STMNT \ + FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ + FT_Pointer _tmp_ = NULL; \ + FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \ + \ + \ + if ( module->clazz->get_interface ) \ + _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \ + *_pptr_ = _tmp_; \ + FT_END_STMNT + +#else /* !C++ */ + +#define FT_FACE_FIND_SERVICE( face, ptr, id ) \ + FT_BEGIN_STMNT \ + FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ + FT_Pointer _tmp_ = NULL; \ + \ + if ( module->clazz->get_interface ) \ + _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \ + ptr = _tmp_; \ + FT_END_STMNT + +#endif /* !C++ */ + + + /* + * @macro: + * FT_FACE_FIND_GLOBAL_SERVICE + * + * @description: + * This macro is used to look up a service from all modules. + * + * @input: + * face :: + * The source face handle. + * + * id :: + * A string describing the service as defined in the service's + * header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to + * `multi-masters'). It is automatically prefixed with + * `FT_SERVICE_ID_'. + * + * @output: + * ptr :: + * A variable that receives the service pointer. Will be NULL + * if not found. + */ +#ifdef __cplusplus + +#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \ + FT_BEGIN_STMNT \ + FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ + FT_Pointer _tmp_; \ + FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \ + \ + \ + _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \ + *_pptr_ = _tmp_; \ + FT_END_STMNT + +#else /* !C++ */ + +#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \ + FT_BEGIN_STMNT \ + FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ + FT_Pointer _tmp_; \ + \ + \ + _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \ + ptr = _tmp_; \ + FT_END_STMNT + +#endif /* !C++ */ + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** S E R V I C E D E S C R I P T O R S *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + /* + * The following structure is used to _describe_ a given service + * to the library. This is useful to build simple static service lists. + */ + typedef struct FT_ServiceDescRec_ + { + const char* serv_id; /* service name */ + const void* serv_data; /* service pointer/data */ + + } FT_ServiceDescRec; + + typedef const FT_ServiceDescRec* FT_ServiceDesc; + + + /*************************************************************************/ + /* */ + /* <Macro> */ + /* FT_DEFINE_SERVICEDESCREC1 */ + /* FT_DEFINE_SERVICEDESCREC2 */ + /* FT_DEFINE_SERVICEDESCREC3 */ + /* FT_DEFINE_SERVICEDESCREC4 */ + /* FT_DEFINE_SERVICEDESCREC5 */ + /* FT_DEFINE_SERVICEDESCREC6 */ + /* FT_DEFINE_SERVICEDESCREC7 */ + /* FT_DEFINE_SERVICEDESCREC8 */ + /* */ + /* <Description> */ + /* Used to initialize an array of FT_ServiceDescRec structures. */ + /* */ + /* When FT_CONFIG_OPTION_PIC is defined a `create' function needs to */ + /* be called with a pointer to return an allocated array. As soon as */ + /* it is no longer needed, a `destroy' function needs to be called to */ + /* release that allocation. */ + /* */ + /* These functions should be manually called from the `pic_init' and */ + /* `pic_free' functions of your module (see FT_DEFINE_MODULE). */ + /* */ + /* When FT_CONFIG_OPTION_PIC is not defined the array will be */ + /* allocated in the global scope (or the scope where the macro is */ + /* used). */ + /* */ +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICEDESCREC1( class_, \ + serv_id_1, serv_data_1 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { NULL, NULL } \ + }; + +#define FT_DEFINE_SERVICEDESCREC2( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { NULL, NULL } \ + }; + +#define FT_DEFINE_SERVICEDESCREC3( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { serv_id_3, serv_data_3 }, \ + { NULL, NULL } \ + }; + +#define FT_DEFINE_SERVICEDESCREC4( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { serv_id_3, serv_data_3 }, \ + { serv_id_4, serv_data_4 }, \ + { NULL, NULL } \ + }; + +#define FT_DEFINE_SERVICEDESCREC5( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { serv_id_3, serv_data_3 }, \ + { serv_id_4, serv_data_4 }, \ + { serv_id_5, serv_data_5 }, \ + { NULL, NULL } \ + }; + +#define FT_DEFINE_SERVICEDESCREC6( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { serv_id_3, serv_data_3 }, \ + { serv_id_4, serv_data_4 }, \ + { serv_id_5, serv_data_5 }, \ + { serv_id_6, serv_data_6 }, \ + { NULL, NULL } \ + }; + +#define FT_DEFINE_SERVICEDESCREC7( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { serv_id_3, serv_data_3 }, \ + { serv_id_4, serv_data_4 }, \ + { serv_id_5, serv_data_5 }, \ + { serv_id_6, serv_data_6 }, \ + { serv_id_7, serv_data_7 }, \ + { NULL, NULL } \ + }; + +#define FT_DEFINE_SERVICEDESCREC8( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7, \ + serv_id_8, serv_data_8 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { serv_id_3, serv_data_3 }, \ + { serv_id_4, serv_data_4 }, \ + { serv_id_5, serv_data_5 }, \ + { serv_id_6, serv_data_6 }, \ + { serv_id_7, serv_data_7 }, \ + { serv_id_8, serv_data_8 }, \ + { NULL, NULL } \ + }; + +#define FT_DEFINE_SERVICEDESCREC9( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7, \ + serv_id_8, serv_data_8, \ + serv_id_9, serv_data_9 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { serv_id_3, serv_data_3 }, \ + { serv_id_4, serv_data_4 }, \ + { serv_id_5, serv_data_5 }, \ + { serv_id_6, serv_data_6 }, \ + { serv_id_7, serv_data_7 }, \ + { serv_id_8, serv_data_8 }, \ + { serv_id_9, serv_data_9 }, \ + { NULL, NULL } \ + }; + +#define FT_DEFINE_SERVICEDESCREC10( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7, \ + serv_id_8, serv_data_8, \ + serv_id_9, serv_data_9, \ + serv_id_10, serv_data_10 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { serv_id_3, serv_data_3 }, \ + { serv_id_4, serv_data_4 }, \ + { serv_id_5, serv_data_5 }, \ + { serv_id_6, serv_data_6 }, \ + { serv_id_7, serv_data_7 }, \ + { serv_id_8, serv_data_8 }, \ + { serv_id_9, serv_data_9 }, \ + { serv_id_10, serv_data_10 }, \ + { NULL, NULL } \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICEDESCREC1( class_, \ + serv_id_1, serv_data_1 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class ) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 2 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = NULL; \ + clazz[1].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#define FT_DEFINE_SERVICEDESCREC2( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class ) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 3 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = serv_id_2; \ + clazz[1].serv_data = serv_data_2; \ + clazz[2].serv_id = NULL; \ + clazz[2].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#define FT_DEFINE_SERVICEDESCREC3( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class ) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 4 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = serv_id_2; \ + clazz[1].serv_data = serv_data_2; \ + clazz[2].serv_id = serv_id_3; \ + clazz[2].serv_data = serv_data_3; \ + clazz[3].serv_id = NULL; \ + clazz[3].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#define FT_DEFINE_SERVICEDESCREC4( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class ) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 5 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = serv_id_2; \ + clazz[1].serv_data = serv_data_2; \ + clazz[2].serv_id = serv_id_3; \ + clazz[2].serv_data = serv_data_3; \ + clazz[3].serv_id = serv_id_4; \ + clazz[3].serv_data = serv_data_4; \ + clazz[4].serv_id = NULL; \ + clazz[4].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#define FT_DEFINE_SERVICEDESCREC5( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class ) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 6 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = serv_id_2; \ + clazz[1].serv_data = serv_data_2; \ + clazz[2].serv_id = serv_id_3; \ + clazz[2].serv_data = serv_data_3; \ + clazz[3].serv_id = serv_id_4; \ + clazz[3].serv_data = serv_data_4; \ + clazz[4].serv_id = serv_id_5; \ + clazz[4].serv_data = serv_data_5; \ + clazz[5].serv_id = NULL; \ + clazz[5].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#define FT_DEFINE_SERVICEDESCREC6( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class ) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 7 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = serv_id_2; \ + clazz[1].serv_data = serv_data_2; \ + clazz[2].serv_id = serv_id_3; \ + clazz[2].serv_data = serv_data_3; \ + clazz[3].serv_id = serv_id_4; \ + clazz[3].serv_data = serv_data_4; \ + clazz[4].serv_id = serv_id_5; \ + clazz[4].serv_data = serv_data_5; \ + clazz[5].serv_id = serv_id_6; \ + clazz[5].serv_data = serv_data_6; \ + clazz[6].serv_id = NULL; \ + clazz[6].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#define FT_DEFINE_SERVICEDESCREC7( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class ) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 8 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = serv_id_2; \ + clazz[1].serv_data = serv_data_2; \ + clazz[2].serv_id = serv_id_3; \ + clazz[2].serv_data = serv_data_3; \ + clazz[3].serv_id = serv_id_4; \ + clazz[3].serv_data = serv_data_4; \ + clazz[4].serv_id = serv_id_5; \ + clazz[4].serv_data = serv_data_5; \ + clazz[5].serv_id = serv_id_6; \ + clazz[5].serv_data = serv_data_6; \ + clazz[6].serv_id = serv_id_7; \ + clazz[6].serv_data = serv_data_7; \ + clazz[7].serv_id = NULL; \ + clazz[7].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#define FT_DEFINE_SERVICEDESCREC8( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7, \ + serv_id_8, serv_data_8 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class ) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 9 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = serv_id_2; \ + clazz[1].serv_data = serv_data_2; \ + clazz[2].serv_id = serv_id_3; \ + clazz[2].serv_data = serv_data_3; \ + clazz[3].serv_id = serv_id_4; \ + clazz[3].serv_data = serv_data_4; \ + clazz[4].serv_id = serv_id_5; \ + clazz[4].serv_data = serv_data_5; \ + clazz[5].serv_id = serv_id_6; \ + clazz[5].serv_data = serv_data_6; \ + clazz[6].serv_id = serv_id_7; \ + clazz[6].serv_data = serv_data_7; \ + clazz[7].serv_id = serv_id_8; \ + clazz[7].serv_data = serv_data_8; \ + clazz[8].serv_id = NULL; \ + clazz[8].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#define FT_DEFINE_SERVICEDESCREC9( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7, \ + serv_id_8, serv_data_8, \ + serv_id_9, serv_data_9 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class ) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 10 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = serv_id_2; \ + clazz[1].serv_data = serv_data_2; \ + clazz[2].serv_id = serv_id_3; \ + clazz[2].serv_data = serv_data_3; \ + clazz[3].serv_id = serv_id_4; \ + clazz[3].serv_data = serv_data_4; \ + clazz[4].serv_id = serv_id_5; \ + clazz[4].serv_data = serv_data_5; \ + clazz[5].serv_id = serv_id_6; \ + clazz[5].serv_data = serv_data_6; \ + clazz[6].serv_id = serv_id_7; \ + clazz[6].serv_data = serv_data_7; \ + clazz[7].serv_id = serv_id_8; \ + clazz[7].serv_data = serv_data_8; \ + clazz[8].serv_id = serv_id_9; \ + clazz[8].serv_data = serv_data_9; \ + clazz[9].serv_id = NULL; \ + clazz[9].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#define FT_DEFINE_SERVICEDESCREC10( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7, \ + serv_id_8, serv_data_8, \ + serv_id_9, serv_data_9, \ + serv_id_10, serv_data_10 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class ) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 11 ) ) \ + return error; \ + \ + clazz[ 0].serv_id = serv_id_1; \ + clazz[ 0].serv_data = serv_data_1; \ + clazz[ 1].serv_id = serv_id_2; \ + clazz[ 1].serv_data = serv_data_2; \ + clazz[ 2].serv_id = serv_id_3; \ + clazz[ 2].serv_data = serv_data_3; \ + clazz[ 3].serv_id = serv_id_4; \ + clazz[ 3].serv_data = serv_data_4; \ + clazz[ 4].serv_id = serv_id_5; \ + clazz[ 4].serv_data = serv_data_5; \ + clazz[ 5].serv_id = serv_id_6; \ + clazz[ 5].serv_data = serv_data_6; \ + clazz[ 6].serv_id = serv_id_7; \ + clazz[ 6].serv_data = serv_data_7; \ + clazz[ 7].serv_id = serv_id_8; \ + clazz[ 7].serv_data = serv_data_8; \ + clazz[ 8].serv_id = serv_id_9; \ + clazz[ 8].serv_data = serv_data_9; \ + clazz[ 9].serv_id = serv_id_10; \ + clazz[ 9].serv_data = serv_data_10; \ + clazz[10].serv_id = NULL; \ + clazz[10].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + + /* + * Parse a list of FT_ServiceDescRec descriptors and look for + * a specific service by ID. Note that the last element in the + * array must be { NULL, NULL }, and that the function should + * return NULL if the service isn't available. + * + * This function can be used by modules to implement their + * `get_service' method. + */ + FT_BASE( FT_Pointer ) + ft_service_list_lookup( FT_ServiceDesc service_descriptors, + const char* service_id ); + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** S E R V I C E S C A C H E *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + /* + * This structure is used to store a cache for several frequently used + * services. It is the type of `face->internal->services'. You + * should only use FT_FACE_LOOKUP_SERVICE to access it. + * + * All fields should have the type FT_Pointer to relax compilation + * dependencies. We assume the developer isn't completely stupid. + * + * Each field must be named `service_XXXX' where `XXX' corresponds to + * the correct FT_SERVICE_ID_XXXX macro. See the definition of + * FT_FACE_LOOKUP_SERVICE below how this is implemented. + * + */ + typedef struct FT_ServiceCacheRec_ + { + FT_Pointer service_POSTSCRIPT_FONT_NAME; + FT_Pointer service_MULTI_MASTERS; + FT_Pointer service_METRICS_VARIATIONS; + FT_Pointer service_GLYPH_DICT; + FT_Pointer service_PFR_METRICS; + FT_Pointer service_WINFNT; + + } FT_ServiceCacheRec, *FT_ServiceCache; + + + /* + * A magic number used within the services cache. + */ + + /* ensure that value `1' has the same width as a pointer */ +#define FT_SERVICE_UNAVAILABLE ((FT_Pointer)~(FT_PtrDist)1) + + + /* + * @macro: + * FT_FACE_LOOKUP_SERVICE + * + * @description: + * This macro is used to look up a service from a face's driver module + * using its cache. + * + * @input: + * face:: + * The source face handle containing the cache. + * + * field :: + * The field name in the cache. + * + * id :: + * The service ID. + * + * @output: + * ptr :: + * A variable receiving the service data. NULL if not available. + */ +#ifdef __cplusplus + +#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \ + FT_BEGIN_STMNT \ + FT_Pointer svc; \ + FT_Pointer* Pptr = (FT_Pointer*)&(ptr); \ + \ + \ + svc = FT_FACE( face )->internal->services. service_ ## id; \ + if ( svc == FT_SERVICE_UNAVAILABLE ) \ + svc = NULL; \ + else if ( svc == NULL ) \ + { \ + FT_FACE_FIND_SERVICE( face, svc, id ); \ + \ + FT_FACE( face )->internal->services. service_ ## id = \ + (FT_Pointer)( svc != NULL ? svc \ + : FT_SERVICE_UNAVAILABLE ); \ + } \ + *Pptr = svc; \ + FT_END_STMNT + +#else /* !C++ */ + +#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \ + FT_BEGIN_STMNT \ + FT_Pointer svc; \ + \ + \ + svc = FT_FACE( face )->internal->services. service_ ## id; \ + if ( svc == FT_SERVICE_UNAVAILABLE ) \ + svc = NULL; \ + else if ( svc == NULL ) \ + { \ + FT_FACE_FIND_SERVICE( face, svc, id ); \ + \ + FT_FACE( face )->internal->services. service_ ## id = \ + (FT_Pointer)( svc != NULL ? svc \ + : FT_SERVICE_UNAVAILABLE ); \ + } \ + ptr = svc; \ + FT_END_STMNT + +#endif /* !C++ */ + + /* + * A macro used to define new service structure types. + */ + +#define FT_DEFINE_SERVICE( name ) \ + typedef struct FT_Service_ ## name ## Rec_ \ + FT_Service_ ## name ## Rec ; \ + typedef struct FT_Service_ ## name ## Rec_ \ + const * FT_Service_ ## name ; \ + struct FT_Service_ ## name ## Rec_ + + /* */ + + /* + * The header files containing the services. + */ + +#define FT_SERVICE_BDF_H <freetype/internal/services/svbdf.h> +#define FT_SERVICE_CFF_TABLE_LOAD_H <freetype/internal/services/svcfftl.h> +#define FT_SERVICE_CID_H <freetype/internal/services/svcid.h> +#define FT_SERVICE_FONT_FORMAT_H <freetype/internal/services/svfntfmt.h> +#define FT_SERVICE_GLYPH_DICT_H <freetype/internal/services/svgldict.h> +#define FT_SERVICE_GX_VALIDATE_H <freetype/internal/services/svgxval.h> +#define FT_SERVICE_KERNING_H <freetype/internal/services/svkern.h> +#define FT_SERVICE_METRICS_VARIATIONS_H <freetype/internal/services/svmetric.h> +#define FT_SERVICE_MULTIPLE_MASTERS_H <freetype/internal/services/svmm.h> +#define FT_SERVICE_OPENTYPE_VALIDATE_H <freetype/internal/services/svotval.h> +#define FT_SERVICE_PFR_H <freetype/internal/services/svpfr.h> +#define FT_SERVICE_POSTSCRIPT_CMAPS_H <freetype/internal/services/svpscmap.h> +#define FT_SERVICE_POSTSCRIPT_INFO_H <freetype/internal/services/svpsinfo.h> +#define FT_SERVICE_POSTSCRIPT_NAME_H <freetype/internal/services/svpostnm.h> +#define FT_SERVICE_PROPERTIES_H <freetype/internal/services/svprop.h> +#define FT_SERVICE_SFNT_H <freetype/internal/services/svsfnt.h> +#define FT_SERVICE_TRUETYPE_ENGINE_H <freetype/internal/services/svtteng.h> +#define FT_SERVICE_TRUETYPE_GLYF_H <freetype/internal/services/svttglyf.h> +#define FT_SERVICE_TT_CMAP_H <freetype/internal/services/svttcmap.h> +#define FT_SERVICE_WINFNT_H <freetype/internal/services/svwinfnt.h> + + /* */ + +FT_END_HEADER + +#endif /* FTSERV_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftstream.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftstream.h new file mode 100644 index 0000000..f90002f --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftstream.h @@ -0,0 +1,536 @@ +/***************************************************************************/ +/* */ +/* ftstream.h */ +/* */ +/* Stream handling (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTSTREAM_H_ +#define FTSTREAM_H_ + + +#include <ft2build.h> +#include FT_SYSTEM_H +#include FT_INTERNAL_OBJECTS_H + + +FT_BEGIN_HEADER + + + /* format of an 8-bit frame_op value: */ + /* */ + /* bit 76543210 */ + /* xxxxxxes */ + /* */ + /* s is set to 1 if the value is signed. */ + /* e is set to 1 if the value is little-endian. */ + /* xxx is a command. */ + +#define FT_FRAME_OP_SHIFT 2 +#define FT_FRAME_OP_SIGNED 1 +#define FT_FRAME_OP_LITTLE 2 +#define FT_FRAME_OP_COMMAND( x ) ( x >> FT_FRAME_OP_SHIFT ) + +#define FT_MAKE_FRAME_OP( command, little, sign ) \ + ( ( command << FT_FRAME_OP_SHIFT ) | ( little << 1 ) | sign ) + +#define FT_FRAME_OP_END 0 +#define FT_FRAME_OP_START 1 /* start a new frame */ +#define FT_FRAME_OP_BYTE 2 /* read 1-byte value */ +#define FT_FRAME_OP_SHORT 3 /* read 2-byte value */ +#define FT_FRAME_OP_LONG 4 /* read 4-byte value */ +#define FT_FRAME_OP_OFF3 5 /* read 3-byte value */ +#define FT_FRAME_OP_BYTES 6 /* read a bytes sequence */ + + + typedef enum FT_Frame_Op_ + { + ft_frame_end = 0, + ft_frame_start = FT_MAKE_FRAME_OP( FT_FRAME_OP_START, 0, 0 ), + + ft_frame_byte = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 0 ), + ft_frame_schar = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 1 ), + + ft_frame_ushort_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 0 ), + ft_frame_short_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 1 ), + ft_frame_ushort_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 0 ), + ft_frame_short_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 1 ), + + ft_frame_ulong_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 0 ), + ft_frame_long_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 1 ), + ft_frame_ulong_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 0 ), + ft_frame_long_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 1 ), + + ft_frame_uoff3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 0 ), + ft_frame_off3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 1 ), + ft_frame_uoff3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ), + ft_frame_off3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ), + + ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 ), + ft_frame_skip = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 1 ) + + } FT_Frame_Op; + + + typedef struct FT_Frame_Field_ + { + FT_Byte value; + FT_Byte size; + FT_UShort offset; + + } FT_Frame_Field; + + + /* Construct an FT_Frame_Field out of a structure type and a field name. */ + /* The structure type must be set in the FT_STRUCTURE macro before */ + /* calling the FT_FRAME_START() macro. */ + /* */ +#define FT_FIELD_SIZE( f ) \ + (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f ) + +#define FT_FIELD_SIZE_DELTA( f ) \ + (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f[0] ) + +#define FT_FIELD_OFFSET( f ) \ + (FT_UShort)( offsetof( FT_STRUCTURE, f ) ) + +#define FT_FRAME_FIELD( frame_op, field ) \ + { \ + frame_op, \ + FT_FIELD_SIZE( field ), \ + FT_FIELD_OFFSET( field ) \ + } + +#define FT_MAKE_EMPTY_FIELD( frame_op ) { frame_op, 0, 0 } + +#define FT_FRAME_START( size ) { ft_frame_start, 0, size } +#define FT_FRAME_END { ft_frame_end, 0, 0 } + +#define FT_FRAME_LONG( f ) FT_FRAME_FIELD( ft_frame_long_be, f ) +#define FT_FRAME_ULONG( f ) FT_FRAME_FIELD( ft_frame_ulong_be, f ) +#define FT_FRAME_SHORT( f ) FT_FRAME_FIELD( ft_frame_short_be, f ) +#define FT_FRAME_USHORT( f ) FT_FRAME_FIELD( ft_frame_ushort_be, f ) +#define FT_FRAME_OFF3( f ) FT_FRAME_FIELD( ft_frame_off3_be, f ) +#define FT_FRAME_UOFF3( f ) FT_FRAME_FIELD( ft_frame_uoff3_be, f ) +#define FT_FRAME_BYTE( f ) FT_FRAME_FIELD( ft_frame_byte, f ) +#define FT_FRAME_CHAR( f ) FT_FRAME_FIELD( ft_frame_schar, f ) + +#define FT_FRAME_LONG_LE( f ) FT_FRAME_FIELD( ft_frame_long_le, f ) +#define FT_FRAME_ULONG_LE( f ) FT_FRAME_FIELD( ft_frame_ulong_le, f ) +#define FT_FRAME_SHORT_LE( f ) FT_FRAME_FIELD( ft_frame_short_le, f ) +#define FT_FRAME_USHORT_LE( f ) FT_FRAME_FIELD( ft_frame_ushort_le, f ) +#define FT_FRAME_OFF3_LE( f ) FT_FRAME_FIELD( ft_frame_off3_le, f ) +#define FT_FRAME_UOFF3_LE( f ) FT_FRAME_FIELD( ft_frame_uoff3_le, f ) + +#define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 } +#define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 } +#define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 } + +#define FT_FRAME_BYTES( field, count ) \ + { \ + ft_frame_bytes, \ + count, \ + FT_FIELD_OFFSET( field ) \ + } + +#define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 } + + + /*************************************************************************/ + /* */ + /* Integer extraction macros -- the `buffer' parameter must ALWAYS be of */ + /* type `char*' or equivalent (1-byte elements). */ + /* */ + +#define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] ) + +#define FT_INT16( x ) ( (FT_Int16)(x) ) +#define FT_UINT16( x ) ( (FT_UInt16)(x) ) +#define FT_INT32( x ) ( (FT_Int32)(x) ) +#define FT_UINT32( x ) ( (FT_UInt32)(x) ) + + +#define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) ) +#define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) + + +#define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8 ) | \ + FT_BYTE_U16( p, 1, 0 ) ) + +#define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \ + FT_BYTE_U16( p, 1, 0 ) ) + +#define FT_PEEK_LONG( p ) FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \ + FT_BYTE_U32( p, 1, 16 ) | \ + FT_BYTE_U32( p, 2, 8 ) | \ + FT_BYTE_U32( p, 3, 0 ) ) + +#define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \ + FT_BYTE_U32( p, 1, 16 ) | \ + FT_BYTE_U32( p, 2, 8 ) | \ + FT_BYTE_U32( p, 3, 0 ) ) + +#define FT_PEEK_OFF3( p ) FT_INT32( FT_BYTE_U32( p, 0, 16 ) | \ + FT_BYTE_U32( p, 1, 8 ) | \ + FT_BYTE_U32( p, 2, 0 ) ) + +#define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \ + FT_BYTE_U32( p, 1, 8 ) | \ + FT_BYTE_U32( p, 2, 0 ) ) + +#define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_BYTE_U16( p, 1, 8 ) | \ + FT_BYTE_U16( p, 0, 0 ) ) + +#define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \ + FT_BYTE_U16( p, 0, 0 ) ) + +#define FT_PEEK_LONG_LE( p ) FT_INT32( FT_BYTE_U32( p, 3, 24 ) | \ + FT_BYTE_U32( p, 2, 16 ) | \ + FT_BYTE_U32( p, 1, 8 ) | \ + FT_BYTE_U32( p, 0, 0 ) ) + +#define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \ + FT_BYTE_U32( p, 2, 16 ) | \ + FT_BYTE_U32( p, 1, 8 ) | \ + FT_BYTE_U32( p, 0, 0 ) ) + +#define FT_PEEK_OFF3_LE( p ) FT_INT32( FT_BYTE_U32( p, 2, 16 ) | \ + FT_BYTE_U32( p, 1, 8 ) | \ + FT_BYTE_U32( p, 0, 0 ) ) + +#define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \ + FT_BYTE_U32( p, 1, 8 ) | \ + FT_BYTE_U32( p, 0, 0 ) ) + + +#define FT_NEXT_CHAR( buffer ) \ + ( (signed char)*buffer++ ) + +#define FT_NEXT_BYTE( buffer ) \ + ( (unsigned char)*buffer++ ) + +#define FT_NEXT_SHORT( buffer ) \ + ( (short)( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) ) ) + +#define FT_NEXT_USHORT( buffer ) \ + ( (unsigned short)( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) ) ) + +#define FT_NEXT_OFF3( buffer ) \ + ( (long)( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) ) ) + +#define FT_NEXT_UOFF3( buffer ) \ + ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) ) ) + +#define FT_NEXT_LONG( buffer ) \ + ( (long)( buffer += 4, FT_PEEK_LONG( buffer - 4 ) ) ) + +#define FT_NEXT_ULONG( buffer ) \ + ( (unsigned long)( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) ) ) + + +#define FT_NEXT_SHORT_LE( buffer ) \ + ( (short)( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) ) ) + +#define FT_NEXT_USHORT_LE( buffer ) \ + ( (unsigned short)( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) ) ) + +#define FT_NEXT_OFF3_LE( buffer ) \ + ( (long)( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) ) ) + +#define FT_NEXT_UOFF3_LE( buffer ) \ + ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) ) ) + +#define FT_NEXT_LONG_LE( buffer ) \ + ( (long)( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) ) ) + +#define FT_NEXT_ULONG_LE( buffer ) \ + ( (unsigned long)( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) ) ) + + + /*************************************************************************/ + /* */ + /* Each GET_xxxx() macro uses an implicit `stream' variable. */ + /* */ +#if 0 +#define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor ) + +#define FT_GET_CHAR() FT_GET_MACRO( CHAR ) +#define FT_GET_BYTE() FT_GET_MACRO( BYTE ) +#define FT_GET_SHORT() FT_GET_MACRO( SHORT ) +#define FT_GET_USHORT() FT_GET_MACRO( USHORT ) +#define FT_GET_OFF3() FT_GET_MACRO( OFF3 ) +#define FT_GET_UOFF3() FT_GET_MACRO( UOFF3 ) +#define FT_GET_LONG() FT_GET_MACRO( LONG ) +#define FT_GET_ULONG() FT_GET_MACRO( ULONG ) +#define FT_GET_TAG4() FT_GET_MACRO( ULONG ) + +#define FT_GET_SHORT_LE() FT_GET_MACRO( SHORT_LE ) +#define FT_GET_USHORT_LE() FT_GET_MACRO( USHORT_LE ) +#define FT_GET_LONG_LE() FT_GET_MACRO( LONG_LE ) +#define FT_GET_ULONG_LE() FT_GET_MACRO( ULONG_LE ) + +#else +#define FT_GET_MACRO( func, type ) ( (type)func( stream ) ) + +#define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetChar, FT_Char ) +#define FT_GET_BYTE() FT_GET_MACRO( FT_Stream_GetChar, FT_Byte ) +#define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_Short ) +#define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_UShort ) +#define FT_GET_OFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_Long ) +#define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_ULong ) +#define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetULong, FT_Long ) +#define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong ) +#define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong ) + +#define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_Short ) +#define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_UShort ) +#define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_Long ) +#define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_ULong ) +#endif + +#define FT_READ_MACRO( func, type, var ) \ + ( var = (type)func( stream, &error ), \ + error != FT_Err_Ok ) + +#define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Byte, var ) +#define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Char, var ) +#define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Short, var ) +#define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_UShort, var ) +#define FT_READ_OFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_Long, var ) +#define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_ULong, var ) +#define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_Long, var ) +#define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_ULong, var ) + +#define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_Short, var ) +#define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_UShort, var ) +#define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_Long, var ) +#define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_ULong, var ) + + +#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM + + /* initialize a stream for reading a regular system stream */ + FT_BASE( FT_Error ) + FT_Stream_Open( FT_Stream stream, + const char* filepathname ); + +#endif /* FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */ + + + /* create a new (input) stream from an FT_Open_Args structure */ + FT_BASE( FT_Error ) + FT_Stream_New( FT_Library library, + const FT_Open_Args* args, + FT_Stream *astream ); + + /* free a stream */ + FT_BASE( void ) + FT_Stream_Free( FT_Stream stream, + FT_Int external ); + + /* initialize a stream for reading in-memory data */ + FT_BASE( void ) + FT_Stream_OpenMemory( FT_Stream stream, + const FT_Byte* base, + FT_ULong size ); + + /* close a stream (does not destroy the stream structure) */ + FT_BASE( void ) + FT_Stream_Close( FT_Stream stream ); + + + /* seek within a stream. position is relative to start of stream */ + FT_BASE( FT_Error ) + FT_Stream_Seek( FT_Stream stream, + FT_ULong pos ); + + /* skip bytes in a stream */ + FT_BASE( FT_Error ) + FT_Stream_Skip( FT_Stream stream, + FT_Long distance ); + + /* return current stream position */ + FT_BASE( FT_ULong ) + FT_Stream_Pos( FT_Stream stream ); + + /* read bytes from a stream into a user-allocated buffer, returns an */ + /* error if not all bytes could be read. */ + FT_BASE( FT_Error ) + FT_Stream_Read( FT_Stream stream, + FT_Byte* buffer, + FT_ULong count ); + + /* read bytes from a stream at a given position */ + FT_BASE( FT_Error ) + FT_Stream_ReadAt( FT_Stream stream, + FT_ULong pos, + FT_Byte* buffer, + FT_ULong count ); + + /* try to read bytes at the end of a stream; return number of bytes */ + /* really available */ + FT_BASE( FT_ULong ) + FT_Stream_TryRead( FT_Stream stream, + FT_Byte* buffer, + FT_ULong count ); + + /* Enter a frame of `count' consecutive bytes in a stream. Returns an */ + /* error if the frame could not be read/accessed. The caller can use */ + /* the FT_Stream_Get_XXX functions to retrieve frame data without */ + /* error checks. */ + /* */ + /* You must _always_ call FT_Stream_ExitFrame() once you have entered */ + /* a stream frame! */ + /* */ + FT_BASE( FT_Error ) + FT_Stream_EnterFrame( FT_Stream stream, + FT_ULong count ); + + /* exit a stream frame */ + FT_BASE( void ) + FT_Stream_ExitFrame( FT_Stream stream ); + + /* Extract a stream frame. If the stream is disk-based, a heap block */ + /* is allocated and the frame bytes are read into it. If the stream */ + /* is memory-based, this function simply set a pointer to the data. */ + /* */ + /* Useful to optimize access to memory-based streams transparently. */ + /* */ + /* All extracted frames must be `freed' with a call to the function */ + /* FT_Stream_ReleaseFrame(). */ + /* */ + FT_BASE( FT_Error ) + FT_Stream_ExtractFrame( FT_Stream stream, + FT_ULong count, + FT_Byte** pbytes ); + + /* release an extract frame (see FT_Stream_ExtractFrame) */ + FT_BASE( void ) + FT_Stream_ReleaseFrame( FT_Stream stream, + FT_Byte** pbytes ); + + /* read a byte from an entered frame */ + FT_BASE( FT_Char ) + FT_Stream_GetChar( FT_Stream stream ); + + /* read a 16-bit big-endian unsigned integer from an entered frame */ + FT_BASE( FT_UShort ) + FT_Stream_GetUShort( FT_Stream stream ); + + /* read a 24-bit big-endian unsigned integer from an entered frame */ + FT_BASE( FT_ULong ) + FT_Stream_GetUOffset( FT_Stream stream ); + + /* read a 32-bit big-endian unsigned integer from an entered frame */ + FT_BASE( FT_ULong ) + FT_Stream_GetULong( FT_Stream stream ); + + /* read a 16-bit little-endian unsigned integer from an entered frame */ + FT_BASE( FT_UShort ) + FT_Stream_GetUShortLE( FT_Stream stream ); + + /* read a 32-bit little-endian unsigned integer from an entered frame */ + FT_BASE( FT_ULong ) + FT_Stream_GetULongLE( FT_Stream stream ); + + + /* read a byte from a stream */ + FT_BASE( FT_Char ) + FT_Stream_ReadChar( FT_Stream stream, + FT_Error* error ); + + /* read a 16-bit big-endian unsigned integer from a stream */ + FT_BASE( FT_UShort ) + FT_Stream_ReadUShort( FT_Stream stream, + FT_Error* error ); + + /* read a 24-bit big-endian unsigned integer from a stream */ + FT_BASE( FT_ULong ) + FT_Stream_ReadUOffset( FT_Stream stream, + FT_Error* error ); + + /* read a 32-bit big-endian integer from a stream */ + FT_BASE( FT_ULong ) + FT_Stream_ReadULong( FT_Stream stream, + FT_Error* error ); + + /* read a 16-bit little-endian unsigned integer from a stream */ + FT_BASE( FT_UShort ) + FT_Stream_ReadUShortLE( FT_Stream stream, + FT_Error* error ); + + /* read a 32-bit little-endian unsigned integer from a stream */ + FT_BASE( FT_ULong ) + FT_Stream_ReadULongLE( FT_Stream stream, + FT_Error* error ); + + /* Read a structure from a stream. The structure must be described */ + /* by an array of FT_Frame_Field records. */ + FT_BASE( FT_Error ) + FT_Stream_ReadFields( FT_Stream stream, + const FT_Frame_Field* fields, + void* structure ); + + +#define FT_STREAM_POS() \ + FT_Stream_Pos( stream ) + +#define FT_STREAM_SEEK( position ) \ + FT_SET_ERROR( FT_Stream_Seek( stream, \ + (FT_ULong)(position) ) ) + +#define FT_STREAM_SKIP( distance ) \ + FT_SET_ERROR( FT_Stream_Skip( stream, \ + (FT_Long)(distance) ) ) + +#define FT_STREAM_READ( buffer, count ) \ + FT_SET_ERROR( FT_Stream_Read( stream, \ + (FT_Byte*)(buffer), \ + (FT_ULong)(count) ) ) + +#define FT_STREAM_READ_AT( position, buffer, count ) \ + FT_SET_ERROR( FT_Stream_ReadAt( stream, \ + (FT_ULong)(position), \ + (FT_Byte*)(buffer), \ + (FT_ULong)(count) ) ) + +#define FT_STREAM_READ_FIELDS( fields, object ) \ + FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) ) + + +#define FT_FRAME_ENTER( size ) \ + FT_SET_ERROR( \ + FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, \ + (FT_ULong)(size) ) ) ) + +#define FT_FRAME_EXIT() \ + FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) ) + +#define FT_FRAME_EXTRACT( size, bytes ) \ + FT_SET_ERROR( \ + FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, \ + (FT_ULong)(size), \ + (FT_Byte**)&(bytes) ) ) ) + +#define FT_FRAME_RELEASE( bytes ) \ + FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \ + (FT_Byte**)&(bytes) ) ) + + +FT_END_HEADER + +#endif /* FTSTREAM_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/fttrace.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/fttrace.h new file mode 100644 index 0000000..8092e41 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/fttrace.h @@ -0,0 +1,153 @@ +/***************************************************************************/ +/* */ +/* fttrace.h */ +/* */ +/* Tracing handling (specification only). */ +/* */ +/* Copyright 2002-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /* definitions of trace levels for FreeType 2 */ + + /* the first level must always be `trace_any' */ +FT_TRACE_DEF( any ) + + /* base components */ +FT_TRACE_DEF( calc ) /* calculations (ftcalc.c) */ +FT_TRACE_DEF( memory ) /* memory manager (ftobjs.c) */ +FT_TRACE_DEF( stream ) /* stream manager (ftstream.c) */ +FT_TRACE_DEF( io ) /* i/o interface (ftsystem.c) */ +FT_TRACE_DEF( list ) /* list management (ftlist.c) */ +FT_TRACE_DEF( init ) /* initialization (ftinit.c) */ +FT_TRACE_DEF( objs ) /* base objects (ftobjs.c) */ +FT_TRACE_DEF( outline ) /* outline management (ftoutln.c) */ +FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */ +FT_TRACE_DEF( gloader ) /* glyph loader (ftgloadr.c) */ + +FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */ +FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */ +FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */ +FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */ +FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */ +FT_TRACE_DEF( bitmap ) /* bitmap checksum (ftobjs.c) */ +FT_TRACE_DEF( psprops ) /* PS driver properties (ftpsprop.c) */ + + /* Cache sub-system */ +FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */ + + /* SFNT driver components */ +FT_TRACE_DEF( sfdriver ) /* SFNT font driver (sfdriver.c) */ +FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */ +FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */ +FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */ +FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */ +FT_TRACE_DEF( ttmtx ) /* metrics-related tables (ttmtx.c) */ +FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */ +FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */ +FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */ + + /* TrueType driver components */ +FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */ +FT_TRACE_DEF( ttgload ) /* TT glyph loader (ttgload.c) */ +FT_TRACE_DEF( ttinterp ) /* bytecode interpreter (ttinterp.c) */ +FT_TRACE_DEF( ttobjs ) /* TT objects manager (ttobjs.c) */ +FT_TRACE_DEF( ttpload ) /* TT data/program loader (ttpload.c) */ +FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */ + + /* Type 1 driver components */ +FT_TRACE_DEF( t1afm ) +FT_TRACE_DEF( t1driver ) +FT_TRACE_DEF( t1gload ) +FT_TRACE_DEF( t1load ) +FT_TRACE_DEF( t1objs ) +FT_TRACE_DEF( t1parse ) + + /* PostScript helper module `psaux' */ +FT_TRACE_DEF( t1decode ) +FT_TRACE_DEF( cffdecode ) +FT_TRACE_DEF( psobjs ) +FT_TRACE_DEF( psconv ) + + /* PostScript hinting module `pshinter' */ +FT_TRACE_DEF( pshrec ) +FT_TRACE_DEF( pshalgo ) + + /* Type 2 driver components */ +FT_TRACE_DEF( cffdriver ) +FT_TRACE_DEF( cffgload ) +FT_TRACE_DEF( cffload ) +FT_TRACE_DEF( cffobjs ) +FT_TRACE_DEF( cffparse ) + +FT_TRACE_DEF( cf2blues ) +FT_TRACE_DEF( cf2hints ) +FT_TRACE_DEF( cf2interp ) + + /* Type 42 driver component */ +FT_TRACE_DEF( t42 ) + + /* CID driver components */ +FT_TRACE_DEF( ciddriver ) +FT_TRACE_DEF( cidgload ) +FT_TRACE_DEF( cidload ) +FT_TRACE_DEF( cidobjs ) +FT_TRACE_DEF( cidparse ) + + /* Windows font component */ +FT_TRACE_DEF( winfnt ) + + /* PCF font components */ +FT_TRACE_DEF( pcfdriver ) +FT_TRACE_DEF( pcfread ) + + /* BDF font components */ +FT_TRACE_DEF( bdfdriver ) +FT_TRACE_DEF( bdflib ) + + /* PFR font component */ +FT_TRACE_DEF( pfr ) + + /* OpenType validation components */ +FT_TRACE_DEF( otvmodule ) +FT_TRACE_DEF( otvcommon ) +FT_TRACE_DEF( otvbase ) +FT_TRACE_DEF( otvgdef ) +FT_TRACE_DEF( otvgpos ) +FT_TRACE_DEF( otvgsub ) +FT_TRACE_DEF( otvjstf ) +FT_TRACE_DEF( otvmath ) + + /* TrueTypeGX/AAT validation components */ +FT_TRACE_DEF( gxvmodule ) +FT_TRACE_DEF( gxvcommon ) +FT_TRACE_DEF( gxvfeat ) +FT_TRACE_DEF( gxvmort ) +FT_TRACE_DEF( gxvmorx ) +FT_TRACE_DEF( gxvbsln ) +FT_TRACE_DEF( gxvjust ) +FT_TRACE_DEF( gxvkern ) +FT_TRACE_DEF( gxvopbd ) +FT_TRACE_DEF( gxvtrak ) +FT_TRACE_DEF( gxvprop ) +FT_TRACE_DEF( gxvlcar ) + + /* autofit components */ +FT_TRACE_DEF( afmodule ) +FT_TRACE_DEF( afhints ) +FT_TRACE_DEF( afcjk ) +FT_TRACE_DEF( aflatin ) +FT_TRACE_DEF( aflatin2 ) +FT_TRACE_DEF( afwarp ) +FT_TRACE_DEF( afshaper ) +FT_TRACE_DEF( afglobal ) + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftvalid.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftvalid.h new file mode 100644 index 0000000..cad47a5 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/ftvalid.h @@ -0,0 +1,159 @@ +/***************************************************************************/ +/* */ +/* ftvalid.h */ +/* */ +/* FreeType validation support (specification). */ +/* */ +/* Copyright 2004-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTVALID_H_ +#define FTVALID_H_ + +#include <ft2build.h> +#include FT_CONFIG_STANDARD_LIBRARY_H /* for ft_setjmp and ft_longjmp */ + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** V A L I D A T I O N ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + /* handle to a validation object */ + typedef struct FT_ValidatorRec_ volatile* FT_Validator; + + + /*************************************************************************/ + /* */ + /* There are three distinct validation levels defined here: */ + /* */ + /* FT_VALIDATE_DEFAULT :: */ + /* A table that passes this validation level can be used reliably by */ + /* FreeType. It generally means that all offsets have been checked to */ + /* prevent out-of-bound reads, that array counts are correct, etc. */ + /* */ + /* FT_VALIDATE_TIGHT :: */ + /* A table that passes this validation level can be used reliably and */ + /* doesn't contain invalid data. For example, a charmap table that */ + /* returns invalid glyph indices will not pass, even though it can */ + /* be used with FreeType in default mode (the library will simply */ + /* return an error later when trying to load the glyph). */ + /* */ + /* It also checks that fields which must be a multiple of 2, 4, or 8, */ + /* don't have incorrect values, etc. */ + /* */ + /* FT_VALIDATE_PARANOID :: */ + /* Only for font debugging. Checks that a table follows the */ + /* specification by 100%. Very few fonts will be able to pass this */ + /* level anyway but it can be useful for certain tools like font */ + /* editors/converters. */ + /* */ + typedef enum FT_ValidationLevel_ + { + FT_VALIDATE_DEFAULT = 0, + FT_VALIDATE_TIGHT, + FT_VALIDATE_PARANOID + + } FT_ValidationLevel; + + +#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ + /* We disable the warning `structure was padded due to */ + /* __declspec(align())' in order to compile cleanly with */ + /* the maximum level of warnings. */ +#pragma warning( push ) +#pragma warning( disable : 4324 ) +#endif /* _MSC_VER */ + + /* validator structure */ + typedef struct FT_ValidatorRec_ + { + ft_jmp_buf jump_buffer; /* used for exception handling */ + + const FT_Byte* base; /* address of table in memory */ + const FT_Byte* limit; /* `base' + sizeof(table) in memory */ + FT_ValidationLevel level; /* validation level */ + FT_Error error; /* error returned. 0 means success */ + + } FT_ValidatorRec; + +#if defined( _MSC_VER ) +#pragma warning( pop ) +#endif + +#define FT_VALIDATOR( x ) ( (FT_Validator)( x ) ) + + + FT_BASE( void ) + ft_validator_init( FT_Validator valid, + const FT_Byte* base, + const FT_Byte* limit, + FT_ValidationLevel level ); + + /* Do not use this. It's broken and will cause your validator to crash */ + /* if you run it on an invalid font. */ + FT_BASE( FT_Int ) + ft_validator_run( FT_Validator valid ); + + /* Sets the error field in a validator, then calls `longjmp' to return */ + /* to high-level caller. Using `setjmp/longjmp' avoids many stupid */ + /* error checks within the validation routines. */ + /* */ + FT_BASE( void ) + ft_validator_error( FT_Validator valid, + FT_Error error ); + + + /* Calls ft_validate_error. Assumes that the `valid' local variable */ + /* holds a pointer to the current validator object. */ + /* */ +#define FT_INVALID( _error ) FT_INVALID_( _error ) +#define FT_INVALID_( _error ) \ + ft_validator_error( valid, FT_THROW( _error ) ) + + /* called when a broken table is detected */ +#define FT_INVALID_TOO_SHORT \ + FT_INVALID( Invalid_Table ) + + /* called when an invalid offset is detected */ +#define FT_INVALID_OFFSET \ + FT_INVALID( Invalid_Offset ) + + /* called when an invalid format/value is detected */ +#define FT_INVALID_FORMAT \ + FT_INVALID( Invalid_Table ) + + /* called when an invalid glyph index is detected */ +#define FT_INVALID_GLYPH_ID \ + FT_INVALID( Invalid_Glyph_Index ) + + /* called when an invalid field value is detected */ +#define FT_INVALID_DATA \ + FT_INVALID( Invalid_Table ) + + +FT_END_HEADER + +#endif /* FTVALID_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/internal.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/internal.h new file mode 100644 index 0000000..8f546e4 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/internal.h @@ -0,0 +1,67 @@ +/***************************************************************************/ +/* */ +/* internal.h */ +/* */ +/* Internal header files (specification only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file is automatically included by `ft2build.h'. */ + /* Do not include it manually! */ + /* */ + /*************************************************************************/ + + +#define FT_INTERNAL_OBJECTS_H <freetype/internal/ftobjs.h> +#define FT_INTERNAL_PIC_H <freetype/internal/ftpic.h> +#define FT_INTERNAL_STREAM_H <freetype/internal/ftstream.h> +#define FT_INTERNAL_MEMORY_H <freetype/internal/ftmemory.h> +#define FT_INTERNAL_DEBUG_H <freetype/internal/ftdebug.h> +#define FT_INTERNAL_CALC_H <freetype/internal/ftcalc.h> +#define FT_INTERNAL_HASH_H <freetype/internal/fthash.h> +#define FT_INTERNAL_DRIVER_H <freetype/internal/ftdrv.h> +#define FT_INTERNAL_TRACE_H <freetype/internal/fttrace.h> +#define FT_INTERNAL_GLYPH_LOADER_H <freetype/internal/ftgloadr.h> +#define FT_INTERNAL_SFNT_H <freetype/internal/sfnt.h> +#define FT_INTERNAL_SERVICE_H <freetype/internal/ftserv.h> +#define FT_INTERNAL_RFORK_H <freetype/internal/ftrfork.h> +#define FT_INTERNAL_VALIDATE_H <freetype/internal/ftvalid.h> + +#define FT_INTERNAL_TRUETYPE_TYPES_H <freetype/internal/tttypes.h> +#define FT_INTERNAL_TYPE1_TYPES_H <freetype/internal/t1types.h> + +#define FT_INTERNAL_POSTSCRIPT_AUX_H <freetype/internal/psaux.h> +#define FT_INTERNAL_POSTSCRIPT_HINTS_H <freetype/internal/pshints.h> +#define FT_INTERNAL_POSTSCRIPT_PROPS_H <freetype/internal/ftpsprop.h> + +#define FT_INTERNAL_AUTOHINT_H <freetype/internal/autohint.h> + +#define FT_INTERNAL_CFF_TYPES_H <freetype/internal/cfftypes.h> +#define FT_INTERNAL_CFF_OBJECTS_TYPES_H <freetype/internal/cffotypes.h> + + +#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ + + /* We disable the warning `conditional expression is constant' here */ + /* in order to compile cleanly with the maximum level of warnings. */ + /* In particular, the warning complains about stuff like `while(0)' */ + /* which is very useful in macro definitions. There is no benefit */ + /* in having it enabled. */ +#pragma warning( disable : 4127 ) + +#endif /* _MSC_VER */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/psaux.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/psaux.h new file mode 100644 index 0000000..f77380d --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/psaux.h @@ -0,0 +1,1372 @@ +/***************************************************************************/ +/* */ +/* psaux.h */ +/* */ +/* Auxiliary functions and data structures related to PostScript fonts */ +/* (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef PSAUX_H_ +#define PSAUX_H_ + + +#include <ft2build.h> +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_TYPE1_TYPES_H +#include FT_INTERNAL_HASH_H +#include FT_INTERNAL_TRUETYPE_TYPES_H +#include FT_SERVICE_POSTSCRIPT_CMAPS_H +#include FT_INTERNAL_CFF_TYPES_H +#include FT_INTERNAL_CFF_OBJECTS_TYPES_H + + + +FT_BEGIN_HEADER + + + /***********************************************************************/ + /* */ + /* PostScript modules driver class. */ + /* */ + typedef struct PS_DriverRec_ + { + FT_DriverRec root; + + FT_UInt hinting_engine; + FT_Bool no_stem_darkening; + FT_Int darken_params[8]; + FT_Int32 random_seed; + + } PS_DriverRec, *PS_Driver; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** T1_TABLE *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + + typedef struct PS_TableRec_* PS_Table; + typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_Table_FuncsRec */ + /* */ + /* <Description> */ + /* A set of function pointers to manage PS_Table objects. */ + /* */ + /* <Fields> */ + /* table_init :: Used to initialize a table. */ + /* */ + /* table_done :: Finalizes resp. destroy a given table. */ + /* */ + /* table_add :: Adds a new object to a table. */ + /* */ + /* table_release :: Releases table data, then finalizes it. */ + /* */ + typedef struct PS_Table_FuncsRec_ + { + FT_Error + (*init)( PS_Table table, + FT_Int count, + FT_Memory memory ); + + void + (*done)( PS_Table table ); + + FT_Error + (*add)( PS_Table table, + FT_Int idx, + void* object, + FT_UInt length ); + + void + (*release)( PS_Table table ); + + } PS_Table_FuncsRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_TableRec */ + /* */ + /* <Description> */ + /* A PS_Table is a simple object used to store an array of objects in */ + /* a single memory block. */ + /* */ + /* <Fields> */ + /* block :: The address in memory of the growheap's block. This */ + /* can change between two object adds, due to */ + /* reallocation. */ + /* */ + /* cursor :: The current top of the grow heap within its block. */ + /* */ + /* capacity :: The current size of the heap block. Increments by */ + /* 1kByte chunks. */ + /* */ + /* init :: Set to 0xDEADBEEF if `elements' and `lengths' have */ + /* been allocated. */ + /* */ + /* max_elems :: The maximum number of elements in table. */ + /* */ + /* num_elems :: The current number of elements in table. */ + /* */ + /* elements :: A table of element addresses within the block. */ + /* */ + /* lengths :: A table of element sizes within the block. */ + /* */ + /* memory :: The object used for memory operations */ + /* (alloc/realloc). */ + /* */ + /* funcs :: A table of method pointers for this object. */ + /* */ + typedef struct PS_TableRec_ + { + FT_Byte* block; /* current memory block */ + FT_Offset cursor; /* current cursor in memory block */ + FT_Offset capacity; /* current size of memory block */ + FT_ULong init; + + FT_Int max_elems; + FT_Int num_elems; + FT_Byte** elements; /* addresses of table elements */ + FT_UInt* lengths; /* lengths of table elements */ + + FT_Memory memory; + PS_Table_FuncsRec funcs; + + } PS_TableRec; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** T1 FIELDS & TOKENS *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + typedef struct PS_ParserRec_* PS_Parser; + + typedef struct T1_TokenRec_* T1_Token; + + typedef struct T1_FieldRec_* T1_Field; + + + /* simple enumeration type used to identify token types */ + typedef enum T1_TokenType_ + { + T1_TOKEN_TYPE_NONE = 0, + T1_TOKEN_TYPE_ANY, + T1_TOKEN_TYPE_STRING, + T1_TOKEN_TYPE_ARRAY, + T1_TOKEN_TYPE_KEY, /* aka `name' */ + + /* do not remove */ + T1_TOKEN_TYPE_MAX + + } T1_TokenType; + + + /* a simple structure used to identify tokens */ + typedef struct T1_TokenRec_ + { + FT_Byte* start; /* first character of token in input stream */ + FT_Byte* limit; /* first character after the token */ + T1_TokenType type; /* type of token */ + + } T1_TokenRec; + + + /* enumeration type used to identify object fields */ + typedef enum T1_FieldType_ + { + T1_FIELD_TYPE_NONE = 0, + T1_FIELD_TYPE_BOOL, + T1_FIELD_TYPE_INTEGER, + T1_FIELD_TYPE_FIXED, + T1_FIELD_TYPE_FIXED_1000, + T1_FIELD_TYPE_STRING, + T1_FIELD_TYPE_KEY, + T1_FIELD_TYPE_BBOX, + T1_FIELD_TYPE_MM_BBOX, + T1_FIELD_TYPE_INTEGER_ARRAY, + T1_FIELD_TYPE_FIXED_ARRAY, + T1_FIELD_TYPE_CALLBACK, + + /* do not remove */ + T1_FIELD_TYPE_MAX + + } T1_FieldType; + + + typedef enum T1_FieldLocation_ + { + T1_FIELD_LOCATION_CID_INFO, + T1_FIELD_LOCATION_FONT_DICT, + T1_FIELD_LOCATION_FONT_EXTRA, + T1_FIELD_LOCATION_FONT_INFO, + T1_FIELD_LOCATION_PRIVATE, + T1_FIELD_LOCATION_BBOX, + T1_FIELD_LOCATION_LOADER, + T1_FIELD_LOCATION_FACE, + T1_FIELD_LOCATION_BLEND, + + /* do not remove */ + T1_FIELD_LOCATION_MAX + + } T1_FieldLocation; + + + typedef void + (*T1_Field_ParseFunc)( FT_Face face, + FT_Pointer parser ); + + + /* structure type used to model object fields */ + typedef struct T1_FieldRec_ + { + const char* ident; /* field identifier */ + T1_FieldLocation location; + T1_FieldType type; /* type of field */ + T1_Field_ParseFunc reader; + FT_UInt offset; /* offset of field in object */ + FT_Byte size; /* size of field in bytes */ + FT_UInt array_max; /* maximum number of elements for */ + /* array */ + FT_UInt count_offset; /* offset of element count for */ + /* arrays; must not be zero if in */ + /* use -- in other words, a */ + /* `num_FOO' element must not */ + /* start the used structure if we */ + /* parse a `FOO' array */ + FT_UInt dict; /* where we expect it */ + } T1_FieldRec; + +#define T1_FIELD_DICT_FONTDICT ( 1 << 0 ) /* also FontInfo and FDArray */ +#define T1_FIELD_DICT_PRIVATE ( 1 << 1 ) + + + +#define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname, _dict ) \ + { \ + _ident, T1CODE, _type, \ + 0, \ + FT_FIELD_OFFSET( _fname ), \ + FT_FIELD_SIZE( _fname ), \ + 0, 0, \ + _dict \ + }, + +#define T1_NEW_CALLBACK_FIELD( _ident, _reader, _dict ) \ + { \ + _ident, T1CODE, T1_FIELD_TYPE_CALLBACK, \ + (T1_Field_ParseFunc)_reader, \ + 0, 0, \ + 0, 0, \ + _dict \ + }, + +#define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max, _dict ) \ + { \ + _ident, T1CODE, _type, \ + 0, \ + FT_FIELD_OFFSET( _fname ), \ + FT_FIELD_SIZE_DELTA( _fname ), \ + _max, \ + FT_FIELD_OFFSET( num_ ## _fname ), \ + _dict \ + }, + +#define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max, _dict ) \ + { \ + _ident, T1CODE, _type, \ + 0, \ + FT_FIELD_OFFSET( _fname ), \ + FT_FIELD_SIZE_DELTA( _fname ), \ + _max, 0, \ + _dict \ + }, + + +#define T1_FIELD_BOOL( _ident, _fname, _dict ) \ + T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname, _dict ) + +#define T1_FIELD_NUM( _ident, _fname, _dict ) \ + T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname, _dict ) + +#define T1_FIELD_FIXED( _ident, _fname, _dict ) \ + T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname, _dict ) + +#define T1_FIELD_FIXED_1000( _ident, _fname, _dict ) \ + T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000, _fname, \ + _dict ) + +#define T1_FIELD_STRING( _ident, _fname, _dict ) \ + T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname, _dict ) + +#define T1_FIELD_KEY( _ident, _fname, _dict ) \ + T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_KEY, _fname, _dict ) + +#define T1_FIELD_BBOX( _ident, _fname, _dict ) \ + T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname, _dict ) + + +#define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax, _dict ) \ + T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \ + _fname, _fmax, _dict ) + +#define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax, _dict ) \ + T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \ + _fname, _fmax, _dict ) + +#define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax, _dict ) \ + T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \ + _fname, _fmax, _dict ) + +#define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax, _dict ) \ + T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \ + _fname, _fmax, _dict ) + +#define T1_FIELD_CALLBACK( _ident, _name, _dict ) \ + T1_NEW_CALLBACK_FIELD( _ident, _name, _dict ) + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** T1 PARSER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + typedef const struct PS_Parser_FuncsRec_* PS_Parser_Funcs; + + typedef struct PS_Parser_FuncsRec_ + { + void + (*init)( PS_Parser parser, + FT_Byte* base, + FT_Byte* limit, + FT_Memory memory ); + + void + (*done)( PS_Parser parser ); + + void + (*skip_spaces)( PS_Parser parser ); + void + (*skip_PS_token)( PS_Parser parser ); + + FT_Long + (*to_int)( PS_Parser parser ); + FT_Fixed + (*to_fixed)( PS_Parser parser, + FT_Int power_ten ); + + FT_Error + (*to_bytes)( PS_Parser parser, + FT_Byte* bytes, + FT_Offset max_bytes, + FT_ULong* pnum_bytes, + FT_Bool delimiters ); + + FT_Int + (*to_coord_array)( PS_Parser parser, + FT_Int max_coords, + FT_Short* coords ); + FT_Int + (*to_fixed_array)( PS_Parser parser, + FT_Int max_values, + FT_Fixed* values, + FT_Int power_ten ); + + void + (*to_token)( PS_Parser parser, + T1_Token token ); + void + (*to_token_array)( PS_Parser parser, + T1_Token tokens, + FT_UInt max_tokens, + FT_Int* pnum_tokens ); + + FT_Error + (*load_field)( PS_Parser parser, + const T1_Field field, + void** objects, + FT_UInt max_objects, + FT_ULong* pflags ); + + FT_Error + (*load_field_table)( PS_Parser parser, + const T1_Field field, + void** objects, + FT_UInt max_objects, + FT_ULong* pflags ); + + } PS_Parser_FuncsRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_ParserRec */ + /* */ + /* <Description> */ + /* A PS_Parser is an object used to parse a Type 1 font very quickly. */ + /* */ + /* <Fields> */ + /* cursor :: The current position in the text. */ + /* */ + /* base :: Start of the processed text. */ + /* */ + /* limit :: End of the processed text. */ + /* */ + /* error :: The last error returned. */ + /* */ + /* memory :: The object used for memory operations (alloc/realloc). */ + /* */ + /* funcs :: A table of functions for the parser. */ + /* */ + typedef struct PS_ParserRec_ + { + FT_Byte* cursor; + FT_Byte* base; + FT_Byte* limit; + FT_Error error; + FT_Memory memory; + + PS_Parser_FuncsRec funcs; + + } PS_ParserRec; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** PS BUILDER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + + typedef struct PS_Builder_ PS_Builder; + typedef const struct PS_Builder_FuncsRec_* PS_Builder_Funcs; + + typedef struct PS_Builder_FuncsRec_ + { + void + (*init)( PS_Builder* ps_builder, + void* builder, + FT_Bool is_t1 ); + + void + (*done)( PS_Builder* builder ); + + } PS_Builder_FuncsRec; + + + /*************************************************************************/ + /* */ + /* <Structure> */ + /* PS_Builder */ + /* */ + /* <Description> */ + /* A structure used during glyph loading to store its outline. */ + /* */ + /* <Fields> */ + /* memory :: The current memory object. */ + /* */ + /* face :: The current face object. */ + /* */ + /* glyph :: The current glyph slot. */ + /* */ + /* loader :: XXX */ + /* */ + /* base :: The base glyph outline. */ + /* */ + /* current :: The current glyph outline. */ + /* */ + /* pos_x :: The horizontal translation (if composite glyph). */ + /* */ + /* pos_y :: The vertical translation (if composite glyph). */ + /* */ + /* left_bearing :: The left side bearing point. */ + /* */ + /* advance :: The horizontal advance vector. */ + /* */ + /* bbox :: Unused. */ + /* */ + /* path_begun :: A flag which indicates that a new path has begun. */ + /* */ + /* load_points :: If this flag is not set, no points are loaded. */ + /* */ + /* no_recurse :: Set but not used. */ + /* */ + /* metrics_only :: A boolean indicating that we only want to compute */ + /* the metrics of a given glyph, not load all of its */ + /* points. */ + /* */ + /* is_t1 :: Set if current font type is Type 1. */ + /* */ + /* funcs :: An array of function pointers for the builder. */ + /* */ + struct PS_Builder_ + { + FT_Memory memory; + FT_Face face; + CFF_GlyphSlot glyph; + FT_GlyphLoader loader; + FT_Outline* base; + FT_Outline* current; + + FT_Pos* pos_x; + FT_Pos* pos_y; + + FT_Vector* left_bearing; + FT_Vector* advance; + + FT_BBox* bbox; /* bounding box */ + FT_Bool path_begun; + FT_Bool load_points; + FT_Bool no_recurse; + + FT_Bool metrics_only; + FT_Bool is_t1; + + PS_Builder_FuncsRec funcs; + + }; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** PS DECODER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + +#define PS_MAX_OPERANDS 48 +#define PS_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */ + /* only 10 are allowed but there exist */ + /* fonts like `HiraKakuProN-W3.ttf' */ + /* (Hiragino Kaku Gothic ProN W3; */ + /* 8.2d6e1; 2014-12-19) that exceed */ + /* this limit */ + + /* execution context charstring zone */ + + typedef struct PS_Decoder_Zone_ + { + FT_Byte* base; + FT_Byte* limit; + FT_Byte* cursor; + + } PS_Decoder_Zone; + + + typedef FT_Error + (*CFF_Decoder_Get_Glyph_Callback)( TT_Face face, + FT_UInt glyph_index, + FT_Byte** pointer, + FT_ULong* length ); + + typedef void + (*CFF_Decoder_Free_Glyph_Callback)( TT_Face face, + FT_Byte** pointer, + FT_ULong length ); + + + typedef struct PS_Decoder_ + { + PS_Builder builder; + + FT_Fixed stack[PS_MAX_OPERANDS + 1]; + FT_Fixed* top; + + PS_Decoder_Zone zones[PS_MAX_SUBRS_CALLS + 1]; + PS_Decoder_Zone* zone; + + FT_Int flex_state; + FT_Int num_flex_vectors; + FT_Vector flex_vectors[7]; + + CFF_Font cff; + CFF_SubFont current_subfont; /* for current glyph_index */ + FT_Generic* cf2_instance; + + FT_Pos* glyph_width; + FT_Bool width_only; + FT_Int num_hints; + + FT_UInt num_locals; + FT_UInt num_globals; + + FT_Int locals_bias; + FT_Int globals_bias; + + FT_Byte** locals; + FT_Byte** globals; + + FT_Byte** glyph_names; /* for pure CFF fonts only */ + FT_UInt num_glyphs; /* number of glyphs in font */ + + FT_Render_Mode hint_mode; + + FT_Bool seac; + + CFF_Decoder_Get_Glyph_Callback get_glyph_callback; + CFF_Decoder_Free_Glyph_Callback free_glyph_callback; + + /* Type 1 stuff */ + FT_Service_PsCMaps psnames; /* for seac */ + + FT_Int lenIV; /* internal for sub routine calls */ + FT_UInt* locals_len; /* array of subrs length (optional) */ + FT_Hash locals_hash; /* used if `num_subrs' was massaged */ + + FT_Matrix font_matrix; + FT_Vector font_offset; + + PS_Blend blend; /* for multiple master support */ + + FT_Long* buildchar; + FT_UInt len_buildchar; + + } PS_Decoder; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** T1 BUILDER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + + typedef struct T1_BuilderRec_* T1_Builder; + + + typedef FT_Error + (*T1_Builder_Check_Points_Func)( T1_Builder builder, + FT_Int count ); + + typedef void + (*T1_Builder_Add_Point_Func)( T1_Builder builder, + FT_Pos x, + FT_Pos y, + FT_Byte flag ); + + typedef FT_Error + (*T1_Builder_Add_Point1_Func)( T1_Builder builder, + FT_Pos x, + FT_Pos y ); + + typedef FT_Error + (*T1_Builder_Add_Contour_Func)( T1_Builder builder ); + + typedef FT_Error + (*T1_Builder_Start_Point_Func)( T1_Builder builder, + FT_Pos x, + FT_Pos y ); + + typedef void + (*T1_Builder_Close_Contour_Func)( T1_Builder builder ); + + + typedef const struct T1_Builder_FuncsRec_* T1_Builder_Funcs; + + typedef struct T1_Builder_FuncsRec_ + { + void + (*init)( T1_Builder builder, + FT_Face face, + FT_Size size, + FT_GlyphSlot slot, + FT_Bool hinting ); + + void + (*done)( T1_Builder builder ); + + T1_Builder_Check_Points_Func check_points; + T1_Builder_Add_Point_Func add_point; + T1_Builder_Add_Point1_Func add_point1; + T1_Builder_Add_Contour_Func add_contour; + T1_Builder_Start_Point_Func start_point; + T1_Builder_Close_Contour_Func close_contour; + + } T1_Builder_FuncsRec; + + + /* an enumeration type to handle charstring parsing states */ + typedef enum T1_ParseState_ + { + T1_Parse_Start, + T1_Parse_Have_Width, + T1_Parse_Have_Moveto, + T1_Parse_Have_Path + + } T1_ParseState; + + + /*************************************************************************/ + /* */ + /* <Structure> */ + /* T1_BuilderRec */ + /* */ + /* <Description> */ + /* A structure used during glyph loading to store its outline. */ + /* */ + /* <Fields> */ + /* memory :: The current memory object. */ + /* */ + /* face :: The current face object. */ + /* */ + /* glyph :: The current glyph slot. */ + /* */ + /* loader :: XXX */ + /* */ + /* base :: The base glyph outline. */ + /* */ + /* current :: The current glyph outline. */ + /* */ + /* max_points :: maximum points in builder outline */ + /* */ + /* max_contours :: Maximum number of contours in builder outline. */ + /* */ + /* pos_x :: The horizontal translation (if composite glyph). */ + /* */ + /* pos_y :: The vertical translation (if composite glyph). */ + /* */ + /* left_bearing :: The left side bearing point. */ + /* */ + /* advance :: The horizontal advance vector. */ + /* */ + /* bbox :: Unused. */ + /* */ + /* parse_state :: An enumeration which controls the charstring */ + /* parsing state. */ + /* */ + /* load_points :: If this flag is not set, no points are loaded. */ + /* */ + /* no_recurse :: Set but not used. */ + /* */ + /* metrics_only :: A boolean indicating that we only want to compute */ + /* the metrics of a given glyph, not load all of its */ + /* points. */ + /* */ + /* funcs :: An array of function pointers for the builder. */ + /* */ + typedef struct T1_BuilderRec_ + { + FT_Memory memory; + FT_Face face; + FT_GlyphSlot glyph; + FT_GlyphLoader loader; + FT_Outline* base; + FT_Outline* current; + + FT_Pos pos_x; + FT_Pos pos_y; + + FT_Vector left_bearing; + FT_Vector advance; + + FT_BBox bbox; /* bounding box */ + T1_ParseState parse_state; + FT_Bool load_points; + FT_Bool no_recurse; + + FT_Bool metrics_only; + + void* hints_funcs; /* hinter-specific */ + void* hints_globals; /* hinter-specific */ + + T1_Builder_FuncsRec funcs; + + } T1_BuilderRec; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** T1 DECODER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + +#if 0 + + /*************************************************************************/ + /* */ + /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ + /* calls during glyph loading. */ + /* */ +#define T1_MAX_SUBRS_CALLS 8 + + + /*************************************************************************/ + /* */ + /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ + /* minimum of 16 is required. */ + /* */ +#define T1_MAX_CHARSTRINGS_OPERANDS 32 + +#endif /* 0 */ + + + typedef struct T1_Decoder_ZoneRec_ + { + FT_Byte* cursor; + FT_Byte* base; + FT_Byte* limit; + + } T1_Decoder_ZoneRec, *T1_Decoder_Zone; + + + typedef struct T1_DecoderRec_* T1_Decoder; + typedef const struct T1_Decoder_FuncsRec_* T1_Decoder_Funcs; + + + typedef FT_Error + (*T1_Decoder_Callback)( T1_Decoder decoder, + FT_UInt glyph_index ); + + + typedef struct T1_Decoder_FuncsRec_ + { + FT_Error + (*init)( T1_Decoder decoder, + FT_Face face, + FT_Size size, + FT_GlyphSlot slot, + FT_Byte** glyph_names, + PS_Blend blend, + FT_Bool hinting, + FT_Render_Mode hint_mode, + T1_Decoder_Callback callback ); + + void + (*done)( T1_Decoder decoder ); + +#ifdef T1_CONFIG_OPTION_OLD_ENGINE + FT_Error + (*parse_charstrings_old)( T1_Decoder decoder, + FT_Byte* base, + FT_UInt len ); +#else + FT_Error + (*parse_metrics)( T1_Decoder decoder, + FT_Byte* base, + FT_UInt len ); +#endif + + FT_Error + (*parse_charstrings)( PS_Decoder* decoder, + FT_Byte* charstring_base, + FT_ULong charstring_len ); + + + } T1_Decoder_FuncsRec; + + + typedef struct T1_DecoderRec_ + { + T1_BuilderRec builder; + + FT_Long stack[T1_MAX_CHARSTRINGS_OPERANDS]; + FT_Long* top; + + T1_Decoder_ZoneRec zones[T1_MAX_SUBRS_CALLS + 1]; + T1_Decoder_Zone zone; + + FT_Service_PsCMaps psnames; /* for seac */ + FT_UInt num_glyphs; + FT_Byte** glyph_names; + + FT_Int lenIV; /* internal for sub routine calls */ + FT_Int num_subrs; + FT_Byte** subrs; + FT_UInt* subrs_len; /* array of subrs length (optional) */ + FT_Hash subrs_hash; /* used if `num_subrs' was massaged */ + + FT_Matrix font_matrix; + FT_Vector font_offset; + + FT_Int flex_state; + FT_Int num_flex_vectors; + FT_Vector flex_vectors[7]; + + PS_Blend blend; /* for multiple master support */ + + FT_Render_Mode hint_mode; + + T1_Decoder_Callback parse_callback; + T1_Decoder_FuncsRec funcs; + + FT_Long* buildchar; + FT_UInt len_buildchar; + + FT_Bool seac; + + FT_Generic cf2_instance; + + } T1_DecoderRec; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** CFF BUILDER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + + typedef struct CFF_Builder_ CFF_Builder; + + + typedef FT_Error + (*CFF_Builder_Check_Points_Func)( CFF_Builder* builder, + FT_Int count ); + + typedef void + (*CFF_Builder_Add_Point_Func)( CFF_Builder* builder, + FT_Pos x, + FT_Pos y, + FT_Byte flag ); + typedef FT_Error + (*CFF_Builder_Add_Point1_Func)( CFF_Builder* builder, + FT_Pos x, + FT_Pos y ); + typedef FT_Error + (*CFF_Builder_Start_Point_Func)( CFF_Builder* builder, + FT_Pos x, + FT_Pos y ); + typedef void + (*CFF_Builder_Close_Contour_Func)( CFF_Builder* builder ); + + typedef FT_Error + (*CFF_Builder_Add_Contour_Func)( CFF_Builder* builder ); + + typedef const struct CFF_Builder_FuncsRec_* CFF_Builder_Funcs; + + typedef struct CFF_Builder_FuncsRec_ + { + void + (*init)( CFF_Builder* builder, + TT_Face face, + CFF_Size size, + CFF_GlyphSlot glyph, + FT_Bool hinting ); + + void + (*done)( CFF_Builder* builder ); + + CFF_Builder_Check_Points_Func check_points; + CFF_Builder_Add_Point_Func add_point; + CFF_Builder_Add_Point1_Func add_point1; + CFF_Builder_Add_Contour_Func add_contour; + CFF_Builder_Start_Point_Func start_point; + CFF_Builder_Close_Contour_Func close_contour; + + } CFF_Builder_FuncsRec; + + + /*************************************************************************/ + /* */ + /* <Structure> */ + /* CFF_Builder */ + /* */ + /* <Description> */ + /* A structure used during glyph loading to store its outline. */ + /* */ + /* <Fields> */ + /* memory :: The current memory object. */ + /* */ + /* face :: The current face object. */ + /* */ + /* glyph :: The current glyph slot. */ + /* */ + /* loader :: The current glyph loader. */ + /* */ + /* base :: The base glyph outline. */ + /* */ + /* current :: The current glyph outline. */ + /* */ + /* pos_x :: The horizontal translation (if composite glyph). */ + /* */ + /* pos_y :: The vertical translation (if composite glyph). */ + /* */ + /* left_bearing :: The left side bearing point. */ + /* */ + /* advance :: The horizontal advance vector. */ + /* */ + /* bbox :: Unused. */ + /* */ + /* path_begun :: A flag which indicates that a new path has begun. */ + /* */ + /* load_points :: If this flag is not set, no points are loaded. */ + /* */ + /* no_recurse :: Set but not used. */ + /* */ + /* metrics_only :: A boolean indicating that we only want to compute */ + /* the metrics of a given glyph, not load all of its */ + /* points. */ + /* */ + /* hints_funcs :: Auxiliary pointer for hinting. */ + /* */ + /* hints_globals :: Auxiliary pointer for hinting. */ + /* */ + /* funcs :: A table of method pointers for this object. */ + /* */ + struct CFF_Builder_ + { + FT_Memory memory; + TT_Face face; + CFF_GlyphSlot glyph; + FT_GlyphLoader loader; + FT_Outline* base; + FT_Outline* current; + + FT_Pos pos_x; + FT_Pos pos_y; + + FT_Vector left_bearing; + FT_Vector advance; + + FT_BBox bbox; /* bounding box */ + + FT_Bool path_begun; + FT_Bool load_points; + FT_Bool no_recurse; + + FT_Bool metrics_only; + + void* hints_funcs; /* hinter-specific */ + void* hints_globals; /* hinter-specific */ + + CFF_Builder_FuncsRec funcs; + }; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** CFF DECODER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + +#define CFF_MAX_OPERANDS 48 +#define CFF_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */ + /* only 10 are allowed but there exist */ + /* fonts like `HiraKakuProN-W3.ttf' */ + /* (Hiragino Kaku Gothic ProN W3; */ + /* 8.2d6e1; 2014-12-19) that exceed */ + /* this limit */ +#define CFF_MAX_TRANS_ELEMENTS 32 + + /* execution context charstring zone */ + + typedef struct CFF_Decoder_Zone_ + { + FT_Byte* base; + FT_Byte* limit; + FT_Byte* cursor; + + } CFF_Decoder_Zone; + + + typedef struct CFF_Decoder_ + { + CFF_Builder builder; + CFF_Font cff; + + FT_Fixed stack[CFF_MAX_OPERANDS + 1]; + FT_Fixed* top; + + CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS + 1]; + CFF_Decoder_Zone* zone; + + FT_Int flex_state; + FT_Int num_flex_vectors; + FT_Vector flex_vectors[7]; + + FT_Pos glyph_width; + FT_Pos nominal_width; + + FT_Bool read_width; + FT_Bool width_only; + FT_Int num_hints; + FT_Fixed buildchar[CFF_MAX_TRANS_ELEMENTS]; + + FT_UInt num_locals; + FT_UInt num_globals; + + FT_Int locals_bias; + FT_Int globals_bias; + + FT_Byte** locals; + FT_Byte** globals; + + FT_Byte** glyph_names; /* for pure CFF fonts only */ + FT_UInt num_glyphs; /* number of glyphs in font */ + + FT_Render_Mode hint_mode; + + FT_Bool seac; + + CFF_SubFont current_subfont; /* for current glyph_index */ + + CFF_Decoder_Get_Glyph_Callback get_glyph_callback; + CFF_Decoder_Free_Glyph_Callback free_glyph_callback; + + } CFF_Decoder; + + + typedef const struct CFF_Decoder_FuncsRec_* CFF_Decoder_Funcs; + + typedef struct CFF_Decoder_FuncsRec_ + { + void + (*init)( CFF_Decoder* decoder, + TT_Face face, + CFF_Size size, + CFF_GlyphSlot slot, + FT_Bool hinting, + FT_Render_Mode hint_mode, + CFF_Decoder_Get_Glyph_Callback get_callback, + CFF_Decoder_Free_Glyph_Callback free_callback ); + + FT_Error + (*prepare)( CFF_Decoder* decoder, + CFF_Size size, + FT_UInt glyph_index ); + +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + FT_Error + (*parse_charstrings_old)( CFF_Decoder* decoder, + FT_Byte* charstring_base, + FT_ULong charstring_len, + FT_Bool in_dict ); +#endif + + FT_Error + (*parse_charstrings)( PS_Decoder* decoder, + FT_Byte* charstring_base, + FT_ULong charstring_len ); + + } CFF_Decoder_FuncsRec; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** AFM PARSER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + typedef struct AFM_ParserRec_* AFM_Parser; + + typedef struct AFM_Parser_FuncsRec_ + { + FT_Error + (*init)( AFM_Parser parser, + FT_Memory memory, + FT_Byte* base, + FT_Byte* limit ); + + void + (*done)( AFM_Parser parser ); + + FT_Error + (*parse)( AFM_Parser parser ); + + } AFM_Parser_FuncsRec; + + + typedef struct AFM_StreamRec_* AFM_Stream; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* AFM_ParserRec */ + /* */ + /* <Description> */ + /* An AFM_Parser is a parser for the AFM files. */ + /* */ + /* <Fields> */ + /* memory :: The object used for memory operations (alloc and */ + /* realloc). */ + /* */ + /* stream :: This is an opaque object. */ + /* */ + /* FontInfo :: The result will be stored here. */ + /* */ + /* get_index :: A user provided function to get a glyph index by its */ + /* name. */ + /* */ + typedef struct AFM_ParserRec_ + { + FT_Memory memory; + AFM_Stream stream; + + AFM_FontInfo FontInfo; + + FT_Int + (*get_index)( const char* name, + FT_Offset len, + void* user_data ); + + void* user_data; + + } AFM_ParserRec; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** TYPE1 CHARMAPS *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + typedef const struct T1_CMap_ClassesRec_* T1_CMap_Classes; + + typedef struct T1_CMap_ClassesRec_ + { + FT_CMap_Class standard; + FT_CMap_Class expert; + FT_CMap_Class custom; + FT_CMap_Class unicode; + + } T1_CMap_ClassesRec; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** PSAux Module Interface *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + typedef struct PSAux_ServiceRec_ + { + /* don't use `PS_Table_Funcs' and friends to avoid compiler warnings */ + const PS_Table_FuncsRec* ps_table_funcs; + const PS_Parser_FuncsRec* ps_parser_funcs; + const T1_Builder_FuncsRec* t1_builder_funcs; + const T1_Decoder_FuncsRec* t1_decoder_funcs; + + void + (*t1_decrypt)( FT_Byte* buffer, + FT_Offset length, + FT_UShort seed ); + + FT_UInt32 + (*cff_random)( FT_UInt32 r ); + + void + (*ps_decoder_init)( PS_Decoder* ps_decoder, + void* decoder, + FT_Bool is_t1 ); + + void + (*t1_make_subfont)( FT_Face face, + PS_Private priv, + CFF_SubFont subfont ); + + T1_CMap_Classes t1_cmap_classes; + + /* fields after this comment line were added after version 2.1.10 */ + const AFM_Parser_FuncsRec* afm_parser_funcs; + + const CFF_Decoder_FuncsRec* cff_decoder_funcs; + + } PSAux_ServiceRec, *PSAux_Service; + + /* backward compatible type definition */ + typedef PSAux_ServiceRec PSAux_Interface; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** Some convenience functions *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + +#define IS_PS_NEWLINE( ch ) \ + ( (ch) == '\r' || \ + (ch) == '\n' ) + +#define IS_PS_SPACE( ch ) \ + ( (ch) == ' ' || \ + IS_PS_NEWLINE( ch ) || \ + (ch) == '\t' || \ + (ch) == '\f' || \ + (ch) == '\0' ) + +#define IS_PS_SPECIAL( ch ) \ + ( (ch) == '/' || \ + (ch) == '(' || (ch) == ')' || \ + (ch) == '<' || (ch) == '>' || \ + (ch) == '[' || (ch) == ']' || \ + (ch) == '{' || (ch) == '}' || \ + (ch) == '%' ) + +#define IS_PS_DELIM( ch ) \ + ( IS_PS_SPACE( ch ) || \ + IS_PS_SPECIAL( ch ) ) + +#define IS_PS_DIGIT( ch ) \ + ( (ch) >= '0' && (ch) <= '9' ) + +#define IS_PS_XDIGIT( ch ) \ + ( IS_PS_DIGIT( ch ) || \ + ( (ch) >= 'A' && (ch) <= 'F' ) || \ + ( (ch) >= 'a' && (ch) <= 'f' ) ) + +#define IS_PS_BASE85( ch ) \ + ( (ch) >= '!' && (ch) <= 'u' ) + +#define IS_PS_TOKEN( cur, limit, token ) \ + ( (char)(cur)[0] == (token)[0] && \ + ( (cur) + sizeof ( (token) ) == (limit) || \ + ( (cur) + sizeof( (token) ) < (limit) && \ + IS_PS_DELIM( (cur)[sizeof ( (token) ) - 1] ) ) ) && \ + ft_strncmp( (char*)(cur), (token), sizeof ( (token) ) - 1 ) == 0 ) + + +FT_END_HEADER + +#endif /* PSAUX_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/pshints.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/pshints.h new file mode 100644 index 0000000..d29314e --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/pshints.h @@ -0,0 +1,722 @@ +/***************************************************************************/ +/* */ +/* pshints.h */ +/* */ +/* Interface to Postscript-specific (Type 1 and Type 2) hints */ +/* recorders (specification only). These are used to support native */ +/* T1/T2 hints in the `type1', `cid', and `cff' font drivers. */ +/* */ +/* Copyright 2001-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef PSHINTS_H_ +#define PSHINTS_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_TYPE1_TABLES_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** INTERNAL REPRESENTATION OF GLOBALS *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + typedef struct PSH_GlobalsRec_* PSH_Globals; + + typedef FT_Error + (*PSH_Globals_NewFunc)( FT_Memory memory, + T1_Private* private_dict, + PSH_Globals* aglobals ); + + typedef void + (*PSH_Globals_SetScaleFunc)( PSH_Globals globals, + FT_Fixed x_scale, + FT_Fixed y_scale, + FT_Fixed x_delta, + FT_Fixed y_delta ); + + typedef void + (*PSH_Globals_DestroyFunc)( PSH_Globals globals ); + + + typedef struct PSH_Globals_FuncsRec_ + { + PSH_Globals_NewFunc create; + PSH_Globals_SetScaleFunc set_scale; + PSH_Globals_DestroyFunc destroy; + + } PSH_Globals_FuncsRec, *PSH_Globals_Funcs; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** PUBLIC TYPE 1 HINTS RECORDER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + /************************************************************************* + * + * @type: + * T1_Hints + * + * @description: + * This is a handle to an opaque structure used to record glyph hints + * from a Type 1 character glyph character string. + * + * The methods used to operate on this object are defined by the + * @T1_Hints_FuncsRec structure. Recording glyph hints is normally + * achieved through the following scheme: + * + * - Open a new hint recording session by calling the `open' method. + * This rewinds the recorder and prepare it for new input. + * + * - For each hint found in the glyph charstring, call the corresponding + * method (`stem', `stem3', or `reset'). Note that these functions do + * not return an error code. + * + * - Close the recording session by calling the `close' method. It + * returns an error code if the hints were invalid or something + * strange happened (e.g., memory shortage). + * + * The hints accumulated in the object can later be used by the + * PostScript hinter. + * + */ + typedef struct T1_HintsRec_* T1_Hints; + + + /************************************************************************* + * + * @type: + * T1_Hints_Funcs + * + * @description: + * A pointer to the @T1_Hints_FuncsRec structure that defines the API of + * a given @T1_Hints object. + * + */ + typedef const struct T1_Hints_FuncsRec_* T1_Hints_Funcs; + + + /************************************************************************* + * + * @functype: + * T1_Hints_OpenFunc + * + * @description: + * A method of the @T1_Hints class used to prepare it for a new Type 1 + * hints recording session. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * @note: + * You should always call the @T1_Hints_CloseFunc method in order to + * close an opened recording session. + * + */ + typedef void + (*T1_Hints_OpenFunc)( T1_Hints hints ); + + + /************************************************************************* + * + * @functype: + * T1_Hints_SetStemFunc + * + * @description: + * A method of the @T1_Hints class used to record a new horizontal or + * vertical stem. This corresponds to the Type 1 `hstem' and `vstem' + * operators. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * dimension :: + * 0 for horizontal stems (hstem), 1 for vertical ones (vstem). + * + * coords :: + * Array of 2 coordinates in 16.16 format, used as (position,length) + * stem descriptor. + * + * @note: + * Use vertical coordinates (y) for horizontal stems (dim=0). Use + * horizontal coordinates (x) for vertical stems (dim=1). + * + * `coords[0]' is the absolute stem position (lowest coordinate); + * `coords[1]' is the length. + * + * The length can be negative, in which case it must be either -20 or + * -21. It is interpreted as a `ghost' stem, according to the Type 1 + * specification. + * + * If the length is -21 (corresponding to a bottom ghost stem), then + * the real stem position is `coords[0]+coords[1]'. + * + */ + typedef void + (*T1_Hints_SetStemFunc)( T1_Hints hints, + FT_UInt dimension, + FT_Fixed* coords ); + + + /************************************************************************* + * + * @functype: + * T1_Hints_SetStem3Func + * + * @description: + * A method of the @T1_Hints class used to record three + * counter-controlled horizontal or vertical stems at once. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * dimension :: + * 0 for horizontal stems, 1 for vertical ones. + * + * coords :: + * An array of 6 values in 16.16 format, holding 3 (position,length) + * pairs for the counter-controlled stems. + * + * @note: + * Use vertical coordinates (y) for horizontal stems (dim=0). Use + * horizontal coordinates (x) for vertical stems (dim=1). + * + * The lengths cannot be negative (ghost stems are never + * counter-controlled). + * + */ + typedef void + (*T1_Hints_SetStem3Func)( T1_Hints hints, + FT_UInt dimension, + FT_Fixed* coords ); + + + /************************************************************************* + * + * @functype: + * T1_Hints_ResetFunc + * + * @description: + * A method of the @T1_Hints class used to reset the stems hints in a + * recording session. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * end_point :: + * The index of the last point in the input glyph in which the + * previously defined hints apply. + * + */ + typedef void + (*T1_Hints_ResetFunc)( T1_Hints hints, + FT_UInt end_point ); + + + /************************************************************************* + * + * @functype: + * T1_Hints_CloseFunc + * + * @description: + * A method of the @T1_Hints class used to close a hint recording + * session. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * end_point :: + * The index of the last point in the input glyph. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The error code is set to indicate that an error occurred during the + * recording session. + * + */ + typedef FT_Error + (*T1_Hints_CloseFunc)( T1_Hints hints, + FT_UInt end_point ); + + + /************************************************************************* + * + * @functype: + * T1_Hints_ApplyFunc + * + * @description: + * A method of the @T1_Hints class used to apply hints to the + * corresponding glyph outline. Must be called once all hints have been + * recorded. + * + * @input: + * hints :: + * A handle to the Type 1 hints recorder. + * + * outline :: + * A pointer to the target outline descriptor. + * + * globals :: + * The hinter globals for this font. + * + * hint_mode :: + * Hinting information. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * On input, all points within the outline are in font coordinates. On + * output, they are in 1/64th of pixels. + * + * The scaling transformation is taken from the `globals' object which + * must correspond to the same font as the glyph. + * + */ + typedef FT_Error + (*T1_Hints_ApplyFunc)( T1_Hints hints, + FT_Outline* outline, + PSH_Globals globals, + FT_Render_Mode hint_mode ); + + + /************************************************************************* + * + * @struct: + * T1_Hints_FuncsRec + * + * @description: + * The structure used to provide the API to @T1_Hints objects. + * + * @fields: + * hints :: + * A handle to the T1 Hints recorder. + * + * open :: + * The function to open a recording session. + * + * close :: + * The function to close a recording session. + * + * stem :: + * The function to set a simple stem. + * + * stem3 :: + * The function to set counter-controlled stems. + * + * reset :: + * The function to reset stem hints. + * + * apply :: + * The function to apply the hints to the corresponding glyph outline. + * + */ + typedef struct T1_Hints_FuncsRec_ + { + T1_Hints hints; + T1_Hints_OpenFunc open; + T1_Hints_CloseFunc close; + T1_Hints_SetStemFunc stem; + T1_Hints_SetStem3Func stem3; + T1_Hints_ResetFunc reset; + T1_Hints_ApplyFunc apply; + + } T1_Hints_FuncsRec; + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** PUBLIC TYPE 2 HINTS RECORDER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + /************************************************************************* + * + * @type: + * T2_Hints + * + * @description: + * This is a handle to an opaque structure used to record glyph hints + * from a Type 2 character glyph character string. + * + * The methods used to operate on this object are defined by the + * @T2_Hints_FuncsRec structure. Recording glyph hints is normally + * achieved through the following scheme: + * + * - Open a new hint recording session by calling the `open' method. + * This rewinds the recorder and prepare it for new input. + * + * - For each hint found in the glyph charstring, call the corresponding + * method (`stems', `hintmask', `counters'). Note that these + * functions do not return an error code. + * + * - Close the recording session by calling the `close' method. It + * returns an error code if the hints were invalid or something + * strange happened (e.g., memory shortage). + * + * The hints accumulated in the object can later be used by the + * Postscript hinter. + * + */ + typedef struct T2_HintsRec_* T2_Hints; + + + /************************************************************************* + * + * @type: + * T2_Hints_Funcs + * + * @description: + * A pointer to the @T2_Hints_FuncsRec structure that defines the API of + * a given @T2_Hints object. + * + */ + typedef const struct T2_Hints_FuncsRec_* T2_Hints_Funcs; + + + /************************************************************************* + * + * @functype: + * T2_Hints_OpenFunc + * + * @description: + * A method of the @T2_Hints class used to prepare it for a new Type 2 + * hints recording session. + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * @note: + * You should always call the @T2_Hints_CloseFunc method in order to + * close an opened recording session. + * + */ + typedef void + (*T2_Hints_OpenFunc)( T2_Hints hints ); + + + /************************************************************************* + * + * @functype: + * T2_Hints_StemsFunc + * + * @description: + * A method of the @T2_Hints class used to set the table of stems in + * either the vertical or horizontal dimension. Equivalent to the + * `hstem', `vstem', `hstemhm', and `vstemhm' Type 2 operators. + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * dimension :: + * 0 for horizontal stems (hstem), 1 for vertical ones (vstem). + * + * count :: + * The number of stems. + * + * coords :: + * An array of `count' (position,length) pairs in 16.16 format. + * + * @note: + * Use vertical coordinates (y) for horizontal stems (dim=0). Use + * horizontal coordinates (x) for vertical stems (dim=1). + * + * There are `2*count' elements in the `coords' array. Each even + * element is an absolute position in font units, each odd element is a + * length in font units. + * + * A length can be negative, in which case it must be either -20 or + * -21. It is interpreted as a `ghost' stem, according to the Type 1 + * specification. + * + */ + typedef void + (*T2_Hints_StemsFunc)( T2_Hints hints, + FT_UInt dimension, + FT_Int count, + FT_Fixed* coordinates ); + + + /************************************************************************* + * + * @functype: + * T2_Hints_MaskFunc + * + * @description: + * A method of the @T2_Hints class used to set a given hintmask (this + * corresponds to the `hintmask' Type 2 operator). + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * end_point :: + * The glyph index of the last point to which the previously defined + * or activated hints apply. + * + * bit_count :: + * The number of bits in the hint mask. + * + * bytes :: + * An array of bytes modelling the hint mask. + * + * @note: + * If the hintmask starts the charstring (before any glyph point + * definition), the value of `end_point' should be 0. + * + * `bit_count' is the number of meaningful bits in the `bytes' array; it + * must be equal to the total number of hints defined so far (i.e., + * horizontal+verticals). + * + * The `bytes' array can come directly from the Type 2 charstring and + * respects the same format. + * + */ + typedef void + (*T2_Hints_MaskFunc)( T2_Hints hints, + FT_UInt end_point, + FT_UInt bit_count, + const FT_Byte* bytes ); + + + /************************************************************************* + * + * @functype: + * T2_Hints_CounterFunc + * + * @description: + * A method of the @T2_Hints class used to set a given counter mask + * (this corresponds to the `hintmask' Type 2 operator). + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * end_point :: + * A glyph index of the last point to which the previously defined or + * active hints apply. + * + * bit_count :: + * The number of bits in the hint mask. + * + * bytes :: + * An array of bytes modelling the hint mask. + * + * @note: + * If the hintmask starts the charstring (before any glyph point + * definition), the value of `end_point' should be 0. + * + * `bit_count' is the number of meaningful bits in the `bytes' array; it + * must be equal to the total number of hints defined so far (i.e., + * horizontal+verticals). + * + * The `bytes' array can come directly from the Type 2 charstring and + * respects the same format. + * + */ + typedef void + (*T2_Hints_CounterFunc)( T2_Hints hints, + FT_UInt bit_count, + const FT_Byte* bytes ); + + + /************************************************************************* + * + * @functype: + * T2_Hints_CloseFunc + * + * @description: + * A method of the @T2_Hints class used to close a hint recording + * session. + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * end_point :: + * The index of the last point in the input glyph. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The error code is set to indicate that an error occurred during the + * recording session. + * + */ + typedef FT_Error + (*T2_Hints_CloseFunc)( T2_Hints hints, + FT_UInt end_point ); + + + /************************************************************************* + * + * @functype: + * T2_Hints_ApplyFunc + * + * @description: + * A method of the @T2_Hints class used to apply hints to the + * corresponding glyph outline. Must be called after the `close' + * method. + * + * @input: + * hints :: + * A handle to the Type 2 hints recorder. + * + * outline :: + * A pointer to the target outline descriptor. + * + * globals :: + * The hinter globals for this font. + * + * hint_mode :: + * Hinting information. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * On input, all points within the outline are in font coordinates. On + * output, they are in 1/64th of pixels. + * + * The scaling transformation is taken from the `globals' object which + * must correspond to the same font than the glyph. + * + */ + typedef FT_Error + (*T2_Hints_ApplyFunc)( T2_Hints hints, + FT_Outline* outline, + PSH_Globals globals, + FT_Render_Mode hint_mode ); + + + /************************************************************************* + * + * @struct: + * T2_Hints_FuncsRec + * + * @description: + * The structure used to provide the API to @T2_Hints objects. + * + * @fields: + * hints :: + * A handle to the T2 hints recorder object. + * + * open :: + * The function to open a recording session. + * + * close :: + * The function to close a recording session. + * + * stems :: + * The function to set the dimension's stems table. + * + * hintmask :: + * The function to set hint masks. + * + * counter :: + * The function to set counter masks. + * + * apply :: + * The function to apply the hints on the corresponding glyph outline. + * + */ + typedef struct T2_Hints_FuncsRec_ + { + T2_Hints hints; + T2_Hints_OpenFunc open; + T2_Hints_CloseFunc close; + T2_Hints_StemsFunc stems; + T2_Hints_MaskFunc hintmask; + T2_Hints_CounterFunc counter; + T2_Hints_ApplyFunc apply; + + } T2_Hints_FuncsRec; + + + /* */ + + + typedef struct PSHinter_Interface_ + { + PSH_Globals_Funcs (*get_globals_funcs)( FT_Module module ); + T1_Hints_Funcs (*get_t1_funcs) ( FT_Module module ); + T2_Hints_Funcs (*get_t2_funcs) ( FT_Module module ); + + } PSHinter_Interface; + + typedef PSHinter_Interface* PSHinter_Service; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_PSHINTER_INTERFACE( \ + class_, \ + get_globals_funcs_, \ + get_t1_funcs_, \ + get_t2_funcs_ ) \ + static const PSHinter_Interface class_ = \ + { \ + get_globals_funcs_, \ + get_t1_funcs_, \ + get_t2_funcs_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_PSHINTER_INTERFACE( \ + class_, \ + get_globals_funcs_, \ + get_t1_funcs_, \ + get_t2_funcs_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + PSHinter_Interface* clazz ) \ + { \ + FT_UNUSED( library ); \ + \ + clazz->get_globals_funcs = get_globals_funcs_; \ + clazz->get_t1_funcs = get_t1_funcs_; \ + clazz->get_t2_funcs = get_t2_funcs_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + +FT_END_HEADER + +#endif /* PSHINTS_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svbdf.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svbdf.h new file mode 100644 index 0000000..4a9ec20 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svbdf.h @@ -0,0 +1,82 @@ +/***************************************************************************/ +/* */ +/* svbdf.h */ +/* */ +/* The FreeType BDF services (specification). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVBDF_H_ +#define SVBDF_H_ + +#include FT_BDF_H +#include FT_INTERNAL_SERVICE_H + + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_BDF "bdf" + + typedef FT_Error + (*FT_BDF_GetCharsetIdFunc)( FT_Face face, + const char* *acharset_encoding, + const char* *acharset_registry ); + + typedef FT_Error + (*FT_BDF_GetPropertyFunc)( FT_Face face, + const char* prop_name, + BDF_PropertyRec *aproperty ); + + + FT_DEFINE_SERVICE( BDF ) + { + FT_BDF_GetCharsetIdFunc get_charset_id; + FT_BDF_GetPropertyFunc get_property; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_BDFRec( class_, \ + get_charset_id_, \ + get_property_ ) \ + static const FT_Service_BDFRec class_ = \ + { \ + get_charset_id_, get_property_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_BDFRec( class_, \ + get_charset_id_, \ + get_property_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Service_BDFRec* clazz ) \ + { \ + clazz->get_charset_id = get_charset_id_; \ + clazz->get_property = get_property_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + + +#endif /* SVBDF_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svcfftl.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svcfftl.h new file mode 100644 index 0000000..db623e6 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svcfftl.h @@ -0,0 +1,112 @@ +/***************************************************************************/ +/* */ +/* svcfftl.h */ +/* */ +/* The FreeType CFF tables loader service (specification). */ +/* */ +/* Copyright 2017-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVCFFTL_H_ +#define SVCFFTL_H_ + +#include FT_INTERNAL_SERVICE_H +#include FT_INTERNAL_CFF_TYPES_H + + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_CFF_LOAD "cff-load" + + + typedef FT_UShort + (*FT_Get_Standard_Encoding_Func)( FT_UInt charcode ); + + typedef FT_Error + (*FT_Load_Private_Dict_Func)( CFF_Font font, + CFF_SubFont subfont, + FT_UInt lenNDV, + FT_Fixed* NDV ); + + typedef FT_Byte + (*FT_FD_Select_Get_Func)( CFF_FDSelect fdselect, + FT_UInt glyph_index ); + + typedef FT_Bool + (*FT_Blend_Check_Vector_Func)( CFF_Blend blend, + FT_UInt vsindex, + FT_UInt lenNDV, + FT_Fixed* NDV ); + + typedef FT_Error + (*FT_Blend_Build_Vector_Func)( CFF_Blend blend, + FT_UInt vsindex, + FT_UInt lenNDV, + FT_Fixed* NDV ); + + + FT_DEFINE_SERVICE( CFFLoad ) + { + FT_Get_Standard_Encoding_Func get_standard_encoding; + FT_Load_Private_Dict_Func load_private_dict; + FT_FD_Select_Get_Func fd_select_get; + FT_Blend_Check_Vector_Func blend_check_vector; + FT_Blend_Build_Vector_Func blend_build_vector; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_CFFLOADREC( class_, \ + get_standard_encoding_, \ + load_private_dict_, \ + fd_select_get_, \ + blend_check_vector_, \ + blend_build_vector_ ) \ + static const FT_Service_CFFLoadRec class_ = \ + { \ + get_standard_encoding_, \ + load_private_dict_, \ + fd_select_get_, \ + blend_check_vector_, \ + blend_build_vector_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_CFFLOADREC( class_, \ + get_standard_encoding_, \ + load_private_dict_, \ + fd_select_get_, \ + blend_check_vector_, \ + blend_build_vector_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Service_CFFLoadRec* clazz ) \ + { \ + clazz->get_standard_encoding = get_standard_encoding_; \ + clazz->load_private_dict = load_private_dict_; \ + clazz->fd_select_get = fd_select_get_; \ + clazz->blend_check_vector = blend_check_vector_; \ + clazz->blend_build_vector = blend_build_vector_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + +FT_END_HEADER + + +#endif + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svcid.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svcid.h new file mode 100644 index 0000000..cb59ac6 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svcid.h @@ -0,0 +1,90 @@ +/***************************************************************************/ +/* */ +/* svcid.h */ +/* */ +/* The FreeType CID font services (specification). */ +/* */ +/* Copyright 2007-2018 by */ +/* Derek Clegg and Michael Toftdal. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVCID_H_ +#define SVCID_H_ + +#include FT_INTERNAL_SERVICE_H + + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_CID "CID" + + typedef FT_Error + (*FT_CID_GetRegistryOrderingSupplementFunc)( FT_Face face, + const char* *registry, + const char* *ordering, + FT_Int *supplement ); + typedef FT_Error + (*FT_CID_GetIsInternallyCIDKeyedFunc)( FT_Face face, + FT_Bool *is_cid ); + typedef FT_Error + (*FT_CID_GetCIDFromGlyphIndexFunc)( FT_Face face, + FT_UInt glyph_index, + FT_UInt *cid ); + + FT_DEFINE_SERVICE( CID ) + { + FT_CID_GetRegistryOrderingSupplementFunc get_ros; + FT_CID_GetIsInternallyCIDKeyedFunc get_is_cid; + FT_CID_GetCIDFromGlyphIndexFunc get_cid_from_glyph_index; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_CIDREC( class_, \ + get_ros_, \ + get_is_cid_, \ + get_cid_from_glyph_index_ ) \ + static const FT_Service_CIDRec class_ = \ + { \ + get_ros_, get_is_cid_, get_cid_from_glyph_index_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_CIDREC( class_, \ + get_ros_, \ + get_is_cid_, \ + get_cid_from_glyph_index_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + FT_Service_CIDRec* clazz ) \ + { \ + FT_UNUSED( library ); \ + \ + clazz->get_ros = get_ros_; \ + clazz->get_is_cid = get_is_cid_; \ + clazz->get_cid_from_glyph_index = get_cid_from_glyph_index_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + + +#endif /* SVCID_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svfntfmt.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svfntfmt.h new file mode 100644 index 0000000..3b732be --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svfntfmt.h @@ -0,0 +1,55 @@ +/***************************************************************************/ +/* */ +/* svfntfmt.h */ +/* */ +/* The FreeType font format service (specification only). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVFNTFMT_H_ +#define SVFNTFMT_H_ + +#include FT_INTERNAL_SERVICE_H + + +FT_BEGIN_HEADER + + + /* + * A trivial service used to return the name of a face's font driver, + * according to the XFree86 nomenclature. Note that the service data + * is a simple constant string pointer. + */ + +#define FT_SERVICE_ID_FONT_FORMAT "font-format" + +#define FT_FONT_FORMAT_TRUETYPE "TrueType" +#define FT_FONT_FORMAT_TYPE_1 "Type 1" +#define FT_FONT_FORMAT_BDF "BDF" +#define FT_FONT_FORMAT_PCF "PCF" +#define FT_FONT_FORMAT_TYPE_42 "Type 42" +#define FT_FONT_FORMAT_CID "CID Type 1" +#define FT_FONT_FORMAT_CFF "CFF" +#define FT_FONT_FORMAT_PFR "PFR" +#define FT_FONT_FORMAT_WINFNT "Windows FNT" + + /* */ + + +FT_END_HEADER + + +#endif /* SVFNTFMT_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svgldict.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svgldict.h new file mode 100644 index 0000000..f1a68e3 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svgldict.h @@ -0,0 +1,91 @@ +/***************************************************************************/ +/* */ +/* svgldict.h */ +/* */ +/* The FreeType glyph dictionary services (specification). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVGLDICT_H_ +#define SVGLDICT_H_ + +#include FT_INTERNAL_SERVICE_H + + +FT_BEGIN_HEADER + + + /* + * A service used to retrieve glyph names, as well as to find the + * index of a given glyph name in a font. + * + */ + +#define FT_SERVICE_ID_GLYPH_DICT "glyph-dict" + + + typedef FT_Error + (*FT_GlyphDict_GetNameFunc)( FT_Face face, + FT_UInt glyph_index, + FT_Pointer buffer, + FT_UInt buffer_max ); + + typedef FT_UInt + (*FT_GlyphDict_NameIndexFunc)( FT_Face face, + FT_String* glyph_name ); + + + FT_DEFINE_SERVICE( GlyphDict ) + { + FT_GlyphDict_GetNameFunc get_name; + FT_GlyphDict_NameIndexFunc name_index; /* optional */ + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ + get_name_, \ + name_index_ ) \ + static const FT_Service_GlyphDictRec class_ = \ + { \ + get_name_, name_index_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ + get_name_, \ + name_index_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + FT_Service_GlyphDictRec* clazz ) \ + { \ + FT_UNUSED( library ); \ + \ + clazz->get_name = get_name_; \ + clazz->name_index = name_index_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + + +#endif /* SVGLDICT_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svgxval.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svgxval.h new file mode 100644 index 0000000..ed79ebe --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svgxval.h @@ -0,0 +1,72 @@ +/***************************************************************************/ +/* */ +/* svgxval.h */ +/* */ +/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ +/* */ +/* Copyright 2004-2018 by */ +/* Masatake YAMATO, Red Hat K.K., */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +/***************************************************************************/ +/* */ +/* gxvalid is derived from both gxlayout module and otvalid module. */ +/* Development of gxlayout is supported by the Information-technology */ +/* Promotion Agency(IPA), Japan. */ +/* */ +/***************************************************************************/ + + +#ifndef SVGXVAL_H_ +#define SVGXVAL_H_ + +#include FT_GX_VALIDATE_H +#include FT_INTERNAL_VALIDATE_H + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_GX_VALIDATE "truetypegx-validate" +#define FT_SERVICE_ID_CLASSICKERN_VALIDATE "classickern-validate" + + typedef FT_Error + (*gxv_validate_func)( FT_Face face, + FT_UInt gx_flags, + FT_Bytes tables[FT_VALIDATE_GX_LENGTH], + FT_UInt table_length ); + + + typedef FT_Error + (*ckern_validate_func)( FT_Face face, + FT_UInt ckern_flags, + FT_Bytes *ckern_table ); + + + FT_DEFINE_SERVICE( GXvalidate ) + { + gxv_validate_func validate; + }; + + FT_DEFINE_SERVICE( CKERNvalidate ) + { + ckern_validate_func validate; + }; + + /* */ + + +FT_END_HEADER + + +#endif /* SVGXVAL_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svkern.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svkern.h new file mode 100644 index 0000000..c7e8f6e --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svkern.h @@ -0,0 +1,51 @@ +/***************************************************************************/ +/* */ +/* svkern.h */ +/* */ +/* The FreeType Kerning service (specification). */ +/* */ +/* Copyright 2006-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVKERN_H_ +#define SVKERN_H_ + +#include FT_INTERNAL_SERVICE_H +#include FT_TRUETYPE_TABLES_H + + +FT_BEGIN_HEADER + +#define FT_SERVICE_ID_KERNING "kerning" + + + typedef FT_Error + (*FT_Kerning_TrackGetFunc)( FT_Face face, + FT_Fixed point_size, + FT_Int degree, + FT_Fixed* akerning ); + + FT_DEFINE_SERVICE( Kerning ) + { + FT_Kerning_TrackGetFunc get_track; + }; + + /* */ + + +FT_END_HEADER + + +#endif /* SVKERN_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svmetric.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svmetric.h new file mode 100644 index 0000000..abaacdd --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svmetric.h @@ -0,0 +1,153 @@ +/***************************************************************************/ +/* */ +/* svmetric.h */ +/* */ +/* The FreeType services for metrics variations (specification). */ +/* */ +/* Copyright 2016-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVMETRIC_H_ +#define SVMETRIC_H_ + +#include FT_INTERNAL_SERVICE_H + + +FT_BEGIN_HEADER + + + /* + * A service to manage the `HVAR, `MVAR', and `VVAR' OpenType tables. + * + */ + +#define FT_SERVICE_ID_METRICS_VARIATIONS "metrics-variations" + + + /* HVAR */ + + typedef FT_Error + (*FT_HAdvance_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + typedef FT_Error + (*FT_LSB_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + typedef FT_Error + (*FT_RSB_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + /* VVAR */ + + typedef FT_Error + (*FT_VAdvance_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + typedef FT_Error + (*FT_TSB_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + typedef FT_Error + (*FT_BSB_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + typedef FT_Error + (*FT_VOrg_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + /* MVAR */ + + typedef void + (*FT_Metrics_Adjust_Func)( FT_Face face ); + + + FT_DEFINE_SERVICE( MetricsVariations ) + { + FT_HAdvance_Adjust_Func hadvance_adjust; + FT_LSB_Adjust_Func lsb_adjust; + FT_RSB_Adjust_Func rsb_adjust; + + FT_VAdvance_Adjust_Func vadvance_adjust; + FT_TSB_Adjust_Func tsb_adjust; + FT_BSB_Adjust_Func bsb_adjust; + FT_VOrg_Adjust_Func vorg_adjust; + + FT_Metrics_Adjust_Func metrics_adjust; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \ + hadvance_adjust_, \ + lsb_adjust_, \ + rsb_adjust_, \ + vadvance_adjust_, \ + tsb_adjust_, \ + bsb_adjust_, \ + vorg_adjust_, \ + metrics_adjust_ ) \ + static const FT_Service_MetricsVariationsRec class_ = \ + { \ + hadvance_adjust_, \ + lsb_adjust_, \ + rsb_adjust_, \ + vadvance_adjust_, \ + tsb_adjust_, \ + bsb_adjust_, \ + vorg_adjust_, \ + metrics_adjust_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \ + hadvance_adjust_, \ + lsb_adjust_, \ + rsb_adjust_, \ + vadvance_adjust_, \ + tsb_adjust_, \ + bsb_adjust_, \ + vorg_adjust_, \ + metrics_adjust_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Service_MetricsVariationsRec* clazz ) \ + { \ + clazz->hadvance_adjust = hadvance_adjust_; \ + clazz->lsb_adjust = lsb_adjust_; \ + clazz->rsb_adjust = rsb_adjust_; \ + clazz->vadvance_adjust = vadvance_adjust_; \ + clazz->tsb_adjust = tsb_adjust_; \ + clazz->bsb_adjust = bsb_adjust_; \ + clazz->vorg_adjust = vorg_adjust_; \ + clazz->metrics_adjust = metrics_adjust_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + +#endif /* SVMETRIC_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svmm.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svmm.h new file mode 100644 index 0000000..bcbb38e --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svmm.h @@ -0,0 +1,172 @@ +/***************************************************************************/ +/* */ +/* svmm.h */ +/* */ +/* The FreeType Multiple Masters and GX var services (specification). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVMM_H_ +#define SVMM_H_ + +#include FT_INTERNAL_SERVICE_H + + +FT_BEGIN_HEADER + + + /* + * A service used to manage multiple-masters data in a given face. + * + * See the related APIs in `ftmm.h' (FT_MULTIPLE_MASTERS_H). + * + */ + +#define FT_SERVICE_ID_MULTI_MASTERS "multi-masters" + + + typedef FT_Error + (*FT_Get_MM_Func)( FT_Face face, + FT_Multi_Master* master ); + + typedef FT_Error + (*FT_Get_MM_Var_Func)( FT_Face face, + FT_MM_Var* *master ); + + typedef FT_Error + (*FT_Set_MM_Design_Func)( FT_Face face, + FT_UInt num_coords, + FT_Long* coords ); + + /* use return value -1 to indicate that the new coordinates */ + /* are equal to the current ones; no changes are thus needed */ + typedef FT_Error + (*FT_Set_Var_Design_Func)( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + /* use return value -1 to indicate that the new coordinates */ + /* are equal to the current ones; no changes are thus needed */ + typedef FT_Error + (*FT_Set_MM_Blend_Func)( FT_Face face, + FT_UInt num_coords, + FT_Long* coords ); + + typedef FT_Error + (*FT_Get_Var_Design_Func)( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + typedef FT_Error + (*FT_Set_Instance_Func)( FT_Face face, + FT_UInt instance_index ); + + typedef FT_Error + (*FT_Get_MM_Blend_Func)( FT_Face face, + FT_UInt num_coords, + FT_Long* coords ); + + typedef FT_Error + (*FT_Get_Var_Blend_Func)( FT_Face face, + FT_UInt *num_coords, + FT_Fixed* *coords, + FT_Fixed* *normalizedcoords, + FT_MM_Var* *mm_var ); + + typedef void + (*FT_Done_Blend_Func)( FT_Face ); + + + FT_DEFINE_SERVICE( MultiMasters ) + { + FT_Get_MM_Func get_mm; + FT_Set_MM_Design_Func set_mm_design; + FT_Set_MM_Blend_Func set_mm_blend; + FT_Get_MM_Blend_Func get_mm_blend; + FT_Get_MM_Var_Func get_mm_var; + FT_Set_Var_Design_Func set_var_design; + FT_Get_Var_Design_Func get_var_design; + FT_Set_Instance_Func set_instance; + + /* for internal use; only needed for code sharing between modules */ + FT_Get_Var_Blend_Func get_var_blend; + FT_Done_Blend_Func done_blend; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ + get_mm_, \ + set_mm_design_, \ + set_mm_blend_, \ + get_mm_blend_, \ + get_mm_var_, \ + set_var_design_, \ + get_var_design_, \ + set_instance_, \ + get_var_blend_, \ + done_blend_ ) \ + static const FT_Service_MultiMastersRec class_ = \ + { \ + get_mm_, \ + set_mm_design_, \ + set_mm_blend_, \ + get_mm_blend_, \ + get_mm_var_, \ + set_var_design_, \ + get_var_design_, \ + set_instance_, \ + get_var_blend_, \ + done_blend_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ + get_mm_, \ + set_mm_design_, \ + set_mm_blend_, \ + get_mm_blend_, \ + get_mm_var_, \ + set_var_design_, \ + get_var_design_, \ + set_instance_, \ + get_var_blend_, \ + done_blend_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Service_MultiMastersRec* clazz ) \ + { \ + clazz->get_mm = get_mm_; \ + clazz->set_mm_design = set_mm_design_; \ + clazz->set_mm_blend = set_mm_blend_; \ + clazz->get_mm_blend = get_mm_blend_; \ + clazz->get_mm_var = get_mm_var_; \ + clazz->set_var_design = set_var_design_; \ + clazz->get_var_design = get_var_design_; \ + clazz->set_instance = set_instance_; \ + clazz->get_var_blend = get_var_blend_; \ + clazz->done_blend = done_blend_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + +#endif /* SVMM_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svotval.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svotval.h new file mode 100644 index 0000000..3129429 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svotval.h @@ -0,0 +1,55 @@ +/***************************************************************************/ +/* */ +/* svotval.h */ +/* */ +/* The FreeType OpenType validation service (specification). */ +/* */ +/* Copyright 2004-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVOTVAL_H_ +#define SVOTVAL_H_ + +#include FT_OPENTYPE_VALIDATE_H +#include FT_INTERNAL_VALIDATE_H + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_OPENTYPE_VALIDATE "opentype-validate" + + + typedef FT_Error + (*otv_validate_func)( FT_Face volatile face, + FT_UInt ot_flags, + FT_Bytes *base, + FT_Bytes *gdef, + FT_Bytes *gpos, + FT_Bytes *gsub, + FT_Bytes *jstf ); + + + FT_DEFINE_SERVICE( OTvalidate ) + { + otv_validate_func validate; + }; + + /* */ + + +FT_END_HEADER + + +#endif /* SVOTVAL_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpfr.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpfr.h new file mode 100644 index 0000000..e65d57e --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpfr.h @@ -0,0 +1,66 @@ +/***************************************************************************/ +/* */ +/* svpfr.h */ +/* */ +/* Internal PFR service functions (specification). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVPFR_H_ +#define SVPFR_H_ + +#include FT_PFR_H +#include FT_INTERNAL_SERVICE_H + + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_PFR_METRICS "pfr-metrics" + + + typedef FT_Error + (*FT_PFR_GetMetricsFunc)( FT_Face face, + FT_UInt *aoutline, + FT_UInt *ametrics, + FT_Fixed *ax_scale, + FT_Fixed *ay_scale ); + + typedef FT_Error + (*FT_PFR_GetKerningFunc)( FT_Face face, + FT_UInt left, + FT_UInt right, + FT_Vector *avector ); + + typedef FT_Error + (*FT_PFR_GetAdvanceFunc)( FT_Face face, + FT_UInt gindex, + FT_Pos *aadvance ); + + + FT_DEFINE_SERVICE( PfrMetrics ) + { + FT_PFR_GetMetricsFunc get_metrics; + FT_PFR_GetKerningFunc get_kerning; + FT_PFR_GetAdvanceFunc get_advance; + + }; + + /* */ + +FT_END_HEADER + +#endif /* SVPFR_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpostnm.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpostnm.h new file mode 100644 index 0000000..4a49d8b --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpostnm.h @@ -0,0 +1,81 @@ +/***************************************************************************/ +/* */ +/* svpostnm.h */ +/* */ +/* The FreeType PostScript name services (specification). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVPOSTNM_H_ +#define SVPOSTNM_H_ + +#include FT_INTERNAL_SERVICE_H + + +FT_BEGIN_HEADER + + /* + * A trivial service used to retrieve the PostScript name of a given + * font when available. The `get_name' field should never be NULL. + * + * The corresponding function can return NULL to indicate that the + * PostScript name is not available. + * + * The name is owned by the face and will be destroyed with it. + */ + +#define FT_SERVICE_ID_POSTSCRIPT_FONT_NAME "postscript-font-name" + + + typedef const char* + (*FT_PsName_GetFunc)( FT_Face face ); + + + FT_DEFINE_SERVICE( PsFontName ) + { + FT_PsName_GetFunc get_ps_font_name; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ + static const FT_Service_PsFontNameRec class_ = \ + { \ + get_ps_font_name_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + FT_Service_PsFontNameRec* clazz ) \ + { \ + FT_UNUSED( library ); \ + \ + clazz->get_ps_font_name = get_ps_font_name_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + + +#endif /* SVPOSTNM_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svprop.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svprop.h new file mode 100644 index 0000000..adc0bcf --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svprop.h @@ -0,0 +1,82 @@ +/***************************************************************************/ +/* */ +/* svprop.h */ +/* */ +/* The FreeType property service (specification). */ +/* */ +/* Copyright 2012-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVPROP_H_ +#define SVPROP_H_ + + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_PROPERTIES "properties" + + + typedef FT_Error + (*FT_Properties_SetFunc)( FT_Module module, + const char* property_name, + const void* value, + FT_Bool value_is_string ); + + typedef FT_Error + (*FT_Properties_GetFunc)( FT_Module module, + const char* property_name, + void* value ); + + + FT_DEFINE_SERVICE( Properties ) + { + FT_Properties_SetFunc set_property; + FT_Properties_GetFunc get_property; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \ + set_property_, \ + get_property_ ) \ + static const FT_Service_PropertiesRec class_ = \ + { \ + set_property_, \ + get_property_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \ + set_property_, \ + get_property_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Service_PropertiesRec* clazz ) \ + { \ + clazz->set_property = set_property_; \ + clazz->get_property = get_property_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + + +#endif /* SVPROP_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpscmap.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpscmap.h new file mode 100644 index 0000000..5589575 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpscmap.h @@ -0,0 +1,177 @@ +/***************************************************************************/ +/* */ +/* svpscmap.h */ +/* */ +/* The FreeType PostScript charmap service (specification). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVPSCMAP_H_ +#define SVPSCMAP_H_ + +#include FT_INTERNAL_OBJECTS_H + + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_POSTSCRIPT_CMAPS "postscript-cmaps" + + + /* + * Adobe glyph name to unicode value. + */ + typedef FT_UInt32 + (*PS_Unicode_ValueFunc)( const char* glyph_name ); + + /* + * Macintosh name id to glyph name. NULL if invalid index. + */ + typedef const char* + (*PS_Macintosh_NameFunc)( FT_UInt name_index ); + + /* + * Adobe standard string ID to glyph name. NULL if invalid index. + */ + typedef const char* + (*PS_Adobe_Std_StringsFunc)( FT_UInt string_index ); + + + /* + * Simple unicode -> glyph index charmap built from font glyph names + * table. + */ + typedef struct PS_UniMap_ + { + FT_UInt32 unicode; /* bit 31 set: is glyph variant */ + FT_UInt glyph_index; + + } PS_UniMap; + + + typedef struct PS_UnicodesRec_* PS_Unicodes; + + typedef struct PS_UnicodesRec_ + { + FT_CMapRec cmap; + FT_UInt num_maps; + PS_UniMap* maps; + + } PS_UnicodesRec; + + + /* + * A function which returns a glyph name for a given index. Returns + * NULL if invalid index. + */ + typedef const char* + (*PS_GetGlyphNameFunc)( FT_Pointer data, + FT_UInt string_index ); + + /* + * A function used to release the glyph name returned by + * PS_GetGlyphNameFunc, when needed + */ + typedef void + (*PS_FreeGlyphNameFunc)( FT_Pointer data, + const char* name ); + + typedef FT_Error + (*PS_Unicodes_InitFunc)( FT_Memory memory, + PS_Unicodes unicodes, + FT_UInt num_glyphs, + PS_GetGlyphNameFunc get_glyph_name, + PS_FreeGlyphNameFunc free_glyph_name, + FT_Pointer glyph_data ); + + typedef FT_UInt + (*PS_Unicodes_CharIndexFunc)( PS_Unicodes unicodes, + FT_UInt32 unicode ); + + typedef FT_UInt32 + (*PS_Unicodes_CharNextFunc)( PS_Unicodes unicodes, + FT_UInt32 *unicode ); + + + FT_DEFINE_SERVICE( PsCMaps ) + { + PS_Unicode_ValueFunc unicode_value; + + PS_Unicodes_InitFunc unicodes_init; + PS_Unicodes_CharIndexFunc unicodes_char_index; + PS_Unicodes_CharNextFunc unicodes_char_next; + + PS_Macintosh_NameFunc macintosh_name; + PS_Adobe_Std_StringsFunc adobe_std_strings; + const unsigned short* adobe_std_encoding; + const unsigned short* adobe_expert_encoding; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \ + unicode_value_, \ + unicodes_init_, \ + unicodes_char_index_, \ + unicodes_char_next_, \ + macintosh_name_, \ + adobe_std_strings_, \ + adobe_std_encoding_, \ + adobe_expert_encoding_ ) \ + static const FT_Service_PsCMapsRec class_ = \ + { \ + unicode_value_, unicodes_init_, \ + unicodes_char_index_, unicodes_char_next_, macintosh_name_, \ + adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \ + unicode_value_, \ + unicodes_init_, \ + unicodes_char_index_, \ + unicodes_char_next_, \ + macintosh_name_, \ + adobe_std_strings_, \ + adobe_std_encoding_, \ + adobe_expert_encoding_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + FT_Service_PsCMapsRec* clazz ) \ + { \ + FT_UNUSED( library ); \ + \ + clazz->unicode_value = unicode_value_; \ + clazz->unicodes_init = unicodes_init_; \ + clazz->unicodes_char_index = unicodes_char_index_; \ + clazz->unicodes_char_next = unicodes_char_next_; \ + clazz->macintosh_name = macintosh_name_; \ + clazz->adobe_std_strings = adobe_std_strings_; \ + clazz->adobe_std_encoding = adobe_std_encoding_; \ + clazz->adobe_expert_encoding = adobe_expert_encoding_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + + +#endif /* SVPSCMAP_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpsinfo.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpsinfo.h new file mode 100644 index 0000000..408f406 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svpsinfo.h @@ -0,0 +1,111 @@ +/***************************************************************************/ +/* */ +/* svpsinfo.h */ +/* */ +/* The FreeType PostScript info service (specification). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVPSINFO_H_ +#define SVPSINFO_H_ + +#include FT_INTERNAL_SERVICE_H +#include FT_INTERNAL_TYPE1_TYPES_H + + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_POSTSCRIPT_INFO "postscript-info" + + + typedef FT_Error + (*PS_GetFontInfoFunc)( FT_Face face, + PS_FontInfoRec* afont_info ); + + typedef FT_Error + (*PS_GetFontExtraFunc)( FT_Face face, + PS_FontExtraRec* afont_extra ); + + typedef FT_Int + (*PS_HasGlyphNamesFunc)( FT_Face face ); + + typedef FT_Error + (*PS_GetFontPrivateFunc)( FT_Face face, + PS_PrivateRec* afont_private ); + + typedef FT_Long + (*PS_GetFontValueFunc)( FT_Face face, + PS_Dict_Keys key, + FT_UInt idx, + void *value, + FT_Long value_len ); + + + FT_DEFINE_SERVICE( PsInfo ) + { + PS_GetFontInfoFunc ps_get_font_info; + PS_GetFontExtraFunc ps_get_font_extra; + PS_HasGlyphNamesFunc ps_has_glyph_names; + PS_GetFontPrivateFunc ps_get_font_private; + PS_GetFontValueFunc ps_get_font_value; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_PSINFOREC( class_, \ + get_font_info_, \ + ps_get_font_extra_, \ + has_glyph_names_, \ + get_font_private_, \ + get_font_value_ ) \ + static const FT_Service_PsInfoRec class_ = \ + { \ + get_font_info_, ps_get_font_extra_, has_glyph_names_, \ + get_font_private_, get_font_value_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_PSINFOREC( class_, \ + get_font_info_, \ + ps_get_font_extra_, \ + has_glyph_names_, \ + get_font_private_, \ + get_font_value_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + FT_Service_PsInfoRec* clazz ) \ + { \ + FT_UNUSED( library ); \ + \ + clazz->ps_get_font_info = get_font_info_; \ + clazz->ps_get_font_extra = ps_get_font_extra_; \ + clazz->ps_has_glyph_names = has_glyph_names_; \ + clazz->ps_get_font_private = get_font_private_; \ + clazz->ps_get_font_value = get_font_value_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + + +#endif /* SVPSINFO_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svsfnt.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svsfnt.h new file mode 100644 index 0000000..e8b37bc --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svsfnt.h @@ -0,0 +1,103 @@ +/***************************************************************************/ +/* */ +/* svsfnt.h */ +/* */ +/* The FreeType SFNT table loading service (specification). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVSFNT_H_ +#define SVSFNT_H_ + +#include FT_INTERNAL_SERVICE_H +#include FT_TRUETYPE_TABLES_H + + +FT_BEGIN_HEADER + + + /* + * SFNT table loading service. + */ + +#define FT_SERVICE_ID_SFNT_TABLE "sfnt-table" + + + /* + * Used to implement FT_Load_Sfnt_Table(). + */ + typedef FT_Error + (*FT_SFNT_TableLoadFunc)( FT_Face face, + FT_ULong tag, + FT_Long offset, + FT_Byte* buffer, + FT_ULong* length ); + + /* + * Used to implement FT_Get_Sfnt_Table(). + */ + typedef void* + (*FT_SFNT_TableGetFunc)( FT_Face face, + FT_Sfnt_Tag tag ); + + + /* + * Used to implement FT_Sfnt_Table_Info(). + */ + typedef FT_Error + (*FT_SFNT_TableInfoFunc)( FT_Face face, + FT_UInt idx, + FT_ULong *tag, + FT_ULong *offset, + FT_ULong *length ); + + + FT_DEFINE_SERVICE( SFNT_Table ) + { + FT_SFNT_TableLoadFunc load_table; + FT_SFNT_TableGetFunc get_table; + FT_SFNT_TableInfoFunc table_info; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ + static const FT_Service_SFNT_TableRec class_ = \ + { \ + load_, get_, info_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Service_SFNT_TableRec* clazz ) \ + { \ + clazz->load_table = load_; \ + clazz->get_table = get_; \ + clazz->table_info = info_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + + +#endif /* SVSFNT_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svttcmap.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svttcmap.h new file mode 100644 index 0000000..cd0e6fd --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svttcmap.h @@ -0,0 +1,106 @@ +/***************************************************************************/ +/* */ +/* svttcmap.h */ +/* */ +/* The FreeType TrueType/sfnt cmap extra information service. */ +/* */ +/* Copyright 2003-2018 by */ +/* Masatake YAMATO, Redhat K.K., */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +/* Development of this service is support of + Information-technology Promotion Agency, Japan. */ + +#ifndef SVTTCMAP_H_ +#define SVTTCMAP_H_ + +#include FT_INTERNAL_SERVICE_H +#include FT_TRUETYPE_TABLES_H + + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_TT_CMAP "tt-cmaps" + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_CMapInfo */ + /* */ + /* <Description> */ + /* A structure used to store TrueType/sfnt specific cmap information */ + /* which is not covered by the generic @FT_CharMap structure. This */ + /* structure can be accessed with the @FT_Get_TT_CMap_Info function. */ + /* */ + /* <Fields> */ + /* language :: */ + /* The language ID used in Mac fonts. Definitions of values are in */ + /* `ttnameid.h'. */ + /* */ + /* format :: */ + /* The cmap format. OpenType 1.6 defines the formats 0 (byte */ + /* encoding table), 2~(high-byte mapping through table), 4~(segment */ + /* mapping to delta values), 6~(trimmed table mapping), 8~(mixed */ + /* 16-bit and 32-bit coverage), 10~(trimmed array), 12~(segmented */ + /* coverage), 13~(last resort font), and 14 (Unicode Variation */ + /* Sequences). */ + /* */ + typedef struct TT_CMapInfo_ + { + FT_ULong language; + FT_Long format; + + } TT_CMapInfo; + + + typedef FT_Error + (*TT_CMap_Info_GetFunc)( FT_CharMap charmap, + TT_CMapInfo *cmap_info ); + + + FT_DEFINE_SERVICE( TTCMaps ) + { + TT_CMap_Info_GetFunc get_cmap_info; + }; + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \ + static const FT_Service_TTCMapsRec class_ = \ + { \ + get_cmap_info_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + FT_Service_TTCMapsRec* clazz ) \ + { \ + FT_UNUSED( library ); \ + \ + clazz->get_cmap_info = get_cmap_info_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + +#endif /* SVTTCMAP_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svtteng.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svtteng.h new file mode 100644 index 0000000..92e3c54 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svtteng.h @@ -0,0 +1,53 @@ +/***************************************************************************/ +/* */ +/* svtteng.h */ +/* */ +/* The FreeType TrueType engine query service (specification). */ +/* */ +/* Copyright 2006-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVTTENG_H_ +#define SVTTENG_H_ + +#include FT_INTERNAL_SERVICE_H +#include FT_MODULE_H + + +FT_BEGIN_HEADER + + + /* + * SFNT table loading service. + */ + +#define FT_SERVICE_ID_TRUETYPE_ENGINE "truetype-engine" + + /* + * Used to implement FT_Get_TrueType_Engine_Type + */ + + FT_DEFINE_SERVICE( TrueTypeEngine ) + { + FT_TrueTypeEngineType engine_type; + }; + + /* */ + + +FT_END_HEADER + + +#endif /* SVTTENG_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svttglyf.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svttglyf.h new file mode 100644 index 0000000..16fac1c --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svttglyf.h @@ -0,0 +1,69 @@ +/***************************************************************************/ +/* */ +/* svttglyf.h */ +/* */ +/* The FreeType TrueType glyph service. */ +/* */ +/* Copyright 2007-2018 by */ +/* David Turner. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#ifndef SVTTGLYF_H_ +#define SVTTGLYF_H_ + +#include FT_INTERNAL_SERVICE_H +#include FT_TRUETYPE_TABLES_H + + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_TT_GLYF "tt-glyf" + + + typedef FT_ULong + (*TT_Glyf_GetLocationFunc)( FT_Face face, + FT_UInt gindex, + FT_ULong *psize ); + + FT_DEFINE_SERVICE( TTGlyf ) + { + TT_Glyf_GetLocationFunc get_location; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ + static const FT_Service_TTGlyfRec class_ = \ + { \ + get_location_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Service_TTGlyfRec* clazz ) \ + { \ + clazz->get_location = get_location_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + +#endif /* SVTTGLYF_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svwinfnt.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svwinfnt.h new file mode 100644 index 0000000..80d481c --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/services/svwinfnt.h @@ -0,0 +1,50 @@ +/***************************************************************************/ +/* */ +/* svwinfnt.h */ +/* */ +/* The FreeType Windows FNT/FONT service (specification). */ +/* */ +/* Copyright 2003-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVWINFNT_H_ +#define SVWINFNT_H_ + +#include FT_INTERNAL_SERVICE_H +#include FT_WINFONTS_H + + +FT_BEGIN_HEADER + + +#define FT_SERVICE_ID_WINFNT "winfonts" + + typedef FT_Error + (*FT_WinFnt_GetHeaderFunc)( FT_Face face, + FT_WinFNT_HeaderRec *aheader ); + + + FT_DEFINE_SERVICE( WinFnt ) + { + FT_WinFnt_GetHeaderFunc get_header; + }; + + /* */ + + +FT_END_HEADER + + +#endif /* SVWINFNT_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/sfnt.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/sfnt.h new file mode 100644 index 0000000..fb1e327 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/sfnt.h @@ -0,0 +1,784 @@ +/***************************************************************************/ +/* */ +/* sfnt.h */ +/* */ +/* High-level `sfnt' driver interface (specification). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SFNT_H_ +#define SFNT_H_ + + +#include <ft2build.h> +#include FT_INTERNAL_DRIVER_H +#include FT_INTERNAL_TRUETYPE_TYPES_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Init_Face_Func */ + /* */ + /* <Description> */ + /* First part of the SFNT face object initialization. This finds */ + /* the face in a SFNT file or collection, and load its format tag in */ + /* face->format_tag. */ + /* */ + /* <Input> */ + /* stream :: The input stream. */ + /* */ + /* face :: A handle to the target face object. */ + /* */ + /* face_index :: The index of the TrueType font, if we are opening a */ + /* collection, in bits 0-15. The numbered instance */ + /* index~+~1 of a GX (sub)font, if applicable, in bits */ + /* 16-30. */ + /* */ + /* num_params :: The number of additional parameters. */ + /* */ + /* params :: Optional additional parameters. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* The stream cursor must be at the font file's origin. */ + /* */ + /* This function recognizes fonts embedded in a `TrueType */ + /* collection'. */ + /* */ + /* Once the format tag has been validated by the font driver, it */ + /* should then call the TT_Load_Face_Func() callback to read the rest */ + /* of the SFNT tables in the object. */ + /* */ + typedef FT_Error + (*TT_Init_Face_Func)( FT_Stream stream, + TT_Face face, + FT_Int face_index, + FT_Int num_params, + FT_Parameter* params ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Load_Face_Func */ + /* */ + /* <Description> */ + /* Second part of the SFNT face object initialization. This loads */ + /* the common SFNT tables (head, OS/2, maxp, metrics, etc.) in the */ + /* face object. */ + /* */ + /* <Input> */ + /* stream :: The input stream. */ + /* */ + /* face :: A handle to the target face object. */ + /* */ + /* face_index :: The index of the TrueType font, if we are opening a */ + /* collection, in bits 0-15. The numbered instance */ + /* index~+~1 of a GX (sub)font, if applicable, in bits */ + /* 16-30. */ + /* */ + /* num_params :: The number of additional parameters. */ + /* */ + /* params :: Optional additional parameters. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* This function must be called after TT_Init_Face_Func(). */ + /* */ + typedef FT_Error + (*TT_Load_Face_Func)( FT_Stream stream, + TT_Face face, + FT_Int face_index, + FT_Int num_params, + FT_Parameter* params ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Done_Face_Func */ + /* */ + /* <Description> */ + /* A callback used to delete the common SFNT data from a face. */ + /* */ + /* <Input> */ + /* face :: A handle to the target face object. */ + /* */ + /* <Note> */ + /* This function does NOT destroy the face object. */ + /* */ + typedef void + (*TT_Done_Face_Func)( TT_Face face ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Load_Any_Func */ + /* */ + /* <Description> */ + /* Load any font table into client memory. */ + /* */ + /* <Input> */ + /* face :: The face object to look for. */ + /* */ + /* tag :: The tag of table to load. Use the value 0 if you want */ + /* to access the whole font file, else set this parameter */ + /* to a valid TrueType table tag that you can forge with */ + /* the MAKE_TT_TAG macro. */ + /* */ + /* offset :: The starting offset in the table (or the file if */ + /* tag == 0). */ + /* */ + /* length :: The address of the decision variable: */ + /* */ + /* If length == NULL: */ + /* Loads the whole table. Returns an error if */ + /* `offset' == 0! */ + /* */ + /* If *length == 0: */ + /* Exits immediately; returning the length of the given */ + /* table or of the font file, depending on the value of */ + /* `tag'. */ + /* */ + /* If *length != 0: */ + /* Loads the next `length' bytes of table or font, */ + /* starting at offset `offset' (in table or font too). */ + /* */ + /* <Output> */ + /* buffer :: The address of target buffer. */ + /* */ + /* <Return> */ + /* TrueType error code. 0 means success. */ + /* */ + typedef FT_Error + (*TT_Load_Any_Func)( TT_Face face, + FT_ULong tag, + FT_Long offset, + FT_Byte *buffer, + FT_ULong* length ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Find_SBit_Image_Func */ + /* */ + /* <Description> */ + /* Check whether an embedded bitmap (an `sbit') exists for a given */ + /* glyph, at a given strike. */ + /* */ + /* <Input> */ + /* face :: The target face object. */ + /* */ + /* glyph_index :: The glyph index. */ + /* */ + /* strike_index :: The current strike index. */ + /* */ + /* <Output> */ + /* arange :: The SBit range containing the glyph index. */ + /* */ + /* astrike :: The SBit strike containing the glyph index. */ + /* */ + /* aglyph_offset :: The offset of the glyph data in `EBDT' table. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. Returns */ + /* SFNT_Err_Invalid_Argument if no sbit exists for the requested */ + /* glyph. */ + /* */ + typedef FT_Error + (*TT_Find_SBit_Image_Func)( TT_Face face, + FT_UInt glyph_index, + FT_ULong strike_index, + TT_SBit_Range *arange, + TT_SBit_Strike *astrike, + FT_ULong *aglyph_offset ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Load_SBit_Metrics_Func */ + /* */ + /* <Description> */ + /* Get the big metrics for a given embedded bitmap. */ + /* */ + /* <Input> */ + /* stream :: The input stream. */ + /* */ + /* range :: The SBit range containing the glyph. */ + /* */ + /* <Output> */ + /* big_metrics :: A big SBit metrics structure for the glyph. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* The stream cursor must be positioned at the glyph's offset within */ + /* the `EBDT' table before the call. */ + /* */ + /* If the image format uses variable metrics, the stream cursor is */ + /* positioned just after the metrics header in the `EBDT' table on */ + /* function exit. */ + /* */ + typedef FT_Error + (*TT_Load_SBit_Metrics_Func)( FT_Stream stream, + TT_SBit_Range range, + TT_SBit_Metrics metrics ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Load_SBit_Image_Func */ + /* */ + /* <Description> */ + /* Load a given glyph sbit image from the font resource. This also */ + /* returns its metrics. */ + /* */ + /* <Input> */ + /* face :: */ + /* The target face object. */ + /* */ + /* strike_index :: */ + /* The strike index. */ + /* */ + /* glyph_index :: */ + /* The current glyph index. */ + /* */ + /* load_flags :: */ + /* The current load flags. */ + /* */ + /* stream :: */ + /* The input stream. */ + /* */ + /* <Output> */ + /* amap :: */ + /* The target pixmap. */ + /* */ + /* ametrics :: */ + /* A big sbit metrics structure for the glyph image. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. Returns an error if no */ + /* glyph sbit exists for the index. */ + /* */ + /* <Note> */ + /* The `map.buffer' field is always freed before the glyph is loaded. */ + /* */ + typedef FT_Error + (*TT_Load_SBit_Image_Func)( TT_Face face, + FT_ULong strike_index, + FT_UInt glyph_index, + FT_UInt load_flags, + FT_Stream stream, + FT_Bitmap *amap, + TT_SBit_MetricsRec *ametrics ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Set_SBit_Strike_Func */ + /* */ + /* <Description> */ + /* Select an sbit strike for a given size request. */ + /* */ + /* <Input> */ + /* face :: The target face object. */ + /* */ + /* req :: The size request. */ + /* */ + /* <Output> */ + /* astrike_index :: The index of the sbit strike. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. Returns an error if no */ + /* sbit strike exists for the selected ppem values. */ + /* */ + typedef FT_Error + (*TT_Set_SBit_Strike_Func)( TT_Face face, + FT_Size_Request req, + FT_ULong* astrike_index ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Load_Strike_Metrics_Func */ + /* */ + /* <Description> */ + /* Load the metrics of a given strike. */ + /* */ + /* <Input> */ + /* face :: The target face object. */ + /* */ + /* strike_index :: The strike index. */ + /* */ + /* <Output> */ + /* metrics :: the metrics of the strike. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. Returns an error if no */ + /* such sbit strike exists. */ + /* */ + typedef FT_Error + (*TT_Load_Strike_Metrics_Func)( TT_Face face, + FT_ULong strike_index, + FT_Size_Metrics* metrics ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Get_PS_Name_Func */ + /* */ + /* <Description> */ + /* Get the PostScript glyph name of a glyph. */ + /* */ + /* <Input> */ + /* idx :: The glyph index. */ + /* */ + /* PSname :: The address of a string pointer. Will be NULL in case */ + /* of error, otherwise it is a pointer to the glyph name. */ + /* */ + /* You must not modify the returned string! */ + /* */ + /* <Output> */ + /* FreeType error code. 0 means success. */ + /* */ + typedef FT_Error + (*TT_Get_PS_Name_Func)( TT_Face face, + FT_UInt idx, + FT_String** PSname ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Load_Metrics_Func */ + /* */ + /* <Description> */ + /* Load a metrics table, which is a table with a horizontal and a */ + /* vertical version. */ + /* */ + /* <Input> */ + /* face :: A handle to the target face object. */ + /* */ + /* stream :: The input stream. */ + /* */ + /* vertical :: A boolean flag. If set, load the vertical one. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + typedef FT_Error + (*TT_Load_Metrics_Func)( TT_Face face, + FT_Stream stream, + FT_Bool vertical ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Get_Metrics_Func */ + /* */ + /* <Description> */ + /* Load the horizontal or vertical header in a face object. */ + /* */ + /* <Input> */ + /* face :: A handle to the target face object. */ + /* */ + /* vertical :: A boolean flag. If set, load vertical metrics. */ + /* */ + /* gindex :: The glyph index. */ + /* */ + /* <Output> */ + /* abearing :: The horizontal (or vertical) bearing. Set to zero in */ + /* case of error. */ + /* */ + /* aadvance :: The horizontal (or vertical) advance. Set to zero in */ + /* case of error. */ + /* */ + typedef void + (*TT_Get_Metrics_Func)( TT_Face face, + FT_Bool vertical, + FT_UInt gindex, + FT_Short* abearing, + FT_UShort* aadvance ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Get_Name_Func */ + /* */ + /* <Description> */ + /* From the `name' table, return a given ENGLISH name record in */ + /* ASCII. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* nameid :: The name id of the name record to return. */ + /* */ + /* <InOut> */ + /* name :: The address of an allocated string pointer. NULL if */ + /* no name is present. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + typedef FT_Error + (*TT_Get_Name_Func)( TT_Face face, + FT_UShort nameid, + FT_String** name ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Get_Name_ID_Func */ + /* */ + /* <Description> */ + /* Search whether an ENGLISH version for a given name ID is in the */ + /* `name' table. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* nameid :: The name id of the name record to return. */ + /* */ + /* <Out> */ + /* win :: If non-negative, an index into the `name' table with */ + /* the corresponding (3,1) or (3,0) Windows entry. */ + /* */ + /* apple :: If non-negative, an index into the `name' table with */ + /* the corresponding (1,0) Apple entry. */ + /* */ + /* <Return> */ + /* 1 if there is either a win or apple entry (or both), 0 otheriwse. */ + /* */ + typedef FT_Bool + (*TT_Get_Name_ID_Func)( TT_Face face, + FT_UShort nameid, + FT_Int *win, + FT_Int *apple ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Load_Table_Func */ + /* */ + /* <Description> */ + /* Load a given TrueType table. */ + /* */ + /* <Input> */ + /* face :: A handle to the target face object. */ + /* */ + /* stream :: The input stream. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* The function uses `face->goto_table' to seek the stream to the */ + /* start of the table, except while loading the font directory. */ + /* */ + typedef FT_Error + (*TT_Load_Table_Func)( TT_Face face, + FT_Stream stream ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Free_Table_Func */ + /* */ + /* <Description> */ + /* Free a given TrueType table. */ + /* */ + /* <Input> */ + /* face :: A handle to the target face object. */ + /* */ + typedef void + (*TT_Free_Table_Func)( TT_Face face ); + + + /* + * @functype: + * TT_Face_GetKerningFunc + * + * @description: + * Return the horizontal kerning value between two glyphs. + * + * @input: + * face :: A handle to the source face object. + * left_glyph :: The left glyph index. + * right_glyph :: The right glyph index. + * + * @return: + * The kerning value in font units. + */ + typedef FT_Int + (*TT_Face_GetKerningFunc)( TT_Face face, + FT_UInt left_glyph, + FT_UInt right_glyph ); + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* SFNT_Interface */ + /* */ + /* <Description> */ + /* This structure holds pointers to the functions used to load and */ + /* free the basic tables that are required in a `sfnt' font file. */ + /* */ + /* <Fields> */ + /* Check the various xxx_Func() descriptions for details. */ + /* */ + typedef struct SFNT_Interface_ + { + TT_Loader_GotoTableFunc goto_table; + + TT_Init_Face_Func init_face; + TT_Load_Face_Func load_face; + TT_Done_Face_Func done_face; + FT_Module_Requester get_interface; + + TT_Load_Any_Func load_any; + + /* these functions are called by `load_face' but they can also */ + /* be called from external modules, if there is a need to do so */ + TT_Load_Table_Func load_head; + TT_Load_Metrics_Func load_hhea; + TT_Load_Table_Func load_cmap; + TT_Load_Table_Func load_maxp; + TT_Load_Table_Func load_os2; + TT_Load_Table_Func load_post; + + TT_Load_Table_Func load_name; + TT_Free_Table_Func free_name; + + /* this field was called `load_kerning' up to version 2.1.10 */ + TT_Load_Table_Func load_kern; + + TT_Load_Table_Func load_gasp; + TT_Load_Table_Func load_pclt; + + /* see `ttload.h'; this field was called `load_bitmap_header' up to */ + /* version 2.1.10 */ + TT_Load_Table_Func load_bhed; + + TT_Load_SBit_Image_Func load_sbit_image; + + /* see `ttpost.h' */ + TT_Get_PS_Name_Func get_psname; + TT_Free_Table_Func free_psnames; + + /* starting here, the structure differs from version 2.1.7 */ + + /* this field was introduced in version 2.1.8, named `get_psname' */ + TT_Face_GetKerningFunc get_kerning; + + /* new elements introduced after version 2.1.10 */ + + /* load the font directory, i.e., the offset table and */ + /* the table directory */ + TT_Load_Table_Func load_font_dir; + TT_Load_Metrics_Func load_hmtx; + + TT_Load_Table_Func load_eblc; + TT_Free_Table_Func free_eblc; + + TT_Set_SBit_Strike_Func set_sbit_strike; + TT_Load_Strike_Metrics_Func load_strike_metrics; + + TT_Get_Metrics_Func get_metrics; + + TT_Get_Name_Func get_name; + TT_Get_Name_ID_Func get_name_id; + + } SFNT_Interface; + + + /* transitional */ + typedef SFNT_Interface* SFNT_Service; + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SFNT_INTERFACE( \ + class_, \ + goto_table_, \ + init_face_, \ + load_face_, \ + done_face_, \ + get_interface_, \ + load_any_, \ + load_head_, \ + load_hhea_, \ + load_cmap_, \ + load_maxp_, \ + load_os2_, \ + load_post_, \ + load_name_, \ + free_name_, \ + load_kern_, \ + load_gasp_, \ + load_pclt_, \ + load_bhed_, \ + load_sbit_image_, \ + get_psname_, \ + free_psnames_, \ + get_kerning_, \ + load_font_dir_, \ + load_hmtx_, \ + load_eblc_, \ + free_eblc_, \ + set_sbit_strike_, \ + load_strike_metrics_, \ + get_metrics_, \ + get_name_, \ + get_name_id_ ) \ + static const SFNT_Interface class_ = \ + { \ + goto_table_, \ + init_face_, \ + load_face_, \ + done_face_, \ + get_interface_, \ + load_any_, \ + load_head_, \ + load_hhea_, \ + load_cmap_, \ + load_maxp_, \ + load_os2_, \ + load_post_, \ + load_name_, \ + free_name_, \ + load_kern_, \ + load_gasp_, \ + load_pclt_, \ + load_bhed_, \ + load_sbit_image_, \ + get_psname_, \ + free_psnames_, \ + get_kerning_, \ + load_font_dir_, \ + load_hmtx_, \ + load_eblc_, \ + free_eblc_, \ + set_sbit_strike_, \ + load_strike_metrics_, \ + get_metrics_, \ + get_name_, \ + get_name_id_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_INTERNAL( a, a_ ) \ + clazz->a = a_; + +#define FT_DEFINE_SFNT_INTERFACE( \ + class_, \ + goto_table_, \ + init_face_, \ + load_face_, \ + done_face_, \ + get_interface_, \ + load_any_, \ + load_head_, \ + load_hhea_, \ + load_cmap_, \ + load_maxp_, \ + load_os2_, \ + load_post_, \ + load_name_, \ + free_name_, \ + load_kern_, \ + load_gasp_, \ + load_pclt_, \ + load_bhed_, \ + load_sbit_image_, \ + get_psname_, \ + free_psnames_, \ + get_kerning_, \ + load_font_dir_, \ + load_hmtx_, \ + load_eblc_, \ + free_eblc_, \ + set_sbit_strike_, \ + load_strike_metrics_, \ + get_metrics_, \ + get_name_, \ + get_name_id_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Library library, \ + SFNT_Interface* clazz ) \ + { \ + FT_UNUSED( library ); \ + \ + clazz->goto_table = goto_table_; \ + clazz->init_face = init_face_; \ + clazz->load_face = load_face_; \ + clazz->done_face = done_face_; \ + clazz->get_interface = get_interface_; \ + clazz->load_any = load_any_; \ + clazz->load_head = load_head_; \ + clazz->load_hhea = load_hhea_; \ + clazz->load_cmap = load_cmap_; \ + clazz->load_maxp = load_maxp_; \ + clazz->load_os2 = load_os2_; \ + clazz->load_post = load_post_; \ + clazz->load_name = load_name_; \ + clazz->free_name = free_name_; \ + clazz->load_kern = load_kern_; \ + clazz->load_gasp = load_gasp_; \ + clazz->load_pclt = load_pclt_; \ + clazz->load_bhed = load_bhed_; \ + clazz->load_sbit_image = load_sbit_image_; \ + clazz->get_psname = get_psname_; \ + clazz->free_psnames = free_psnames_; \ + clazz->get_kerning = get_kerning_; \ + clazz->load_font_dir = load_font_dir_; \ + clazz->load_hmtx = load_hmtx_; \ + clazz->load_eblc = load_eblc_; \ + clazz->free_eblc = free_eblc_; \ + clazz->set_sbit_strike = set_sbit_strike_; \ + clazz->load_strike_metrics = load_strike_metrics_; \ + clazz->get_metrics = get_metrics_; \ + clazz->get_name = get_name_; \ + clazz->get_name_id = get_name_id_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + +FT_END_HEADER + +#endif /* SFNT_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/t1types.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/t1types.h new file mode 100644 index 0000000..2118e33 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/t1types.h @@ -0,0 +1,257 @@ +/***************************************************************************/ +/* */ +/* t1types.h */ +/* */ +/* Basic Type1/Type2 type definitions and interface (specification */ +/* only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef T1TYPES_H_ +#define T1TYPES_H_ + + +#include <ft2build.h> +#include FT_TYPE1_TABLES_H +#include FT_INTERNAL_POSTSCRIPT_HINTS_H +#include FT_INTERNAL_SERVICE_H +#include FT_INTERNAL_HASH_H +#include FT_SERVICE_POSTSCRIPT_CMAPS_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** REQUIRED TYPE1/TYPE2 TABLES DEFINITIONS ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* T1_EncodingRec */ + /* */ + /* <Description> */ + /* A structure modeling a custom encoding. */ + /* */ + /* <Fields> */ + /* num_chars :: The number of character codes in the encoding. */ + /* Usually 256. */ + /* */ + /* code_first :: The lowest valid character code in the encoding. */ + /* */ + /* code_last :: The highest valid character code in the encoding */ + /* + 1. When equal to code_first there are no valid */ + /* character codes. */ + /* */ + /* char_index :: An array of corresponding glyph indices. */ + /* */ + /* char_name :: An array of corresponding glyph names. */ + /* */ + typedef struct T1_EncodingRecRec_ + { + FT_Int num_chars; + FT_Int code_first; + FT_Int code_last; + + FT_UShort* char_index; + FT_String** char_name; + + } T1_EncodingRec, *T1_Encoding; + + + /* used to hold extra data of PS_FontInfoRec that + * cannot be stored in the publicly defined structure. + * + * Note these can't be blended with multiple-masters. + */ + typedef struct PS_FontExtraRec_ + { + FT_UShort fs_type; + + } PS_FontExtraRec; + + + typedef struct T1_FontRec_ + { + PS_FontInfoRec font_info; /* font info dictionary */ + PS_FontExtraRec font_extra; /* font info extra fields */ + PS_PrivateRec private_dict; /* private dictionary */ + FT_String* font_name; /* top-level dictionary */ + + T1_EncodingType encoding_type; + T1_EncodingRec encoding; + + FT_Byte* subrs_block; + FT_Byte* charstrings_block; + FT_Byte* glyph_names_block; + + FT_Int num_subrs; + FT_Byte** subrs; + FT_UInt* subrs_len; + FT_Hash subrs_hash; + + FT_Int num_glyphs; + FT_String** glyph_names; /* array of glyph names */ + FT_Byte** charstrings; /* array of glyph charstrings */ + FT_UInt* charstrings_len; + + FT_Byte paint_type; + FT_Byte font_type; + FT_Matrix font_matrix; + FT_Vector font_offset; + FT_BBox font_bbox; + FT_Long font_id; + + FT_Fixed stroke_width; + + } T1_FontRec, *T1_Font; + + + typedef struct CID_SubrsRec_ + { + FT_Int num_subrs; + FT_Byte** code; + + } CID_SubrsRec, *CID_Subrs; + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** AFM FONT INFORMATION STRUCTURES ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + typedef struct AFM_TrackKernRec_ + { + FT_Int degree; + FT_Fixed min_ptsize; + FT_Fixed min_kern; + FT_Fixed max_ptsize; + FT_Fixed max_kern; + + } AFM_TrackKernRec, *AFM_TrackKern; + + typedef struct AFM_KernPairRec_ + { + FT_UInt index1; + FT_UInt index2; + FT_Int x; + FT_Int y; + + } AFM_KernPairRec, *AFM_KernPair; + + typedef struct AFM_FontInfoRec_ + { + FT_Bool IsCIDFont; + FT_BBox FontBBox; + FT_Fixed Ascender; + FT_Fixed Descender; + AFM_TrackKern TrackKerns; /* free if non-NULL */ + FT_UInt NumTrackKern; + AFM_KernPair KernPairs; /* free if non-NULL */ + FT_UInt NumKernPair; + + } AFM_FontInfoRec, *AFM_FontInfo; + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** ORIGINAL T1_FACE CLASS DEFINITION ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + typedef struct T1_FaceRec_* T1_Face; + typedef struct CID_FaceRec_* CID_Face; + + + typedef struct T1_FaceRec_ + { + FT_FaceRec root; + T1_FontRec type1; + const void* psnames; + const void* psaux; + const void* afm_data; + FT_CharMapRec charmaprecs[2]; + FT_CharMap charmaps[2]; + + /* support for Multiple Masters fonts */ + PS_Blend blend; + + /* undocumented, optional: indices of subroutines that express */ + /* the NormalizeDesignVector and the ConvertDesignVector procedure, */ + /* respectively, as Type 2 charstrings; -1 if keywords not present */ + FT_Int ndv_idx; + FT_Int cdv_idx; + + /* undocumented, optional: has the same meaning as len_buildchar */ + /* for Type 2 fonts; manipulated by othersubrs 19, 24, and 25 */ + FT_UInt len_buildchar; + FT_Long* buildchar; + + /* since version 2.1 - interface to PostScript hinter */ + const void* pshinter; + + } T1_FaceRec; + + + typedef struct CID_FaceRec_ + { + FT_FaceRec root; + void* psnames; + void* psaux; + CID_FaceInfoRec cid; + PS_FontExtraRec font_extra; +#if 0 + void* afm_data; +#endif + CID_Subrs subrs; + + /* since version 2.1 - interface to PostScript hinter */ + void* pshinter; + + /* since version 2.1.8, but was originally positioned after `afm_data' */ + FT_Byte* binary_data; /* used if hex data has been converted */ + FT_Stream cid_stream; + + } CID_FaceRec; + + +FT_END_HEADER + +#endif /* T1TYPES_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/internal/tttypes.h b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/tttypes.h new file mode 100644 index 0000000..10dd336 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/internal/tttypes.h @@ -0,0 +1,1689 @@ +/***************************************************************************/ +/* */ +/* tttypes.h */ +/* */ +/* Basic SFNT/TrueType type definitions and interface (specification */ +/* only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef TTTYPES_H_ +#define TTTYPES_H_ + + +#include <ft2build.h> +#include FT_TRUETYPE_TABLES_H +#include FT_INTERNAL_OBJECTS_H + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include FT_MULTIPLE_MASTERS_H +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** REQUIRED TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TTC_HeaderRec */ + /* */ + /* <Description> */ + /* TrueType collection header. This table contains the offsets of */ + /* the font headers of each distinct TrueType face in the file. */ + /* */ + /* <Fields> */ + /* tag :: Must be `ttc ' to indicate a TrueType collection. */ + /* */ + /* version :: The version number. */ + /* */ + /* count :: The number of faces in the collection. The */ + /* specification says this should be an unsigned long, but */ + /* we use a signed long since we need the value -1 for */ + /* specific purposes. */ + /* */ + /* offsets :: The offsets of the font headers, one per face. */ + /* */ + typedef struct TTC_HeaderRec_ + { + FT_ULong tag; + FT_Fixed version; + FT_Long count; + FT_ULong* offsets; + + } TTC_HeaderRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* SFNT_HeaderRec */ + /* */ + /* <Description> */ + /* SFNT file format header. */ + /* */ + /* <Fields> */ + /* format_tag :: The font format tag. */ + /* */ + /* num_tables :: The number of tables in file. */ + /* */ + /* search_range :: Must be `16 * (max power of 2 <= num_tables)'. */ + /* */ + /* entry_selector :: Must be log2 of `search_range / 16'. */ + /* */ + /* range_shift :: Must be `num_tables * 16 - search_range'. */ + /* */ + typedef struct SFNT_HeaderRec_ + { + FT_ULong format_tag; + FT_UShort num_tables; + FT_UShort search_range; + FT_UShort entry_selector; + FT_UShort range_shift; + + FT_ULong offset; /* not in file */ + + } SFNT_HeaderRec, *SFNT_Header; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_TableRec */ + /* */ + /* <Description> */ + /* This structure describes a given table of a TrueType font. */ + /* */ + /* <Fields> */ + /* Tag :: A four-bytes tag describing the table. */ + /* */ + /* CheckSum :: The table checksum. This value can be ignored. */ + /* */ + /* Offset :: The offset of the table from the start of the TrueType */ + /* font in its resource. */ + /* */ + /* Length :: The table length (in bytes). */ + /* */ + typedef struct TT_TableRec_ + { + FT_ULong Tag; /* table type */ + FT_ULong CheckSum; /* table checksum */ + FT_ULong Offset; /* table file offset */ + FT_ULong Length; /* table length */ + + } TT_TableRec, *TT_Table; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* WOFF_HeaderRec */ + /* */ + /* <Description> */ + /* WOFF file format header. */ + /* */ + /* <Fields> */ + /* See */ + /* */ + /* https://www.w3.org/TR/WOFF/#WOFFHeader */ + /* */ + typedef struct WOFF_HeaderRec_ + { + FT_ULong signature; + FT_ULong flavor; + FT_ULong length; + FT_UShort num_tables; + FT_UShort reserved; + FT_ULong totalSfntSize; + FT_UShort majorVersion; + FT_UShort minorVersion; + FT_ULong metaOffset; + FT_ULong metaLength; + FT_ULong metaOrigLength; + FT_ULong privOffset; + FT_ULong privLength; + + } WOFF_HeaderRec, *WOFF_Header; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* WOFF_TableRec */ + /* */ + /* <Description> */ + /* This structure describes a given table of a WOFF font. */ + /* */ + /* <Fields> */ + /* Tag :: A four-bytes tag describing the table. */ + /* */ + /* Offset :: The offset of the table from the start of the WOFF */ + /* font in its resource. */ + /* */ + /* CompLength :: Compressed table length (in bytes). */ + /* */ + /* OrigLength :: Uncompressed table length (in bytes). */ + /* */ + /* CheckSum :: The table checksum. This value can be ignored. */ + /* */ + /* OrigOffset :: The uncompressed table file offset. This value gets */ + /* computed while constructing the (uncompressed) SFNT */ + /* header. It is not contained in the WOFF file. */ + /* */ + typedef struct WOFF_TableRec_ + { + FT_ULong Tag; /* table ID */ + FT_ULong Offset; /* table file offset */ + FT_ULong CompLength; /* compressed table length */ + FT_ULong OrigLength; /* uncompressed table length */ + FT_ULong CheckSum; /* uncompressed checksum */ + + FT_ULong OrigOffset; /* uncompressed table file offset */ + /* (not in the WOFF file) */ + } WOFF_TableRec, *WOFF_Table; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_LongMetricsRec */ + /* */ + /* <Description> */ + /* A structure modeling the long metrics of the `hmtx' and `vmtx' */ + /* TrueType tables. The values are expressed in font units. */ + /* */ + /* <Fields> */ + /* advance :: The advance width or height for the glyph. */ + /* */ + /* bearing :: The left-side or top-side bearing for the glyph. */ + /* */ + typedef struct TT_LongMetricsRec_ + { + FT_UShort advance; + FT_Short bearing; + + } TT_LongMetricsRec, *TT_LongMetrics; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* TT_ShortMetrics */ + /* */ + /* <Description> */ + /* A simple type to model the short metrics of the `hmtx' and `vmtx' */ + /* tables. */ + /* */ + typedef FT_Short TT_ShortMetrics; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_NameRec */ + /* */ + /* <Description> */ + /* A structure modeling TrueType name records. Name records are used */ + /* to store important strings like family name, style name, */ + /* copyright, etc. in _localized_ versions (i.e., language, encoding, */ + /* etc). */ + /* */ + /* <Fields> */ + /* platformID :: The ID of the name's encoding platform. */ + /* */ + /* encodingID :: The platform-specific ID for the name's encoding. */ + /* */ + /* languageID :: The platform-specific ID for the name's language. */ + /* */ + /* nameID :: The ID specifying what kind of name this is. */ + /* */ + /* stringLength :: The length of the string in bytes. */ + /* */ + /* stringOffset :: The offset to the string in the `name' table. */ + /* */ + /* string :: A pointer to the string's bytes. Note that these */ + /* are usually UTF-16 encoded characters. */ + /* */ + typedef struct TT_NameRec_ + { + FT_UShort platformID; + FT_UShort encodingID; + FT_UShort languageID; + FT_UShort nameID; + FT_UShort stringLength; + FT_ULong stringOffset; + + /* this last field is not defined in the spec */ + /* but used by the FreeType engine */ + + FT_Byte* string; + + } TT_NameRec, *TT_Name; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_LangTagRec */ + /* */ + /* <Description> */ + /* A structure modeling language tag records in SFNT `name' tables, */ + /* introduced in OpenType version 1.6. */ + /* */ + /* <Fields> */ + /* stringLength :: The length of the string in bytes. */ + /* */ + /* stringOffset :: The offset to the string in the `name' table. */ + /* */ + /* string :: A pointer to the string's bytes. Note that these */ + /* are UTF-16BE encoded characters. */ + /* */ + typedef struct TT_LangTagRec_ + { + FT_UShort stringLength; + FT_ULong stringOffset; + + /* this last field is not defined in the spec */ + /* but used by the FreeType engine */ + + FT_Byte* string; + + } TT_LangTagRec, *TT_LangTag; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_NameTableRec */ + /* */ + /* <Description> */ + /* A structure modeling the TrueType name table. */ + /* */ + /* <Fields> */ + /* format :: The format of the name table. */ + /* */ + /* numNameRecords :: The number of names in table. */ + /* */ + /* storageOffset :: The offset of the name table in the `name' */ + /* TrueType table. */ + /* */ + /* names :: An array of name records. */ + /* */ + /* numLangTagRecords :: The number of language tags in table. */ + /* */ + /* langTags :: An array of language tag records. */ + /* */ + /* stream :: The file's input stream. */ + /* */ + typedef struct TT_NameTableRec_ + { + FT_UShort format; + FT_UInt numNameRecords; + FT_UInt storageOffset; + TT_NameRec* names; + FT_UInt numLangTagRecords; + TT_LangTagRec* langTags; + FT_Stream stream; + + } TT_NameTableRec, *TT_NameTable; + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_GaspRangeRec */ + /* */ + /* <Description> */ + /* A tiny structure used to model a gasp range according to the */ + /* TrueType specification. */ + /* */ + /* <Fields> */ + /* maxPPEM :: The maximum ppem value to which `gaspFlag' applies. */ + /* */ + /* gaspFlag :: A flag describing the grid-fitting and anti-aliasing */ + /* modes to be used. */ + /* */ + typedef struct TT_GaspRangeRec_ + { + FT_UShort maxPPEM; + FT_UShort gaspFlag; + + } TT_GaspRangeRec, *TT_GaspRange; + + +#define TT_GASP_GRIDFIT 0x01 +#define TT_GASP_DOGRAY 0x02 + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_GaspRec */ + /* */ + /* <Description> */ + /* A structure modeling the TrueType `gasp' table used to specify */ + /* grid-fitting and anti-aliasing behaviour. */ + /* */ + /* <Fields> */ + /* version :: The version number. */ + /* */ + /* numRanges :: The number of gasp ranges in table. */ + /* */ + /* gaspRanges :: An array of gasp ranges. */ + /* */ + typedef struct TT_Gasp_ + { + FT_UShort version; + FT_UShort numRanges; + TT_GaspRange gaspRanges; + + } TT_GaspRec; + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** EMBEDDED BITMAPS SUPPORT ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_SBit_MetricsRec */ + /* */ + /* <Description> */ + /* A structure used to hold the big metrics of a given glyph bitmap */ + /* in a TrueType or OpenType font. These are usually found in the */ + /* `EBDT' (Microsoft) or `bloc' (Apple) table. */ + /* */ + /* <Fields> */ + /* height :: The glyph height in pixels. */ + /* */ + /* width :: The glyph width in pixels. */ + /* */ + /* horiBearingX :: The horizontal left bearing. */ + /* */ + /* horiBearingY :: The horizontal top bearing. */ + /* */ + /* horiAdvance :: The horizontal advance. */ + /* */ + /* vertBearingX :: The vertical left bearing. */ + /* */ + /* vertBearingY :: The vertical top bearing. */ + /* */ + /* vertAdvance :: The vertical advance. */ + /* */ + typedef struct TT_SBit_MetricsRec_ + { + FT_UShort height; + FT_UShort width; + + FT_Short horiBearingX; + FT_Short horiBearingY; + FT_UShort horiAdvance; + + FT_Short vertBearingX; + FT_Short vertBearingY; + FT_UShort vertAdvance; + + } TT_SBit_MetricsRec, *TT_SBit_Metrics; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_SBit_SmallMetricsRec */ + /* */ + /* <Description> */ + /* A structure used to hold the small metrics of a given glyph bitmap */ + /* in a TrueType or OpenType font. These are usually found in the */ + /* `EBDT' (Microsoft) or the `bdat' (Apple) table. */ + /* */ + /* <Fields> */ + /* height :: The glyph height in pixels. */ + /* */ + /* width :: The glyph width in pixels. */ + /* */ + /* bearingX :: The left-side bearing. */ + /* */ + /* bearingY :: The top-side bearing. */ + /* */ + /* advance :: The advance width or height. */ + /* */ + typedef struct TT_SBit_Small_Metrics_ + { + FT_Byte height; + FT_Byte width; + + FT_Char bearingX; + FT_Char bearingY; + FT_Byte advance; + + } TT_SBit_SmallMetricsRec, *TT_SBit_SmallMetrics; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_SBit_LineMetricsRec */ + /* */ + /* <Description> */ + /* A structure used to describe the text line metrics of a given */ + /* bitmap strike, for either a horizontal or vertical layout. */ + /* */ + /* <Fields> */ + /* ascender :: The ascender in pixels. */ + /* */ + /* descender :: The descender in pixels. */ + /* */ + /* max_width :: The maximum glyph width in pixels. */ + /* */ + /* caret_slope_enumerator :: Rise of the caret slope, typically set */ + /* to 1 for non-italic fonts. */ + /* */ + /* caret_slope_denominator :: Rise of the caret slope, typically set */ + /* to 0 for non-italic fonts. */ + /* */ + /* caret_offset :: Offset in pixels to move the caret for */ + /* proper positioning. */ + /* */ + /* min_origin_SB :: Minimum of horiBearingX (resp. */ + /* vertBearingY). */ + /* min_advance_SB :: Minimum of */ + /* */ + /* horizontal advance - */ + /* ( horiBearingX + width ) */ + /* */ + /* resp. */ + /* */ + /* vertical advance - */ + /* ( vertBearingY + height ) */ + /* */ + /* max_before_BL :: Maximum of horiBearingY (resp. */ + /* vertBearingY). */ + /* */ + /* min_after_BL :: Minimum of */ + /* */ + /* horiBearingY - height */ + /* */ + /* resp. */ + /* */ + /* vertBearingX - width */ + /* */ + /* pads :: Unused (to make the size of the record */ + /* a multiple of 32 bits. */ + /* */ + typedef struct TT_SBit_LineMetricsRec_ + { + FT_Char ascender; + FT_Char descender; + FT_Byte max_width; + FT_Char caret_slope_numerator; + FT_Char caret_slope_denominator; + FT_Char caret_offset; + FT_Char min_origin_SB; + FT_Char min_advance_SB; + FT_Char max_before_BL; + FT_Char min_after_BL; + FT_Char pads[2]; + + } TT_SBit_LineMetricsRec, *TT_SBit_LineMetrics; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_SBit_RangeRec */ + /* */ + /* <Description> */ + /* A TrueType/OpenType subIndexTable as defined in the `EBLC' */ + /* (Microsoft) or `bloc' (Apple) tables. */ + /* */ + /* <Fields> */ + /* first_glyph :: The first glyph index in the range. */ + /* */ + /* last_glyph :: The last glyph index in the range. */ + /* */ + /* index_format :: The format of index table. Valid values are 1 */ + /* to 5. */ + /* */ + /* image_format :: The format of `EBDT' image data. */ + /* */ + /* image_offset :: The offset to image data in `EBDT'. */ + /* */ + /* image_size :: For index formats 2 and 5. This is the size in */ + /* bytes of each glyph bitmap. */ + /* */ + /* big_metrics :: For index formats 2 and 5. This is the big */ + /* metrics for each glyph bitmap. */ + /* */ + /* num_glyphs :: For index formats 4 and 5. This is the number of */ + /* glyphs in the code array. */ + /* */ + /* glyph_offsets :: For index formats 1 and 3. */ + /* */ + /* glyph_codes :: For index formats 4 and 5. */ + /* */ + /* table_offset :: The offset of the index table in the `EBLC' */ + /* table. Only used during strike loading. */ + /* */ + typedef struct TT_SBit_RangeRec_ + { + FT_UShort first_glyph; + FT_UShort last_glyph; + + FT_UShort index_format; + FT_UShort image_format; + FT_ULong image_offset; + + FT_ULong image_size; + TT_SBit_MetricsRec metrics; + FT_ULong num_glyphs; + + FT_ULong* glyph_offsets; + FT_UShort* glyph_codes; + + FT_ULong table_offset; + + } TT_SBit_RangeRec, *TT_SBit_Range; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_SBit_StrikeRec */ + /* */ + /* <Description> */ + /* A structure used describe a given bitmap strike in the `EBLC' */ + /* (Microsoft) or `bloc' (Apple) tables. */ + /* */ + /* <Fields> */ + /* num_index_ranges :: The number of index ranges. */ + /* */ + /* index_ranges :: An array of glyph index ranges. */ + /* */ + /* color_ref :: Unused. `color_ref' is put in for future */ + /* enhancements, but these fields are already */ + /* in use by other platforms (e.g. Newton). */ + /* For details, please see */ + /* */ + /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html */ + /* */ + /* hori :: The line metrics for horizontal layouts. */ + /* */ + /* vert :: The line metrics for vertical layouts. */ + /* */ + /* start_glyph :: The lowest glyph index for this strike. */ + /* */ + /* end_glyph :: The highest glyph index for this strike. */ + /* */ + /* x_ppem :: The number of horizontal pixels per EM. */ + /* */ + /* y_ppem :: The number of vertical pixels per EM. */ + /* */ + /* bit_depth :: The bit depth. Valid values are 1, 2, 4, */ + /* and 8. */ + /* */ + /* flags :: Is this a vertical or horizontal strike? For */ + /* details, please see */ + /* */ + /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html */ + /* */ + typedef struct TT_SBit_StrikeRec_ + { + FT_Int num_ranges; + TT_SBit_Range sbit_ranges; + FT_ULong ranges_offset; + + FT_ULong color_ref; + + TT_SBit_LineMetricsRec hori; + TT_SBit_LineMetricsRec vert; + + FT_UShort start_glyph; + FT_UShort end_glyph; + + FT_Byte x_ppem; + FT_Byte y_ppem; + + FT_Byte bit_depth; + FT_Char flags; + + } TT_SBit_StrikeRec, *TT_SBit_Strike; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_SBit_ComponentRec */ + /* */ + /* <Description> */ + /* A simple structure to describe a compound sbit element. */ + /* */ + /* <Fields> */ + /* glyph_code :: The element's glyph index. */ + /* */ + /* x_offset :: The element's left bearing. */ + /* */ + /* y_offset :: The element's top bearing. */ + /* */ + typedef struct TT_SBit_ComponentRec_ + { + FT_UShort glyph_code; + FT_Char x_offset; + FT_Char y_offset; + + } TT_SBit_ComponentRec, *TT_SBit_Component; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_SBit_ScaleRec */ + /* */ + /* <Description> */ + /* A structure used describe a given bitmap scaling table, as defined */ + /* in the `EBSC' table. */ + /* */ + /* <Fields> */ + /* hori :: The horizontal line metrics. */ + /* */ + /* vert :: The vertical line metrics. */ + /* */ + /* x_ppem :: The number of horizontal pixels per EM. */ + /* */ + /* y_ppem :: The number of vertical pixels per EM. */ + /* */ + /* x_ppem_substitute :: Substitution x_ppem value. */ + /* */ + /* y_ppem_substitute :: Substitution y_ppem value. */ + /* */ + typedef struct TT_SBit_ScaleRec_ + { + TT_SBit_LineMetricsRec hori; + TT_SBit_LineMetricsRec vert; + + FT_Byte x_ppem; + FT_Byte y_ppem; + + FT_Byte x_ppem_substitute; + FT_Byte y_ppem_substitute; + + } TT_SBit_ScaleRec, *TT_SBit_Scale; + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** POSTSCRIPT GLYPH NAMES SUPPORT ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_Post_20Rec */ + /* */ + /* <Description> */ + /* Postscript names sub-table, format 2.0. Stores the PS name of */ + /* each glyph in the font face. */ + /* */ + /* <Fields> */ + /* num_glyphs :: The number of named glyphs in the table. */ + /* */ + /* num_names :: The number of PS names stored in the table. */ + /* */ + /* glyph_indices :: The indices of the glyphs in the names arrays. */ + /* */ + /* glyph_names :: The PS names not in Mac Encoding. */ + /* */ + typedef struct TT_Post_20Rec_ + { + FT_UShort num_glyphs; + FT_UShort num_names; + FT_UShort* glyph_indices; + FT_Char** glyph_names; + + } TT_Post_20Rec, *TT_Post_20; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_Post_25Rec */ + /* */ + /* <Description> */ + /* Postscript names sub-table, format 2.5. Stores the PS name of */ + /* each glyph in the font face. */ + /* */ + /* <Fields> */ + /* num_glyphs :: The number of glyphs in the table. */ + /* */ + /* offsets :: An array of signed offsets in a normal Mac */ + /* Postscript name encoding. */ + /* */ + typedef struct TT_Post_25_ + { + FT_UShort num_glyphs; + FT_Char* offsets; + + } TT_Post_25Rec, *TT_Post_25; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_Post_NamesRec */ + /* */ + /* <Description> */ + /* Postscript names table, either format 2.0 or 2.5. */ + /* */ + /* <Fields> */ + /* loaded :: A flag to indicate whether the PS names are loaded. */ + /* */ + /* format_20 :: The sub-table used for format 2.0. */ + /* */ + /* format_25 :: The sub-table used for format 2.5. */ + /* */ + typedef struct TT_Post_NamesRec_ + { + FT_Bool loaded; + + union + { + TT_Post_20Rec format_20; + TT_Post_25Rec format_25; + + } names; + + } TT_Post_NamesRec, *TT_Post_Names; + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** GX VARIATION TABLE SUPPORT ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + typedef struct GX_BlendRec_ *GX_Blend; +#endif + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** EMBEDDED BDF PROPERTIES TABLE SUPPORT ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + /* + * These types are used to support a `BDF ' table that isn't part of the + * official TrueType specification. It is mainly used in SFNT-based + * bitmap fonts that were generated from a set of BDF fonts. + * + * The format of the table is as follows. + * + * USHORT version `BDF ' table version number, should be 0x0001. + * USHORT strikeCount Number of strikes (bitmap sizes) in this table. + * ULONG stringTable Offset (from start of BDF table) to string + * table. + * + * This is followed by an array of `strikeCount' descriptors, having the + * following format. + * + * USHORT ppem Vertical pixels per EM for this strike. + * USHORT numItems Number of items for this strike (properties and + * atoms). Maximum is 255. + * + * This array in turn is followed by `strikeCount' value sets. Each + * `value set' is an array of `numItems' items with the following format. + * + * ULONG item_name Offset in string table to item name. + * USHORT item_type The item type. Possible values are + * 0 => string (e.g., COMMENT) + * 1 => atom (e.g., FONT or even SIZE) + * 2 => int32 + * 3 => uint32 + * 0x10 => A flag to indicate a properties. This + * is ORed with the above values. + * ULONG item_value For strings => Offset into string table without + * the corresponding double quotes. + * For atoms => Offset into string table. + * For integers => Direct value. + * + * All strings in the string table consist of bytes and are + * zero-terminated. + * + */ + +#ifdef TT_CONFIG_OPTION_BDF + + typedef struct TT_BDFRec_ + { + FT_Byte* table; + FT_Byte* table_end; + FT_Byte* strings; + FT_ULong strings_size; + FT_UInt num_strikes; + FT_Bool loaded; + + } TT_BDFRec, *TT_BDF; + +#endif /* TT_CONFIG_OPTION_BDF */ + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** ***/ + /*** ORIGINAL TT_FACE CLASS DEFINITION ***/ + /*** ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This structure/class is defined here because it is common to the */ + /* following formats: TTF, OpenType-TT, and OpenType-CFF. */ + /* */ + /* Note, however, that the classes TT_Size and TT_GlyphSlot are not */ + /* shared between font drivers, and are thus defined in `ttobjs.h'. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* TT_Face */ + /* */ + /* <Description> */ + /* A handle to a TrueType face/font object. A TT_Face encapsulates */ + /* the resolution and scaling independent parts of a TrueType font */ + /* resource. */ + /* */ + /* <Note> */ + /* The TT_Face structure is also used as a `parent class' for the */ + /* OpenType-CFF class (T2_Face). */ + /* */ + typedef struct TT_FaceRec_* TT_Face; + + + /* a function type used for the truetype bytecode interpreter hooks */ + typedef FT_Error + (*TT_Interpreter)( void* exec_context ); + + /* forward declaration */ + typedef struct TT_LoaderRec_* TT_Loader; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Loader_GotoTableFunc */ + /* */ + /* <Description> */ + /* Seeks a stream to the start of a given TrueType table. */ + /* */ + /* <Input> */ + /* face :: A handle to the target face object. */ + /* */ + /* tag :: A 4-byte tag used to name the table. */ + /* */ + /* stream :: The input stream. */ + /* */ + /* <Output> */ + /* length :: The length of the table in bytes. Set to 0 if not */ + /* needed. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* The stream cursor must be at the font file's origin. */ + /* */ + typedef FT_Error + (*TT_Loader_GotoTableFunc)( TT_Face face, + FT_ULong tag, + FT_Stream stream, + FT_ULong* length ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Loader_StartGlyphFunc */ + /* */ + /* <Description> */ + /* Seeks a stream to the start of a given glyph element, and opens a */ + /* frame for it. */ + /* */ + /* <Input> */ + /* loader :: The current TrueType glyph loader object. */ + /* */ + /* glyph index :: The index of the glyph to access. */ + /* */ + /* offset :: The offset of the glyph according to the */ + /* `locations' table. */ + /* */ + /* byte_count :: The size of the frame in bytes. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + /* <Note> */ + /* This function is normally equivalent to FT_STREAM_SEEK(offset) */ + /* followed by FT_FRAME_ENTER(byte_count) with the loader's stream, */ + /* but alternative formats (e.g. compressed ones) might use something */ + /* different. */ + /* */ + typedef FT_Error + (*TT_Loader_StartGlyphFunc)( TT_Loader loader, + FT_UInt glyph_index, + FT_ULong offset, + FT_UInt byte_count ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Loader_ReadGlyphFunc */ + /* */ + /* <Description> */ + /* Reads one glyph element (its header, a simple glyph, or a */ + /* composite) from the loader's current stream frame. */ + /* */ + /* <Input> */ + /* loader :: The current TrueType glyph loader object. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + typedef FT_Error + (*TT_Loader_ReadGlyphFunc)( TT_Loader loader ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Loader_EndGlyphFunc */ + /* */ + /* <Description> */ + /* Closes the current loader stream frame for the glyph. */ + /* */ + /* <Input> */ + /* loader :: The current TrueType glyph loader object. */ + /* */ + typedef void + (*TT_Loader_EndGlyphFunc)( TT_Loader loader ); + + + typedef enum TT_SbitTableType_ + { + TT_SBIT_TABLE_TYPE_NONE = 0, + TT_SBIT_TABLE_TYPE_EBLC, /* `EBLC' (Microsoft), */ + /* `bloc' (Apple) */ + TT_SBIT_TABLE_TYPE_CBLC, /* `CBLC' (Google) */ + TT_SBIT_TABLE_TYPE_SBIX, /* `sbix' (Apple) */ + + /* do not remove */ + TT_SBIT_TABLE_TYPE_MAX + + } TT_SbitTableType; + + + /* OpenType 1.8 brings new tables for variation font support; */ + /* to make the old MM and GX fonts still work we need to check */ + /* the presence (and validity) of the functionality provided */ + /* by those tables. The following flag macros are for the */ + /* field `variation_support'. */ + /* */ + /* Note that `fvar' gets checked immediately at font loading, */ + /* while the other features are only loaded if MM support is */ + /* actually requested. */ + + /* FVAR */ +#define TT_FACE_FLAG_VAR_FVAR ( 1 << 0 ) + + /* HVAR */ +#define TT_FACE_FLAG_VAR_HADVANCE ( 1 << 1 ) +#define TT_FACE_FLAG_VAR_LSB ( 1 << 2 ) +#define TT_FACE_FLAG_VAR_RSB ( 1 << 3 ) + + /* VVAR */ +#define TT_FACE_FLAG_VAR_VADVANCE ( 1 << 4 ) +#define TT_FACE_FLAG_VAR_TSB ( 1 << 5 ) +#define TT_FACE_FLAG_VAR_BSB ( 1 << 6 ) +#define TT_FACE_FLAG_VAR_VORG ( 1 << 7 ) + + /* MVAR */ +#define TT_FACE_FLAG_VAR_MVAR ( 1 << 8 ) + + + /*************************************************************************/ + /* */ + /* TrueType Face Type */ + /* */ + /* <Struct> */ + /* TT_Face */ + /* */ + /* <Description> */ + /* The TrueType face class. These objects model the resolution and */ + /* point-size independent data found in a TrueType font file. */ + /* */ + /* <Fields> */ + /* root :: The base FT_Face structure, managed by the */ + /* base layer. */ + /* */ + /* ttc_header :: The TrueType collection header, used when */ + /* the file is a `ttc' rather than a `ttf'. */ + /* For ordinary font files, the field */ + /* `ttc_header.count' is set to 0. */ + /* */ + /* format_tag :: The font format tag. */ + /* */ + /* num_tables :: The number of TrueType tables in this font */ + /* file. */ + /* */ + /* dir_tables :: The directory of TrueType tables for this */ + /* font file. */ + /* */ + /* header :: The font's font header (`head' table). */ + /* Read on font opening. */ + /* */ + /* horizontal :: The font's horizontal header (`hhea' */ + /* table). This field also contains the */ + /* associated horizontal metrics table */ + /* (`hmtx'). */ + /* */ + /* max_profile :: The font's maximum profile table. Read on */ + /* font opening. Note that some maximum */ + /* values cannot be taken directly from this */ + /* table. We thus define additional fields */ + /* below to hold the computed maxima. */ + /* */ + /* vertical_info :: A boolean which is set when the font file */ + /* contains vertical metrics. If not, the */ + /* value of the `vertical' field is */ + /* undefined. */ + /* */ + /* vertical :: The font's vertical header (`vhea' table). */ + /* This field also contains the associated */ + /* vertical metrics table (`vmtx'), if found. */ + /* IMPORTANT: The contents of this field is */ + /* undefined if the `vertical_info' field is */ + /* unset. */ + /* */ + /* num_names :: The number of name records within this */ + /* TrueType font. */ + /* */ + /* name_table :: The table of name records (`name'). */ + /* */ + /* os2 :: The font's OS/2 table (`OS/2'). */ + /* */ + /* postscript :: The font's PostScript table (`post' */ + /* table). The PostScript glyph names are */ + /* not loaded by the driver on face opening. */ + /* See the `ttpost' module for more details. */ + /* */ + /* cmap_table :: Address of the face's `cmap' SFNT table */ + /* in memory (it's an extracted frame). */ + /* */ + /* cmap_size :: The size in bytes of the `cmap_table' */ + /* described above. */ + /* */ + /* goto_table :: A function called by each TrueType table */ + /* loader to position a stream's cursor to */ + /* the start of a given table according to */ + /* its tag. It defaults to TT_Goto_Face but */ + /* can be different for strange formats (e.g. */ + /* Type 42). */ + /* */ + /* access_glyph_frame :: A function used to access the frame of a */ + /* given glyph within the face's font file. */ + /* */ + /* forget_glyph_frame :: A function used to forget the frame of a */ + /* given glyph when all data has been loaded. */ + /* */ + /* read_glyph_header :: A function used to read a glyph header. */ + /* It must be called between an `access' and */ + /* `forget'. */ + /* */ + /* read_simple_glyph :: A function used to read a simple glyph. */ + /* It must be called after the header was */ + /* read, and before the `forget'. */ + /* */ + /* read_composite_glyph :: A function used to read a composite glyph. */ + /* It must be called after the header was */ + /* read, and before the `forget'. */ + /* */ + /* sfnt :: A pointer to the SFNT service. */ + /* */ + /* psnames :: A pointer to the PostScript names service. */ + /* */ + /* mm :: A pointer to the Multiple Masters service. */ + /* */ + /* var :: A pointer to the Metrics Variations */ + /* service. */ + /* */ + /* hdmx :: The face's horizontal device metrics */ + /* (`hdmx' table). This table is optional in */ + /* TrueType/OpenType fonts. */ + /* */ + /* gasp :: The grid-fitting and scaling properties */ + /* table (`gasp'). This table is optional in */ + /* TrueType/OpenType fonts. */ + /* */ + /* pclt :: The `pclt' SFNT table. */ + /* */ + /* num_sbit_scales :: The number of sbit scales for this font. */ + /* */ + /* sbit_scales :: Array of sbit scales embedded in this */ + /* font. This table is optional in a */ + /* TrueType/OpenType font. */ + /* */ + /* postscript_names :: A table used to store the Postscript names */ + /* of the glyphs for this font. See the */ + /* file `ttconfig.h' for comments on the */ + /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */ + /* */ + /* font_program_size :: Size in bytecodes of the face's font */ + /* program. 0 if none defined. Ignored for */ + /* Type 2 fonts. */ + /* */ + /* font_program :: The face's font program (bytecode stream) */ + /* executed at load time, also used during */ + /* glyph rendering. Comes from the `fpgm' */ + /* table. Ignored for Type 2 font fonts. */ + /* */ + /* cvt_program_size :: The size in bytecodes of the face's cvt */ + /* program. Ignored for Type 2 fonts. */ + /* */ + /* cvt_program :: The face's cvt program (bytecode stream) */ + /* executed each time an instance/size is */ + /* changed/reset. Comes from the `prep' */ + /* table. Ignored for Type 2 fonts. */ + /* */ + /* cvt_size :: Size of the control value table (in */ + /* entries). Ignored for Type 2 fonts. */ + /* */ + /* cvt :: The face's original control value table. */ + /* Coordinates are expressed in unscaled font */ + /* units. Comes from the `cvt ' table. */ + /* Ignored for Type 2 fonts. */ + /* */ + /* interpreter :: A pointer to the TrueType bytecode */ + /* interpreters field is also used to hook */ + /* the debugger in `ttdebug'. */ + /* */ + /* extra :: Reserved for third-party font drivers. */ + /* */ + /* postscript_name :: The PS name of the font. Used by the */ + /* postscript name service. */ + /* */ + /* glyf_len :: The length of the `glyf' table. Needed */ + /* for malformed `loca' tables. */ + /* */ + /* glyf_offset :: The file offset of the `glyf' table. */ + /* */ + /* is_cff2 :: Set if the font format is CFF2. */ + /* */ + /* doblend :: A boolean which is set if the font should */ + /* be blended (this is for GX var). */ + /* */ + /* blend :: Contains the data needed to control GX */ + /* variation tables (rather like Multiple */ + /* Master data). */ + /* */ + /* variation_support :: Flags that indicate which OpenType */ + /* functionality related to font variation */ + /* support is present, valid, and usable. */ + /* For example, TT_FACE_FLAG_VAR_FVAR is only */ + /* set if we have at least one design axis. */ + /* */ + /* var_postscript_prefix :: */ + /* The PostScript name prefix needed for */ + /* constructing a variation font instance's */ + /* PS name . */ + /* */ + /* var_postscript_prefix_len :: */ + /* The length of the `var_postscript_prefix' */ + /* string. */ + /* */ + /* horz_metrics_size :: The size of the `hmtx' table. */ + /* */ + /* vert_metrics_size :: The size of the `vmtx' table. */ + /* */ + /* num_locations :: The number of glyph locations in this */ + /* TrueType file. This should be */ + /* identical to the number of glyphs. */ + /* Ignored for Type 2 fonts. */ + /* */ + /* glyph_locations :: An array of longs. These are offsets to */ + /* glyph data within the `glyf' table. */ + /* Ignored for Type 2 font faces. */ + /* */ + /* hdmx_table :: A pointer to the `hdmx' table. */ + /* */ + /* hdmx_table_size :: The size of the `hdmx' table. */ + /* */ + /* hdmx_record_count :: The number of hdmx records. */ + /* */ + /* hdmx_record_size :: The size of a single hdmx record. */ + /* */ + /* hdmx_record_sizes :: An array holding the ppem sizes available */ + /* in the `hdmx' table. */ + /* */ + /* sbit_table :: A pointer to the font's embedded bitmap */ + /* location table. */ + /* */ + /* sbit_table_size :: The size of `sbit_table'. */ + /* */ + /* sbit_table_type :: The sbit table type (CBLC, sbix, etc.). */ + /* */ + /* sbit_num_strikes :: The number of sbit strikes exposed by */ + /* FreeType's API, omitting invalid strikes. */ + /* */ + /* sbit_strike_map :: A mapping between the strike indices */ + /* exposed by the API and the indices used in */ + /* the font's sbit table. */ + /* */ + /* kern_table :: A pointer to the `kern' table. */ + /* */ + /* kern_table_size :: The size of the `kern' table. */ + /* */ + /* num_kern_tables :: The number of supported kern subtables */ + /* (up to 32; FreeType recognizes only */ + /* horizontal ones with format 0). */ + /* */ + /* kern_avail_bits :: The availability status of kern subtables; */ + /* if bit n is set, table n is available. */ + /* */ + /* kern_order_bits :: The sortedness status of kern subtables; */ + /* if bit n is set, table n is sorted. */ + /* */ + /* bdf :: Data related to an SFNT font's `bdf' */ + /* table; see `tttypes.h'. */ + /* */ + /* horz_metrics_offset :: The file offset of the `hmtx' table. */ + /* */ + /* vert_metrics_offset :: The file offset of the `vmtx' table. */ + /* */ + /* sph_found_func_flags :: Flags identifying special bytecode */ + /* functions (used by the v38 implementation */ + /* of the bytecode interpreter). */ + /* */ + /* sph_compatibility_mode :: */ + /* This flag is set if we are in ClearType */ + /* backward compatibility mode (used by the */ + /* v38 implementation of the bytecode */ + /* interpreter). */ + /* */ + /* ebdt_start :: The file offset of the sbit data table */ + /* (CBDT, bdat, etc.). */ + /* */ + /* ebdt_size :: The size of the sbit data table. */ + /* */ + typedef struct TT_FaceRec_ + { + FT_FaceRec root; + + TTC_HeaderRec ttc_header; + + FT_ULong format_tag; + FT_UShort num_tables; + TT_Table dir_tables; + + TT_Header header; /* TrueType header table */ + TT_HoriHeader horizontal; /* TrueType horizontal header */ + + TT_MaxProfile max_profile; + + FT_Bool vertical_info; + TT_VertHeader vertical; /* TT Vertical header, if present */ + + FT_UShort num_names; /* number of name records */ + TT_NameTableRec name_table; /* name table */ + + TT_OS2 os2; /* TrueType OS/2 table */ + TT_Postscript postscript; /* TrueType Postscript table */ + + FT_Byte* cmap_table; /* extracted `cmap' table */ + FT_ULong cmap_size; + + TT_Loader_GotoTableFunc goto_table; + + TT_Loader_StartGlyphFunc access_glyph_frame; + TT_Loader_EndGlyphFunc forget_glyph_frame; + TT_Loader_ReadGlyphFunc read_glyph_header; + TT_Loader_ReadGlyphFunc read_simple_glyph; + TT_Loader_ReadGlyphFunc read_composite_glyph; + + /* a typeless pointer to the SFNT_Interface table used to load */ + /* the basic TrueType tables in the face object */ + void* sfnt; + + /* a typeless pointer to the FT_Service_PsCMapsRec table used to */ + /* handle glyph names <-> unicode & Mac values */ + void* psnames; + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* a typeless pointer to the FT_Service_MultiMasters table used to */ + /* handle variation fonts */ + void* mm; + + /* a typeless pointer to the FT_Service_MetricsVariationsRec table */ + /* used to handle the HVAR, VVAR, and MVAR OpenType tables */ + void* var; +#endif + + /* a typeless pointer to the PostScript Aux service */ + void* psaux; + + + /***********************************************************************/ + /* */ + /* Optional TrueType/OpenType tables */ + /* */ + /***********************************************************************/ + + /* grid-fitting and scaling table */ + TT_GaspRec gasp; /* the `gasp' table */ + + /* PCL 5 table */ + TT_PCLT pclt; + + /* embedded bitmaps support */ + FT_ULong num_sbit_scales; + TT_SBit_Scale sbit_scales; + + /* postscript names table */ + TT_Post_NamesRec postscript_names; + + + /***********************************************************************/ + /* */ + /* TrueType-specific fields (ignored by the CFF driver) */ + /* */ + /***********************************************************************/ + + /* the font program, if any */ + FT_ULong font_program_size; + FT_Byte* font_program; + + /* the cvt program, if any */ + FT_ULong cvt_program_size; + FT_Byte* cvt_program; + + /* the original, unscaled, control value table */ + FT_ULong cvt_size; + FT_Short* cvt; + + /* A pointer to the bytecode interpreter to use. This is also */ + /* used to hook the debugger for the `ttdebug' utility. */ + TT_Interpreter interpreter; + + + /***********************************************************************/ + /* */ + /* Other tables or fields. This is used by derivative formats like */ + /* OpenType. */ + /* */ + /***********************************************************************/ + + FT_Generic extra; + + const char* postscript_name; + + FT_ULong glyf_len; + FT_ULong glyf_offset; /* since 2.7.1 */ + + FT_Bool is_cff2; /* since 2.7.1 */ + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Bool doblend; + GX_Blend blend; + + FT_UInt32 variation_support; /* since 2.7.1 */ + + const char* var_postscript_prefix; /* since 2.7.2 */ + FT_UInt var_postscript_prefix_len; /* since 2.7.2 */ + +#endif + + /* since version 2.2 */ + + FT_ULong horz_metrics_size; + FT_ULong vert_metrics_size; + + FT_ULong num_locations; /* in broken TTF, gid > 0xFFFF */ + FT_Byte* glyph_locations; + + FT_Byte* hdmx_table; + FT_ULong hdmx_table_size; + FT_UInt hdmx_record_count; + FT_ULong hdmx_record_size; + FT_Byte* hdmx_record_sizes; + + FT_Byte* sbit_table; + FT_ULong sbit_table_size; + TT_SbitTableType sbit_table_type; + FT_UInt sbit_num_strikes; + FT_UInt* sbit_strike_map; + + FT_Byte* kern_table; + FT_ULong kern_table_size; + FT_UInt num_kern_tables; + FT_UInt32 kern_avail_bits; + FT_UInt32 kern_order_bits; + +#ifdef TT_CONFIG_OPTION_BDF + TT_BDFRec bdf; +#endif /* TT_CONFIG_OPTION_BDF */ + + /* since 2.3.0 */ + FT_ULong horz_metrics_offset; + FT_ULong vert_metrics_offset; + +#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY + /* since 2.4.12 */ + FT_ULong sph_found_func_flags; /* special functions found */ + /* for this face */ + FT_Bool sph_compatibility_mode; +#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ + +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + /* since 2.7 */ + FT_ULong ebdt_start; /* either `CBDT', `EBDT', or `bdat' */ + FT_ULong ebdt_size; +#endif + + } TT_FaceRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_GlyphZoneRec */ + /* */ + /* <Description> */ + /* A glyph zone is used to load, scale and hint glyph outline */ + /* coordinates. */ + /* */ + /* <Fields> */ + /* memory :: A handle to the memory manager. */ + /* */ + /* max_points :: The maximum size in points of the zone. */ + /* */ + /* max_contours :: Max size in links contours of the zone. */ + /* */ + /* n_points :: The current number of points in the zone. */ + /* */ + /* n_contours :: The current number of contours in the zone. */ + /* */ + /* org :: The original glyph coordinates (font */ + /* units/scaled). */ + /* */ + /* cur :: The current glyph coordinates (scaled/hinted). */ + /* */ + /* tags :: The point control tags. */ + /* */ + /* contours :: The contours end points. */ + /* */ + /* first_point :: Offset of the current subglyph's first point. */ + /* */ + typedef struct TT_GlyphZoneRec_ + { + FT_Memory memory; + FT_UShort max_points; + FT_Short max_contours; + FT_UShort n_points; /* number of points in zone */ + FT_Short n_contours; /* number of contours */ + + FT_Vector* org; /* original point coordinates */ + FT_Vector* cur; /* current point coordinates */ + FT_Vector* orus; /* original (unscaled) point coordinates */ + + FT_Byte* tags; /* current touch flags */ + FT_UShort* contours; /* contour end points */ + + FT_UShort first_point; /* offset of first (#0) point */ + + } TT_GlyphZoneRec, *TT_GlyphZone; + + + /* handle to execution context */ + typedef struct TT_ExecContextRec_* TT_ExecContext; + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* TT_Size */ + /* */ + /* <Description> */ + /* A handle to a TrueType size object. */ + /* */ + typedef struct TT_SizeRec_* TT_Size; + + + /* glyph loader structure */ + typedef struct TT_LoaderRec_ + { + TT_Face face; + TT_Size size; + FT_GlyphSlot glyph; + FT_GlyphLoader gloader; + + FT_ULong load_flags; + FT_UInt glyph_index; + + FT_Stream stream; + FT_Int byte_len; + + FT_Short n_contours; + FT_BBox bbox; + FT_Int left_bearing; + FT_Int advance; + FT_Int linear; + FT_Bool linear_def; + FT_Vector pp1; + FT_Vector pp2; + + /* the zone where we load our glyphs */ + TT_GlyphZoneRec base; + TT_GlyphZoneRec zone; + + TT_ExecContext exec; + FT_Byte* instructions; + FT_ULong ins_pos; + + /* for possible extensibility in other formats */ + void* other; + + /* since version 2.1.8 */ + FT_Int top_bearing; + FT_Int vadvance; + FT_Vector pp3; + FT_Vector pp4; + + /* since version 2.2.1 */ + FT_Byte* cursor; + FT_Byte* limit; + + /* since version 2.6.2 */ + FT_ListRec composites; + + } TT_LoaderRec; + + +FT_END_HEADER + +#endif /* TTTYPES_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/t1tables.h b/src_v2/libs/sloth/freetype/freetype2/freetype/t1tables.h new file mode 100644 index 0000000..3503c26 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/t1tables.h @@ -0,0 +1,770 @@ +/***************************************************************************/ +/* */ +/* t1tables.h */ +/* */ +/* Basic Type 1/Type 2 tables definitions and interface (specification */ +/* only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef T1TABLES_H_ +#define T1TABLES_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* type1_tables */ + /* */ + /* <Title> */ + /* Type 1 Tables */ + /* */ + /* <Abstract> */ + /* Type~1 (PostScript) specific font tables. */ + /* */ + /* <Description> */ + /* This section contains the definition of Type 1-specific tables, */ + /* including structures related to other PostScript font formats. */ + /* */ + /* <Order> */ + /* PS_FontInfoRec */ + /* PS_FontInfo */ + /* PS_PrivateRec */ + /* PS_Private */ + /* */ + /* CID_FaceDictRec */ + /* CID_FaceDict */ + /* CID_FaceInfoRec */ + /* CID_FaceInfo */ + /* */ + /* FT_Has_PS_Glyph_Names */ + /* FT_Get_PS_Font_Info */ + /* FT_Get_PS_Font_Private */ + /* FT_Get_PS_Font_Value */ + /* */ + /* T1_Blend_Flags */ + /* T1_EncodingType */ + /* PS_Dict_Keys */ + /* */ + /*************************************************************************/ + + + /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */ + /* structures in order to support Multiple Master fonts. */ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_FontInfoRec */ + /* */ + /* <Description> */ + /* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */ + /* Note that for Multiple Master fonts, each instance has its own */ + /* FontInfo dictionary. */ + /* */ + typedef struct PS_FontInfoRec_ + { + FT_String* version; + FT_String* notice; + FT_String* full_name; + FT_String* family_name; + FT_String* weight; + FT_Long italic_angle; + FT_Bool is_fixed_pitch; + FT_Short underline_position; + FT_UShort underline_thickness; + + } PS_FontInfoRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_FontInfo */ + /* */ + /* <Description> */ + /* A handle to a @PS_FontInfoRec structure. */ + /* */ + typedef struct PS_FontInfoRec_* PS_FontInfo; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* T1_FontInfo */ + /* */ + /* <Description> */ + /* This type is equivalent to @PS_FontInfoRec. It is deprecated but */ + /* kept to maintain source compatibility between various versions of */ + /* FreeType. */ + /* */ + typedef PS_FontInfoRec T1_FontInfo; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_PrivateRec */ + /* */ + /* <Description> */ + /* A structure used to model a Type~1 or Type~2 private dictionary. */ + /* Note that for Multiple Master fonts, each instance has its own */ + /* Private dictionary. */ + /* */ + typedef struct PS_PrivateRec_ + { + FT_Int unique_id; + FT_Int lenIV; + + FT_Byte num_blue_values; + FT_Byte num_other_blues; + FT_Byte num_family_blues; + FT_Byte num_family_other_blues; + + FT_Short blue_values[14]; + FT_Short other_blues[10]; + + FT_Short family_blues [14]; + FT_Short family_other_blues[10]; + + FT_Fixed blue_scale; + FT_Int blue_shift; + FT_Int blue_fuzz; + + FT_UShort standard_width[1]; + FT_UShort standard_height[1]; + + FT_Byte num_snap_widths; + FT_Byte num_snap_heights; + FT_Bool force_bold; + FT_Bool round_stem_up; + + FT_Short snap_widths [13]; /* including std width */ + FT_Short snap_heights[13]; /* including std height */ + + FT_Fixed expansion_factor; + + FT_Long language_group; + FT_Long password; + + FT_Short min_feature[2]; + + } PS_PrivateRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* PS_Private */ + /* */ + /* <Description> */ + /* A handle to a @PS_PrivateRec structure. */ + /* */ + typedef struct PS_PrivateRec_* PS_Private; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* T1_Private */ + /* */ + /* <Description> */ + /* This type is equivalent to @PS_PrivateRec. It is deprecated but */ + /* kept to maintain source compatibility between various versions of */ + /* FreeType. */ + /* */ + typedef PS_PrivateRec T1_Private; + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* T1_Blend_Flags */ + /* */ + /* <Description> */ + /* A set of flags used to indicate which fields are present in a */ + /* given blend dictionary (font info or private). Used to support */ + /* Multiple Masters fonts. */ + /* */ + /* <Values> */ + /* T1_BLEND_UNDERLINE_POSITION :: */ + /* T1_BLEND_UNDERLINE_THICKNESS :: */ + /* T1_BLEND_ITALIC_ANGLE :: */ + /* T1_BLEND_BLUE_VALUES :: */ + /* T1_BLEND_OTHER_BLUES :: */ + /* T1_BLEND_STANDARD_WIDTH :: */ + /* T1_BLEND_STANDARD_HEIGHT :: */ + /* T1_BLEND_STEM_SNAP_WIDTHS :: */ + /* T1_BLEND_STEM_SNAP_HEIGHTS :: */ + /* T1_BLEND_BLUE_SCALE :: */ + /* T1_BLEND_BLUE_SHIFT :: */ + /* T1_BLEND_FAMILY_BLUES :: */ + /* T1_BLEND_FAMILY_OTHER_BLUES :: */ + /* T1_BLEND_FORCE_BOLD :: */ + /* */ + typedef enum T1_Blend_Flags_ + { + /* required fields in a FontInfo blend dictionary */ + T1_BLEND_UNDERLINE_POSITION = 0, + T1_BLEND_UNDERLINE_THICKNESS, + T1_BLEND_ITALIC_ANGLE, + + /* required fields in a Private blend dictionary */ + T1_BLEND_BLUE_VALUES, + T1_BLEND_OTHER_BLUES, + T1_BLEND_STANDARD_WIDTH, + T1_BLEND_STANDARD_HEIGHT, + T1_BLEND_STEM_SNAP_WIDTHS, + T1_BLEND_STEM_SNAP_HEIGHTS, + T1_BLEND_BLUE_SCALE, + T1_BLEND_BLUE_SHIFT, + T1_BLEND_FAMILY_BLUES, + T1_BLEND_FAMILY_OTHER_BLUES, + T1_BLEND_FORCE_BOLD, + + T1_BLEND_MAX /* do not remove */ + + } T1_Blend_Flags; + + + /* these constants are deprecated; use the corresponding */ + /* `T1_Blend_Flags' values instead */ +#define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION +#define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS +#define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE +#define t1_blend_blue_values T1_BLEND_BLUE_VALUES +#define t1_blend_other_blues T1_BLEND_OTHER_BLUES +#define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH +#define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT +#define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS +#define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS +#define t1_blend_blue_scale T1_BLEND_BLUE_SCALE +#define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT +#define t1_blend_family_blues T1_BLEND_FAMILY_BLUES +#define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES +#define t1_blend_force_bold T1_BLEND_FORCE_BOLD +#define t1_blend_max T1_BLEND_MAX + + /* */ + + + /* maximum number of Multiple Masters designs, as defined in the spec */ +#define T1_MAX_MM_DESIGNS 16 + + /* maximum number of Multiple Masters axes, as defined in the spec */ +#define T1_MAX_MM_AXIS 4 + + /* maximum number of elements in a design map */ +#define T1_MAX_MM_MAP_POINTS 20 + + + /* this structure is used to store the BlendDesignMap entry for an axis */ + typedef struct PS_DesignMap_ + { + FT_Byte num_points; + FT_Long* design_points; + FT_Fixed* blend_points; + + } PS_DesignMapRec, *PS_DesignMap; + + /* backward compatible definition */ + typedef PS_DesignMapRec T1_DesignMap; + + + typedef struct PS_BlendRec_ + { + FT_UInt num_designs; + FT_UInt num_axis; + + FT_String* axis_names[T1_MAX_MM_AXIS]; + FT_Fixed* design_pos[T1_MAX_MM_DESIGNS]; + PS_DesignMapRec design_map[T1_MAX_MM_AXIS]; + + FT_Fixed* weight_vector; + FT_Fixed* default_weight_vector; + + PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1]; + PS_Private privates [T1_MAX_MM_DESIGNS + 1]; + + FT_ULong blend_bitflags; + + FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1]; + + /* since 2.3.0 */ + + /* undocumented, optional: the default design instance; */ + /* corresponds to default_weight_vector -- */ + /* num_default_design_vector == 0 means it is not present */ + /* in the font and associated metrics files */ + FT_UInt default_design_vector[T1_MAX_MM_DESIGNS]; + FT_UInt num_default_design_vector; + + } PS_BlendRec, *PS_Blend; + + + /* backward compatible definition */ + typedef PS_BlendRec T1_Blend; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FaceDictRec */ + /* */ + /* <Description> */ + /* A structure used to represent data in a CID top-level dictionary. */ + /* */ + typedef struct CID_FaceDictRec_ + { + PS_PrivateRec private_dict; + + FT_UInt len_buildchar; + FT_Fixed forcebold_threshold; + FT_Pos stroke_width; + FT_Fixed expansion_factor; + + FT_Byte paint_type; + FT_Byte font_type; + FT_Matrix font_matrix; + FT_Vector font_offset; + + FT_UInt num_subrs; + FT_ULong subrmap_offset; + FT_Int sd_bytes; + + } CID_FaceDictRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FaceDict */ + /* */ + /* <Description> */ + /* A handle to a @CID_FaceDictRec structure. */ + /* */ + typedef struct CID_FaceDictRec_* CID_FaceDict; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FontDict */ + /* */ + /* <Description> */ + /* This type is equivalent to @CID_FaceDictRec. It is deprecated but */ + /* kept to maintain source compatibility between various versions of */ + /* FreeType. */ + /* */ + typedef CID_FaceDictRec CID_FontDict; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FaceInfoRec */ + /* */ + /* <Description> */ + /* A structure used to represent CID Face information. */ + /* */ + typedef struct CID_FaceInfoRec_ + { + FT_String* cid_font_name; + FT_Fixed cid_version; + FT_Int cid_font_type; + + FT_String* registry; + FT_String* ordering; + FT_Int supplement; + + PS_FontInfoRec font_info; + FT_BBox font_bbox; + FT_ULong uid_base; + + FT_Int num_xuid; + FT_ULong xuid[16]; + + FT_ULong cidmap_offset; + FT_Int fd_bytes; + FT_Int gd_bytes; + FT_ULong cid_count; + + FT_Int num_dicts; + CID_FaceDict font_dicts; + + FT_ULong data_offset; + + } CID_FaceInfoRec; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_FaceInfo */ + /* */ + /* <Description> */ + /* A handle to a @CID_FaceInfoRec structure. */ + /* */ + typedef struct CID_FaceInfoRec_* CID_FaceInfo; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* CID_Info */ + /* */ + /* <Description> */ + /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */ + /* kept to maintain source compatibility between various versions of */ + /* FreeType. */ + /* */ + typedef CID_FaceInfoRec CID_Info; + + + /************************************************************************ + * + * @function: + * FT_Has_PS_Glyph_Names + * + * @description: + * Return true if a given face provides reliable PostScript glyph + * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro, + * except that certain fonts (mostly TrueType) contain incorrect + * glyph name tables. + * + * When this function returns true, the caller is sure that the glyph + * names returned by @FT_Get_Glyph_Name are reliable. + * + * @input: + * face :: + * face handle + * + * @return: + * Boolean. True if glyph names are reliable. + * + */ + FT_EXPORT( FT_Int ) + FT_Has_PS_Glyph_Names( FT_Face face ); + + + /************************************************************************ + * + * @function: + * FT_Get_PS_Font_Info + * + * @description: + * Retrieve the @PS_FontInfoRec structure corresponding to a given + * PostScript font. + * + * @input: + * face :: + * PostScript face handle. + * + * @output: + * afont_info :: + * Output font info structure pointer. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * String pointers within the @PS_FontInfoRec structure are owned by + * the face and don't need to be freed by the caller. Missing entries + * in the font's FontInfo dictionary are represented by NULL pointers. + * + * If the font's format is not PostScript-based, this function will + * return the `FT_Err_Invalid_Argument' error code. + * + */ + FT_EXPORT( FT_Error ) + FT_Get_PS_Font_Info( FT_Face face, + PS_FontInfo afont_info ); + + + /************************************************************************ + * + * @function: + * FT_Get_PS_Font_Private + * + * @description: + * Retrieve the @PS_PrivateRec structure corresponding to a given + * PostScript font. + * + * @input: + * face :: + * PostScript face handle. + * + * @output: + * afont_private :: + * Output private dictionary structure pointer. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The string pointers within the @PS_PrivateRec structure are owned by + * the face and don't need to be freed by the caller. + * + * If the font's format is not PostScript-based, this function returns + * the `FT_Err_Invalid_Argument' error code. + * + */ + FT_EXPORT( FT_Error ) + FT_Get_PS_Font_Private( FT_Face face, + PS_Private afont_private ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* T1_EncodingType */ + /* */ + /* <Description> */ + /* An enumeration describing the `Encoding' entry in a Type 1 */ + /* dictionary. */ + /* */ + /* <Values> */ + /* T1_ENCODING_TYPE_NONE :: */ + /* T1_ENCODING_TYPE_ARRAY :: */ + /* T1_ENCODING_TYPE_STANDARD :: */ + /* T1_ENCODING_TYPE_ISOLATIN1 :: */ + /* T1_ENCODING_TYPE_EXPERT :: */ + /* */ + /* <Since> */ + /* 2.4.8 */ + /* */ + typedef enum T1_EncodingType_ + { + T1_ENCODING_TYPE_NONE = 0, + T1_ENCODING_TYPE_ARRAY, + T1_ENCODING_TYPE_STANDARD, + T1_ENCODING_TYPE_ISOLATIN1, + T1_ENCODING_TYPE_EXPERT + + } T1_EncodingType; + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* PS_Dict_Keys */ + /* */ + /* <Description> */ + /* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */ + /* the Type~1 dictionary entry to retrieve. */ + /* */ + /* <Values> */ + /* PS_DICT_FONT_TYPE :: */ + /* PS_DICT_FONT_MATRIX :: */ + /* PS_DICT_FONT_BBOX :: */ + /* PS_DICT_PAINT_TYPE :: */ + /* PS_DICT_FONT_NAME :: */ + /* PS_DICT_UNIQUE_ID :: */ + /* PS_DICT_NUM_CHAR_STRINGS :: */ + /* PS_DICT_CHAR_STRING_KEY :: */ + /* PS_DICT_CHAR_STRING :: */ + /* PS_DICT_ENCODING_TYPE :: */ + /* PS_DICT_ENCODING_ENTRY :: */ + /* PS_DICT_NUM_SUBRS :: */ + /* PS_DICT_SUBR :: */ + /* PS_DICT_STD_HW :: */ + /* PS_DICT_STD_VW :: */ + /* PS_DICT_NUM_BLUE_VALUES :: */ + /* PS_DICT_BLUE_VALUE :: */ + /* PS_DICT_BLUE_FUZZ :: */ + /* PS_DICT_NUM_OTHER_BLUES :: */ + /* PS_DICT_OTHER_BLUE :: */ + /* PS_DICT_NUM_FAMILY_BLUES :: */ + /* PS_DICT_FAMILY_BLUE :: */ + /* PS_DICT_NUM_FAMILY_OTHER_BLUES :: */ + /* PS_DICT_FAMILY_OTHER_BLUE :: */ + /* PS_DICT_BLUE_SCALE :: */ + /* PS_DICT_BLUE_SHIFT :: */ + /* PS_DICT_NUM_STEM_SNAP_H :: */ + /* PS_DICT_STEM_SNAP_H :: */ + /* PS_DICT_NUM_STEM_SNAP_V :: */ + /* PS_DICT_STEM_SNAP_V :: */ + /* PS_DICT_FORCE_BOLD :: */ + /* PS_DICT_RND_STEM_UP :: */ + /* PS_DICT_MIN_FEATURE :: */ + /* PS_DICT_LEN_IV :: */ + /* PS_DICT_PASSWORD :: */ + /* PS_DICT_LANGUAGE_GROUP :: */ + /* PS_DICT_VERSION :: */ + /* PS_DICT_NOTICE :: */ + /* PS_DICT_FULL_NAME :: */ + /* PS_DICT_FAMILY_NAME :: */ + /* PS_DICT_WEIGHT :: */ + /* PS_DICT_IS_FIXED_PITCH :: */ + /* PS_DICT_UNDERLINE_POSITION :: */ + /* PS_DICT_UNDERLINE_THICKNESS :: */ + /* PS_DICT_FS_TYPE :: */ + /* PS_DICT_ITALIC_ANGLE :: */ + /* */ + /* <Since> */ + /* 2.4.8 */ + /* */ + typedef enum PS_Dict_Keys_ + { + /* conventionally in the font dictionary */ + PS_DICT_FONT_TYPE, /* FT_Byte */ + PS_DICT_FONT_MATRIX, /* FT_Fixed */ + PS_DICT_FONT_BBOX, /* FT_Fixed */ + PS_DICT_PAINT_TYPE, /* FT_Byte */ + PS_DICT_FONT_NAME, /* FT_String* */ + PS_DICT_UNIQUE_ID, /* FT_Int */ + PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */ + PS_DICT_CHAR_STRING_KEY, /* FT_String* */ + PS_DICT_CHAR_STRING, /* FT_String* */ + PS_DICT_ENCODING_TYPE, /* T1_EncodingType */ + PS_DICT_ENCODING_ENTRY, /* FT_String* */ + + /* conventionally in the font Private dictionary */ + PS_DICT_NUM_SUBRS, /* FT_Int */ + PS_DICT_SUBR, /* FT_String* */ + PS_DICT_STD_HW, /* FT_UShort */ + PS_DICT_STD_VW, /* FT_UShort */ + PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */ + PS_DICT_BLUE_VALUE, /* FT_Short */ + PS_DICT_BLUE_FUZZ, /* FT_Int */ + PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */ + PS_DICT_OTHER_BLUE, /* FT_Short */ + PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */ + PS_DICT_FAMILY_BLUE, /* FT_Short */ + PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */ + PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */ + PS_DICT_BLUE_SCALE, /* FT_Fixed */ + PS_DICT_BLUE_SHIFT, /* FT_Int */ + PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */ + PS_DICT_STEM_SNAP_H, /* FT_Short */ + PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */ + PS_DICT_STEM_SNAP_V, /* FT_Short */ + PS_DICT_FORCE_BOLD, /* FT_Bool */ + PS_DICT_RND_STEM_UP, /* FT_Bool */ + PS_DICT_MIN_FEATURE, /* FT_Short */ + PS_DICT_LEN_IV, /* FT_Int */ + PS_DICT_PASSWORD, /* FT_Long */ + PS_DICT_LANGUAGE_GROUP, /* FT_Long */ + + /* conventionally in the font FontInfo dictionary */ + PS_DICT_VERSION, /* FT_String* */ + PS_DICT_NOTICE, /* FT_String* */ + PS_DICT_FULL_NAME, /* FT_String* */ + PS_DICT_FAMILY_NAME, /* FT_String* */ + PS_DICT_WEIGHT, /* FT_String* */ + PS_DICT_IS_FIXED_PITCH, /* FT_Bool */ + PS_DICT_UNDERLINE_POSITION, /* FT_Short */ + PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */ + PS_DICT_FS_TYPE, /* FT_UShort */ + PS_DICT_ITALIC_ANGLE, /* FT_Long */ + + PS_DICT_MAX = PS_DICT_ITALIC_ANGLE + + } PS_Dict_Keys; + + + /************************************************************************ + * + * @function: + * FT_Get_PS_Font_Value + * + * @description: + * Retrieve the value for the supplied key from a PostScript font. + * + * @input: + * face :: + * PostScript face handle. + * + * key :: + * An enumeration value representing the dictionary key to retrieve. + * + * idx :: + * For array values, this specifies the index to be returned. + * + * value :: + * A pointer to memory into which to write the value. + * + * valen_len :: + * The size, in bytes, of the memory supplied for the value. + * + * @output: + * value :: + * The value matching the above key, if it exists. + * + * @return: + * The amount of memory (in bytes) required to hold the requested + * value (if it exists, -1 otherwise). + * + * @note: + * The values returned are not pointers into the internal structures of + * the face, but are `fresh' copies, so that the memory containing them + * belongs to the calling application. This also enforces the + * `read-only' nature of these values, i.e., this function cannot be + * used to manipulate the face. + * + * `value' is a void pointer because the values returned can be of + * various types. + * + * If either `value' is NULL or `value_len' is too small, just the + * required memory size for the requested entry is returned. + * + * The `idx' parameter is used, not only to retrieve elements of, for + * example, the FontMatrix or FontBBox, but also to retrieve name keys + * from the CharStrings dictionary, and the charstrings themselves. It + * is ignored for atomic values. + * + * PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To + * get the value as in the font stream, you need to divide by + * 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale). + * + * IMPORTANT: Only key/value pairs read by the FreeType interpreter can + * be retrieved. So, for example, PostScript procedures such as NP, + * ND, and RD are not available. Arbitrary keys are, obviously, not be + * available either. + * + * If the font's format is not PostScript-based, this function returns + * the `FT_Err_Invalid_Argument' error code. + * + * @since: + * 2.4.8 + * + */ + FT_EXPORT( FT_Long ) + FT_Get_PS_Font_Value( FT_Face face, + PS_Dict_Keys key, + FT_UInt idx, + void *value, + FT_Long value_len ); + + /* */ + +FT_END_HEADER + +#endif /* T1TABLES_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/ttnameid.h b/src_v2/libs/sloth/freetype/freetype2/freetype/ttnameid.h new file mode 100644 index 0000000..8605183 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/ttnameid.h @@ -0,0 +1,1236 @@ +/***************************************************************************/ +/* */ +/* ttnameid.h */ +/* */ +/* TrueType name ID definitions (specification only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef TTNAMEID_H_ +#define TTNAMEID_H_ + + +#include <ft2build.h> + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* <Section> */ + /* truetype_tables */ + /* */ + + + /*************************************************************************/ + /* */ + /* Possible values for the `platform' identifier code in the name */ + /* records of an SFNT `name' table. */ + /* */ + /*************************************************************************/ + + + /*********************************************************************** + * + * @enum: + * TT_PLATFORM_XXX + * + * @description: + * A list of valid values for the `platform_id' identifier code in + * @FT_CharMapRec and @FT_SfntName structures. + * + * @values: + * TT_PLATFORM_APPLE_UNICODE :: + * Used by Apple to indicate a Unicode character map and/or name entry. + * See @TT_APPLE_ID_XXX for corresponding `encoding_id' values. Note + * that name entries in this format are coded as big-endian UCS-2 + * character codes _only_. + * + * TT_PLATFORM_MACINTOSH :: + * Used by Apple to indicate a MacOS-specific charmap and/or name entry. + * See @TT_MAC_ID_XXX for corresponding `encoding_id' values. Note that + * most TrueType fonts contain an Apple roman charmap to be usable on + * MacOS systems (even if they contain a Microsoft charmap as well). + * + * TT_PLATFORM_ISO :: + * This value was used to specify ISO/IEC 10646 charmaps. It is however + * now deprecated. See @TT_ISO_ID_XXX for a list of corresponding + * `encoding_id' values. + * + * TT_PLATFORM_MICROSOFT :: + * Used by Microsoft to indicate Windows-specific charmaps. See + * @TT_MS_ID_XXX for a list of corresponding `encoding_id' values. + * Note that most fonts contain a Unicode charmap using + * (TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS). + * + * TT_PLATFORM_CUSTOM :: + * Used to indicate application-specific charmaps. + * + * TT_PLATFORM_ADOBE :: + * This value isn't part of any font format specification, but is used + * by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec + * structure. See @TT_ADOBE_ID_XXX. + */ + +#define TT_PLATFORM_APPLE_UNICODE 0 +#define TT_PLATFORM_MACINTOSH 1 +#define TT_PLATFORM_ISO 2 /* deprecated */ +#define TT_PLATFORM_MICROSOFT 3 +#define TT_PLATFORM_CUSTOM 4 +#define TT_PLATFORM_ADOBE 7 /* artificial */ + + + /*********************************************************************** + * + * @enum: + * TT_APPLE_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_APPLE_UNICODE charmaps and name entries. + * + * @values: + * TT_APPLE_ID_DEFAULT :: + * Unicode version 1.0. + * + * TT_APPLE_ID_UNICODE_1_1 :: + * Unicode 1.1; specifies Hangul characters starting at U+34xx. + * + * TT_APPLE_ID_ISO_10646 :: + * Deprecated (identical to preceding). + * + * TT_APPLE_ID_UNICODE_2_0 :: + * Unicode 2.0 and beyond (UTF-16 BMP only). + * + * TT_APPLE_ID_UNICODE_32 :: + * Unicode 3.1 and beyond, using UTF-32. + * + * TT_APPLE_ID_VARIANT_SELECTOR :: + * From Adobe, not Apple. Not a normal cmap. Specifies variations + * on a real cmap. + * + * TT_APPLE_ID_FULL_UNICODE :: + * Used for fallback fonts that provide complete Unicode coverage with + * a type~13 cmap. + */ + +#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */ +#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */ +#define TT_APPLE_ID_ISO_10646 2 /* deprecated */ +#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */ +#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */ +#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */ +#define TT_APPLE_ID_FULL_UNICODE 6 /* used with type 13 cmaps */ + + + /*********************************************************************** + * + * @enum: + * TT_MAC_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_MACINTOSH charmaps and name entries. + */ + +#define TT_MAC_ID_ROMAN 0 +#define TT_MAC_ID_JAPANESE 1 +#define TT_MAC_ID_TRADITIONAL_CHINESE 2 +#define TT_MAC_ID_KOREAN 3 +#define TT_MAC_ID_ARABIC 4 +#define TT_MAC_ID_HEBREW 5 +#define TT_MAC_ID_GREEK 6 +#define TT_MAC_ID_RUSSIAN 7 +#define TT_MAC_ID_RSYMBOL 8 +#define TT_MAC_ID_DEVANAGARI 9 +#define TT_MAC_ID_GURMUKHI 10 +#define TT_MAC_ID_GUJARATI 11 +#define TT_MAC_ID_ORIYA 12 +#define TT_MAC_ID_BENGALI 13 +#define TT_MAC_ID_TAMIL 14 +#define TT_MAC_ID_TELUGU 15 +#define TT_MAC_ID_KANNADA 16 +#define TT_MAC_ID_MALAYALAM 17 +#define TT_MAC_ID_SINHALESE 18 +#define TT_MAC_ID_BURMESE 19 +#define TT_MAC_ID_KHMER 20 +#define TT_MAC_ID_THAI 21 +#define TT_MAC_ID_LAOTIAN 22 +#define TT_MAC_ID_GEORGIAN 23 +#define TT_MAC_ID_ARMENIAN 24 +#define TT_MAC_ID_MALDIVIAN 25 +#define TT_MAC_ID_SIMPLIFIED_CHINESE 25 +#define TT_MAC_ID_TIBETAN 26 +#define TT_MAC_ID_MONGOLIAN 27 +#define TT_MAC_ID_GEEZ 28 +#define TT_MAC_ID_SLAVIC 29 +#define TT_MAC_ID_VIETNAMESE 30 +#define TT_MAC_ID_SINDHI 31 +#define TT_MAC_ID_UNINTERP 32 + + + /*********************************************************************** + * + * @enum: + * TT_ISO_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_ISO charmaps and name entries. + * + * Their use is now deprecated. + * + * @values: + * TT_ISO_ID_7BIT_ASCII :: + * ASCII. + * TT_ISO_ID_10646 :: + * ISO/10646. + * TT_ISO_ID_8859_1 :: + * Also known as Latin-1. + */ + +#define TT_ISO_ID_7BIT_ASCII 0 +#define TT_ISO_ID_10646 1 +#define TT_ISO_ID_8859_1 2 + + + /*********************************************************************** + * + * @enum: + * TT_MS_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_MICROSOFT charmaps and name entries. + * + * @values: + * TT_MS_ID_SYMBOL_CS :: + * Microsoft symbol encoding. See @FT_ENCODING_MS_SYMBOL. + * + * TT_MS_ID_UNICODE_CS :: + * Microsoft WGL4 charmap, matching Unicode. See + * @FT_ENCODING_UNICODE. + * + * TT_MS_ID_SJIS :: + * Shift JIS Japanese encoding. See @FT_ENCODING_SJIS. + * + * TT_MS_ID_PRC :: + * Chinese encodings as used in the People's Republic of China (PRC). + * This means the encodings GB~2312 and its supersets GBK and + * GB~18030. See @FT_ENCODING_PRC. + * + * TT_MS_ID_BIG_5 :: + * Traditional Chinese as used in Taiwan and Hong Kong. See + * @FT_ENCODING_BIG5. + * + * TT_MS_ID_WANSUNG :: + * Korean Extended Wansung encoding. See @FT_ENCODING_WANSUNG. + * + * TT_MS_ID_JOHAB :: + * Korean Johab encoding. See @FT_ENCODING_JOHAB. + * + * TT_MS_ID_UCS_4 :: + * UCS-4 or UTF-32 charmaps. This has been added to the OpenType + * specification version 1.4 (mid-2001). + */ + +#define TT_MS_ID_SYMBOL_CS 0 +#define TT_MS_ID_UNICODE_CS 1 +#define TT_MS_ID_SJIS 2 +#define TT_MS_ID_PRC 3 +#define TT_MS_ID_BIG_5 4 +#define TT_MS_ID_WANSUNG 5 +#define TT_MS_ID_JOHAB 6 +#define TT_MS_ID_UCS_4 10 + + /* this value is deprecated */ +#define TT_MS_ID_GB2312 TT_MS_ID_PRC + + + /*********************************************************************** + * + * @enum: + * TT_ADOBE_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_ADOBE charmaps. This is a FreeType-specific extension! + * + * @values: + * TT_ADOBE_ID_STANDARD :: + * Adobe standard encoding. + * TT_ADOBE_ID_EXPERT :: + * Adobe expert encoding. + * TT_ADOBE_ID_CUSTOM :: + * Adobe custom encoding. + * TT_ADOBE_ID_LATIN_1 :: + * Adobe Latin~1 encoding. + */ + +#define TT_ADOBE_ID_STANDARD 0 +#define TT_ADOBE_ID_EXPERT 1 +#define TT_ADOBE_ID_CUSTOM 2 +#define TT_ADOBE_ID_LATIN_1 3 + + + /*********************************************************************** + * + * @enum: + * TT_MAC_LANGID_XXX + * + * @description: + * Possible values of the language identifier field in the name records + * of the SFNT `name' table if the `platform' identifier code is + * @TT_PLATFORM_MACINTOSH. These values are also used as return values + * for function @FT_Get_CMap_Language_ID. + * + * The canonical source for Apple's IDs is + * + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html + */ + +#define TT_MAC_LANGID_ENGLISH 0 +#define TT_MAC_LANGID_FRENCH 1 +#define TT_MAC_LANGID_GERMAN 2 +#define TT_MAC_LANGID_ITALIAN 3 +#define TT_MAC_LANGID_DUTCH 4 +#define TT_MAC_LANGID_SWEDISH 5 +#define TT_MAC_LANGID_SPANISH 6 +#define TT_MAC_LANGID_DANISH 7 +#define TT_MAC_LANGID_PORTUGUESE 8 +#define TT_MAC_LANGID_NORWEGIAN 9 +#define TT_MAC_LANGID_HEBREW 10 +#define TT_MAC_LANGID_JAPANESE 11 +#define TT_MAC_LANGID_ARABIC 12 +#define TT_MAC_LANGID_FINNISH 13 +#define TT_MAC_LANGID_GREEK 14 +#define TT_MAC_LANGID_ICELANDIC 15 +#define TT_MAC_LANGID_MALTESE 16 +#define TT_MAC_LANGID_TURKISH 17 +#define TT_MAC_LANGID_CROATIAN 18 +#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19 +#define TT_MAC_LANGID_URDU 20 +#define TT_MAC_LANGID_HINDI 21 +#define TT_MAC_LANGID_THAI 22 +#define TT_MAC_LANGID_KOREAN 23 +#define TT_MAC_LANGID_LITHUANIAN 24 +#define TT_MAC_LANGID_POLISH 25 +#define TT_MAC_LANGID_HUNGARIAN 26 +#define TT_MAC_LANGID_ESTONIAN 27 +#define TT_MAC_LANGID_LETTISH 28 +#define TT_MAC_LANGID_SAAMISK 29 +#define TT_MAC_LANGID_FAEROESE 30 +#define TT_MAC_LANGID_FARSI 31 +#define TT_MAC_LANGID_RUSSIAN 32 +#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33 +#define TT_MAC_LANGID_FLEMISH 34 +#define TT_MAC_LANGID_IRISH 35 +#define TT_MAC_LANGID_ALBANIAN 36 +#define TT_MAC_LANGID_ROMANIAN 37 +#define TT_MAC_LANGID_CZECH 38 +#define TT_MAC_LANGID_SLOVAK 39 +#define TT_MAC_LANGID_SLOVENIAN 40 +#define TT_MAC_LANGID_YIDDISH 41 +#define TT_MAC_LANGID_SERBIAN 42 +#define TT_MAC_LANGID_MACEDONIAN 43 +#define TT_MAC_LANGID_BULGARIAN 44 +#define TT_MAC_LANGID_UKRAINIAN 45 +#define TT_MAC_LANGID_BYELORUSSIAN 46 +#define TT_MAC_LANGID_UZBEK 47 +#define TT_MAC_LANGID_KAZAKH 48 +#define TT_MAC_LANGID_AZERBAIJANI 49 +#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49 +#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50 +#define TT_MAC_LANGID_ARMENIAN 51 +#define TT_MAC_LANGID_GEORGIAN 52 +#define TT_MAC_LANGID_MOLDAVIAN 53 +#define TT_MAC_LANGID_KIRGHIZ 54 +#define TT_MAC_LANGID_TAJIKI 55 +#define TT_MAC_LANGID_TURKMEN 56 +#define TT_MAC_LANGID_MONGOLIAN 57 +#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57 +#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58 +#define TT_MAC_LANGID_PASHTO 59 +#define TT_MAC_LANGID_KURDISH 60 +#define TT_MAC_LANGID_KASHMIRI 61 +#define TT_MAC_LANGID_SINDHI 62 +#define TT_MAC_LANGID_TIBETAN 63 +#define TT_MAC_LANGID_NEPALI 64 +#define TT_MAC_LANGID_SANSKRIT 65 +#define TT_MAC_LANGID_MARATHI 66 +#define TT_MAC_LANGID_BENGALI 67 +#define TT_MAC_LANGID_ASSAMESE 68 +#define TT_MAC_LANGID_GUJARATI 69 +#define TT_MAC_LANGID_PUNJABI 70 +#define TT_MAC_LANGID_ORIYA 71 +#define TT_MAC_LANGID_MALAYALAM 72 +#define TT_MAC_LANGID_KANNADA 73 +#define TT_MAC_LANGID_TAMIL 74 +#define TT_MAC_LANGID_TELUGU 75 +#define TT_MAC_LANGID_SINHALESE 76 +#define TT_MAC_LANGID_BURMESE 77 +#define TT_MAC_LANGID_KHMER 78 +#define TT_MAC_LANGID_LAO 79 +#define TT_MAC_LANGID_VIETNAMESE 80 +#define TT_MAC_LANGID_INDONESIAN 81 +#define TT_MAC_LANGID_TAGALOG 82 +#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83 +#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84 +#define TT_MAC_LANGID_AMHARIC 85 +#define TT_MAC_LANGID_TIGRINYA 86 +#define TT_MAC_LANGID_GALLA 87 +#define TT_MAC_LANGID_SOMALI 88 +#define TT_MAC_LANGID_SWAHILI 89 +#define TT_MAC_LANGID_RUANDA 90 +#define TT_MAC_LANGID_RUNDI 91 +#define TT_MAC_LANGID_CHEWA 92 +#define TT_MAC_LANGID_MALAGASY 93 +#define TT_MAC_LANGID_ESPERANTO 94 +#define TT_MAC_LANGID_WELSH 128 +#define TT_MAC_LANGID_BASQUE 129 +#define TT_MAC_LANGID_CATALAN 130 +#define TT_MAC_LANGID_LATIN 131 +#define TT_MAC_LANGID_QUECHUA 132 +#define TT_MAC_LANGID_GUARANI 133 +#define TT_MAC_LANGID_AYMARA 134 +#define TT_MAC_LANGID_TATAR 135 +#define TT_MAC_LANGID_UIGHUR 136 +#define TT_MAC_LANGID_DZONGKHA 137 +#define TT_MAC_LANGID_JAVANESE 138 +#define TT_MAC_LANGID_SUNDANESE 139 + + /* The following codes are new as of 2000-03-10 */ +#define TT_MAC_LANGID_GALICIAN 140 +#define TT_MAC_LANGID_AFRIKAANS 141 +#define TT_MAC_LANGID_BRETON 142 +#define TT_MAC_LANGID_INUKTITUT 143 +#define TT_MAC_LANGID_SCOTTISH_GAELIC 144 +#define TT_MAC_LANGID_MANX_GAELIC 145 +#define TT_MAC_LANGID_IRISH_GAELIC 146 +#define TT_MAC_LANGID_TONGAN 147 +#define TT_MAC_LANGID_GREEK_POLYTONIC 148 +#define TT_MAC_LANGID_GREELANDIC 149 +#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150 + + + /*********************************************************************** + * + * @enum: + * TT_MS_LANGID_XXX + * + * @description: + * Possible values of the language identifier field in the name records + * of the SFNT `name' table if the `platform' identifier code is + * @TT_PLATFORM_MICROSOFT. These values are also used as return values + * for function @FT_Get_CMap_Language_ID. + * + * The canonical source for Microsoft's IDs is + * + * https://www.microsoft.com/globaldev/reference/lcid-all.mspx , + * + * however, we only provide macros for language identifiers present in + * the OpenType specification: Microsoft has abandoned the concept of + * LCIDs (language code identifiers), and format~1 of the `name' table + * provides a better mechanism for languages not covered here. + * + * More legacy values not listed in the reference can be found in the + * @FT_TRUETYPE_IDS_H header file. + */ + +#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401 +#define TT_MS_LANGID_ARABIC_IRAQ 0x0801 +#define TT_MS_LANGID_ARABIC_EGYPT 0x0C01 +#define TT_MS_LANGID_ARABIC_LIBYA 0x1001 +#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401 +#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801 +#define TT_MS_LANGID_ARABIC_TUNISIA 0x1C01 +#define TT_MS_LANGID_ARABIC_OMAN 0x2001 +#define TT_MS_LANGID_ARABIC_YEMEN 0x2401 +#define TT_MS_LANGID_ARABIC_SYRIA 0x2801 +#define TT_MS_LANGID_ARABIC_JORDAN 0x2C01 +#define TT_MS_LANGID_ARABIC_LEBANON 0x3001 +#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401 +#define TT_MS_LANGID_ARABIC_UAE 0x3801 +#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3C01 +#define TT_MS_LANGID_ARABIC_QATAR 0x4001 +#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402 +#define TT_MS_LANGID_CATALAN_CATALAN 0x0403 +#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404 +#define TT_MS_LANGID_CHINESE_PRC 0x0804 +#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0C04 +#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004 +#define TT_MS_LANGID_CHINESE_MACAO 0x1404 +#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405 +#define TT_MS_LANGID_DANISH_DENMARK 0x0406 +#define TT_MS_LANGID_GERMAN_GERMANY 0x0407 +#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807 +#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0C07 +#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007 +#define TT_MS_LANGID_GERMAN_LIECHTENSTEIN 0x1407 +#define TT_MS_LANGID_GREEK_GREECE 0x0408 +#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409 +#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809 +#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0C09 +#define TT_MS_LANGID_ENGLISH_CANADA 0x1009 +#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409 +#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809 +#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1C09 +#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009 +#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409 +#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809 +#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2C09 +#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009 +#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409 +#define TT_MS_LANGID_ENGLISH_INDIA 0x4009 +#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409 +#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809 +#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040A +#define TT_MS_LANGID_SPANISH_MEXICO 0x080A +#define TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT 0x0C0A +#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100A +#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140A +#define TT_MS_LANGID_SPANISH_PANAMA 0x180A +#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1C0A +#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200A +#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240A +#define TT_MS_LANGID_SPANISH_PERU 0x280A +#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2C0A +#define TT_MS_LANGID_SPANISH_ECUADOR 0x300A +#define TT_MS_LANGID_SPANISH_CHILE 0x340A +#define TT_MS_LANGID_SPANISH_URUGUAY 0x380A +#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3C0A +#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400A +#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440A +#define TT_MS_LANGID_SPANISH_HONDURAS 0x480A +#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4C0A +#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500A +#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540A +#define TT_MS_LANGID_FINNISH_FINLAND 0x040B +#define TT_MS_LANGID_FRENCH_FRANCE 0x040C +#define TT_MS_LANGID_FRENCH_BELGIUM 0x080C +#define TT_MS_LANGID_FRENCH_CANADA 0x0C0C +#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100C +#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140C +#define TT_MS_LANGID_FRENCH_MONACO 0x180C +#define TT_MS_LANGID_HEBREW_ISRAEL 0x040D +#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040E +#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040F +#define TT_MS_LANGID_ITALIAN_ITALY 0x0410 +#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810 +#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411 +#define TT_MS_LANGID_KOREAN_KOREA 0x0412 +#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413 +#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814 +#define TT_MS_LANGID_POLISH_POLAND 0x0415 +#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416 +#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816 +#define TT_MS_LANGID_ROMANSH_SWITZERLAND 0x0417 +#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418 +#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419 +#define TT_MS_LANGID_CROATIAN_CROATIA 0x041A +#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081A +#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0C1A +#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101A +#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141A +#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181A +#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x1C1A +#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZ_CYRILLIC 0x201A +#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041B +#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041C +#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041D +#define TT_MS_LANGID_SWEDISH_FINLAND 0x081D +#define TT_MS_LANGID_THAI_THAILAND 0x041E +#define TT_MS_LANGID_TURKISH_TURKEY 0x041F +#define TT_MS_LANGID_URDU_PAKISTAN 0x0420 +#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421 +#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422 +#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423 +#define TT_MS_LANGID_SLOVENIAN_SLOVENIA 0x0424 +#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425 +#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426 +#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427 +#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428 +#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042A +#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042B +#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042C +#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082C +#define TT_MS_LANGID_BASQUE_BASQUE 0x042D +#define TT_MS_LANGID_UPPER_SORBIAN_GERMANY 0x042E +#define TT_MS_LANGID_LOWER_SORBIAN_GERMANY 0x082E +#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042F +#define TT_MS_LANGID_SETSWANA_SOUTH_AFRICA 0x0432 +#define TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA 0x0434 +#define TT_MS_LANGID_ISIZULU_SOUTH_AFRICA 0x0435 +#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436 +#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437 +#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438 +#define TT_MS_LANGID_HINDI_INDIA 0x0439 +#define TT_MS_LANGID_MALTESE_MALTA 0x043A +#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY 0x043B +#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN 0x083B +#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND 0x0C3B +#define TT_MS_LANGID_SAMI_LULE_NORWAY 0x103B +#define TT_MS_LANGID_SAMI_LULE_SWEDEN 0x143B +#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY 0x183B +#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN 0x1C3B +#define TT_MS_LANGID_SAMI_SKOLT_FINLAND 0x203B +#define TT_MS_LANGID_SAMI_INARI_FINLAND 0x243B +#define TT_MS_LANGID_IRISH_IRELAND 0x083C +#define TT_MS_LANGID_MALAY_MALAYSIA 0x043E +#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083E +#define TT_MS_LANGID_KAZAKH_KAZAKHSTAN 0x043F +#define TT_MS_LANGID_KYRGYZ_KYRGYZSTAN /* Cyrillic*/ 0x0440 +#define TT_MS_LANGID_KISWAHILI_KENYA 0x0441 +#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843 +#define TT_MS_LANGID_TATAR_RUSSIA 0x0444 +#define TT_MS_LANGID_BENGALI_INDIA 0x0445 +#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845 +#define TT_MS_LANGID_PUNJABI_INDIA 0x0446 +#define TT_MS_LANGID_GUJARATI_INDIA 0x0447 +#define TT_MS_LANGID_ODIA_INDIA 0x0448 +#define TT_MS_LANGID_TAMIL_INDIA 0x0449 +#define TT_MS_LANGID_TELUGU_INDIA 0x044A +#define TT_MS_LANGID_KANNADA_INDIA 0x044B +#define TT_MS_LANGID_MALAYALAM_INDIA 0x044C +#define TT_MS_LANGID_ASSAMESE_INDIA 0x044D +#define TT_MS_LANGID_MARATHI_INDIA 0x044E +#define TT_MS_LANGID_SANSKRIT_INDIA 0x044F +#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450 +#define TT_MS_LANGID_MONGOLIAN_PRC 0x0850 +#define TT_MS_LANGID_TIBETAN_PRC 0x0451 +#define TT_MS_LANGID_WELSH_UNITED_KINGDOM 0x0452 +#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453 +#define TT_MS_LANGID_LAO_LAOS 0x0454 +#define TT_MS_LANGID_GALICIAN_GALICIAN 0x0456 +#define TT_MS_LANGID_KONKANI_INDIA 0x0457 +#define TT_MS_LANGID_SYRIAC_SYRIA 0x045A +#define TT_MS_LANGID_SINHALA_SRI_LANKA 0x045B +#define TT_MS_LANGID_INUKTITUT_CANADA 0x045D +#define TT_MS_LANGID_INUKTITUT_CANADA_LATIN 0x085D +#define TT_MS_LANGID_AMHARIC_ETHIOPIA 0x045E +#define TT_MS_LANGID_TAMAZIGHT_ALGERIA 0x085F +#define TT_MS_LANGID_NEPALI_NEPAL 0x0461 +#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462 +#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463 +#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464 +#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465 +#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468 +#define TT_MS_LANGID_YORUBA_NIGERIA 0x046A +#define TT_MS_LANGID_QUECHUA_BOLIVIA 0x046B +#define TT_MS_LANGID_QUECHUA_ECUADOR 0x086B +#define TT_MS_LANGID_QUECHUA_PERU 0x0C6B +#define TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA 0x046C +#define TT_MS_LANGID_BASHKIR_RUSSIA 0x046D +#define TT_MS_LANGID_LUXEMBOURGISH_LUXEMBOURG 0x046E +#define TT_MS_LANGID_GREENLANDIC_GREENLAND 0x046F +#define TT_MS_LANGID_IGBO_NIGERIA 0x0470 +#define TT_MS_LANGID_YI_PRC 0x0478 +#define TT_MS_LANGID_MAPUDUNGUN_CHILE 0x047A +#define TT_MS_LANGID_MOHAWK_MOHAWK 0x047C +#define TT_MS_LANGID_BRETON_FRANCE 0x047E +#define TT_MS_LANGID_UIGHUR_PRC 0x0480 +#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481 +#define TT_MS_LANGID_OCCITAN_FRANCE 0x0482 +#define TT_MS_LANGID_CORSICAN_FRANCE 0x0483 +#define TT_MS_LANGID_ALSATIAN_FRANCE 0x0484 +#define TT_MS_LANGID_YAKUT_RUSSIA 0x0485 +#define TT_MS_LANGID_KICHE_GUATEMALA 0x0486 +#define TT_MS_LANGID_KINYARWANDA_RWANDA 0x0487 +#define TT_MS_LANGID_WOLOF_SENEGAL 0x0488 +#define TT_MS_LANGID_DARI_AFGHANISTAN 0x048C + + /* */ + + + /* legacy macro definitions not present in OpenType 1.8.1 */ +#define TT_MS_LANGID_ARABIC_GENERAL 0x0001 +#define TT_MS_LANGID_CATALAN_SPAIN \ + TT_MS_LANGID_CATALAN_CATALAN +#define TT_MS_LANGID_CHINESE_GENERAL 0x0004 +#define TT_MS_LANGID_CHINESE_MACAU \ + TT_MS_LANGID_CHINESE_MACAO +#define TT_MS_LANGID_GERMAN_LIECHTENSTEI \ + TT_MS_LANGID_GERMAN_LIECHTENSTEIN +#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009 +#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809 +#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3C09 +#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT \ + TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT +#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40AU +#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1C0C +#define TT_MS_LANGID_FRENCH_REUNION 0x200C +#define TT_MS_LANGID_FRENCH_CONGO 0x240C + /* which was formerly: */ +#define TT_MS_LANGID_FRENCH_ZAIRE \ + TT_MS_LANGID_FRENCH_CONGO +#define TT_MS_LANGID_FRENCH_SENEGAL 0x280C +#define TT_MS_LANGID_FRENCH_CAMEROON 0x2C0C +#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300C +#define TT_MS_LANGID_FRENCH_MALI 0x340C +#define TT_MS_LANGID_FRENCH_MOROCCO 0x380C +#define TT_MS_LANGID_FRENCH_HAITI 0x3C0C +#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40CU +#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA \ + TT_MS_LANGID_KOREAN_KOREA +#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 +#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND \ + TT_MS_LANGID_ROMANSH_SWITZERLAND +#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818 +#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819 +#define TT_MS_LANGID_URDU_INDIA 0x0820 +#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827 +#define TT_MS_LANGID_SLOVENE_SLOVENIA \ + TT_MS_LANGID_SLOVENIAN_SLOVENIA +#define TT_MS_LANGID_FARSI_IRAN 0x0429 +#define TT_MS_LANGID_BASQUE_SPAIN \ + TT_MS_LANGID_BASQUE_BASQUE +#define TT_MS_LANGID_SORBIAN_GERMANY \ + TT_MS_LANGID_UPPER_SORBIAN_GERMANY +#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430 +#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431 +#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA \ + TT_MS_LANGID_SETSWANA_SOUTH_AFRICA +#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 +#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA \ + TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA +#define TT_MS_LANGID_ZULU_SOUTH_AFRICA \ + TT_MS_LANGID_ISIZULU_SOUTH_AFRICA +#define TT_MS_LANGID_SAAMI_LAPONIA 0x043B + /* the next two values are incorrectly inverted */ +#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C +#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C +#define TT_MS_LANGID_YIDDISH_GERMANY 0x043D +#define TT_MS_LANGID_KAZAK_KAZAKSTAN \ + TT_MS_LANGID_KAZAKH_KAZAKHSTAN +#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \ + TT_MS_LANGID_KYRGYZ_KYRGYZSTAN +#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN \ + TT_MS_LANGID_KYRGYZ_KYRGYZSTAN +#define TT_MS_LANGID_SWAHILI_KENYA \ + TT_MS_LANGID_KISWAHILI_KENYA +#define TT_MS_LANGID_TATAR_TATARSTAN \ + TT_MS_LANGID_TATAR_RUSSIA +#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846 +#define TT_MS_LANGID_ORIYA_INDIA \ + TT_MS_LANGID_ODIA_INDIA +#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN \ + TT_MS_LANGID_MONGOLIAN_PRC +#define TT_MS_LANGID_TIBETAN_CHINA \ + TT_MS_LANGID_TIBETAN_PRC +#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851 +#define TT_MS_LANGID_TIBETAN_BHUTAN \ + TT_MS_LANGID_DZONGHKA_BHUTAN +#define TT_MS_LANGID_WELSH_WALES \ + TT_MS_LANGID_WELSH_UNITED_KINGDOM +#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455 +#define TT_MS_LANGID_GALICIAN_SPAIN \ + TT_MS_LANGID_GALICIAN_GALICIAN +#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458 +#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459 +#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859 +#define TT_MS_LANGID_SINHALESE_SRI_LANKA \ + TT_MS_LANGID_SINHALA_SRI_LANKA +#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045C +#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045F +#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN \ + TT_MS_LANGID_TAMAZIGHT_ALGERIA +#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460 +#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860 +#define TT_MS_LANGID_KASHMIRI_INDIA \ + TT_MS_LANGID_KASHMIRI_SASIA +#define TT_MS_LANGID_NEPALI_INDIA 0x0861 +#define TT_MS_LANGID_DIVEHI_MALDIVES \ + TT_MS_LANGID_DHIVEHI_MALDIVES +#define TT_MS_LANGID_EDO_NIGERIA 0x0466 +#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467 +#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469 +#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA \ + TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA +#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \ + TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA +#define TT_MS_LANGID_KANURI_NIGERIA 0x0471 +#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472 +#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473 +#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873 +#define TT_MS_LANGID_TIGRIGNA_ERYTREA \ + TT_MS_LANGID_TIGRIGNA_ERYTHREA +#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474 +#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475 +#define TT_MS_LANGID_LATIN 0x0476 +#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477 +#define TT_MS_LANGID_YI_CHINA \ + TT_MS_LANGID_YI_PRC +#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479 +#define TT_MS_LANGID_UIGHUR_CHINA \ + TT_MS_LANGID_UIGHUR_PRC + + + /*********************************************************************** + * + * @enum: + * TT_NAME_ID_XXX + * + * @description: + * Possible values of the `name' identifier field in the name records of + * an SFNT `name' table. These values are platform independent. + */ + +#define TT_NAME_ID_COPYRIGHT 0 +#define TT_NAME_ID_FONT_FAMILY 1 +#define TT_NAME_ID_FONT_SUBFAMILY 2 +#define TT_NAME_ID_UNIQUE_ID 3 +#define TT_NAME_ID_FULL_NAME 4 +#define TT_NAME_ID_VERSION_STRING 5 +#define TT_NAME_ID_PS_NAME 6 +#define TT_NAME_ID_TRADEMARK 7 + + /* the following values are from the OpenType spec */ +#define TT_NAME_ID_MANUFACTURER 8 +#define TT_NAME_ID_DESIGNER 9 +#define TT_NAME_ID_DESCRIPTION 10 +#define TT_NAME_ID_VENDOR_URL 11 +#define TT_NAME_ID_DESIGNER_URL 12 +#define TT_NAME_ID_LICENSE 13 +#define TT_NAME_ID_LICENSE_URL 14 + /* number 15 is reserved */ +#define TT_NAME_ID_TYPOGRAPHIC_FAMILY 16 +#define TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY 17 +#define TT_NAME_ID_MAC_FULL_NAME 18 + + /* The following code is new as of 2000-01-21 */ +#define TT_NAME_ID_SAMPLE_TEXT 19 + + /* This is new in OpenType 1.3 */ +#define TT_NAME_ID_CID_FINDFONT_NAME 20 + + /* This is new in OpenType 1.5 */ +#define TT_NAME_ID_WWS_FAMILY 21 +#define TT_NAME_ID_WWS_SUBFAMILY 22 + + /* This is new in OpenType 1.7 */ +#define TT_NAME_ID_LIGHT_BACKGROUND 23 +#define TT_NAME_ID_DARK_BACKGROUND 24 + + /* This is new in OpenType 1.8 */ +#define TT_NAME_ID_VARIATIONS_PREFIX 25 + + /* these two values are deprecated */ +#define TT_NAME_ID_PREFERRED_FAMILY TT_NAME_ID_TYPOGRAPHIC_FAMILY +#define TT_NAME_ID_PREFERRED_SUBFAMILY TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY + + + /*********************************************************************** + * + * @enum: + * TT_UCR_XXX + * + * @description: + * Possible bit mask values for the `ulUnicodeRangeX' fields in an SFNT + * `OS/2' table. + */ + + /* ulUnicodeRange1 */ + /* --------------- */ + + /* Bit 0 Basic Latin */ +#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */ + /* Bit 1 C1 Controls and Latin-1 Supplement */ +#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */ + /* Bit 2 Latin Extended-A */ +#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */ + /* Bit 3 Latin Extended-B */ +#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */ + /* Bit 4 IPA Extensions */ + /* Phonetic Extensions */ + /* Phonetic Extensions Supplement */ +#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */ + /* U+1D00-U+1D7F */ + /* U+1D80-U+1DBF */ + /* Bit 5 Spacing Modifier Letters */ + /* Modifier Tone Letters */ +#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */ + /* U+A700-U+A71F */ + /* Bit 6 Combining Diacritical Marks */ + /* Combining Diacritical Marks Supplement */ +#define TT_UCR_COMBINING_DIACRITICAL_MARKS (1L << 6) /* U+0300-U+036F */ + /* U+1DC0-U+1DFF */ + /* Bit 7 Greek and Coptic */ +#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */ + /* Bit 8 Coptic */ +#define TT_UCR_COPTIC (1L << 8) /* U+2C80-U+2CFF */ + /* Bit 9 Cyrillic */ + /* Cyrillic Supplement */ + /* Cyrillic Extended-A */ + /* Cyrillic Extended-B */ +#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */ + /* U+0500-U+052F */ + /* U+2DE0-U+2DFF */ + /* U+A640-U+A69F */ + /* Bit 10 Armenian */ +#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */ + /* Bit 11 Hebrew */ +#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */ + /* Bit 12 Vai */ +#define TT_UCR_VAI (1L << 12) /* U+A500-U+A63F */ + /* Bit 13 Arabic */ + /* Arabic Supplement */ +#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */ + /* U+0750-U+077F */ + /* Bit 14 NKo */ +#define TT_UCR_NKO (1L << 14) /* U+07C0-U+07FF */ + /* Bit 15 Devanagari */ +#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */ + /* Bit 16 Bengali */ +#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */ + /* Bit 17 Gurmukhi */ +#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */ + /* Bit 18 Gujarati */ +#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */ + /* Bit 19 Oriya */ +#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */ + /* Bit 20 Tamil */ +#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */ + /* Bit 21 Telugu */ +#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */ + /* Bit 22 Kannada */ +#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */ + /* Bit 23 Malayalam */ +#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */ + /* Bit 24 Thai */ +#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */ + /* Bit 25 Lao */ +#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */ + /* Bit 26 Georgian */ + /* Georgian Supplement */ +#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */ + /* U+2D00-U+2D2F */ + /* Bit 27 Balinese */ +#define TT_UCR_BALINESE (1L << 27) /* U+1B00-U+1B7F */ + /* Bit 28 Hangul Jamo */ +#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */ + /* Bit 29 Latin Extended Additional */ + /* Latin Extended-C */ + /* Latin Extended-D */ +#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */ + /* U+2C60-U+2C7F */ + /* U+A720-U+A7FF */ + /* Bit 30 Greek Extended */ +#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */ + /* Bit 31 General Punctuation */ + /* Supplemental Punctuation */ +#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */ + /* U+2E00-U+2E7F */ + + /* ulUnicodeRange2 */ + /* --------------- */ + + /* Bit 32 Superscripts And Subscripts */ +#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */ + /* Bit 33 Currency Symbols */ +#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */ + /* Bit 34 Combining Diacritical Marks For Symbols */ +#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ + (1L << 2) /* U+20D0-U+20FF */ + /* Bit 35 Letterlike Symbols */ +#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */ + /* Bit 36 Number Forms */ +#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */ + /* Bit 37 Arrows */ + /* Supplemental Arrows-A */ + /* Supplemental Arrows-B */ + /* Miscellaneous Symbols and Arrows */ +#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */ + /* U+27F0-U+27FF */ + /* U+2900-U+297F */ + /* U+2B00-U+2BFF */ + /* Bit 38 Mathematical Operators */ + /* Supplemental Mathematical Operators */ + /* Miscellaneous Mathematical Symbols-A */ + /* Miscellaneous Mathematical Symbols-B */ +#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */ + /* U+2A00-U+2AFF */ + /* U+27C0-U+27EF */ + /* U+2980-U+29FF */ + /* Bit 39 Miscellaneous Technical */ +#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */ + /* Bit 40 Control Pictures */ +#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */ + /* Bit 41 Optical Character Recognition */ +#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */ + /* Bit 42 Enclosed Alphanumerics */ +#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */ + /* Bit 43 Box Drawing */ +#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */ + /* Bit 44 Block Elements */ +#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */ + /* Bit 45 Geometric Shapes */ +#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */ + /* Bit 46 Miscellaneous Symbols */ +#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */ + /* Bit 47 Dingbats */ +#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */ + /* Bit 48 CJK Symbols and Punctuation */ +#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */ + /* Bit 49 Hiragana */ +#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */ + /* Bit 50 Katakana */ + /* Katakana Phonetic Extensions */ +#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */ + /* U+31F0-U+31FF */ + /* Bit 51 Bopomofo */ + /* Bopomofo Extended */ +#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */ + /* U+31A0-U+31BF */ + /* Bit 52 Hangul Compatibility Jamo */ +#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */ + /* Bit 53 Phags-Pa */ +#define TT_UCR_CJK_MISC (1L << 21) /* U+A840-U+A87F */ +#define TT_UCR_KANBUN TT_UCR_CJK_MISC /* deprecated */ +#define TT_UCR_PHAGSPA + /* Bit 54 Enclosed CJK Letters and Months */ +#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */ + /* Bit 55 CJK Compatibility */ +#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */ + /* Bit 56 Hangul Syllables */ +#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */ + /* Bit 57 High Surrogates */ + /* High Private Use Surrogates */ + /* Low Surrogates */ + + /* According to OpenType specs v.1.3+, */ + /* setting bit 57 implies that there is */ + /* at least one codepoint beyond the */ + /* Basic Multilingual Plane that is */ + /* supported by this font. So it really */ + /* means >= U+10000. */ +#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DB7F */ + /* U+DB80-U+DBFF */ + /* U+DC00-U+DFFF */ +#define TT_UCR_NON_PLANE_0 TT_UCR_SURROGATES + /* Bit 58 Phoenician */ +#define TT_UCR_PHOENICIAN (1L << 26) /*U+10900-U+1091F*/ + /* Bit 59 CJK Unified Ideographs */ + /* CJK Radicals Supplement */ + /* Kangxi Radicals */ + /* Ideographic Description Characters */ + /* CJK Unified Ideographs Extension A */ + /* CJK Unified Ideographs Extension B */ + /* Kanbun */ +#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */ + /* U+2E80-U+2EFF */ + /* U+2F00-U+2FDF */ + /* U+2FF0-U+2FFF */ + /* U+3400-U+4DB5 */ + /*U+20000-U+2A6DF*/ + /* U+3190-U+319F */ + /* Bit 60 Private Use */ +#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */ + /* Bit 61 CJK Strokes */ + /* CJK Compatibility Ideographs */ + /* CJK Compatibility Ideographs Supplement */ +#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+31C0-U+31EF */ + /* U+F900-U+FAFF */ + /*U+2F800-U+2FA1F*/ + /* Bit 62 Alphabetic Presentation Forms */ +#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */ + /* Bit 63 Arabic Presentation Forms-A */ +#define TT_UCR_ARABIC_PRESENTATION_FORMS_A (1L << 31) /* U+FB50-U+FDFF */ + + /* ulUnicodeRange3 */ + /* --------------- */ + + /* Bit 64 Combining Half Marks */ +#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */ + /* Bit 65 Vertical forms */ + /* CJK Compatibility Forms */ +#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE10-U+FE1F */ + /* U+FE30-U+FE4F */ + /* Bit 66 Small Form Variants */ +#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */ + /* Bit 67 Arabic Presentation Forms-B */ +#define TT_UCR_ARABIC_PRESENTATION_FORMS_B (1L << 3) /* U+FE70-U+FEFE */ + /* Bit 68 Halfwidth and Fullwidth Forms */ +#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */ + /* Bit 69 Specials */ +#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */ + /* Bit 70 Tibetan */ +#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FFF */ + /* Bit 71 Syriac */ +#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */ + /* Bit 72 Thaana */ +#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */ + /* Bit 73 Sinhala */ +#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */ + /* Bit 74 Myanmar */ +#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */ + /* Bit 75 Ethiopic */ + /* Ethiopic Supplement */ + /* Ethiopic Extended */ +#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+137F */ + /* U+1380-U+139F */ + /* U+2D80-U+2DDF */ + /* Bit 76 Cherokee */ +#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */ + /* Bit 77 Unified Canadian Aboriginal Syllabics */ +#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+167F */ + /* Bit 78 Ogham */ +#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */ + /* Bit 79 Runic */ +#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */ + /* Bit 80 Khmer */ + /* Khmer Symbols */ +#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */ + /* U+19E0-U+19FF */ + /* Bit 81 Mongolian */ +#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */ + /* Bit 82 Braille Patterns */ +#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */ + /* Bit 83 Yi Syllables */ + /* Yi Radicals */ +#define TT_UCR_YI (1L << 19) /* U+A000-U+A48F */ + /* U+A490-U+A4CF */ + /* Bit 84 Tagalog */ + /* Hanunoo */ + /* Buhid */ + /* Tagbanwa */ +#define TT_UCR_PHILIPPINE (1L << 20) /* U+1700-U+171F */ + /* U+1720-U+173F */ + /* U+1740-U+175F */ + /* U+1760-U+177F */ + /* Bit 85 Old Italic */ +#define TT_UCR_OLD_ITALIC (1L << 21) /*U+10300-U+1032F*/ + /* Bit 86 Gothic */ +#define TT_UCR_GOTHIC (1L << 22) /*U+10330-U+1034F*/ + /* Bit 87 Deseret */ +#define TT_UCR_DESERET (1L << 23) /*U+10400-U+1044F*/ + /* Bit 88 Byzantine Musical Symbols */ + /* Musical Symbols */ + /* Ancient Greek Musical Notation */ +#define TT_UCR_MUSICAL_SYMBOLS (1L << 24) /*U+1D000-U+1D0FF*/ + /*U+1D100-U+1D1FF*/ + /*U+1D200-U+1D24F*/ + /* Bit 89 Mathematical Alphanumeric Symbols */ +#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS (1L << 25) /*U+1D400-U+1D7FF*/ + /* Bit 90 Private Use (plane 15) */ + /* Private Use (plane 16) */ +#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY (1L << 26) /*U+F0000-U+FFFFD*/ + /*U+100000-U+10FFFD*/ + /* Bit 91 Variation Selectors */ + /* Variation Selectors Supplement */ +#define TT_UCR_VARIATION_SELECTORS (1L << 27) /* U+FE00-U+FE0F */ + /*U+E0100-U+E01EF*/ + /* Bit 92 Tags */ +#define TT_UCR_TAGS (1L << 28) /*U+E0000-U+E007F*/ + /* Bit 93 Limbu */ +#define TT_UCR_LIMBU (1L << 29) /* U+1900-U+194F */ + /* Bit 94 Tai Le */ +#define TT_UCR_TAI_LE (1L << 30) /* U+1950-U+197F */ + /* Bit 95 New Tai Lue */ +#define TT_UCR_NEW_TAI_LUE (1L << 31) /* U+1980-U+19DF */ + + /* ulUnicodeRange4 */ + /* --------------- */ + + /* Bit 96 Buginese */ +#define TT_UCR_BUGINESE (1L << 0) /* U+1A00-U+1A1F */ + /* Bit 97 Glagolitic */ +#define TT_UCR_GLAGOLITIC (1L << 1) /* U+2C00-U+2C5F */ + /* Bit 98 Tifinagh */ +#define TT_UCR_TIFINAGH (1L << 2) /* U+2D30-U+2D7F */ + /* Bit 99 Yijing Hexagram Symbols */ +#define TT_UCR_YIJING (1L << 3) /* U+4DC0-U+4DFF */ + /* Bit 100 Syloti Nagri */ +#define TT_UCR_SYLOTI_NAGRI (1L << 4) /* U+A800-U+A82F */ + /* Bit 101 Linear B Syllabary */ + /* Linear B Ideograms */ + /* Aegean Numbers */ +#define TT_UCR_LINEAR_B (1L << 5) /*U+10000-U+1007F*/ + /*U+10080-U+100FF*/ + /*U+10100-U+1013F*/ + /* Bit 102 Ancient Greek Numbers */ +#define TT_UCR_ANCIENT_GREEK_NUMBERS (1L << 6) /*U+10140-U+1018F*/ + /* Bit 103 Ugaritic */ +#define TT_UCR_UGARITIC (1L << 7) /*U+10380-U+1039F*/ + /* Bit 104 Old Persian */ +#define TT_UCR_OLD_PERSIAN (1L << 8) /*U+103A0-U+103DF*/ + /* Bit 105 Shavian */ +#define TT_UCR_SHAVIAN (1L << 9) /*U+10450-U+1047F*/ + /* Bit 106 Osmanya */ +#define TT_UCR_OSMANYA (1L << 10) /*U+10480-U+104AF*/ + /* Bit 107 Cypriot Syllabary */ +#define TT_UCR_CYPRIOT_SYLLABARY (1L << 11) /*U+10800-U+1083F*/ + /* Bit 108 Kharoshthi */ +#define TT_UCR_KHAROSHTHI (1L << 12) /*U+10A00-U+10A5F*/ + /* Bit 109 Tai Xuan Jing Symbols */ +#define TT_UCR_TAI_XUAN_JING (1L << 13) /*U+1D300-U+1D35F*/ + /* Bit 110 Cuneiform */ + /* Cuneiform Numbers and Punctuation */ +#define TT_UCR_CUNEIFORM (1L << 14) /*U+12000-U+123FF*/ + /*U+12400-U+1247F*/ + /* Bit 111 Counting Rod Numerals */ +#define TT_UCR_COUNTING_ROD_NUMERALS (1L << 15) /*U+1D360-U+1D37F*/ + /* Bit 112 Sundanese */ +#define TT_UCR_SUNDANESE (1L << 16) /* U+1B80-U+1BBF */ + /* Bit 113 Lepcha */ +#define TT_UCR_LEPCHA (1L << 17) /* U+1C00-U+1C4F */ + /* Bit 114 Ol Chiki */ +#define TT_UCR_OL_CHIKI (1L << 18) /* U+1C50-U+1C7F */ + /* Bit 115 Saurashtra */ +#define TT_UCR_SAURASHTRA (1L << 19) /* U+A880-U+A8DF */ + /* Bit 116 Kayah Li */ +#define TT_UCR_KAYAH_LI (1L << 20) /* U+A900-U+A92F */ + /* Bit 117 Rejang */ +#define TT_UCR_REJANG (1L << 21) /* U+A930-U+A95F */ + /* Bit 118 Cham */ +#define TT_UCR_CHAM (1L << 22) /* U+AA00-U+AA5F */ + /* Bit 119 Ancient Symbols */ +#define TT_UCR_ANCIENT_SYMBOLS (1L << 23) /*U+10190-U+101CF*/ + /* Bit 120 Phaistos Disc */ +#define TT_UCR_PHAISTOS_DISC (1L << 24) /*U+101D0-U+101FF*/ + /* Bit 121 Carian */ + /* Lycian */ + /* Lydian */ +#define TT_UCR_OLD_ANATOLIAN (1L << 25) /*U+102A0-U+102DF*/ + /*U+10280-U+1029F*/ + /*U+10920-U+1093F*/ + /* Bit 122 Domino Tiles */ + /* Mahjong Tiles */ +#define TT_UCR_GAME_TILES (1L << 26) /*U+1F030-U+1F09F*/ + /*U+1F000-U+1F02F*/ + /* Bit 123-127 Reserved for process-internal usage */ + + /* */ + + /* for backward compatibility with older FreeType versions */ +#define TT_UCR_ARABIC_PRESENTATION_A \ + TT_UCR_ARABIC_PRESENTATION_FORMS_A +#define TT_UCR_ARABIC_PRESENTATION_B \ + TT_UCR_ARABIC_PRESENTATION_FORMS_B + +#define TT_UCR_COMBINING_DIACRITICS \ + TT_UCR_COMBINING_DIACRITICAL_MARKS +#define TT_UCR_COMBINING_DIACRITICS_SYMB \ + TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB + + +FT_END_HEADER + +#endif /* TTNAMEID_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/tttables.h b/src_v2/libs/sloth/freetype/freetype2/freetype/tttables.h new file mode 100644 index 0000000..ce6a617 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/tttables.h @@ -0,0 +1,846 @@ +/***************************************************************************/ +/* */ +/* tttables.h */ +/* */ +/* Basic SFNT/TrueType tables definitions and interface */ +/* (specification only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef TTTABLES_H_ +#define TTTABLES_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* <Section> */ + /* truetype_tables */ + /* */ + /* <Title> */ + /* TrueType Tables */ + /* */ + /* <Abstract> */ + /* TrueType specific table types and functions. */ + /* */ + /* <Description> */ + /* This section contains definitions of some basic tables specific to */ + /* TrueType and OpenType as well as some routines used to access and */ + /* process them. */ + /* */ + /* <Order> */ + /* TT_Header */ + /* TT_HoriHeader */ + /* TT_VertHeader */ + /* TT_OS2 */ + /* TT_Postscript */ + /* TT_PCLT */ + /* TT_MaxProfile */ + /* */ + /* FT_Sfnt_Tag */ + /* FT_Get_Sfnt_Table */ + /* FT_Load_Sfnt_Table */ + /* FT_Sfnt_Table_Info */ + /* */ + /* FT_Get_CMap_Language_ID */ + /* FT_Get_CMap_Format */ + /* */ + /* FT_PARAM_TAG_UNPATENTED_HINTING */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_Header */ + /* */ + /* <Description> */ + /* A structure to model a TrueType font header table. All fields */ + /* follow the OpenType specification. */ + /* */ + typedef struct TT_Header_ + { + FT_Fixed Table_Version; + FT_Fixed Font_Revision; + + FT_Long CheckSum_Adjust; + FT_Long Magic_Number; + + FT_UShort Flags; + FT_UShort Units_Per_EM; + + FT_Long Created [2]; + FT_Long Modified[2]; + + FT_Short xMin; + FT_Short yMin; + FT_Short xMax; + FT_Short yMax; + + FT_UShort Mac_Style; + FT_UShort Lowest_Rec_PPEM; + + FT_Short Font_Direction; + FT_Short Index_To_Loc_Format; + FT_Short Glyph_Data_Format; + + } TT_Header; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_HoriHeader */ + /* */ + /* <Description> */ + /* A structure to model a TrueType horizontal header, the `hhea' */ + /* table, as well as the corresponding horizontal metrics table, */ + /* `hmtx'. */ + /* */ + /* <Fields> */ + /* Version :: The table version. */ + /* */ + /* Ascender :: The font's ascender, i.e., the distance */ + /* from the baseline to the top-most of all */ + /* glyph points found in the font. */ + /* */ + /* This value is invalid in many fonts, as */ + /* it is usually set by the font designer, */ + /* and often reflects only a portion of the */ + /* glyphs found in the font (maybe ASCII). */ + /* */ + /* You should use the `sTypoAscender' field */ + /* of the `OS/2' table instead if you want */ + /* the correct one. */ + /* */ + /* Descender :: The font's descender, i.e., the distance */ + /* from the baseline to the bottom-most of */ + /* all glyph points found in the font. It */ + /* is negative. */ + /* */ + /* This value is invalid in many fonts, as */ + /* it is usually set by the font designer, */ + /* and often reflects only a portion of the */ + /* glyphs found in the font (maybe ASCII). */ + /* */ + /* You should use the `sTypoDescender' */ + /* field of the `OS/2' table instead if you */ + /* want the correct one. */ + /* */ + /* Line_Gap :: The font's line gap, i.e., the distance */ + /* to add to the ascender and descender to */ + /* get the BTB, i.e., the */ + /* baseline-to-baseline distance for the */ + /* font. */ + /* */ + /* advance_Width_Max :: This field is the maximum of all advance */ + /* widths found in the font. It can be */ + /* used to compute the maximum width of an */ + /* arbitrary string of text. */ + /* */ + /* min_Left_Side_Bearing :: The minimum left side bearing of all */ + /* glyphs within the font. */ + /* */ + /* min_Right_Side_Bearing :: The minimum right side bearing of all */ + /* glyphs within the font. */ + /* */ + /* xMax_Extent :: The maximum horizontal extent (i.e., the */ + /* `width' of a glyph's bounding box) for */ + /* all glyphs in the font. */ + /* */ + /* caret_Slope_Rise :: The rise coefficient of the cursor's */ + /* slope of the cursor (slope=rise/run). */ + /* */ + /* caret_Slope_Run :: The run coefficient of the cursor's */ + /* slope. */ + /* */ + /* caret_Offset :: The cursor's offset for slanted fonts. */ + /* */ + /* Reserved :: 8~reserved bytes. */ + /* */ + /* metric_Data_Format :: Always~0. */ + /* */ + /* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */ + /* table -- this value can be smaller than */ + /* the total number of glyphs in the font. */ + /* */ + /* long_metrics :: A pointer into the `hmtx' table. */ + /* */ + /* short_metrics :: A pointer into the `hmtx' table. */ + /* */ + /* <Note> */ + /* For an OpenType variation font, the values of the following fields */ + /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ + /* friends) if the font contains an `MVAR' table: `caret_Slope_Rise', */ + /* `caret_Slope_Run', and `caret_Offset'. */ + /* */ + typedef struct TT_HoriHeader_ + { + FT_Fixed Version; + FT_Short Ascender; + FT_Short Descender; + FT_Short Line_Gap; + + FT_UShort advance_Width_Max; /* advance width maximum */ + + FT_Short min_Left_Side_Bearing; /* minimum left-sb */ + FT_Short min_Right_Side_Bearing; /* minimum right-sb */ + FT_Short xMax_Extent; /* xmax extents */ + FT_Short caret_Slope_Rise; + FT_Short caret_Slope_Run; + FT_Short caret_Offset; + + FT_Short Reserved[4]; + + FT_Short metric_Data_Format; + FT_UShort number_Of_HMetrics; + + /* The following fields are not defined by the OpenType specification */ + /* but they are used to connect the metrics header to the relevant */ + /* `hmtx' table. */ + + void* long_metrics; + void* short_metrics; + + } TT_HoriHeader; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_VertHeader */ + /* */ + /* <Description> */ + /* A structure used to model a TrueType vertical header, the `vhea' */ + /* table, as well as the corresponding vertical metrics table, */ + /* `vmtx'. */ + /* */ + /* <Fields> */ + /* Version :: The table version. */ + /* */ + /* Ascender :: The font's ascender, i.e., the distance */ + /* from the baseline to the top-most of */ + /* all glyph points found in the font. */ + /* */ + /* This value is invalid in many fonts, as */ + /* it is usually set by the font designer, */ + /* and often reflects only a portion of */ + /* the glyphs found in the font (maybe */ + /* ASCII). */ + /* */ + /* You should use the `sTypoAscender' */ + /* field of the `OS/2' table instead if */ + /* you want the correct one. */ + /* */ + /* Descender :: The font's descender, i.e., the */ + /* distance from the baseline to the */ + /* bottom-most of all glyph points found */ + /* in the font. It is negative. */ + /* */ + /* This value is invalid in many fonts, as */ + /* it is usually set by the font designer, */ + /* and often reflects only a portion of */ + /* the glyphs found in the font (maybe */ + /* ASCII). */ + /* */ + /* You should use the `sTypoDescender' */ + /* field of the `OS/2' table instead if */ + /* you want the correct one. */ + /* */ + /* Line_Gap :: The font's line gap, i.e., the distance */ + /* to add to the ascender and descender to */ + /* get the BTB, i.e., the */ + /* baseline-to-baseline distance for the */ + /* font. */ + /* */ + /* advance_Height_Max :: This field is the maximum of all */ + /* advance heights found in the font. It */ + /* can be used to compute the maximum */ + /* height of an arbitrary string of text. */ + /* */ + /* min_Top_Side_Bearing :: The minimum top side bearing of all */ + /* glyphs within the font. */ + /* */ + /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */ + /* glyphs within the font. */ + /* */ + /* yMax_Extent :: The maximum vertical extent (i.e., the */ + /* `height' of a glyph's bounding box) for */ + /* all glyphs in the font. */ + /* */ + /* caret_Slope_Rise :: The rise coefficient of the cursor's */ + /* slope of the cursor (slope=rise/run). */ + /* */ + /* caret_Slope_Run :: The run coefficient of the cursor's */ + /* slope. */ + /* */ + /* caret_Offset :: The cursor's offset for slanted fonts. */ + /* */ + /* Reserved :: 8~reserved bytes. */ + /* */ + /* metric_Data_Format :: Always~0. */ + /* */ + /* number_Of_VMetrics :: Number of VMetrics entries in the */ + /* `vmtx' table -- this value can be */ + /* smaller than the total number of glyphs */ + /* in the font. */ + /* */ + /* long_metrics :: A pointer into the `vmtx' table. */ + /* */ + /* short_metrics :: A pointer into the `vmtx' table. */ + /* */ + /* <Note> */ + /* For an OpenType variation font, the values of the following fields */ + /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ + /* friends) if the font contains an `MVAR' table: `Ascender', */ + /* `Descender', `Line_Gap', `caret_Slope_Rise', `caret_Slope_Run', */ + /* and `caret_Offset'. */ + /* */ + typedef struct TT_VertHeader_ + { + FT_Fixed Version; + FT_Short Ascender; + FT_Short Descender; + FT_Short Line_Gap; + + FT_UShort advance_Height_Max; /* advance height maximum */ + + FT_Short min_Top_Side_Bearing; /* minimum top-sb */ + FT_Short min_Bottom_Side_Bearing; /* minimum bottom-sb */ + FT_Short yMax_Extent; /* ymax extents */ + FT_Short caret_Slope_Rise; + FT_Short caret_Slope_Run; + FT_Short caret_Offset; + + FT_Short Reserved[4]; + + FT_Short metric_Data_Format; + FT_UShort number_Of_VMetrics; + + /* The following fields are not defined by the OpenType specification */ + /* but they are used to connect the metrics header to the relevant */ + /* `vmtx' table. */ + + void* long_metrics; + void* short_metrics; + + } TT_VertHeader; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_OS2 */ + /* */ + /* <Description> */ + /* A structure to model a TrueType `OS/2' table. All fields comply */ + /* to the OpenType specification. */ + /* */ + /* Note that we now support old Mac fonts that do not include an */ + /* `OS/2' table. In this case, the `version' field is always set to */ + /* 0xFFFF. */ + /* */ + /* <Note> */ + /* For an OpenType variation font, the values of the following fields */ + /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ + /* friends) if the font contains an `MVAR' table: `sCapHeight', */ + /* `sTypoAscender', `sTypoDescender', `sTypoLineGap', `sxHeight', */ + /* `usWinAscent', `usWinDescent', `yStrikeoutPosition', */ + /* `yStrikeoutSize', `ySubscriptXOffset', `ySubScriptXSize', */ + /* `ySubscriptYOffset', `ySubscriptYSize', `ySuperscriptXOffset', */ + /* `ySuperscriptXSize', `ySuperscriptYOffset', and */ + /* `ySuperscriptYSize'. */ + /* */ + /* Possible values for bits in the `ulUnicodeRangeX' fields are given */ + /* by the @TT_UCR_XXX macros. */ + /* */ + + typedef struct TT_OS2_ + { + FT_UShort version; /* 0x0001 - more or 0xFFFF */ + FT_Short xAvgCharWidth; + FT_UShort usWeightClass; + FT_UShort usWidthClass; + FT_UShort fsType; + FT_Short ySubscriptXSize; + FT_Short ySubscriptYSize; + FT_Short ySubscriptXOffset; + FT_Short ySubscriptYOffset; + FT_Short ySuperscriptXSize; + FT_Short ySuperscriptYSize; + FT_Short ySuperscriptXOffset; + FT_Short ySuperscriptYOffset; + FT_Short yStrikeoutSize; + FT_Short yStrikeoutPosition; + FT_Short sFamilyClass; + + FT_Byte panose[10]; + + FT_ULong ulUnicodeRange1; /* Bits 0-31 */ + FT_ULong ulUnicodeRange2; /* Bits 32-63 */ + FT_ULong ulUnicodeRange3; /* Bits 64-95 */ + FT_ULong ulUnicodeRange4; /* Bits 96-127 */ + + FT_Char achVendID[4]; + + FT_UShort fsSelection; + FT_UShort usFirstCharIndex; + FT_UShort usLastCharIndex; + FT_Short sTypoAscender; + FT_Short sTypoDescender; + FT_Short sTypoLineGap; + FT_UShort usWinAscent; + FT_UShort usWinDescent; + + /* only version 1 and higher: */ + + FT_ULong ulCodePageRange1; /* Bits 0-31 */ + FT_ULong ulCodePageRange2; /* Bits 32-63 */ + + /* only version 2 and higher: */ + + FT_Short sxHeight; + FT_Short sCapHeight; + FT_UShort usDefaultChar; + FT_UShort usBreakChar; + FT_UShort usMaxContext; + + /* only version 5 and higher: */ + + FT_UShort usLowerOpticalPointSize; /* in twips (1/20th points) */ + FT_UShort usUpperOpticalPointSize; /* in twips (1/20th points) */ + + } TT_OS2; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_Postscript */ + /* */ + /* <Description> */ + /* A structure to model a TrueType `post' table. All fields comply */ + /* to the OpenType specification. This structure does not reference */ + /* a font's PostScript glyph names; use @FT_Get_Glyph_Name to */ + /* retrieve them. */ + /* */ + /* <Note> */ + /* For an OpenType variation font, the values of the following fields */ + /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ + /* friends) if the font contains an `MVAR' table: `underlinePosition' */ + /* and `underlineThickness'. */ + /* */ + typedef struct TT_Postscript_ + { + FT_Fixed FormatType; + FT_Fixed italicAngle; + FT_Short underlinePosition; + FT_Short underlineThickness; + FT_ULong isFixedPitch; + FT_ULong minMemType42; + FT_ULong maxMemType42; + FT_ULong minMemType1; + FT_ULong maxMemType1; + + /* Glyph names follow in the `post' table, but we don't */ + /* load them by default. */ + + } TT_Postscript; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_PCLT */ + /* */ + /* <Description> */ + /* A structure to model a TrueType `PCLT' table. All fields comply */ + /* to the OpenType specification. */ + /* */ + typedef struct TT_PCLT_ + { + FT_Fixed Version; + FT_ULong FontNumber; + FT_UShort Pitch; + FT_UShort xHeight; + FT_UShort Style; + FT_UShort TypeFamily; + FT_UShort CapHeight; + FT_UShort SymbolSet; + FT_Char TypeFace[16]; + FT_Char CharacterComplement[8]; + FT_Char FileName[6]; + FT_Char StrokeWeight; + FT_Char WidthType; + FT_Byte SerifStyle; + FT_Byte Reserved; + + } TT_PCLT; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_MaxProfile */ + /* */ + /* <Description> */ + /* The maximum profile (`maxp') table contains many max values, which */ + /* can be used to pre-allocate arrays for speeding up glyph loading */ + /* and hinting. */ + /* */ + /* <Fields> */ + /* version :: The version number. */ + /* */ + /* numGlyphs :: The number of glyphs in this TrueType */ + /* font. */ + /* */ + /* maxPoints :: The maximum number of points in a */ + /* non-composite TrueType glyph. See also */ + /* `maxCompositePoints'. */ + /* */ + /* maxContours :: The maximum number of contours in a */ + /* non-composite TrueType glyph. See also */ + /* `maxCompositeContours'. */ + /* */ + /* maxCompositePoints :: The maximum number of points in a */ + /* composite TrueType glyph. See also */ + /* `maxPoints'. */ + /* */ + /* maxCompositeContours :: The maximum number of contours in a */ + /* composite TrueType glyph. See also */ + /* `maxContours'. */ + /* */ + /* maxZones :: The maximum number of zones used for */ + /* glyph hinting. */ + /* */ + /* maxTwilightPoints :: The maximum number of points in the */ + /* twilight zone used for glyph hinting. */ + /* */ + /* maxStorage :: The maximum number of elements in the */ + /* storage area used for glyph hinting. */ + /* */ + /* maxFunctionDefs :: The maximum number of function */ + /* definitions in the TrueType bytecode for */ + /* this font. */ + /* */ + /* maxInstructionDefs :: The maximum number of instruction */ + /* definitions in the TrueType bytecode for */ + /* this font. */ + /* */ + /* maxStackElements :: The maximum number of stack elements used */ + /* during bytecode interpretation. */ + /* */ + /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */ + /* used for glyph hinting. */ + /* */ + /* maxComponentElements :: The maximum number of simple (i.e., non- */ + /* composite) glyphs in a composite glyph. */ + /* */ + /* maxComponentDepth :: The maximum nesting depth of composite */ + /* glyphs. */ + /* */ + /* <Note> */ + /* This structure is only used during font loading. */ + /* */ + typedef struct TT_MaxProfile_ + { + FT_Fixed version; + FT_UShort numGlyphs; + FT_UShort maxPoints; + FT_UShort maxContours; + FT_UShort maxCompositePoints; + FT_UShort maxCompositeContours; + FT_UShort maxZones; + FT_UShort maxTwilightPoints; + FT_UShort maxStorage; + FT_UShort maxFunctionDefs; + FT_UShort maxInstructionDefs; + FT_UShort maxStackElements; + FT_UShort maxSizeOfInstructions; + FT_UShort maxComponentElements; + FT_UShort maxComponentDepth; + + } TT_MaxProfile; + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_Sfnt_Tag */ + /* */ + /* <Description> */ + /* An enumeration to specify indices of SFNT tables loaded and parsed */ + /* by FreeType during initialization of an SFNT font. Used in the */ + /* @FT_Get_Sfnt_Table API function. */ + /* */ + /* <Values> */ + /* FT_SFNT_HEAD :: To access the font's @TT_Header structure. */ + /* */ + /* FT_SFNT_MAXP :: To access the font's @TT_MaxProfile structure. */ + /* */ + /* FT_SFNT_OS2 :: To access the font's @TT_OS2 structure. */ + /* */ + /* FT_SFNT_HHEA :: To access the font's @TT_HoriHeader structure. */ + /* */ + /* FT_SFNT_VHEA :: To access the font's @TT_VertHeader structure. */ + /* */ + /* FT_SFNT_POST :: To access the font's @TT_Postscript structure. */ + /* */ + /* FT_SFNT_PCLT :: To access the font's @TT_PCLT structure. */ + /* */ + typedef enum FT_Sfnt_Tag_ + { + FT_SFNT_HEAD, + FT_SFNT_MAXP, + FT_SFNT_OS2, + FT_SFNT_HHEA, + FT_SFNT_VHEA, + FT_SFNT_POST, + FT_SFNT_PCLT, + + FT_SFNT_MAX + + } FT_Sfnt_Tag; + + /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag' */ + /* values instead */ +#define ft_sfnt_head FT_SFNT_HEAD +#define ft_sfnt_maxp FT_SFNT_MAXP +#define ft_sfnt_os2 FT_SFNT_OS2 +#define ft_sfnt_hhea FT_SFNT_HHEA +#define ft_sfnt_vhea FT_SFNT_VHEA +#define ft_sfnt_post FT_SFNT_POST +#define ft_sfnt_pclt FT_SFNT_PCLT + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Sfnt_Table */ + /* */ + /* <Description> */ + /* Return a pointer to a given SFNT table stored within a face. */ + /* */ + /* <Input> */ + /* face :: A handle to the source. */ + /* */ + /* tag :: The index of the SFNT table. */ + /* */ + /* <Return> */ + /* A type-less pointer to the table. This will be NULL in case of */ + /* error, or if the corresponding table was not found *OR* loaded */ + /* from the file. */ + /* */ + /* Use a typecast according to `tag' to access the structure */ + /* elements. */ + /* */ + /* <Note> */ + /* The table is owned by the face object and disappears with it. */ + /* */ + /* This function is only useful to access SFNT tables that are loaded */ + /* by the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for */ + /* a list. */ + /* */ + /* Here an example how to access the `vhea' table: */ + /* */ + /* { */ + /* TT_VertHeader* vert_header; */ + /* */ + /* */ + /* vert_header = */ + /* (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); */ + /* } */ + /* */ + FT_EXPORT( void* ) + FT_Get_Sfnt_Table( FT_Face face, + FT_Sfnt_Tag tag ); + + + /************************************************************************** + * + * @function: + * FT_Load_Sfnt_Table + * + * @description: + * Load any SFNT font table into client memory. + * + * @input: + * face :: + * A handle to the source face. + * + * tag :: + * The four-byte tag of the table to load. Use value~0 if you want + * to access the whole font file. Otherwise, you can use one of the + * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new + * one with @FT_MAKE_TAG. + * + * offset :: + * The starting offset in the table (or file if tag~==~0). + * + * @output: + * buffer :: + * The target buffer address. The client must ensure that the memory + * array is big enough to hold the data. + * + * @inout: + * length :: + * If the `length' parameter is NULL, try to load the whole table. + * Return an error code if it fails. + * + * Else, if `*length' is~0, exit immediately while returning the + * table's (or file) full size in it. + * + * Else the number of bytes to read from the table or file, from the + * starting offset. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If you need to determine the table's length you should first call this + * function with `*length' set to~0, as in the following example: + * + * { + * FT_ULong length = 0; + * + * + * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); + * if ( error ) { ... table does not exist ... } + * + * buffer = malloc( length ); + * if ( buffer == NULL ) { ... not enough memory ... } + * + * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); + * if ( error ) { ... could not load table ... } + * } + * + * Note that structures like @TT_Header or @TT_OS2 can't be used with + * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that + * those structures depend on the processor architecture, with varying + * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian). + * + */ + FT_EXPORT( FT_Error ) + FT_Load_Sfnt_Table( FT_Face face, + FT_ULong tag, + FT_Long offset, + FT_Byte* buffer, + FT_ULong* length ); + + + /************************************************************************** + * + * @function: + * FT_Sfnt_Table_Info + * + * @description: + * Return information on an SFNT table. + * + * @input: + * face :: + * A handle to the source face. + * + * table_index :: + * The index of an SFNT table. The function returns + * FT_Err_Table_Missing for an invalid value. + * + * @inout: + * tag :: + * The name tag of the SFNT table. If the value is NULL, `table_index' + * is ignored, and `length' returns the number of SFNT tables in the + * font. + * + * @output: + * length :: + * The length of the SFNT table (or the number of SFNT tables, depending + * on `tag'). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * While parsing fonts, FreeType handles SFNT tables with length zero as + * missing. + * + */ + FT_EXPORT( FT_Error ) + FT_Sfnt_Table_Info( FT_Face face, + FT_UInt table_index, + FT_ULong *tag, + FT_ULong *length ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_CMap_Language_ID */ + /* */ + /* <Description> */ + /* Return cmap language ID as specified in the OpenType standard. */ + /* Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. */ + /* */ + /* <Input> */ + /* charmap :: */ + /* The target charmap. */ + /* */ + /* <Return> */ + /* The language ID of `charmap'. If `charmap' doesn't belong to an */ + /* SFNT face, just return~0 as the default value. */ + /* */ + /* For a format~14 cmap (to access Unicode IVS), the return value is */ + /* 0xFFFFFFFF. */ + /* */ + FT_EXPORT( FT_ULong ) + FT_Get_CMap_Language_ID( FT_CharMap charmap ); + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_CMap_Format */ + /* */ + /* <Description> */ + /* Return the format of an SFNT `cmap' table. */ + /* */ + /* <Input> */ + /* charmap :: */ + /* The target charmap. */ + /* */ + /* <Return> */ + /* The format of `charmap'. If `charmap' doesn't belong to an SFNT */ + /* face, return -1. */ + /* */ + FT_EXPORT( FT_Long ) + FT_Get_CMap_Format( FT_CharMap charmap ); + + /* */ + + +FT_END_HEADER + +#endif /* TTTABLES_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/freetype/tttags.h b/src_v2/libs/sloth/freetype/freetype2/freetype/tttags.h new file mode 100644 index 0000000..e5cee68 --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/freetype/tttags.h @@ -0,0 +1,121 @@ +/***************************************************************************/ +/* */ +/* tttags.h */ +/* */ +/* Tags for TrueType and OpenType tables (specification only). */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef TTAGS_H_ +#define TTAGS_H_ + + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + +#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' ) +#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' ) +#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) +#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' ) +#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' ) +#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) +#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) +#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' ) +#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' ) +#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) +#define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' ) +#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) +#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) +#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) +#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) +#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) +#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) +#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) +#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) +#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' ) +#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) +#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) +#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) +#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) +#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' ) +#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' ) +#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) +#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' ) +#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' ) +#define TTAG_HVAR FT_MAKE_TAG( 'H', 'V', 'A', 'R' ) +#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' ) +#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' ) +#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) +#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' ) +#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' ) +#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' ) +#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' ) +#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' ) +#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) +#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) +#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) +#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' ) +#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) +#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' ) +#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' ) +#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) +#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' ) +#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' ) +#define TTAG_MVAR FT_MAKE_TAG( 'M', 'V', 'A', 'R' ) +#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) +#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' ) +#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) +#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) +#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) +#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' ) +#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) +#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) +#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' ) +#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' ) +#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' ) +#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' ) +#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) +#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) +#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) +#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) +#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' ) +#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' ) +#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) +#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) +#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) +#define TTAG_VVAR FT_MAKE_TAG( 'V', 'V', 'A', 'R' ) +#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' ) + +/* used by "Keyboard.dfont" on legacy Mac OS X */ +#define TTAG_0xA5kbd FT_MAKE_TAG( 0xA5, 'k', 'b', 'd' ) + +/* used by "LastResort.dfont" on legacy Mac OS X */ +#define TTAG_0xA5lst FT_MAKE_TAG( 0xA5, 'l', 's', 't' ) + + +FT_END_HEADER + +#endif /* TTAGS_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/freetype2/ft2build.h b/src_v2/libs/sloth/freetype/freetype2/ft2build.h new file mode 100644 index 0000000..e7ce99b --- /dev/null +++ b/src_v2/libs/sloth/freetype/freetype2/ft2build.h @@ -0,0 +1,42 @@ +/***************************************************************************/ +/* */ +/* ft2build.h */ +/* */ +/* FreeType 2 build and setup macros. */ +/* */ +/* Copyright 1996-2018 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This is the `entry point' for FreeType header file inclusions. It is */ + /* the only header file which should be included directly; all other */ + /* FreeType header files should be accessed with macro names (after */ + /* including `ft2build.h'). */ + /* */ + /* A typical example is */ + /* */ + /* #include <ft2build.h> */ + /* #include FT_FREETYPE_H */ + /* */ + /*************************************************************************/ + + +#ifndef FT2BUILD_H_ +#define FT2BUILD_H_ + +#include <freetype/config/ftheader.h> + +#endif /* FT2BUILD_H_ */ + + +/* END */ diff --git a/src_v2/libs/sloth/freetype/libfreetype-mac.a b/src_v2/libs/sloth/freetype/libfreetype-mac.a new file mode 100644 index 0000000..8b62b8b Binary files /dev/null and b/src_v2/libs/sloth/freetype/libfreetype-mac.a differ diff --git a/src_v2/libs/sloth/sloth.h b/src_v2/libs/sloth/sloth.h new file mode 100644 index 0000000..9ad0c7b --- /dev/null +++ b/src_v2/libs/sloth/sloth.h @@ -0,0 +1,4121 @@ +#ifndef SLOTH_H +#define SLOTH_H + +// DOCUMENTATION +// +// Bare minimum usage requirements: +// Copy the following into ONE file in your codebase +// +// #define SLOTH_IMPLEMENTATION 1 +// #include "stb_sprintf.h" +// #include "sloth.h" +// +// Examples: +// +// Immediately following this block comment is an example +// of setting sloth.h up with a sokol_app/sokol_gfx environment. +// +// How It Works: +// +// sloth.h exposes an immediate mode interface that allows +// you to write expressive interfaces via simple, composable +// commands. +// +// For example, a button might look like: +// if (my_button(&sloth_ctx).clicked) { +// // respond to button click +// } +// +// Internally, sloth is actually a retained mode ui that +// maintains a tree of widgets which make up the interface. +// That tree is pruned and growns each frame based on the +// immediate mode function calls. +// +// So if on Frame N, you call my_button for the first time +// a widget will be added to the widget tree. +// On Frame N+1, if you call my_button again, the existing +// widget is used. +// On Frame N+2, if you don't call my_button, the widget +// corresponding to the button will be removed from the tree. +// +// This allows for an immediate mode interface (simple, easy to understand) +// that is rendered with arbitrarily complex layout routines +// (expressive, hand tailored). +// +// The one drawback of this is that all user input must happen +// on a one frame delay, since a widget doesn't know its +// size and position until the layout routine has been run, +// which happens at the end of the frame. +// This is usually a small price to pay. + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// TODO +// - CLEANUP +// - remove _OLD functions +// - remove widget_tree_last_addition, since we don't use that anymore? +// (pending) +// +// - copying selected text +// - UTF-8 and UTF-32 Support in fonts and glyphs +// - Glpyh IDs should have an 8 bit family and a 32 bit id, so that +// the id supports utf8 +// - Figure out things like weight and bold/italics for font rendering +// - Widget contents scrolling +// - glyph atlas should use premultiplied alpha +// - if we use a separate texture for different glyph families, is there +// a way we could use one bit alpha mask textures for families that +// only have text glyphs? +// - possibly, we could default to one bit textures until it contains +// an image that has rgb data in it, and then upgrade the texture +// to rgb? +// - popup buffer - a way to push widgets onto a buffer that gets added +// to the vertex buffer later. Either that or a way to make the buffer +// respect z distance to the camera? +// - widget pool growing reallocates in the middle of a frame. We need to +// turn it into a buffer arena +// - Constant line height for text of a particular family +// right now, the line height changes based on if it has a glyph with +// a descender on it or not + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// OPTIMIZATION CANDIDATES: +// +// - widgets currently contain their entire style, layout, and input +// descriptors. Creating pointers to these will make the structure +// size of each widget much smaller (especially as style and layout +// continue to grow). +// - One downside is that you'd want to force users to register +// these descriptors so that they have known memory lifetimes. +// On the other hand, this would also reduce duplicate memory +// storage of the same descriptor. +// - One thing that could work is to hash the descriptors when they +// are provided, and either point to an existing one thats already +// stored, or store the new one. +// This would require some eviction strategy. +// - This might make things like style composability an option +// ie. The default for fields becomes (INHERIT OR DEFAULT) +// On the other hand, having to loop looking upwards in a hierarchy +// isn't great. Maybe at registration time, the actual values for +// every field are computed (a styles parent would have to be known +// at registration time) +// +// - Turn Glyph_Layout's into a discriminated union that serves one of +// several purposes: +// - Describe a glyph +// - Change active font properties like typeface, size, bold, etc. +// (effectively, start a span) +// +// - Long Text - odds are, long blocks of text will not all be visible +// at once. + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// SAMPLE PROGRAM +// + +#if 0 + +TODO + +#endif + + +#ifndef STB_SPRINTF_H_INCLUDE +# error "sloth.h relies on stb_sprintf.h. Include it first." +#endif + +//////// TYPE DEFINITIONS //////// +// NOTE: These allow for the standard +// types to be overridden by outer code +// simply by defining the macro first + +#ifndef Sloth_Char +# define Sloth_Char char +#endif + +#ifndef Sloth_U8 +# define Sloth_U8 unsigned char +#endif + +#ifndef Sloth_U32 +# define Sloth_U32 unsigned int +#endif + +#ifndef Sloth_U64 +# define Sloth_U64 unsigned long long int +#endif + +#ifndef Sloth_S32 +# define Sloth_S32 int +#endif + +#ifndef Sloth_R32 +# define Sloth_R32 float +#endif +#define Sloth_R32_Max 3.402823466e+38f +#define Sloth_R32_Min -3.402823466e+38f + +#ifndef Sloth_Bool +# define Sloth_Bool bool +#endif + +#ifndef Sloth_Function +# define Sloth_Function +#endif + +#ifndef Sloth_Temp_String_Memory_Size +# define Sloth_Temp_String_Memory_Size 512 +#endif + +#ifndef sloth_realloc +Sloth_Function Sloth_U8* +sloth_realloc_wrapper(Sloth_U8* base, Sloth_U32 old_size, Sloth_U32 new_size) +{ + if (new_size == 0) { + free(base); + return 0; + } else { + return (Sloth_U8*)realloc(base, new_size); + } +} +# define sloth_realloc(base, old_size, new_size) sloth_realloc_wrapper((Sloth_U8*)(base), (old_size), (new_size)) +#endif + +#ifndef sloth_free +# define sloth_free(base, size) free(base); +#endif + +#ifndef sloth_assert +# ifdef DEBUG +# define sloth_assert(c) if (!(c)) { do{ *((volatile int*)0) = 0xFFFF; }while(0); } +# else +# define sloth_assert(c) +# endif +#endif + +#define sloth_invalid_code_path sloth_assert(false) +#ifdef DEBUG +# define sloth_invalid_default_case default: { sloth_invalid_code_path; } break; +#else +# define sloth_invalid_default_case default: {} break; +#endif + +#ifndef SLOTH_PROFILE_BEGIN +# define SLOTH_PROFILE_BEGIN +#endif + +//////// DATA TYPES //////// + +typedef struct Sloth_Ctx Sloth_Ctx; + +typedef struct Sloth_ID Sloth_ID; +struct Sloth_ID +{ + Sloth_U32 value; +}; + +typedef struct Sloth_ID_Result Sloth_ID_Result; +struct Sloth_ID_Result +{ + Sloth_ID id; + Sloth_U32 display_len; + Sloth_Char* formatted; +}; + +typedef union Sloth_V2 Sloth_V2; +union Sloth_V2 +{ + struct { + Sloth_R32 x; + Sloth_R32 y; + }; + Sloth_R32 E[2]; +}; + +typedef union Sloth_V4 Sloth_V4; +union Sloth_V4 +{ + struct { + Sloth_R32 x; + Sloth_R32 y; + Sloth_R32 z; + Sloth_R32 w; + }; + struct { + Sloth_R32 r; + Sloth_R32 g; + Sloth_R32 b; + Sloth_R32 a; + }; + Sloth_R32 E[4]; +}; + +typedef union Sloth_Rect Sloth_Rect; +union Sloth_Rect +{ + struct { + Sloth_V2 value_min; + Sloth_V2 value_max; + }; +}; + +enum { + Sloth_Axis_X = 0, + Sloth_Axis_Y = 1, +}; + +// HASHTABLE +// Implementation Details +// - Open Addressing - on collision, the table probes outward looking for +// a suitable empty slot +// - Robin Hood Hashing - when probing, keys that will probe more times +// are stored first, increasing lookup speed. +typedef struct Sloth_Hashtable Sloth_Hashtable; +struct Sloth_Hashtable +{ + Sloth_U32* keys; + Sloth_U8** values; + + // The allocated count of keys and values + // ie. the size of keys is sizeof(U32) * cap; + Sloth_U32 cap; + + // The total number of registered values + Sloth_U32 used; +}; + +// ARENA +// A push buffer arena - only supports push/pop memory and clearing +typedef struct Sloth_Arena Sloth_Arena; +struct Sloth_Arena +{ + char* name; + Sloth_U8** buckets; + Sloth_U32 buckets_cap; + Sloth_U32 buckets_len; + Sloth_U32 bucket_cap; + Sloth_U32 curr_bucket_len; +}; + +typedef struct Sloth_Arena_Loc Sloth_Arena_Loc; +struct Sloth_Arena_Loc +{ + Sloth_U32 bucket_index; + Sloth_U32 bucket_at; // pos in bucket +}; + +typedef union Sloth_Glyph_ID Sloth_Glyph_ID; +union Sloth_Glyph_ID +{ + Sloth_U32 value; + struct { + Sloth_U8 id[3]; + Sloth_U8 family; + }; +}; + +typedef struct Sloth_Font_Weight_Family Sloth_Font_Weight_Family; +struct Sloth_Font_Weight_Family +{ + Sloth_U32 weight; + Sloth_U32 glyph_family; +}; + +#define SLOTH_FONT_WEIGHTS_CAP 8 + +typedef struct Sloth_Font_ID Sloth_Font_ID; +struct Sloth_Font_ID +{ + Sloth_U32 value; + Sloth_U32 weight_index; +}; + +typedef struct Sloth_Font_Metrics Sloth_Font_Metrics; +struct Sloth_Font_Metrics +{ + Sloth_R32 pixel_height; + Sloth_R32 line_height; +}; + +typedef struct Sloth_Font Sloth_Font; +struct Sloth_Font +{ + char name[32]; + Sloth_U8* renderer_data; + Sloth_Font_Metrics metrics; + Sloth_Font_Weight_Family weights[SLOTH_FONT_WEIGHTS_CAP]; + Sloth_U32 weights_len; +}; + +typedef Sloth_U8* Sloth_Font_Renderer_Load_Font(Sloth_Ctx* sloth, Sloth_Font* font, Sloth_U8* font_data, Sloth_U32 font_data_size, Sloth_U32 font_index, Sloth_R32 pixel_height); +typedef Sloth_Glyph_ID Sloth_Font_Renderer_Register_Glyph(Sloth_Ctx* sloth, Sloth_Font_ID font_id, Sloth_U32 codepoint); + +typedef Sloth_U32 Sloth_Glyph_Data_Format; +enum +{ + Sloth_GlyphData_RGBA8, + Sloth_GlyphData_RGB8, + Sloth_GlyphData_Alpha8, +}; + +static Sloth_U32 sloth_glyph_data_format_strides[] = { + 4, // Sloth_GlyphData_RGBA8 + 3, // Sloth_GlyphData_RGB8 + 1, // Sloth_GlyphData_Alpha8 +}; + +typedef struct Sloth_Glyph_Desc Sloth_Glyph_Desc; +struct Sloth_Glyph_Desc +{ + Sloth_U32 family; + Sloth_U32 id; + Sloth_U8* data; + Sloth_U32 width; + Sloth_U32 height; + Sloth_U32 stride; + Sloth_Glyph_Data_Format format; + + Sloth_R32 cursor_to_glyph_start_xoff; + Sloth_R32 cursor_to_next_glyph; + Sloth_R32 baseline_offset_y; + + Sloth_R32 copy_gamma; +}; + +typedef struct Sloth_Glyph Sloth_Glyph; +struct Sloth_Glyph +{ + Sloth_U32 width; + Sloth_U32 height; + Sloth_U32 offset_x; + Sloth_U32 offset_y; + + Sloth_R32 lsb; + Sloth_R32 x_advance; + Sloth_R32 baseline_offset_y; +}; + +typedef struct Sloth_Glyph_Atlas Sloth_Glyph_Atlas; +struct Sloth_Glyph_Atlas +{ + // TODO: Probably want a way to have more than one texture. + Sloth_U8* data; + Sloth_U32 dim; // the texture will always be a power of 2 + Sloth_U32 last_glyph; + Sloth_U32 last_row_first_glyph; + + Sloth_Glyph* glyphs; + Sloth_U32 glyphs_cap; + Sloth_Hashtable glyphs_table; + + Sloth_U8 is_dirty; +}; + +typedef struct Sloth_Glyph_Info Sloth_Glyph_Info; +struct Sloth_Glyph_Info +{ + Sloth_Glyph glyph; + + Sloth_Rect uv; +}; + +typedef void Sloth_Renderer_Atlas_Updated(Sloth_Ctx* sloth); + +typedef Sloth_U8 Sloth_Size_Kind; +enum { + Sloth_SizeKind_None, + Sloth_SizeKind_Pixels, + Sloth_SizeKind_TextContent, + Sloth_SizeKind_PercentOfSelf, // NOTE: not valid for widget width/height fields + Sloth_SizeKind_PercentOfParent, + Sloth_SizeKind_ChildrenSum, + Sloth_SizeKind_Count, +}; + +typedef struct Sloth_Size Sloth_Size; +struct Sloth_Size +{ + Sloth_R32 value; + Sloth_Size_Kind kind; +}; + +typedef union Sloth_Size_Range Sloth_Size_Range; +union Sloth_Size_Range +{ + struct { + Sloth_Size min; + Sloth_Size max; + }; + Sloth_Size E[2]; +}; + +typedef union Sloth_Size_Box Sloth_Size_Box; +union Sloth_Size_Box +{ + struct { + // @Maintenance + // left & right correspond to E[Sloth_Axis_X].min and E[Sloth_Axis_X].max + // top & bottom correspond to E[Sloth_Axis_Y].min and E[Sloth_Axis_Y].max + Sloth_Size left; + Sloth_Size right; + + Sloth_Size top; + Sloth_Size bottom; + }; + Sloth_Size_Range E[2]; +}; + +typedef Sloth_U8 Sloth_Layout_Direction; +enum { + Sloth_LayoutDirection_TopDown, + Sloth_LayoutDirection_BottomUp, + Sloth_LayoutDirection_LeftToRight, + Sloth_LayoutDirection_RightToLeft, +}; + +typedef Sloth_U8 Sloth_Layout_Position_Kind; +enum { + // The parent elements Sloth_Layout_Direction value + // dictates how this child gets layed out. Subsequent + // siblings will reference this widget's position to + // determine their position + Sloth_LayoutPosition_ParentDecides, + + // The widget's margin.top and margin.left are used to + // offset this widget from its parents top and left. + // Subsequent siblings will ignore this widget in their + // layout passes + Sloth_LayoutPosition_FixedInParent, + + // The widget's margin.top and margin.left are used to + // offset this widget from the top and left of the screen + // Subsequent siblings will ignore this widget in their + // layout passes + Sloth_LayoutPosition_FixedOnScreen, +}; + +typedef struct Sloth_Layout_Position Sloth_Layout_Position; +struct Sloth_Layout_Position +{ + Sloth_Layout_Position_Kind kind; + union { + Sloth_Size_Box at; + struct { + Sloth_Size left; + Sloth_Size right; + Sloth_Size top; + Sloth_Size bottom; + }; + }; + Sloth_R32 z; +}; + +typedef struct Sloth_Widget_Layout Sloth_Widget_Layout; +struct Sloth_Widget_Layout +{ + union { + struct { + Sloth_Size width; + Sloth_Size height; + }; + Sloth_Size size[2]; + }; + + Sloth_Size_Box margin; + + Sloth_Layout_Direction direction; + Sloth_Layout_Position position; +}; + +typedef Sloth_U32 Sloth_Text_Style_Flags; +enum +{ + Sloth_TextStyle_Defaults = 0, + + // Alignment + Sloth_TextStyle_Align_Left = 1, + Sloth_TextStyle_Align_Center = 2, + Sloth_TextStyle_Align_Right = 4, + + // Wrapping + // default is to wrap + Sloth_TextStyle_NoWrapText = 8, +}; + +typedef struct Sloth_Widget_Style Sloth_Widget_Style; +struct Sloth_Widget_Style +{ + Sloth_U32 color_bg; + Sloth_U32 color_text; + Sloth_U32 color_outline; + + Sloth_Glyph_ID bg_glyph; + + Sloth_R32 outline_thickness; + + // Top Left, Top Right, Bottom Right, Bottom Left + Sloth_Size border_radius[4]; + + Sloth_Text_Style_Flags text_style; +}; + +typedef Sloth_U32 Sloth_Widget_Input_Flags; +enum +{ + Sloth_WidgetInput_None = 0, + Sloth_WidgetInput_Draggable = 1, + Sloth_WidgetInput_TextSelectable = 2, + Sloth_WidgetInput_TextCursor = 4, + Sloth_WidgetInput_DoNotCaptureMouse = 8, +}; + +typedef struct Sloth_Widget_Input Sloth_Widget_Input; +struct Sloth_Widget_Input +{ + Sloth_Widget_Input_Flags flags; +}; + +typedef struct Sloth_Widget_Desc Sloth_Widget_Desc; +struct Sloth_Widget_Desc +{ + Sloth_Widget_Layout layout; + Sloth_Widget_Style style; + Sloth_Widget_Input input; +}; + +typedef struct Sloth_Glyph_Layout Sloth_Glyph_Layout; +struct Sloth_Glyph_Layout +{ + Sloth_Glyph_ID glyph_id; + Sloth_Glyph_Info info; + Sloth_Rect bounds; + Sloth_U32 color; + + // TODO: Hanging bytes, could be much better used space + // will take care of later + Sloth_U8 draw; + Sloth_U8 is_line_start; + Sloth_U8 selected; +}; + +typedef struct Sloth_Widget_Cached Sloth_Widget_Cached; +struct Sloth_Widget_Cached +{ + Sloth_U8 canary_start_; + + // Effective Desc + // Fields that are used during interaction + // These are cached from the previous frame + Sloth_V2 offset; // offset from parent origin + Sloth_V2 dim; // pixel dimensions + Sloth_Rect bounds; + + // only used if in free list + Sloth_Widget_Cached* free_next; + + Sloth_U8 canary_end_; +}; + +typedef struct Sloth_Widget Sloth_Widget; +struct Sloth_Widget +{ + char* str; // TEMP + + // Tree Structuring + Sloth_Widget* child_first; + Sloth_Widget* child_last; + Sloth_Widget* sibling_next; + Sloth_Widget* sibling_prev; + Sloth_Widget* parent; + + Sloth_ID id; + Sloth_U32 touched_last_frame; + + Sloth_Widget_Cached* cached; + + // Primed Desc + // Fields that describe how to render the + // widget, and which will be used for interaction + // next frame + Sloth_Widget_Layout layout; + Sloth_Widget_Style style; + Sloth_Widget_Input input; + + Sloth_Glyph_Layout* text; + Sloth_U32 text_len; + Sloth_V2 text_dim; +}; + +typedef struct Sloth_Widget_Pool Sloth_Widget_Pool; +struct Sloth_Widget_Pool +{ + Sloth_Widget* values; + Sloth_U32 cap; + Sloth_U32 len; + + Sloth_Widget* free_list; +}; + +typedef struct Sloth_Widget_Cached_Pool Sloth_Widget_Cached_Pool; +struct Sloth_Widget_Cached_Pool +{ + Sloth_Widget_Cached** buckets; + Sloth_U32 buckets_cap; + Sloth_U32 buckets_len; + Sloth_U32 bucket_at; + Sloth_U32 bucket_at_len; + Sloth_U32 bucket_cap; + + Sloth_Widget_Cached* free_list; +}; + +typedef struct Sloth_Widget_Result Sloth_Widget_Result; +struct Sloth_Widget_Result +{ + Sloth_Widget* widget; + + // mouse input + Sloth_U8 released; + Sloth_U8 clicked; + Sloth_U8 held; + Sloth_V2 drag_offset_pixels; + Sloth_V2 drag_offset_percent_parent; + + // text input + Sloth_U32 selected_glyphs_first; + Sloth_U32 selected_glyphs_one_past_last; + Sloth_U32 glyph_cursor_pos; +}; + +#define SLOTH_VERTEX_STRIDE 9 + +typedef struct Sloth_VIBuffer Sloth_VIBuffer; +struct Sloth_VIBuffer +{ + Sloth_R32* verts; + Sloth_U32 verts_cap; + Sloth_U32 verts_len; + + Sloth_U32* indices; + Sloth_U32 indices_cap; + Sloth_U32 indices_len; +}; + +enum { + SLOTH_DEBUG_DID_CALL_ADVANCE, + SLOTH_DEBUG_DID_CALL_PREPARE, +}; + +typedef Sloth_U8 Sloth_Mouse_State; +enum { + Sloth_MouseState_None = 0, + Sloth_MouseState_IsDown = 1, + Sloth_MouseState_WasDown = 2, +}; + +typedef void Sloth_Render_VIBuffer(Sloth_Ctx* sloth, Sloth_VIBuffer buffer); + +struct Sloth_Ctx +{ + Sloth_Arena per_frame_memory; + Sloth_Arena scratch; + + Sloth_Widget_Pool widgets; + Sloth_Widget_Cached_Pool widget_caches; + Sloth_Hashtable widget_cache_lut; + + // Fonts + Sloth_U8* font_renderer_data; + Sloth_Font_Renderer_Load_Font* font_renderer_load_font; + Sloth_Font_Renderer_Register_Glyph* font_renderer_register_glyph; + Sloth_Font* fonts; + Sloth_U32 fonts_cap; + Sloth_U32 fonts_len; + + // the actual root of the current tree + Sloth_Widget* widget_tree_root; + + Sloth_Widget* widget_tree_parent_cur; + Sloth_Widget* widget_tree_last_addition; + + // what the tree expects the next child will + // be, based on the tree layout cached from the + // previous frame. + Sloth_Widget* widget_tree_next_child; + Sloth_U32 widget_tree_depth_cur; + Sloth_U32 widget_tree_depth_max; + + // Glyphs & Fonts + Sloth_Glyph_Atlas glyph_atlas; + Sloth_Font_ID active_text_glyph_family; + Sloth_Renderer_Atlas_Updated* renderer_atlas_updated; + + // The geometry to render this frame + Sloth_VIBuffer vibuf; + Sloth_U8* render_data; + + // Input Tracking + Sloth_V2 screen_dim; + Sloth_V2 mouse_pos; + Sloth_Mouse_State mouse_button_l; + Sloth_Mouse_State mouse_button_r; + Sloth_V2 mouse_down_pos; + + // + Sloth_ID last_active_widget; + Sloth_ID hot_widget; + Sloth_U8 hot_widget_age; + Sloth_ID active_widget; + Sloth_U8 active_widget_age; + Sloth_U32 active_widget_selected_glyphs_first; + Sloth_U32 active_widget_selected_glyphs_one_past_last; + + // Debug checks + Sloth_U32 sentinel; +}; + +//////// INTERFACE //////// + +// Sloth Id Generation +// An Id will be constructed by hashing the string provided +// If ## appears in the input string, everything before the ## +// will be returned as a display string; +// If ### appears in the input string, the id will be constructed +// only of everything after the ###. +Sloth_Function Sloth_ID_Result sloth_make_id_v(Sloth_Char* fmt, va_list args); +Sloth_Function Sloth_ID_Result sloth_make_id_f(Sloth_Char* fmt, ...); +Sloth_Function Sloth_ID_Result sloth_make_id_len(Sloth_U32 len, Sloth_Char* str); +Sloth_Function Sloth_ID_Result sloth_make_id(Sloth_Char* str); +Sloth_Function Sloth_Bool sloth_ids_equal(Sloth_ID a, Sloth_ID b); + +// Sloth Vector and Rect +Sloth_Function Sloth_V2 sloth_make_v2(Sloth_R32 x, Sloth_R32 y); +Sloth_Function Sloth_V2 sloth_v2_add(Sloth_V2 a, Sloth_V2 b); +Sloth_Function Sloth_V2 sloth_v2_sub(Sloth_V2 a, Sloth_V2 b); +Sloth_Function Sloth_V2 sloth_v2_mulf(Sloth_V2 a, Sloth_R32 b); + +Sloth_Function Sloth_Rect sloth_rect_union(Sloth_Rect a, Sloth_Rect b); +Sloth_Function void sloth_rect_expand(Sloth_Rect* target, Sloth_R32 left, Sloth_R32 top, Sloth_R32 right, Sloth_R32 bottom); +Sloth_Function Sloth_V2 sloth_rect_dim(Sloth_Rect r); +Sloth_Function Sloth_Bool sloth_rect_contains(Sloth_Rect r, Sloth_V2 p); +Sloth_Function Sloth_V2 sloth_rect_get_closest_point(Sloth_Rect r, Sloth_V2 p); + +// Size Functions +Sloth_Function Sloth_Size sloth_size(Sloth_Size_Kind k, Sloth_R32 v); +Sloth_Function Sloth_Size sloth_size_pixels(Sloth_R32 v); +Sloth_Function Sloth_Size sloth_size_text_content(); +Sloth_Function Sloth_Size sloth_size_percent_parent(Sloth_R32 v); +Sloth_Function Sloth_Size sloth_size_children_sum(); + +Sloth_Function Sloth_Size_Box sloth_size_box_uniform(Sloth_Size_Kind k, Sloth_R32 v); +Sloth_Function Sloth_Size_Box sloth_size_box_uniform_pixels(Sloth_R32 v); + +// Hashtable Functions +Sloth_Function void sloth_hashtable_add(Sloth_Hashtable* table, Sloth_U32 key, Sloth_U8* value); +Sloth_Function Sloth_Bool sloth_hashtable_rem(Sloth_Hashtable* table, Sloth_U32 key); +Sloth_Function Sloth_U8* sloth_hashtable_get(Sloth_Hashtable* table, Sloth_U32 key); +Sloth_Function void sloth_hashtable_free(Sloth_Hashtable* table); + +// Arena Functions +Sloth_Function void sloth_arena_grow(Sloth_Arena* arena, Sloth_U32 min_size); + +// convenience function that auto casts to a type size +#define sloth_arena_push_array(arena, type, count) (type*)sloth_arena_push((arena), sizeof(type) * (count)) +Sloth_Function Sloth_U8* sloth_arena_push(Sloth_Arena* arena, Sloth_U32 size); + +Sloth_Function void sloth_arena_pop(Sloth_Arena* arena, Sloth_Arena_Loc to); +Sloth_Function Sloth_Arena_Loc sloth_arena_at(Sloth_Arena* arena); +Sloth_Function void sloth_arena_clear(Sloth_Arena* arena); +Sloth_Function void sloth_arena_free(Sloth_Arena* arena); + +// Fonts +Sloth_Function Sloth_Font_ID sloth_font_load_from_memory(Sloth_Ctx* sloth, char* font_name, Sloth_U32 font_name_len, Sloth_U8* data, Sloth_U32 data_size, Sloth_R32 pixel_height); +Sloth_Function Sloth_Font_ID sloth_font_register_family(Sloth_Ctx* sloth, Sloth_Font_ID font_id, Sloth_U32 weight, Sloth_U32 family); +Sloth_Function Sloth_Glyph_ID sloth_font_register_codepoint(Sloth_Ctx* sloth, Sloth_Font_ID font_id, Sloth_U32 codepoint); +Sloth_Function Sloth_Font* sloth_glyph_to_font(Sloth_Ctx* sloth, Sloth_Glyph_ID glyph_id); +Sloth_Function void sloth_font_set_metrics(Sloth_Ctx* sloth, Sloth_Font_ID id, Sloth_Font_Metrics metrics); + +// Atlas +Sloth_Function void sloth_glyph_atlas_resize(Sloth_Glyph_Atlas* atlas, Sloth_U32 new_dim); +Sloth_Function Sloth_Glyph_ID sloth_glyph_atlas_register(Sloth_Glyph_Atlas* atlas, Sloth_Glyph_Desc desc); +Sloth_Function void sloth_glyph_atlas_unregister(Sloth_Glyph_Atlas* atlas, Sloth_Glyph_ID id); +Sloth_Function bool sloth_glyph_atlas_contains(Sloth_Glyph_Atlas* atlas, Sloth_Glyph_ID id); +Sloth_Function Sloth_Glyph_Info sloth_glyph_atlas_lookup(Sloth_Glyph_Atlas* atlas, Sloth_Glyph_ID id); +Sloth_Function void sloth_glyph_atlas_free(Sloth_Glyph_Atlas* atlas); +Sloth_Function Sloth_Glyph_ID sloth_make_glyph_id(Sloth_U32 family, Sloth_U32 id); +Sloth_Function bool sloth_glyph_id_matches_charcode(Sloth_Glyph_ID id, Sloth_U32 charcode); + +// Input +Sloth_Function bool sloth_mouse_button_transitioned_down(Sloth_Mouse_State btn); +Sloth_Function bool sloth_mouse_button_transitioned_up (Sloth_Mouse_State btn); +Sloth_Function bool sloth_mouse_button_held_down (Sloth_Mouse_State btn); +Sloth_Function bool sloth_mouse_button_held_up (Sloth_Mouse_State btn); + +// Widget Functions + +// Widget Pool Functions +Sloth_Function Sloth_Widget* sloth_widget_pool_take(Sloth_Ctx* sloth); +Sloth_Function void sloth_widget_pool_give(Sloth_Ctx* sloth, Sloth_Widget* widget); +Sloth_Function void sloth_widget_pool_grow(Sloth_Widget_Pool* pool); +Sloth_Function void sloth_widget_pool_free(Sloth_Widget_Pool* pool); + +// Widget Cached Pool +Sloth_Function Sloth_Widget_Cached* sloth_widget_cached_pool_take(Sloth_Ctx* sloth); +Sloth_Function void sloth_widget_cached_pool_give(Sloth_Ctx* sloth, Sloth_Widget_Cached* widget); +Sloth_Function void sloth_widget_cached_pool_grow(Sloth_Widget_Cached_Pool* pool); +Sloth_Function void sloth_widget_cached_pool_free(Sloth_Widget_Cached_Pool* pool); + + +// Widget Tree Functions +// Construction +Sloth_Function Sloth_Widget* sloth_push_widget_on_tree(Sloth_Ctx* sloth, Sloth_ID id); +Sloth_Function Sloth_Widget* sloth_pop_widget_off_tree(Sloth_Ctx* sloth); +// Walking +typedef void Sloth_Tree_Walk_Cb(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data); +Sloth_Function void sloth_tree_walk_inorder_(Sloth_Ctx* sloth, Sloth_Widget* start, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data); +Sloth_Function void sloth_tree_walk_preorder_(Sloth_Ctx* sloth, Sloth_Widget* start, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data); +Sloth_Function void sloth_tree_walk_postorder_(Sloth_Ctx* sloth, Sloth_Widget* start, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data); +Sloth_Function void sloth_tree_walk_inorder(Sloth_Ctx* sloth, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data); +Sloth_Function void sloth_tree_walk_preorder(Sloth_Ctx* sloth, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data); +Sloth_Function void sloth_tree_walk_postorder(Sloth_Ctx* sloth, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data); + +// Widget Operations +Sloth_Function Sloth_Widget_Result sloth_push_widget_v(Sloth_Ctx* sloth, Sloth_Widget_Desc desc, char* fmt, va_list args); +Sloth_Function Sloth_Widget_Result sloth_push_widget_f(Sloth_Ctx* sloth, Sloth_Widget_Desc desc, char* fmt, ...); +Sloth_Function Sloth_Widget_Result sloth_push_widget(Sloth_Ctx* sloth, Sloth_Widget_Desc desc, char* text); + +// VIBuffer Operations +Sloth_Function void sloth_vibuffer_set_vert(Sloth_VIBuffer* buf, Sloth_U32 vert_index, Sloth_R32 x, Sloth_R32 y, Sloth_R32 z, Sloth_R32 u, Sloth_R32 v, Sloth_V4 c); +Sloth_Function Sloth_U32 sloth_vibuffer_push_vert(Sloth_VIBuffer* buf, Sloth_R32 x, Sloth_R32 y, Sloth_R32 z, Sloth_R32 u, Sloth_R32 v, Sloth_V4 c); +Sloth_Function Sloth_U32 sloth_vibuffer_push_tri(Sloth_VIBuffer* buf, Sloth_U32 a, Sloth_U32 b, Sloth_U32 c); +Sloth_Function void sloth_vibuffer_push_quad(Sloth_VIBuffer* buf, Sloth_U32 a, Sloth_U32 b, Sloth_U32 c, Sloth_U32 d); +Sloth_Function void sloth_vibuffer_free(Sloth_VIBuffer* buf); + +// Ctx Operations +Sloth_Function void sloth_ctx_activate_glyph_family(Sloth_Ctx* sloth, Sloth_U32 family); +Sloth_Function void sloth_ctx_free(Sloth_Ctx* sloth); + +// TODO +// - Convenience functions +// - load_sprite +// - load_font + +//////// IMPLEMENTATION //////// +#ifdef SLOTH_IMPLEMENTATION + +#define sloth_array_grow(base, len, cap, min_cap, ele_type) (ele_type*)sloth_array_grow_((Sloth_U8*)(base), (len), (cap), (min_cap), sizeof(ele_type)) +Sloth_Function Sloth_U8* +sloth_array_grow_(Sloth_U8* base, Sloth_U32 len, Sloth_U32* cap, Sloth_U32 min_cap, Sloth_U32 ele_size) +{ + SLOTH_PROFILE_BEGIN; + if (len < *cap) return base; + + Sloth_U32 new_cap = *cap * 2; + if (new_cap == 0) new_cap = min_cap; + + Sloth_U8* new_base = sloth_realloc( + base, + *cap * ele_size, + new_cap * ele_size + ); + *cap = new_cap; + + return new_base; +} + + +// Temporary string memory +// TODO: Store this in the Sloth_Ctx rather than as a global +static Sloth_U8 sloth_temp_string_memory[Sloth_Temp_String_Memory_Size]; + +#define Sloth_Max(a,b) ((a) > (b) ? (a) : (b)) +#define Sloth_Min(a,b) ((a) < (b) ? (a) : (b)) +#define Sloth_Clamp(lower, v, higher) Sloth_Max(lower, Sloth_Min(higher, v)) + +#define sloth_has_flag(value, flag) (((value) & (flag)) != 0) +#define sloth_floor_r32(v) (Sloth_R32)((int)(v)) + +#define sloth_copy_memory(dst, src, len) sloth_copy_memory_((Sloth_U8*)(dst), (Sloth_U8*)(src), (len)) +Sloth_Function void +sloth_copy_memory_(Sloth_U8* dst, Sloth_U8* src, Sloth_U32 len) +{ + SLOTH_PROFILE_BEGIN; + for (Sloth_U32 i = 0; i < len; i++) dst[i] = src[i]; +} + +#define sloth_is_pow2(a) (!((Sloth_U32)(a) & ((Sloth_U32)(a) - 1))) + +Sloth_Function Sloth_ID_Result +sloth_make_id_v(Sloth_Char* fmt, va_list args) +{ + SLOTH_PROFILE_BEGIN; + Sloth_U32 len = (Sloth_U32)stbsp_vsnprintf( + (char*)sloth_temp_string_memory, + Sloth_Temp_String_Memory_Size, + (char*)fmt, + args + ); + + // Break up formatted string into its parts + // (what to display, what to discard) + Sloth_U32 discard_to = 0; + Sloth_U32 display_before = len; + for (Sloth_U32 i = 0; i < len; i++) + { + if (sloth_temp_string_memory[i] == '#') { + if (i + 1 < len && sloth_temp_string_memory[i + 1] == '#') + { + if (i + 2 < len && sloth_temp_string_memory[i + 2] == '#' && (i + 3) > discard_to) + { + discard_to = i + 3; + display_before = i; + i += 2; + } + else if (i < display_before) + { + display_before = i; + } + } + } + } + + // Hash the non-discarded formatted string + // djb2 hash - http://www.cse.yorku.ca/~oz/hash.html + Sloth_U32 hash = 5381; + for (Sloth_U32 i = discard_to; i < len; i++) + { + hash = ((hash << 5) + hash) + (Sloth_U8)sloth_temp_string_memory[i]; + } + + Sloth_ID_Result result; + result.id.value = hash; + result.display_len = display_before; + result.formatted = (Sloth_Char*)&sloth_temp_string_memory[0]; + return result; +} + +Sloth_Function Sloth_ID_Result +sloth_make_id_f(Sloth_Char* fmt, ...) +{ + SLOTH_PROFILE_BEGIN; + va_list args; + va_start(args, fmt); + Sloth_ID_Result result = sloth_make_id_v(fmt, args); + va_end(args); + return result; +} + +Sloth_Function Sloth_ID_Result +sloth_make_id_len(Sloth_U32 len, Sloth_Char* str) +{ + SLOTH_PROFILE_BEGIN; + Sloth_ID_Result result = sloth_make_id_f((char*)"%.*s", len, str); + return result; +} + +Sloth_Function Sloth_ID_Result +sloth_make_id(Sloth_Char* str) +{ + SLOTH_PROFILE_BEGIN; + Sloth_ID_Result result = sloth_make_id_f((char*)"%s", str); + return result; +} + +Sloth_Function Sloth_Bool +sloth_ids_equal(Sloth_ID a, Sloth_ID b) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Bool result = a.value == b.value; + return result; +} + +Sloth_Function Sloth_V2 +sloth_make_v2(Sloth_R32 x, Sloth_R32 y) +{ + SLOTH_PROFILE_BEGIN; + Sloth_V2 result; + result.x = x; + result.y = y; + return result; +} + +Sloth_Function Sloth_V2 +sloth_v2_add(Sloth_V2 a, Sloth_V2 b) +{ + SLOTH_PROFILE_BEGIN; + Sloth_V2 result; + result.x = a.x + b.x; + result.y = a.y + b.y; + return result; +} + +Sloth_Function Sloth_V2 +sloth_v2_sub(Sloth_V2 a, Sloth_V2 b) +{ + SLOTH_PROFILE_BEGIN; + Sloth_V2 result; + result.x = a.x - b.x; + result.y = a.y - b.y; + return result; +} + +Sloth_Function Sloth_V2 +sloth_v2_mulf(Sloth_V2 a, Sloth_R32 b) +{ + SLOTH_PROFILE_BEGIN; + Sloth_V2 result; + result.x = a.x * b; + result.y = a.y * b; + return result; +} + +Sloth_Function Sloth_V2 +sloth_rect_dim(Sloth_Rect r) +{ + SLOTH_PROFILE_BEGIN; + Sloth_V2 result; + result.x = r.value_max.x - r.value_min.x; + result.y = r.value_max.y - r.value_min.y; + return result; +} + +Sloth_Function Sloth_Rect +sloth_rect_union(Sloth_Rect a, Sloth_Rect b) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Rect result; + result.value_min.x = Sloth_Max(a.value_min.x, b.value_min.x); + result.value_min.y = Sloth_Max(a.value_min.y, b.value_min.y); + result.value_max.x = Sloth_Min(a.value_max.x, b.value_max.x); + result.value_max.y = Sloth_Min(a.value_max.y, b.value_max.y); + Sloth_V2 result_dim = sloth_rect_dim(result); + if (result_dim.x < 0 || result_dim.y < 0) { + result.value_min.x = 0; result.value_min.y = 0; + result.value_max.x = 0; result.value_max.y = 0; + } + return result; +} + +Sloth_Function void +sloth_rect_expand(Sloth_Rect* target, Sloth_R32 left, Sloth_R32 top, Sloth_R32 right, Sloth_R32 bottom) +{ + SLOTH_PROFILE_BEGIN; + target->value_min.x -= left; + target->value_min.y -= top; + target->value_max.x += right; + target->value_max.y += bottom; +} + +Sloth_Function Sloth_Bool +sloth_rect_contains(Sloth_Rect r, Sloth_V2 p) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Bool result = ( + p.x >= r.value_min.x && p.x <= r.value_max.x && + p.y >= r.value_min.y && p.y <= r.value_max.y + ); + return result; +} + +Sloth_Function Sloth_V2 +sloth_rect_get_closest_point(Sloth_Rect r, Sloth_V2 p) +{ + SLOTH_PROFILE_BEGIN; + Sloth_V2 result = p; + result.x = Sloth_Max(r.value_min.x, Sloth_Min(r.value_max.x, p.x)); + result.y = Sloth_Max(r.value_min.y, Sloth_Min(r.value_max.y, p.y)); + return result; +} + +Sloth_Function Sloth_Size +sloth_size(Sloth_Size_Kind k, Sloth_R32 v) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Size result; + result.value = v; + result.kind = k; + return result; +} + +Sloth_Function Sloth_Size +sloth_size_pixels(Sloth_R32 v) +{ + SLOTH_PROFILE_BEGIN; + return sloth_size(Sloth_SizeKind_Pixels, v); +} + +Sloth_Function Sloth_Size +sloth_size_text_content() +{ + SLOTH_PROFILE_BEGIN; + return sloth_size(Sloth_SizeKind_TextContent, 0); +} + +Sloth_Function Sloth_Size +sloth_size_percent_parent(Sloth_R32 v) +{ + SLOTH_PROFILE_BEGIN; + return sloth_size(Sloth_SizeKind_PercentOfParent, v); +} + +Sloth_Function Sloth_Size +sloth_size_children_sum() +{ + SLOTH_PROFILE_BEGIN; + return sloth_size(Sloth_SizeKind_ChildrenSum, 0); +} + +Sloth_Function Sloth_Size_Box +sloth_size_box_uniform(Sloth_Size_Kind k, Sloth_R32 v) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Size_Box result; + result.left = sloth_size(k, v); + result.right = result.left; + result.top = result.left; + result.bottom = result.left; + return result; +} + +Sloth_Function Sloth_Size_Box +sloth_size_box_uniform_pixels(Sloth_R32 v) +{ + SLOTH_PROFILE_BEGIN; + return sloth_size_box_uniform(Sloth_SizeKind_Pixels, v); +} + +#define sloth_zero_struct_(ptr) sloth_zero_size__(sizeof(*ptr), (Sloth_U8*)(ptr)); +Sloth_Function void +sloth_zero_size__(Sloth_U32 size, Sloth_U8* base) +{ + for (Sloth_U32 i = 0; i < size; i++) base[i] = 0; +} + +Sloth_Function void +sloth_hashtable_realloc(Sloth_Hashtable* table, Sloth_U32 old_cap, Sloth_U32 new_cap) +{ + table->keys = (Sloth_U32*)sloth_realloc( + table->keys, old_cap, sizeof(Sloth_U32) * new_cap); + table->values = (Sloth_U8**)sloth_realloc( + table->values, old_cap, sizeof(Sloth_U8*) * new_cap + ); + + Sloth_U32 indices_to_zero = new_cap - old_cap; + sloth_zero_size__( + sizeof(Sloth_U32) * indices_to_zero, + (Sloth_U8*)(table->keys + old_cap) + ); + sloth_zero_size__( + sizeof(Sloth_U8*) * indices_to_zero, + (Sloth_U8*)(table->values + old_cap) + ); + + table->cap = new_cap; +} + +#define SLOTH_HASHTABLE_TOMBSTONE (1 << 31) +// Since this hashtable takes any 32 bit integer as a key, this +// macro simply masks off the tombstone bit if it was present +#define SLOTH_HASHTABLE_VALIDATE_KEY(key) ((key) & ~SLOTH_HASHTABLE_TOMBSTONE) + +#define SLOTH_HASHTABLE_CAP_MASK(table) ((table)->cap - 1) + +// effectively key % table->cap +// this will be true so long as cap is a power of two +Sloth_Function Sloth_U32 +sloth_hashtable_desired_pos(Sloth_Hashtable* table, Sloth_U32 key) +{ + Sloth_U32 result = key & SLOTH_HASHTABLE_CAP_MASK(table); + if (result == 0) result = 1; + return result; +} + +#define SLOTH_HASHTABLE_PROBE_DISTANCE(table, key, pos) (pos) - (sloth_hashtable_desired_pos((table), (key))) + +#define SLOTH_HASHTABLE_KEY_IS_DELETED(key) ((key) & SLOTH_HASHTABLE_TOMBSTONE) + +Sloth_Function void +sloth_hashtable_insert_(Sloth_Hashtable* table, Sloth_U32 key, Sloth_U8* value, Sloth_U32 index) +{ + table->keys[index] = key; + table->values[index] = value; +} + +Sloth_Function void +sloth_hashtable_add(Sloth_Hashtable* table, Sloth_U32 key, Sloth_U8* value) +{ + if (table->cap == 0) sloth_hashtable_realloc(table, 0, 2048); + + Sloth_U32 active_key = SLOTH_HASHTABLE_VALIDATE_KEY(key); + Sloth_U8* active_value = value; + Sloth_U32 index = sloth_hashtable_desired_pos(table, active_key); + Sloth_U32 dist = 0; + for (;;) + { + if (table->keys[index] == 0) + { + sloth_hashtable_insert_(table, active_key, active_value, index); + break; + } + + Sloth_U32 existing_key = table->keys[index]; + Sloth_U32 existing_dist = SLOTH_HASHTABLE_PROBE_DISTANCE( + table, existing_key, index + ); + if (existing_dist < dist) { + if (SLOTH_HASHTABLE_KEY_IS_DELETED(table->keys[index])) + { + sloth_hashtable_insert_(table, active_key, active_value, index); + break; + } + + // swap existing with the insertion and keep probing + Sloth_U8* existing_value = table->values[index]; + table->values[index] = active_value; + table->keys[index] = active_key; + active_key = existing_key; + active_value = existing_value; + dist = existing_dist; + } + + index = (index + 1) & SLOTH_HASHTABLE_CAP_MASK(table); + dist += 1; + } + + table->used += 1; +} + +Sloth_Function Sloth_U32 +sloth_hashtable_lookup_index_(Sloth_Hashtable* table, Sloth_U32 key, bool* is_empty) +{ + if (!table->keys) { + if (is_empty) *is_empty = true; + return 0; + } + key = SLOTH_HASHTABLE_VALIDATE_KEY(key); + Sloth_U32 index = sloth_hashtable_desired_pos(table, key); + while (table->keys[index] != 0 && table->keys[index] != key) { + index = (index + 1) & SLOTH_HASHTABLE_CAP_MASK(table); + } + Sloth_U32 fkey = table->keys[index]; + if (is_empty) { + if (fkey == 0) *is_empty = true; + if (SLOTH_HASHTABLE_KEY_IS_DELETED(fkey)) *is_empty = true; + } else { + if (fkey == 0) return 0; + if (SLOTH_HASHTABLE_KEY_IS_DELETED(fkey)) return 0; + } + return index; +} + +Sloth_Function Sloth_Bool +sloth_hashtable_rem(Sloth_Hashtable* table, Sloth_U32 key) +{ + bool unused = false; + Sloth_U32 index = sloth_hashtable_lookup_index_(table, key, &unused); + if (index == 0) return false; + table->keys[index] = table->keys[index] | SLOTH_HASHTABLE_TOMBSTONE; + table->values[index] = 0; + table->used -= 1; + return true; +} + +Sloth_Function Sloth_U8* +sloth_hashtable_get(Sloth_Hashtable* table, Sloth_U32 key) +{ + Sloth_U32 index = sloth_hashtable_lookup_index_(table, key, 0); + if (index == 0) return 0; + return table->values[index]; +} + +Sloth_Function void +sloth_hashtable_free(Sloth_Hashtable* table) +{ + Sloth_U8* unused; + unused = sloth_realloc(table->keys, sizeof(Sloth_U32) * table->cap, 0); + unused = sloth_realloc(table->values, table->cap, 0); +} + +Sloth_Function void +sloth_arena_grow(Sloth_Arena* arena, Sloth_U32 min_size) +{ + SLOTH_PROFILE_BEGIN; + printf("Growing arena: %s\n", arena->name); + if (!arena->buckets) { + arena->buckets = sloth_array_grow(arena->buckets, 0, &arena->buckets_cap, 64, Sloth_U8*); + sloth_zero_size__(sizeof(Sloth_U8*) * 64, (Sloth_U8*)arena->buckets); + arena->buckets_len = 0; + arena->bucket_cap = 1024 * 1024; // 1 MB + arena->curr_bucket_len = 0; + } + if (arena->curr_bucket_len + min_size >= arena->bucket_cap) + { + arena->buckets_len += 1; + } + sloth_assert(arena->buckets_len < arena->buckets_cap); + if (!arena->buckets[arena->buckets_len]) { + Sloth_U32 unused = 0; + arena->buckets[arena->buckets_len] = sloth_array_grow(arena->buckets[arena->buckets_len], 0, &unused, Sloth_Max(arena->bucket_cap, min_size), Sloth_U8); + arena->curr_bucket_len = 0; + } +} + +Sloth_Function Sloth_U8* +sloth_arena_push(Sloth_Arena* arena, Sloth_U32 size) +{ + SLOTH_PROFILE_BEGIN; + if (arena->curr_bucket_len + size > arena->bucket_cap) sloth_arena_grow(arena, size); + + Sloth_U8* bucket = arena->buckets[arena->buckets_len]; + Sloth_U8* result = bucket + arena->curr_bucket_len; + arena->curr_bucket_len += size; + + return result; +} + +Sloth_Function void +sloth_arena_pop(Sloth_Arena* arena, Sloth_Arena_Loc to) +{ + SLOTH_PROFILE_BEGIN; + if (to.bucket_index > arena->buckets_cap) return; + if (to.bucket_index > arena->buckets_len) return; + if (to.bucket_at > arena->bucket_cap) return; + if (to.bucket_index == arena->buckets_len && to.bucket_at > arena->curr_bucket_len) return; + + Sloth_U32 bucket_before = arena->buckets_len; + Sloth_U32 bucket_before_len = arena->curr_bucket_len; + + arena->buckets_len = to.bucket_index; + arena->curr_bucket_len = to.bucket_at; + + if (to.bucket_index == bucket_before) + { + Sloth_U32 rewind_dist = bucket_before_len - to.bucket_at; + Sloth_U8* old_at = arena->buckets[arena->buckets_len] + to.bucket_at; + sloth_zero_size__(rewind_dist, old_at); + } + else if (to.bucket_index < bucket_before) + { + // clear all buckets back to the current one (excluding the current one + for (Sloth_U32 i = bucket_before; i > to.bucket_index && i < bucket_before; i--) + { + sloth_zero_size__(arena->bucket_cap, arena->buckets[i]); + } + // clear the current one back to the current point + sloth_zero_size__(arena->bucket_cap - to.bucket_at, arena->buckets[arena->buckets_len] + to.bucket_at); + } + else + { + sloth_invalid_code_path; + } +} + +Sloth_Function Sloth_Arena_Loc +sloth_arena_at(Sloth_Arena* arena) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Arena_Loc result; + result.bucket_index = arena->buckets_len; + result.bucket_at = arena->curr_bucket_len; + return result;; +} + +Sloth_Function void +sloth_arena_clear(Sloth_Arena* arena) +{ + SLOTH_PROFILE_BEGIN; + arena->buckets_len = 0; + arena->curr_bucket_len = 0; + + // @DebugClear +#ifdef DEBUG + for (Sloth_U32 i = 0; i < arena->buckets_cap; i++) + { + Sloth_U8* bucket = arena->buckets[i]; + if (bucket) sloth_zero_size__(arena->bucket_cap, bucket); + } +#endif +} + +Sloth_Function void +sloth_arena_free(Sloth_Arena* arena) +{ + SLOTH_PROFILE_BEGIN; + for (Sloth_U32 i = 0; i < arena->buckets_cap; i++) + { + Sloth_U8* bucket = arena->buckets[i]; + if (bucket) { + arena->buckets[i] = sloth_realloc(bucket, arena->bucket_cap, 0); + } + } + arena->buckets = (Sloth_U8**)sloth_realloc(arena->buckets, sizeof(Sloth_U8*) * arena->buckets_cap, 0); + arena->buckets_cap = 0; + arena->buckets_len = 0; + arena->bucket_cap = 0; + arena->curr_bucket_len = 0; +} + +Sloth_Function Sloth_Font_ID +sloth_font_load_from_memory(Sloth_Ctx* sloth, char* font_name, Sloth_U32 font_name_len, Sloth_U8* data, Sloth_U32 data_size, Sloth_R32 pixel_height) +{ + SLOTH_PROFILE_BEGIN; + sloth->fonts = sloth_array_grow(sloth->fonts, sloth->fonts_len, &sloth->fonts_cap, 8, Sloth_Font); + + Sloth_Font_ID result; + result.value = sloth->fonts_len++; + result.weight_index = 0; + + Sloth_Font* new_font = sloth->fonts + result.value; + sloth_zero_struct_(new_font); + sloth_copy_memory_((Sloth_U8*)new_font->name, (Sloth_U8*)font_name, font_name_len); + new_font->renderer_data = sloth->font_renderer_load_font(sloth, new_font, data, data_size, 0, pixel_height); + new_font->metrics.pixel_height = pixel_height; + + return result; +} + +Sloth_Function Sloth_Font* +sloth_font_get_(Sloth_Ctx* sloth, Sloth_Font_ID font_id) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Font* font = sloth->fonts + font_id.value; + return font; +} + +Sloth_Function Sloth_Font_ID +sloth_font_register_family(Sloth_Ctx* sloth, Sloth_Font_ID font_id, Sloth_U32 weight, Sloth_U32 family) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Font* font = sloth_font_get_(sloth, font_id); + sloth_assert(font->weights_len < SLOTH_FONT_WEIGHTS_CAP); + + Sloth_Font_ID result = font_id; + result.weight_index = font->weights_len++; + font->weights[result.weight_index].weight = weight; + font->weights[result.weight_index].glyph_family = family; + + return result; +} + +Sloth_Function Sloth_Glyph_ID +sloth_font_register_codepoint(Sloth_Ctx* sloth, Sloth_Font_ID font_id, Sloth_U32 codepoint) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Glyph_ID result; + sloth_zero_struct_(&result); + if (sloth->font_renderer_register_glyph) { + sloth->font_renderer_register_glyph(sloth, font_id, codepoint); + } + return result; +} + +Sloth_Function Sloth_Font* +sloth_glyph_to_font(Sloth_Ctx* sloth, Sloth_Glyph_ID glyph_id) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Font* result = 0; + for (Sloth_U32 i = 0; i < sloth->fonts_len; i++) + { + Sloth_Font* at = sloth->fonts + i; + for (Sloth_U32 w = 0; w < at->weights_len; w++) + { + if (at->weights[w].glyph_family == glyph_id.family) + { + result = at; + break; + } + } + if (result) break; + } + return result; +} + +Sloth_Function Sloth_Font_Metrics +sloth_font_get_metrics(Sloth_Ctx* sloth, Sloth_Font_ID id) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Font_Metrics result; sloth_zero_struct_(&result); + Sloth_Font* font = sloth_font_get_(sloth, id); + if (!font) return result; + return font->metrics; +} + +Sloth_Function void +sloth_font_set_metrics(Sloth_Ctx* sloth, Sloth_Font_ID id, Sloth_Font_Metrics metrics) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Font* font = sloth_font_get_(sloth, id); + if (!font) return; + font->metrics = metrics; +} + + +Sloth_Function void +sloth_glyph_atlas_resize(Sloth_Glyph_Atlas* atlas, Sloth_U32 new_dim) +{ + SLOTH_PROFILE_BEGIN; + sloth_assert(sloth_is_pow2(new_dim)); + Sloth_U32 new_size = new_dim * new_dim * sizeof(Sloth_U32); + Sloth_U32 old_size = atlas->dim * atlas->dim * sizeof(Sloth_U32); + atlas->data = sloth_realloc(atlas->data, old_size, new_size); + atlas->dim = new_dim; +} + +Sloth_Function Sloth_U32 +sloth_xy_to_texture_offset(Sloth_U32 x, Sloth_U32 y, Sloth_U32 dim, Sloth_U32 bytes_per_pixel) +{ + SLOTH_PROFILE_BEGIN; + return (((y * dim) + x) * bytes_per_pixel); +} +Sloth_Function Sloth_U32 +sloth_xy_to_texture_offset_u32(Sloth_U32 x, Sloth_U32 y, Sloth_U32 dim) +{ + SLOTH_PROFILE_BEGIN; + return sloth_xy_to_texture_offset(x, y, dim, sizeof(Sloth_U32)); +} +Sloth_Function Sloth_U32 +sloth_xy_to_texture_offset_u8(Sloth_U32 x, Sloth_U32 y, Sloth_U32 dim) +{ + SLOTH_PROFILE_BEGIN; + return sloth_xy_to_texture_offset(x, y, dim, sizeof(Sloth_U8)); +} + +Sloth_Function Sloth_U32 +sloth_color_apply_gamma(Sloth_U32 color, Sloth_R32 power) +{ + SLOTH_PROFILE_BEGIN; + if (power == 1) return color; + + Sloth_R32 r = (Sloth_R32)((color >> 24) & 0xFF) / 255.0f; + Sloth_R32 g = (Sloth_R32)((color >> 16) & 0xFF) / 255.0f; + Sloth_R32 b = (Sloth_R32)((color >> 8) & 0xFF) / 255.0f; + Sloth_R32 a = (Sloth_R32)((color ) & 0xFF) / 255.0f; + + Sloth_R32 gamma_r = powf(r, power); + Sloth_R32 gamma_g = powf(g, power); + Sloth_R32 gamma_b = powf(b, power); + Sloth_R32 gamma_a = powf(a, power); + + Sloth_U32 result = (((Sloth_U32)(gamma_r * 255) << 24) | + ((Sloth_U32)(gamma_g * 255) << 16) | + ((Sloth_U32)(gamma_b * 255) << 8) | + ((Sloth_U32)(gamma_a * 255))); + return result; +} + +Sloth_Function Sloth_Glyph_ID +sloth_glyph_atlas_register(Sloth_Glyph_Atlas* atlas, Sloth_Glyph_Desc desc) +{ + SLOTH_PROFILE_BEGIN; + if (!atlas->glyphs || atlas->glyphs_table.used >= atlas->glyphs_cap) + { + atlas->glyphs = sloth_array_grow( + atlas->glyphs, atlas->glyphs_table.used, &atlas->glyphs_cap, 256, Sloth_Glyph + ); + } + + Sloth_Glyph_ID new_glyph_id; + new_glyph_id.value = desc.id & 0x00FFFFFF; + new_glyph_id.family = desc.family & 0xFF; + + // check if this glyph has already been registered + if (sloth_hashtable_lookup_index_(&atlas->glyphs_table, new_glyph_id.value, 0) != 0) { + return new_glyph_id; + } + + Sloth_U32 new_glyph_index = atlas->glyphs_table.used; + Sloth_Glyph* new_glyph = atlas->glyphs + new_glyph_index; + sloth_hashtable_add(&atlas->glyphs_table, new_glyph_id.value, (Sloth_U8*)new_glyph); + + // TODO(PS): glyphs_table.used > 1 is because we've already + // added the new glyph. If its the first glyph, there is no + // previous glyph, but the table has a glyph in it already. + // + Sloth_U32 dst_x = 0; + Sloth_U32 dst_y = 1; + if (atlas->glyphs_table.used > 1) { + Sloth_Glyph last_glyph = atlas->glyphs[atlas->last_glyph]; + dst_x = last_glyph.offset_x + last_glyph.width + 1; // add room for apron + dst_y = last_glyph.offset_y; + } + atlas->last_glyph = new_glyph_index; + + // See if we should create the atlas texture in the first place + if (atlas->dim == 0) + { + sloth_glyph_atlas_resize(atlas, 2048); + } + + // See if we need to move to a new row + Sloth_U32 apron_dim = 2; + if ((dst_x + desc.width + apron_dim) > atlas->dim) + { + Sloth_Glyph first_glyph_in_row = atlas->glyphs[atlas->last_row_first_glyph]; + dst_x = 0; + dst_y = first_glyph_in_row.offset_y + first_glyph_in_row.height + (apron_dim / 2); + atlas->last_row_first_glyph = new_glyph_index; + + if (dst_y + desc.height + (apron_dim / 2) >= atlas->dim) + { + // TODO: I'm punting this case till later. Current implementation + // will auto create the texture with size 2048x2048 if its null, but + // wont grow again beyond that. + // The complexity I don't want to deal with right now is that wehn + // the texture is resized, it either has to: + // a) reflow all existing glyphs (I don't like this) + // b) begin finding the empty space to the right of existing rows + // of glyphs. + // b is the solution I want to go with but I don't want to do that + // right now + + + // NOTE: If this assert fires, you just need to grow your glyph dim + + // TODO: It would be nice if this would just do it for you, or better yet + // do it if we're under some bound (Say 4096) but create a second texture + // if we're above. To do that, it'll also want to make sure things like + // Glyph Families (ie. a font's sprites) are all on one texture + sloth_assert(dst_y + desc.height < atlas->dim); + } + } + + Sloth_U32 apron_x = dst_x; + Sloth_U32 apron_y = dst_y - 1; + dst_x += 1; + + new_glyph->offset_x = dst_x; + new_glyph->offset_y = dst_y; + new_glyph->width = desc.width; + new_glyph->height = desc.height; + new_glyph->lsb = desc.cursor_to_glyph_start_xoff; + new_glyph->x_advance = desc.cursor_to_next_glyph; + new_glyph->baseline_offset_y = desc.baseline_offset_y; + + if (desc.data) + { + Sloth_R32 copy_gamma = 1; + if (desc.copy_gamma != 0) copy_gamma = desc.copy_gamma; + + Sloth_U8* src_row_at = desc.data; + Sloth_U8* dst_row_at = atlas->data + (((dst_y * atlas->dim) + dst_x) * sizeof(Sloth_U32)); + switch (desc.format) + { + case Sloth_GlyphData_RGBA8: + case Sloth_GlyphData_RGB8: + { + Sloth_U32 stride = sloth_glyph_data_format_strides[desc.format]; + for (Sloth_U32 y = dst_y; y < dst_y + desc.height; y++) + { + Sloth_U8* dst_at = dst_row_at; + Sloth_U8* src_at = src_row_at; + for (Sloth_U32 x = dst_x; x < dst_x + desc.width; x++) + { + dst_at[0] = sloth_color_apply_gamma(*src_at++, copy_gamma); + dst_at[1] = sloth_color_apply_gamma(*src_at++, copy_gamma); + dst_at[2] = sloth_color_apply_gamma(*src_at++, copy_gamma); + if (desc.format == Sloth_GlyphData_RGBA8) { + dst_at[3] = sloth_color_apply_gamma(*src_at++, copy_gamma); + } else { + dst_at[3] = 0xFF; + } + dst_at += 4; + } + dst_row_at += atlas->dim * sizeof(Sloth_U32); + src_row_at += desc.stride * stride; + } + } break; + + case Sloth_GlyphData_Alpha8: + { + for (Sloth_U32 y = dst_y; y < dst_y + desc.height; y++) + { + Sloth_U8* dst_at = dst_row_at; + Sloth_U8* src_at = src_row_at; + for (Sloth_U32 x = dst_x; x < dst_x + desc.width; x++) + { + Sloth_U8 alpha = *src_at++; + dst_at[0] = 0xFF; + dst_at[1] = 0xFF; + dst_at[2] = 0xFF; + dst_at[3] = sloth_color_apply_gamma(alpha, copy_gamma);; + dst_at += 4; + } + dst_row_at += atlas->dim * sizeof(Sloth_U32); + src_row_at += desc.stride; + } + } break; + + sloth_invalid_default_case; + } + } + + // Draw the Apron + Sloth_U32 apron_vertical0 = sloth_xy_to_texture_offset_u32(apron_x, apron_y, atlas->dim); + Sloth_U32 apron_vertical1 = sloth_xy_to_texture_offset_u32(apron_x + desc.width + 1, apron_y, atlas->dim); + for (Sloth_U32 apron_y_at = 0; apron_y_at < desc.height + apron_dim; apron_y_at++) + { + Sloth_U32* a0 = (Sloth_U32*)(atlas->data + apron_vertical0); + Sloth_U32* a1 = (Sloth_U32*)(atlas->data + apron_vertical1); + // get the pixel immediately to the inside of the apron and copy its value + // out to the apron + Sloth_U32* g0 = (Sloth_U32*)(atlas->data + apron_vertical0 + sizeof(Sloth_U32)); + Sloth_U32* g1 = (Sloth_U32*)(atlas->data + apron_vertical1 - sizeof(Sloth_U32)); + *a0 = *g0; + *a1 = *g1; + apron_vertical0 += atlas->dim * sizeof(Sloth_U32); + apron_vertical1 += atlas->dim * sizeof(Sloth_U32); + } + + Sloth_U32 apron_horiz0 = sloth_xy_to_texture_offset_u32(apron_x, apron_y, atlas->dim); + Sloth_U32 apron_horiz1 = sloth_xy_to_texture_offset_u32(apron_x, apron_y + desc.height + 1, atlas->dim); + for (Sloth_U32 apron_x_at = 0; apron_x_at < desc.width + apron_dim; apron_x_at++) + { + Sloth_U32* a0 = (Sloth_U32*)(atlas->data + apron_horiz0); + Sloth_U32* a1 = (Sloth_U32*)(atlas->data + apron_horiz1); + // get the pixel immediately to the inside of the apron and copy its value + // out to the apron + Sloth_U32* g0 = (Sloth_U32*)(atlas->data + apron_horiz0 + (atlas->dim * sizeof(Sloth_U32))); + Sloth_U32* g1 = (Sloth_U32*)(atlas->data + apron_horiz1 - (atlas->dim * sizeof(Sloth_U32))); + *a0 = *g0; + *a1 = *g1; + apron_horiz0 += sizeof(Sloth_U32); + apron_horiz1 += sizeof(Sloth_U32); + } + + atlas->is_dirty = true; + return new_glyph_id; +} + +Sloth_Function void +sloth_glyph_atlas_unregister(Sloth_Glyph_Atlas* atlas, Sloth_Glyph_ID id) +{ + SLOTH_PROFILE_BEGIN; + // TODO: + sloth_invalid_code_path; +} + +Sloth_Function bool +sloth_glyph_atlas_contains(Sloth_Glyph_Atlas* atlas, Sloth_Glyph_ID id) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Glyph* glyph = (Sloth_Glyph*)sloth_hashtable_get(&atlas->glyphs_table, id.value); + return (glyph != 0); +} + +Sloth_Function Sloth_Glyph_Info +sloth_glyph_atlas_lookup(Sloth_Glyph_Atlas* atlas, Sloth_Glyph_ID id) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Glyph_Info result; + sloth_zero_struct_(&result); + + Sloth_Glyph* glyph = (Sloth_Glyph*)sloth_hashtable_get(&atlas->glyphs_table, id.value); + if (!glyph) return result; + + result.glyph = *glyph; + result.uv.value_min.x = (Sloth_R32)glyph->offset_x / (Sloth_R32)atlas->dim; + result.uv.value_min.y = (Sloth_R32)glyph->offset_y / (Sloth_R32)atlas->dim; + result.uv.value_max.x = (Sloth_R32)(glyph->offset_x + glyph->width) / (Sloth_R32)atlas->dim; + result.uv.value_max.y = (Sloth_R32)(glyph->offset_y + glyph->height) / (Sloth_R32)atlas->dim; + + return result; +} + +Sloth_Function void +sloth_glyph_atlas_free(Sloth_Glyph_Atlas* atlas) +{ + SLOTH_PROFILE_BEGIN; + Sloth_U8* unused; + unused = sloth_realloc(atlas->data, atlas->dim * atlas->dim, 0); + unused = sloth_realloc(atlas->glyphs, sizeof(Sloth_Glyph) * atlas->glyphs_cap, 0); + sloth_hashtable_free(&atlas->glyphs_table); +} + +Sloth_Function Sloth_Glyph_ID +sloth_make_glyph_id(Sloth_U32 family, Sloth_U32 id) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Glyph_ID result; + result.value = id & 0x00FFFFFF; + result.family = family; + return result; +} + +Sloth_Function bool +sloth_glyph_id_matches_charcode(Sloth_Glyph_ID id, Sloth_U32 charcode) +{ + SLOTH_PROFILE_BEGIN; + Sloth_U32 id_code = (id.id[0] | + id.id[1] << 8 | + id.id[2] << 16); + return id_code == charcode; +} + +Sloth_Function bool +sloth_mouse_button_is_down(Sloth_Mouse_State btn) +{ + SLOTH_PROFILE_BEGIN; + return (btn & Sloth_MouseState_IsDown); +} +Sloth_Function bool +sloth_mouse_button_was_down(Sloth_Mouse_State btn) +{ + SLOTH_PROFILE_BEGIN; + return (btn & Sloth_MouseState_WasDown); +} + +Sloth_Function bool +sloth_mouse_button_transitioned_down(Sloth_Mouse_State btn) +{ + SLOTH_PROFILE_BEGIN; + return sloth_mouse_button_is_down(btn) && !sloth_mouse_button_was_down(btn); +} + +Sloth_Function bool +sloth_mouse_button_transitioned_up (Sloth_Mouse_State btn) +{ + SLOTH_PROFILE_BEGIN; + return !sloth_mouse_button_is_down(btn) && sloth_mouse_button_was_down(btn); +} + +Sloth_Function bool +sloth_mouse_button_held_down (Sloth_Mouse_State btn) +{ + SLOTH_PROFILE_BEGIN; + return sloth_mouse_button_is_down(btn) && sloth_mouse_button_was_down(btn); +} + +Sloth_Function bool +sloth_mouse_button_held_up (Sloth_Mouse_State btn) +{ + SLOTH_PROFILE_BEGIN; + return !sloth_mouse_button_is_down(btn) && !sloth_mouse_button_was_down(btn); +} + +Sloth_Function void +sloth_widget_pool_grow(Sloth_Widget_Pool* pool) +{ + if (pool->len >= pool->cap) printf("growing widget pool\n"); + pool->values = sloth_array_grow( + pool->values, + pool->len, + &pool->cap, + 2048, + Sloth_Widget + ); +} + +Sloth_Function Sloth_Widget* +sloth_widget_pool_take(Sloth_Ctx* sloth) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget* result = 0; + if (!sloth->widgets.free_list) + { + sloth_widget_pool_grow(&sloth->widgets); + result = sloth->widgets.values + sloth->widgets.len++; + } + else + { + result = sloth->widgets.free_list; + sloth->widgets.free_list = result->sibling_next; + } + sloth_zero_struct_(result); + return result; +} + +Sloth_Function void +sloth_widget_pool_give(Sloth_Ctx* sloth, Sloth_Widget* widget) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget* child = widget->child_first; + while (child) { + Sloth_Widget* next = child->sibling_next; + sloth_widget_pool_give(sloth, child); + child = next; + } + + widget->sibling_next = 0; + widget->sibling_next = sloth->widgets.free_list; + sloth->widgets.free_list = widget; +} + +Sloth_Function void +sloth_widget_pool_free(Sloth_Widget_Pool* pool) +{ + SLOTH_PROFILE_BEGIN; + sloth_free((void*)pool->values, sizeof(Sloth_Widget) * pool->cap); + sloth_zero_struct_(pool); +} + +Sloth_Function void +sloth_widget_cached_pool_grow(Sloth_Widget_Cached_Pool* pool) +{ + if (!pool->buckets) { + pool->buckets_cap = 32; + pool->buckets = (Sloth_Widget_Cached**)sloth_realloc((void*)pool->buckets, 0, pool->buckets_cap * sizeof(Sloth_Widget_Cached_Pool*)); + pool->buckets_len = 0; + pool->bucket_at = 0; + pool->bucket_at_len = 0; + pool->bucket_cap = 1024; + sloth_zero_size__(sizeof(Sloth_Widget_Cached_Pool*) * pool->buckets_cap, (Sloth_U8*)pool->buckets); + } + + if (pool->bucket_at_len >= pool->bucket_cap) + { + pool->bucket_at += 1; + pool->bucket_at_len = 0; + } + + if (pool->buckets[pool->bucket_at] == 0) { + Sloth_Widget_Cached** at = pool->buckets + pool->bucket_at_len; + *at = (Sloth_Widget_Cached*)sloth_realloc((void*)*at, 0, pool->bucket_cap * sizeof(Sloth_Widget_Cached_Pool)); + } +} + +Sloth_Function Sloth_Widget_Cached* +sloth_widget_cached_pool_take(Sloth_Ctx* sloth) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget_Cached_Pool* p = &sloth->widget_caches; + Sloth_Widget_Cached* result = 0; + if (!p->free_list) + { + sloth_widget_cached_pool_grow(p); + result = p->buckets[p->bucket_at] + p->bucket_at_len++; + } + else + { + result = p->free_list; + p->free_list = result->free_next; + } + sloth_zero_struct_(result); + return result; +} + +Sloth_Function void +sloth_widget_cached_pool_give(Sloth_Ctx* sloth, Sloth_Widget_Cached* widget) +{ + SLOTH_PROFILE_BEGIN; + widget->free_next = sloth->widget_caches.free_list; + sloth->widget_caches.free_list = widget; +} + +Sloth_Function void +sloth_widget_cached_pool_free(Sloth_Widget_Cached_Pool* pool) +{ + SLOTH_PROFILE_BEGIN; + for (Sloth_U32 i = 0; i < pool->buckets_cap; i++) + { + sloth_free((void*)pool->buckets[i], sizeof(Sloth_Widget_Cached) * pool->bucket_cap); + } + sloth_free((void*)pool->buckets, sizeof(Sloth_Widget_Cached*) * pool->buckets_cap); + sloth_zero_struct_(pool); +} + +#ifdef DEBUG +# define sloth_validate_widget_(w) sloth_validate_widget__(w) +#endif + +Sloth_Function void +sloth_validate_widget__(Sloth_Widget* w) +{ + sloth_assert(w->cached); + sloth_assert(w->cached->canary_start_ == 0 && w->cached->canary_end_ == 0); + + // Look for cycles in w->siblings + for (Sloth_Widget* s = w->sibling_prev; s != 0; s = s->sibling_prev) + { + sloth_assert(s != w); + } + + // Look for cycles in w->children + for (Sloth_Widget* c = w->child_first; c != 0; c = c->child_first) + { + sloth_assert(c != w); + sloth_validate_widget__(c); + } + +} + +Sloth_Function Sloth_Widget_Cached* +sloth_get_cached_data_for_id(Sloth_Ctx* sloth, Sloth_ID id) +{ + Sloth_Widget_Cached* result = 0; + result = (Sloth_Widget_Cached*)sloth_hashtable_get(&sloth->widget_cache_lut, id.value); + if (!result) { + result = sloth_widget_cached_pool_take(sloth); + sloth_hashtable_add(&sloth->widget_cache_lut, id.value, (Sloth_U8*)result); + } + sloth_assert(result != 0); + return result; +} + +Sloth_Function Sloth_Widget* +sloth_push_widget_on_tree(Sloth_Ctx* sloth, Sloth_ID id) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget* widget = sloth_widget_pool_take(sloth); + if (sloth->widget_tree_parent_cur) { + Sloth_Widget* parent = sloth->widget_tree_parent_cur; + if (parent->child_last) + { + widget->sibling_prev = parent->child_last; + sloth_assert(widget->sibling_prev != widget->sibling_next); + parent->child_last->sibling_next = widget; + sloth_assert(parent->child_last->sibling_next != parent->child_last); + parent->child_last = widget; + } + else + { + parent->child_first = widget; + parent->child_last = widget; + widget->sibling_prev = 0; + } + widget->parent = parent; + } + else + { + sloth->widget_tree_root = widget; + } + + sloth->widget_tree_last_addition = widget; + sloth->widget_tree_parent_cur = widget; + sloth->widget_tree_next_child = widget->child_first; + sloth->widget_tree_depth_cur += 1; + if (sloth->widget_tree_depth_cur > sloth->widget_tree_depth_max) { + sloth->widget_tree_depth_max = sloth->widget_tree_depth_cur; + } + widget->id = id; + widget->cached = sloth_get_cached_data_for_id(sloth, id); + + return widget; +} + +Sloth_Function Sloth_Widget* +sloth_pop_widget_off_tree(Sloth_Ctx* sloth) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget* parent_cur = sloth->widget_tree_parent_cur; + + if (parent_cur != sloth->widget_tree_root) { + // parent_cur is either the root or its parent has a valid + // SLL of children + sloth_assert((parent_cur->parent != 0 && parent_cur->parent->child_first != 0)); + + // parent_cur either must have a previous sibling, or + // it's parent must think this is the first child + // not both. + sloth_assert((bool)(parent_cur->sibling_prev != 0) != (bool)(parent_cur->parent->child_first == parent_cur)); + } + + // if there's an expected next child, that means last + // frame this widget had more children than it does now + if (sloth->widget_tree_next_child) { + if (parent_cur->child_last) { + Sloth_Widget* last_widget = parent_cur->child_last; + last_widget->sibling_next = 0; + } else { + parent_cur->child_first = 0; + } + Sloth_Widget* at = sloth->widget_tree_next_child; + while (at != 0) { + Sloth_Widget* next_at = at->sibling_next; + sloth_widget_pool_give(sloth, sloth->widget_tree_next_child); + at = next_at; + } + } + + if (sloth->widget_tree_parent_cur != sloth->widget_tree_root) + { + sloth->widget_tree_parent_cur = parent_cur->parent; + sloth->widget_tree_next_child = parent_cur->sibling_next; + sloth->widget_tree_depth_cur -= 1; + } + else + { + // we're at the root + sloth->widget_tree_next_child = 0; + } + + sloth_assert(sloth->widget_tree_parent_cur); + sloth_validate_widget_(parent_cur); + return parent_cur; +} + +// Order: Left Root Right +Sloth_Function void +sloth_tree_walk_inorder_(Sloth_Ctx* sloth, Sloth_Widget* start, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + if (sloth->widgets.len == 0) return; + + Sloth_Arena_Loc scratch_at = sloth_arena_at(&sloth->scratch); + Sloth_Widget** stack = sloth_arena_push_array(&sloth->scratch, Sloth_Widget*, sloth->widgets.len); + Sloth_U32 stack_len = 0; + + Sloth_Widget* at = start; + while (true) + { + if (at != 0) + { + stack[stack_len++] = at; // push + at = at->child_first; + } + else if (stack_len > 0) + { + at = stack[--stack_len]; // pop + cb(sloth, at, user_data); + at = at->sibling_next; + } + else + { + break; + } + } + + sloth_arena_pop(&sloth->scratch, scratch_at); +} + +// Order: root, children, siblings +Sloth_Function void +sloth_tree_walk_preorder_(Sloth_Ctx* sloth, Sloth_Widget* start, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + if (sloth->widgets.len == 0) return; + + Sloth_Arena_Loc scratch_at = sloth_arena_at(&sloth->scratch); + Sloth_Widget** stack = sloth_arena_push_array(&sloth->scratch, Sloth_Widget*, sloth->widgets.len); + Sloth_U32 stack_len = 0; + + Sloth_Widget* at = start; + stack[stack_len++] = at; + + while (stack_len > 0) + { + at = stack[--stack_len]; // pop + if (at != 0) // if the requested node exists + { + cb(sloth, at, user_data); // visit + stack[stack_len++] = at->sibling_next; // right node + stack[stack_len++] = at->child_first; // left node + } + } + + sloth_arena_pop(&sloth->scratch, scratch_at); +} + +typedef struct Sloth_Postorder_Widget Sloth_Postorder_Widget; +struct Sloth_Postorder_Widget +{ + Sloth_Widget* widget; + Sloth_U8 is_right_child; +}; + +// Order: children, siblings, root +// NOTE: I believe this is a bit of a modification on +// postorder traversal, since we still want children +// to be visited from left to right. +Sloth_Function void +sloth_tree_walk_postorder_(Sloth_Ctx* sloth, Sloth_Widget* start, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + if (sloth->widgets.len == 0) return; + + Sloth_Arena_Loc scratch_at = sloth_arena_at(&sloth->scratch); + Sloth_Postorder_Widget* stack = sloth_arena_push_array(&sloth->scratch, Sloth_Postorder_Widget, sloth->widgets.len); + Sloth_U32 stack_len = 0; + + Sloth_Widget* at = start; + do { + while (at != 0) // while at exists + { + if (at->sibling_next != 0) // if right exists + { + Sloth_U32 index_r = stack_len++; // push right + stack[index_r].widget = at->sibling_next; // push right + stack[index_r].is_right_child = true; + } + // push + Sloth_U32 index_l = stack_len++; + stack[index_l].widget = at; + stack[index_l].is_right_child = false; + + at = at->child_first; // go to left + } + + Sloth_Postorder_Widget* wat = &stack[--stack_len]; + at = wat->widget; + while (at != 0 && !wat->is_right_child) // while at exists and is not the right child of a node + { + cb(sloth, at, user_data); // visit + if (stack_len == 0) { + wat = 0; + break; + } + wat = &stack[--stack_len]; + at = wat->widget; + } + + if (wat && wat->is_right_child) + { + wat->is_right_child = false; + at = wat->widget; + } + } while (stack_len > 0); + + sloth_arena_pop(&sloth->scratch, scratch_at); +} + +Sloth_Function void +sloth_tree_walk_inorder(Sloth_Ctx* sloth, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + sloth_tree_walk_inorder_(sloth, sloth->widget_tree_root, cb, user_data); +} + +Sloth_Function void +sloth_tree_walk_preorder(Sloth_Ctx* sloth, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + sloth_tree_walk_preorder_(sloth, sloth->widget_tree_root, cb, user_data); +} + +Sloth_Function void +sloth_tree_walk_postorder(Sloth_Ctx* sloth, Sloth_Tree_Walk_Cb* cb, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + sloth_tree_walk_postorder_(sloth, sloth->widget_tree_root, cb, user_data); +} + + +#ifdef DEBUG +# define sloth_widget_validate_layout_(w) sloth_widget_validate_layout__(w) +#else +# define sloth_widget_validate_layout_(w) +#endif +Sloth_Function void +sloth_widget_validate_layout__(Sloth_Widget* widget) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget_Layout layout = widget->layout; + sloth_assert(layout.margin.left.kind != Sloth_SizeKind_TextContent && layout.margin.left.kind != Sloth_SizeKind_ChildrenSum); + sloth_assert(layout.margin.right.kind != Sloth_SizeKind_TextContent && layout.margin.right.kind != Sloth_SizeKind_ChildrenSum); + sloth_assert(layout.margin.top.kind != Sloth_SizeKind_TextContent && layout.margin.top.kind != Sloth_SizeKind_ChildrenSum); + sloth_assert(layout.margin.bottom.kind != Sloth_SizeKind_TextContent && layout.margin.bottom.kind != Sloth_SizeKind_ChildrenSum); + + sloth_assert(layout.size[0].kind != Sloth_SizeKind_PercentOfSelf); + sloth_assert(layout.size[1].kind != Sloth_SizeKind_PercentOfSelf); +} + +Sloth_Function void +sloth_widget_handle_input_drag(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_Widget_Result* result) +{ + if (!sloth_has_flag(widget->input.flags, Sloth_WidgetInput_Draggable)) return; + result->drag_offset_pixels.x = sloth->mouse_pos.x - sloth->mouse_down_pos.x; + result->drag_offset_pixels.y = sloth->mouse_pos.y - sloth->mouse_down_pos.y; + + Sloth_Widget* parent = widget->parent; + if (parent) { + Sloth_Widget_Cached parent_cached = *widget->parent->cached; + result->drag_offset_percent_parent.x = result->drag_offset_pixels.x / parent_cached.dim.x; + result->drag_offset_percent_parent.y = result->drag_offset_pixels.y / parent_cached.dim.y; + } +} + +Sloth_Function Sloth_Widget_Result +sloth_widget_handle_input(Sloth_Ctx* sloth, Sloth_Widget* widget) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget_Result result; sloth_zero_struct_(&result); + result.widget = widget; + + Sloth_Widget_Input input = widget->input; + Sloth_Widget_Cached cached = *widget->cached; + if (sloth_ids_equal(sloth->active_widget, widget->id)) + { + result.clicked = sloth_mouse_button_transitioned_down(sloth->mouse_button_l); + result.held = sloth_mouse_button_held_down(sloth->mouse_button_l); + sloth_widget_handle_input_drag(sloth, widget, &result); + + if (sloth_has_flag(input.flags, Sloth_WidgetInput_TextSelectable)) + { + result.selected_glyphs_first = sloth->active_widget_selected_glyphs_first; + result.selected_glyphs_one_past_last = sloth->active_widget_selected_glyphs_one_past_last; + } + } + + if (sloth_ids_equal(sloth->last_active_widget, widget->id)) + { + if (sloth_mouse_button_transitioned_up(sloth->mouse_button_l)) + { + result.released = true; + sloth_widget_handle_input_drag(sloth, widget, &result); + } + + if (sloth_has_flag(input.flags, Sloth_WidgetInput_TextSelectable)) + { + result.selected_glyphs_first = sloth->active_widget_selected_glyphs_first; + result.selected_glyphs_one_past_last = sloth->active_widget_selected_glyphs_one_past_last; + } + } + + return result; +} + +Sloth_Function Sloth_Widget_Result +sloth_push_widget_v(Sloth_Ctx* sloth, Sloth_Widget_Desc desc, char* fmt, va_list args) +{ + SLOTH_PROFILE_BEGIN; + Sloth_ID_Result idr = sloth_make_id_v(fmt, args); + + Sloth_Widget* widget = sloth_push_widget_on_tree(sloth, idr.id); + sloth_assert(widget->parent || widget == sloth->widget_tree_root); + widget->layout = desc.layout; + widget->style = desc.style; + widget->input = desc.input; + widget->str = fmt; + + Sloth_Widget_Result result = sloth_widget_handle_input(sloth, widget); + + // TODO: convoluted - probably a more consise, reusable way to + // access this information + Sloth_Font_ID text_font = sloth->active_text_glyph_family; + Sloth_U32 text_family = 0; + if (sloth->fonts) { + text_family = sloth->fonts[text_font.value].weights[text_font.weight_index].glyph_family; + } + + bool show_selected = sloth_has_flag(desc.input.flags, Sloth_WidgetInput_TextSelectable); + show_selected &= sloth_ids_equal(sloth->last_active_widget, widget->id); + + widget->text = sloth_arena_push_array(&sloth->per_frame_memory, Sloth_Glyph_Layout, idr.display_len + 1); + for (Sloth_U32 glyph_i = 0; glyph_i < idr.display_len; glyph_i++) + { + Sloth_U32 char_code = (Sloth_U32)idr.formatted[glyph_i]; + Sloth_Glyph_ID g = sloth_make_glyph_id(text_family, char_code); + + + bool after_first = glyph_i >= result.selected_glyphs_first; + bool before_last = glyph_i < result.selected_glyphs_one_past_last; + bool is_selected = (show_selected && after_first && before_last); + widget->text[glyph_i].selected = is_selected; + widget->text[glyph_i].glyph_id = g; + + if (!sloth_glyph_atlas_contains(&sloth->glyph_atlas, g)) + { + sloth_font_register_codepoint(sloth, text_font, char_code); + } + + } + widget->text_len = idr.display_len; + + sloth_widget_validate_layout__(widget); + + return result; +} + +Sloth_Function Sloth_Widget_Result +sloth_push_widget_f(Sloth_Ctx* sloth, Sloth_Widget_Desc desc, char* fmt, ...) +{ + SLOTH_PROFILE_BEGIN; + va_list args; va_start(args, fmt); + Sloth_Widget_Result result = sloth_push_widget_v(sloth, desc, fmt, args); + va_end(args); + return result; +} + +Sloth_Function Sloth_Widget_Result +sloth_push_widget(Sloth_Ctx* sloth, Sloth_Widget_Desc desc, char* text) +{ + SLOTH_PROFILE_BEGIN; + return sloth_push_widget_f(sloth, desc, text); +} + +Sloth_Function void +sloth_pop_widget(Sloth_Ctx* sloth) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget* last_widget = sloth_pop_widget_off_tree(sloth); + sloth_assert(sloth->widget_tree_parent_cur); +} + +typedef struct Sloth_Layout_Cache Sloth_Layout_Cache; +struct Sloth_Layout_Cache +{ + Sloth_U8 axis; + Sloth_R32 last_sibling_end; +}; + +Sloth_Function Sloth_R32 +sloth_size_evaluate_margin(Sloth_Widget* widget, Sloth_Size margin_size, Sloth_U8 axis) +{ + SLOTH_PROFILE_BEGIN; + Sloth_R32 result = 0; + if (margin_size.kind != Sloth_SizeKind_None) + { + if (margin_size.kind == Sloth_SizeKind_Pixels) { + result = margin_size.value; + } else { + Sloth_Rect bounds; + if (margin_size.kind == Sloth_SizeKind_PercentOfParent) { + bounds = widget->parent->cached->bounds; + } else if (margin_size.kind == Sloth_SizeKind_PercentOfSelf) { + bounds = widget->cached->bounds; + } else { + sloth_invalid_code_path; + } + result = (bounds.value_max.E[axis] - bounds.value_min.E[axis]) * margin_size.value; + } + } + return result; +} + +Sloth_Function Sloth_R32 +sloth_size_box_evaluate(Sloth_Widget* widget, Sloth_Size_Box margin, Sloth_U8 axis) +{ + SLOTH_PROFILE_BEGIN; + Sloth_R32 result = 0; + result += sloth_size_evaluate_margin(widget, margin.E[axis].min, axis); + result += sloth_size_evaluate_margin(widget, margin.E[axis].max, axis); + return result; +} + +Sloth_Function void +sloth_size_fixup_fixed_size_apply(Sloth_Widget* widget, Sloth_U8 axis) +{ + Sloth_R32 margin = sloth_size_evaluate_margin(widget, widget->layout.margin.E[axis].min, axis); + margin += sloth_size_evaluate_margin(widget, widget->layout.margin.E[axis].max, axis); + widget->cached->dim.E[axis] = widget->text_dim.E[axis] + margin; +} + +// @PerAxisTreeWalkCB +Sloth_Function void +sloth_size_fixup_cb_fixed_size(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Layout_Cache* lc = (Sloth_Layout_Cache*)user_data; + Sloth_U8 axis = lc->axis; + switch (widget->layout.size[axis].kind) + { + case Sloth_SizeKind_Pixels: + { + widget->cached->dim.E[axis] = widget->layout.size[axis].value; + } break; + case Sloth_SizeKind_TextContent: + { + sloth_size_fixup_fixed_size_apply(widget, axis); + } break; + default: {} break; // do nothing + } +} + +// @PerAxisTreeWalkCB +Sloth_Function void +sloth_size_fixup_cb_percent_parent(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Layout_Cache* lc = (Sloth_Layout_Cache*)user_data; + Sloth_U8 axis = lc->axis; + switch (widget->layout.size[axis].kind) + { + case Sloth_SizeKind_PercentOfParent: + { + Sloth_Widget* parent = widget->parent; + sloth_assert(parent); + + // NOTE: this violation rises from the fact that that + // this child relies on its parent for size, and the parent + // relies on its children for size. This will be solved in + // the violation fixup step + bool unsolved_violation = parent->layout.size[axis].kind == Sloth_SizeKind_ChildrenSum; + if (!unsolved_violation) + { + Sloth_R32 parent_margin = sloth_size_box_evaluate(parent, parent->layout.margin, axis); + widget->cached->dim.E[axis] = (parent->cached->dim.E[axis] - parent_margin) * widget->layout.size[axis].value; + } + } break; + + case Sloth_SizeKind_TextContent: + { + if (axis == Sloth_Axis_Y) { + sloth_size_fixup_fixed_size_apply(widget, axis); + } + sloth_assert(widget->cached->dim.E[axis] >= widget->text_dim.E[axis]); + } break; + default: {} break; // do nothing + } +} + +// @PerAxisTreeWalkCB +Sloth_Function void +sloth_size_fixup_cb_children_sum(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Layout_Cache* lc = (Sloth_Layout_Cache*)user_data; + Sloth_U8 axis = lc->axis; + switch (widget->layout.size[axis].kind) + { + case Sloth_SizeKind_ChildrenSum: + { + Sloth_R32 dim = 0; + Sloth_R32 max = 0; + if (widget->child_first) { + // Because no widgets have been laid out yet, we have to iterate + // over all its children + for (Sloth_Widget* child = widget->child_first; + child != 0; + child = child->sibling_next + ){ + // TODO: Account for any child gap layout properties + dim += child->cached->dim.E[axis]; + max = Sloth_Max(child->cached->dim.E[axis], max); + } + } + + if (widget->layout.direction == Sloth_LayoutDirection_LeftToRight || + widget->layout.direction == Sloth_LayoutDirection_RightToLeft) + { + if (axis == Sloth_Axis_X) { + widget->cached->dim.x = dim; + } else { + widget->cached->dim.y = max; + } + } + else if (widget->layout.direction == Sloth_LayoutDirection_TopDown || + widget->layout.direction == Sloth_LayoutDirection_BottomUp) + { + if (axis == Sloth_Axis_X) { + widget->cached->dim.x = max; + } else { + widget->cached->dim.y = dim; + } + } + else + { + sloth_invalid_code_path; + } + + // TODO: This is a place, where if we wanted to, we could implement + // wrapping a-la flexbox + // ie. All the children should know their dimensions by now, so we + // can just reposition them if laying them out in a row would overflow + // this widgets parent + } break; + default: {} break; // do nothing + } +} + +// @PerAxisTreeWalkCB +Sloth_Function void +sloth_size_fixup_cb_violations(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Layout_Cache* lc = (Sloth_Layout_Cache*)user_data; + Sloth_U8 axis = lc->axis; + switch (widget->layout.size[axis].kind) + { + case Sloth_SizeKind_PercentOfParent: + { + Sloth_Widget* parent = widget->parent; + Sloth_Widget_Layout pl = parent->layout; + bool unsolved_violation = pl.size[axis].kind == Sloth_SizeKind_ChildrenSum; + // TODO: + } break; + default: {} break; // do nothing + } +} + +Sloth_Function Sloth_Rect +sloth_widget_calc_inner_bounds(Sloth_Widget* widget) +{ + SLOTH_PROFILE_BEGIN; + SLOTH_PROFILE_BEGIN; + sloth_widget_validate_layout_(widget); + Sloth_Rect result = widget->cached->bounds; + result.value_min.x += sloth_size_evaluate_margin(widget, widget->layout.margin.left, Sloth_Axis_X); + result.value_min.y += sloth_size_evaluate_margin(widget, widget->layout.margin.top, Sloth_Axis_Y); + result.value_max.x -= sloth_size_evaluate_margin(widget, widget->layout.margin.right, Sloth_Axis_X); + result.value_max.y -= sloth_size_evaluate_margin(widget, widget->layout.margin.bottom, Sloth_Axis_Y); + if (result.value_max.x < result.value_min.x) { + Sloth_R32 avg = (result.value_max.x + result.value_min.x) / 2; + result.value_max.x = avg; + result.value_min.x = avg; + } + if (result.value_max.y < result.value_min.y) { + Sloth_R32 avg = (result.value_max.y + result.value_min.y) / 2; + result.value_max.y = avg; + result.value_min.y = avg; + } + return result; +} + +// This is used to figure out which extents of a child are relevant +// to its next sibling attempting to draw itself. ie. based on this +// widgets dimensions, how far should the next widget offset itself +// based on how the parent wants to lay its children out +Sloth_Function Sloth_V2 +sloth_layout_get_child_relevant_extents(Sloth_Widget* parent, Sloth_Rect widget_bounds) +{ + SLOTH_PROFILE_BEGIN; + Sloth_V2 relevant_extents; + sloth_zero_struct_(&relevant_extents); + switch (parent->layout.direction) + { + case Sloth_LayoutDirection_TopDown: + { + relevant_extents.E[Sloth_Axis_X] = widget_bounds.value_min.x; + relevant_extents.E[Sloth_Axis_Y] = widget_bounds.value_max.y; + } break; + case Sloth_LayoutDirection_BottomUp: + { + relevant_extents.E[Sloth_Axis_X] = widget_bounds.value_min.x; + relevant_extents.E[Sloth_Axis_Y] = widget_bounds.value_min.y; + } break; + case Sloth_LayoutDirection_LeftToRight: + { + relevant_extents.E[Sloth_Axis_X] = widget_bounds.value_max.x; + relevant_extents.E[Sloth_Axis_Y] = widget_bounds.value_min.y; + } break; + case Sloth_LayoutDirection_RightToLeft: + { + relevant_extents.E[Sloth_Axis_X] = widget_bounds.value_min.x; + relevant_extents.E[Sloth_Axis_Y] = widget_bounds.value_min.y; + } break; + default: break; + } + return relevant_extents; +} + +Sloth_Function Sloth_V2 +sloth_layout_clip_bounds_to_start_pos(Sloth_Widget* widget, Sloth_Rect clip_bounds) +{ + SLOTH_PROFILE_BEGIN; + Sloth_V2 start; + switch (widget->layout.direction) + { + case Sloth_LayoutDirection_TopDown: + case Sloth_LayoutDirection_LeftToRight: { + start = clip_bounds.value_min; + } break; + case Sloth_LayoutDirection_RightToLeft: { + start.x = clip_bounds.value_max.x; + start.y = clip_bounds.value_min.y; + } break; + case Sloth_LayoutDirection_BottomUp: { + start.x = clip_bounds.value_min.x; + start.y = clip_bounds.value_max.y; + } break; + } + return start; +} + +Sloth_Function void +sloth_layout_position_parent_decides(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_Layout_Cache* lc) +{ + SLOTH_PROFILE_BEGIN; + Sloth_U8 axis = lc->axis; + Sloth_V2 offset = widget->cached->offset; + Sloth_Rect bounds = widget->cached->bounds; + + Sloth_Rect clip_bounds; + if (widget->parent) + { + clip_bounds = sloth_widget_calc_inner_bounds(widget->parent); + Sloth_V2 start = sloth_layout_clip_bounds_to_start_pos(widget->parent, clip_bounds); + if (widget == widget->parent->child_first) + { + offset.E[axis] = start.E[axis]; + } + else + { + sloth_assert(widget->sibling_prev != 0); + Sloth_Widget* last_relevant_sibling = widget->sibling_prev; + while(last_relevant_sibling && last_relevant_sibling->layout.position.kind != Sloth_LayoutPosition_ParentDecides) + { + last_relevant_sibling = last_relevant_sibling->sibling_prev; + } + if (last_relevant_sibling) { + Sloth_V2 extents = sloth_layout_get_child_relevant_extents(widget->parent, last_relevant_sibling->cached->bounds); + offset.E[axis] = extents.E[axis]; + } else { + offset.E[axis] = start.E[axis]; // act as first sibling + } + } + } + else + { + // Root + lc->last_sibling_end = 0; + offset.E[axis] = 0; + + // effectively, do not clip + clip_bounds.value_min.x = Sloth_R32_Min; + clip_bounds.value_min.y = Sloth_R32_Min; + clip_bounds.value_max.x = Sloth_R32_Max; + clip_bounds.value_max.y = Sloth_R32_Max; + } + + // Clip bounds to parent + if (widget->parent) { + switch (widget->parent->layout.direction) + { + case Sloth_LayoutDirection_RightToLeft: + { + if (axis == Sloth_Axis_X) { + offset.E[axis] -= widget->cached->dim.E[axis]; + } + } break; + case Sloth_LayoutDirection_BottomUp: + { + if (axis == Sloth_Axis_Y) { + offset.E[axis] -= widget->cached->dim.E[axis]; + } + } break; + } + } + bounds.value_min.E[axis] = Sloth_Max( + offset.E[axis], + clip_bounds.value_min.E[axis] + ); + bounds.value_max.E[axis] = Sloth_Min( + offset.E[axis] + widget->cached->dim.E[axis], + clip_bounds.value_max.E[axis] + ); + widget->cached->dim.E[axis] = sloth_rect_dim(bounds).E[axis]; + + widget->cached->offset = offset; + widget->cached->bounds = bounds; +} + +// At this point, everything has had its dimensions figured out +Sloth_Function void +sloth_layout_position_fixed(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_Layout_Cache* lc) +{ + SLOTH_PROFILE_BEGIN; + Sloth_U32 axis = lc->axis; + + Sloth_Layout_Position pos = widget->layout.position; + Sloth_R32 desired_offset_from_min = sloth_size_evaluate_margin(widget, pos.at.E[axis].min, axis); + Sloth_R32 desired_offset_from_max = sloth_size_evaluate_margin(widget, pos.at.E[axis].max, axis); + desired_offset_from_max += widget->cached->dim.E[axis]; + if (pos.at.E[axis].min.kind != Sloth_SizeKind_None && + pos.at.E[axis].max.kind != Sloth_SizeKind_None) + { + // NOTE(PS): this isn't invalid. What we want to do is recalculate this + // widget's width, and reflow its text/children based on the implied offsets + sloth_invalid_code_path; + } + + Sloth_Widget* parent = widget->parent; + Sloth_R32 desired_offset = 0; + switch (widget->layout.position.kind) + { + case Sloth_LayoutPosition_FixedInParent: + { + desired_offset = parent->cached->offset.E[axis] + desired_offset_from_min; + if (pos.at.E[axis].max.kind != Sloth_SizeKind_None) { + desired_offset = parent->cached->offset.E[axis] + parent->cached->dim.E[axis] - desired_offset_from_max; + } + } break; + + case Sloth_LayoutPosition_FixedOnScreen: + { + desired_offset = desired_offset_from_min; + if (pos.at.E[axis].max.kind != Sloth_SizeKind_None) { + desired_offset = sloth->screen_dim.E[axis] - desired_offset_from_max; + } + } break; + + sloth_invalid_default_case; + } + + widget->cached->offset.E[axis] = desired_offset; + widget->cached->bounds.value_min.E[axis] = desired_offset; + widget->cached->bounds.value_max.E[axis] = desired_offset + widget->cached->dim.E[axis]; +} + +// @PerAxisTreeWalkCB +// This function produces the final bounding boxes of each widget +Sloth_Function void +sloth_layout_cb(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Layout_Cache* lc = (Sloth_Layout_Cache*)user_data; + + switch (widget->layout.position.kind) + { + case Sloth_LayoutPosition_ParentDecides: + { + sloth_layout_position_parent_decides(sloth, widget, lc); + } break; + + case Sloth_LayoutPosition_FixedInParent: + case Sloth_LayoutPosition_FixedOnScreen: + { + sloth_layout_position_fixed(sloth, widget, lc); + } break; + + sloth_invalid_default_case; + } +} + +Sloth_Function Sloth_U32 +sloth_render_quad_ptc(Sloth_VIBuffer* vibuf, Sloth_Rect bounds, Sloth_R32 z, Sloth_V2 uv_min, Sloth_V2 uv_max, Sloth_U32 color) +{ + SLOTH_PROFILE_BEGIN; + Sloth_V4 c4; + c4.r = (Sloth_R32)((color >> 24) & 0xFF) / 255.0f; + c4.g = (Sloth_R32)((color >> 16) & 0xFF) / 255.0f; + c4.b = (Sloth_R32)((color >> 8) & 0xFF) / 255.0f; + c4.a = (Sloth_R32)((color >> 0) & 0xFF) / 255.0f; + + Sloth_U32 v0 = sloth_vibuffer_push_vert( + vibuf, bounds.value_min.x, bounds.value_min.y, z, uv_min.x, uv_min.y, c4 + ); + Sloth_U32 v1 = sloth_vibuffer_push_vert( + vibuf, bounds.value_max.x, bounds.value_min.y, z, uv_max.x, uv_min.y, c4 + ); + Sloth_U32 v2 = sloth_vibuffer_push_vert( + vibuf, bounds.value_max.x, bounds.value_max.y, z, uv_max.x, uv_max.y, c4 + ); + Sloth_U32 v3 = sloth_vibuffer_push_vert( + vibuf, bounds.value_min.x, bounds.value_max.y, z, uv_min.x, uv_max.y, c4 + ); + sloth_vibuffer_push_quad(vibuf, v0, v1, v2, v3); + + return v0; +} + +Sloth_Function void +sloth_render_update_quad_ptc(Sloth_VIBuffer* vibuf, Sloth_U32 quad_v0_index, Sloth_Rect bounds, Sloth_R32 z, Sloth_V2 uv_min, Sloth_V2 uv_max, Sloth_U32 color) +{ + SLOTH_PROFILE_BEGIN; + Sloth_V4 c4; + c4.r = (Sloth_R32)((color >> 24) & 0xFF) / 255.0f; + c4.g = (Sloth_R32)((color >> 16) & 0xFF) / 255.0f; + c4.b = (Sloth_R32)((color >> 8) & 0xFF) / 255.0f; + c4.a = (Sloth_R32)((color >> 0) & 0xFF) / 255.0f; + + sloth_assert(vibuf->verts_len > quad_v0_index + 3); + + sloth_vibuffer_set_vert( + vibuf, quad_v0_index, bounds.value_min.x, bounds.value_min.y, z, uv_min.x, uv_min.y, c4 + ); + sloth_vibuffer_set_vert( + vibuf, quad_v0_index + 1, bounds.value_max.x, bounds.value_min.y, z, uv_max.x, uv_min.y, c4 + ); + sloth_vibuffer_set_vert( + vibuf, quad_v0_index + 2, bounds.value_max.x, bounds.value_max.y, z, uv_max.x, uv_max.y, c4 + ); + sloth_vibuffer_set_vert( + vibuf, quad_v0_index + 3, bounds.value_min.x, bounds.value_max.y, z, uv_min.x, uv_max.y, c4 + ); +} + +Sloth_Function void +sloth_render_outline_ptc(Sloth_VIBuffer* vibuf, Sloth_Rect bounds, Sloth_R32 z, Sloth_R32 thickness, Sloth_V2 uv_min, Sloth_V2 uv_max, Sloth_U32 color) +{ + SLOTH_PROFILE_BEGIN; + // Outline is rendered like + // + // t t t t t t << notice the overhangs + // l r + // l r + // l r + // b b b b b b << + + // TODO(rjf): I'm not sure I want the outline to + // extend beyond the bounds requested. Better to have + // it an inset outline + Sloth_V2 top_min, top_max; + top_min.x = bounds.value_min.x; + top_min.y = bounds.value_min.y; + top_max.x = bounds.value_max.x; + top_max.y = bounds.value_min.y + thickness; + Sloth_Rect top; + top.value_min = top_min; + top.value_max = top_max; + + Sloth_V2 bot_min, bot_max; + bot_min.x = bounds.value_min.x; + bot_min.y = bounds.value_max.y - thickness; + bot_max.x = bounds.value_max.x; + bot_max.y = bounds.value_max.y; + Sloth_Rect bot; + bot.value_min = bot_min; + bot.value_max = bot_max; + + Sloth_V2 rig_min, rig_max; + rig_min.x = bounds.value_min.x; + rig_min.y = bounds.value_min.y + thickness; + rig_max.x = bounds.value_min.x + thickness; + rig_max.y = bounds.value_max.y - thickness; + Sloth_Rect rig; + rig.value_min = rig_min; + rig.value_max = rig_max; + + Sloth_V2 lef_min, lef_max; + lef_min.x = bounds.value_max.x - thickness; + lef_min.y = bounds.value_min.y + thickness; + lef_max.x = bounds.value_max.x; + lef_max.y = bounds.value_max.y - thickness; + Sloth_Rect lef; + lef.value_min = lef_min; + lef.value_max = lef_max; + + // TODO(PS): uv_min and uv_max here are not correct + // they need to be projected onto the outline + sloth_render_quad_ptc(vibuf, top, z, uv_min, uv_max, color); + sloth_render_quad_ptc(vibuf, bot, z, uv_min, uv_max, color); + sloth_render_quad_ptc(vibuf, lef, z, uv_min, uv_max, color); + sloth_render_quad_ptc(vibuf, rig, z, uv_min, uv_max, color); +} + +Sloth_Function Sloth_Rect +sloth_render_get_glyph_bounds(Sloth_Glyph_Info glyph, Sloth_V2 at, Sloth_V2* new_at) +{ + SLOTH_PROFILE_BEGIN; + + Sloth_Rect bounds; + bounds.value_min.x = at.x + glyph.glyph.lsb; + bounds.value_min.y = at.y + glyph.glyph.baseline_offset_y; + bounds.value_max = sloth_v2_add( + bounds.value_min, sloth_make_v2((Sloth_R32)glyph.glyph.width, (Sloth_R32)glyph.glyph.height) + ); + if (new_at) { + *new_at = at; + new_at->x = sloth_floor_r32(at.x + glyph.glyph.x_advance); + } + return bounds; +} + +Sloth_Function bool +sloth_render_clip_glyph_layout(Sloth_Ctx* sloth, Sloth_Glyph_Layout* glyph, Sloth_Rect text_bounds) +{ + SLOTH_PROFILE_BEGIN; + + Sloth_Rect bounds = glyph->bounds; + + // find nearest valid point for each extent that is within text_bounds + Sloth_Rect clipped_bounds; + clipped_bounds.value_min = sloth_rect_get_closest_point(text_bounds, bounds.value_min); + clipped_bounds.value_max = sloth_rect_get_closest_point(text_bounds, bounds.value_max); + + // if those points are teh same, zero everything out return false (don't draw) + Sloth_V2 clipped_dim = sloth_rect_dim(clipped_bounds); + if (clipped_dim.x == 0 || clipped_dim.y == 0) + { + return false; + } + + // get insets as percentage of overall width + Sloth_V2 bounds_dim = sloth_rect_dim(glyph->bounds); + Sloth_R32 inset_l_pct = (clipped_bounds.value_min.x - bounds.value_min.x) / bounds_dim.x; + Sloth_R32 inset_r_pct = (clipped_bounds.value_max.x - bounds.value_max.x) / bounds_dim.x; + Sloth_R32 inset_t_pct = (clipped_bounds.value_min.y - bounds.value_min.y) / bounds_dim.y; + Sloth_R32 inset_b_pct = (clipped_bounds.value_max.y - bounds.value_max.y) / bounds_dim.y; + + // convert pct insets to be in terms of uv coordinates + Sloth_V2 uv_dim = sloth_rect_dim(glyph->info.uv); + Sloth_R32 inset_l_uv = inset_l_pct * uv_dim.x; + Sloth_R32 inset_r_uv = inset_r_pct * uv_dim.x; + Sloth_R32 inset_t_uv = inset_t_pct * uv_dim.y; + Sloth_R32 inset_b_uv = inset_b_pct * uv_dim.y; + + // NOTE: I checked when I wrote this that this body + // of operations doesn't modify the dimensions of + // clipped_bounds, meaning we don't also need to apply + // some similar operation to the uvs + clipped_bounds.value_min.x = sloth_floor_r32(clipped_bounds.value_min.x); + clipped_bounds.value_min.y = sloth_floor_r32(clipped_bounds.value_min.y); + clipped_bounds.value_max.x = sloth_floor_r32(clipped_bounds.value_max.x); + clipped_bounds.value_max.y = sloth_floor_r32(clipped_bounds.value_max.y); + + glyph->bounds = clipped_bounds; + + glyph->info.uv.value_min.x += inset_l_uv; + glyph->info.uv.value_min.y += inset_t_uv; + glyph->info.uv.value_max.x += inset_r_uv; + glyph->info.uv.value_max.y += inset_b_uv; + + // safety checks: + // we should always be able to assume that the result of this operation + // produces two rects that are smaller than the original + Sloth_R32 epsilon = 0.01f; + sloth_assert((sloth_rect_dim(glyph->bounds).x - bounds_dim.x) < epsilon); + sloth_assert((sloth_rect_dim(glyph->bounds).y - bounds_dim.y) < epsilon); + sloth_assert((sloth_rect_dim(glyph->info.uv).x - uv_dim.x) < epsilon); + sloth_assert((sloth_rect_dim(glyph->info.uv).y - uv_dim.y) < epsilon); + + return true; +} + +Sloth_Function void +sloth_render_shift_glyphs(Sloth_Glyph_Layout* glyphs, Sloth_U32 first, Sloth_U32 one_past_last, Sloth_U32 axis, Sloth_R32 shift) +{ + SLOTH_PROFILE_BEGIN; + + for (Sloth_U32 i = first; i < one_past_last; i++) + { + Sloth_Glyph_Layout* at = glyphs + i; + at->bounds.value_min.E[axis] += shift; + at->bounds.value_max.E[axis] += shift; + } +} + +Sloth_Function void +sloth_render_distribute_glyphs(Sloth_Glyph_Layout* glyphs, Sloth_U32 first, Sloth_U32 one_past_last, Sloth_U32 axis, Sloth_R32 space_between_glyphs) +{ + SLOTH_PROFILE_BEGIN; + + Sloth_Glyph_Layout* prev = glyphs + first; + for (Sloth_U32 i = first + 1; i < one_past_last; i++) + { + Sloth_Glyph_Layout* at = glyphs + i; + at->bounds.value_min.E[axis] = prev->bounds.value_max.E[axis] + space_between_glyphs; + at->bounds.value_max.E[axis] = prev->bounds.value_max.E[axis] + space_between_glyphs; + prev = at; + } +} + +Sloth_Function void +sloth_render_text_apply_align_center(Sloth_Widget* widget, Sloth_Glyph_Layout* glyphs, Sloth_U32 glyphs_cap, Sloth_Rect text_bounds) +{ + SLOTH_PROFILE_BEGIN; + + Sloth_R32 line_max_width = sloth_rect_dim(text_bounds).x; + Sloth_U32 last_line_start_i = 0; + Sloth_R32 last_line_start_x = glyphs[0].bounds.value_min.x; + for (Sloth_U32 glyph_i = 1; glyph_i < glyphs_cap; glyph_i++) + { + if (!glyphs[glyph_i].is_line_start) continue; + + // process the line just completed + Sloth_R32 last_line_end_x = glyphs[glyph_i - 1].bounds.value_max.x; + Sloth_R32 last_line_w = last_line_end_x - last_line_start_x; + Sloth_R32 last_line_room = line_max_width - last_line_w; + //sloth_assert(last_line_room >= 0); + Sloth_R32 last_line_offset = last_line_room / 2; + sloth_render_shift_glyphs(glyphs, last_line_start_i, glyph_i, Sloth_Axis_X, last_line_offset); + + // start the new line + last_line_start_i = glyph_i; + last_line_start_x = glyphs[glyph_i].bounds.value_min.x; + } +} + +Sloth_Function void +sloth_render_text_apply_align_right(Sloth_Widget* widget, Sloth_Glyph_Layout* glyphs, Sloth_U32 glyphs_cap, Sloth_Rect text_bounds) +{ + SLOTH_PROFILE_BEGIN; + + Sloth_R32 line_max_width = sloth_rect_dim(text_bounds).x; + Sloth_U32 last_line_start_i = 0; + Sloth_R32 last_line_start_x = glyphs[0].bounds.value_min.x; + for (Sloth_U32 glyph_i = 1; glyph_i < glyphs_cap; glyph_i++) + { + if (!glyphs[glyph_i].is_line_start) continue; + + // process the line just completed + Sloth_R32 last_line_end_x = glyphs[glyph_i - 1].bounds.value_max.x; + Sloth_R32 last_line_w = last_line_end_x - last_line_start_x; + Sloth_R32 last_line_room = line_max_width - last_line_w; + //sloth_assert(last_line_room >= 0); + sloth_render_shift_glyphs(glyphs, last_line_start_i, glyph_i, Sloth_Axis_X, last_line_room); + + // start the new line + last_line_start_i = glyph_i; + last_line_start_x = glyphs[glyph_i].bounds.value_min.x; + } +} + +Sloth_Function Sloth_V2 +sloth_layout_text_in_widget(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_Rect text_bounds) +{ + SLOTH_PROFILE_BEGIN; + + Sloth_V2 text_dim; sloth_zero_struct_(&text_dim); + + Sloth_U32 last_line_break = 0; + Sloth_Glyph_Layout* text = widget->text; + + Sloth_Font* active_font = 0; + Sloth_R32 line_advance = 0; + Sloth_V2 at; at.x = 0; at.y = 0; + for (Sloth_U32 glyph_i = 0; glyph_i < widget->text_len; glyph_i++) + { + Sloth_Glyph_Layout* text_at = text + glyph_i; + + Sloth_V2 next_at; + Sloth_Rect glyph_bounds; + bool is_newline = sloth_glyph_id_matches_charcode(text_at->glyph_id, '\n'); + if (!is_newline) + { + text_at->info = sloth_glyph_atlas_lookup(&sloth->glyph_atlas, text_at->glyph_id); + text_at->color = widget->style.color_text; + + if (glyph_i == 0) + { + text_at->is_line_start = true; + active_font = sloth_glyph_to_font(sloth, text_at->glyph_id); + if (active_font) { + line_advance = active_font->metrics.line_height; + } else { + line_advance = text_at->info.glyph.height; + } + at.y += line_advance; + } + + next_at = at; + glyph_bounds = sloth_render_get_glyph_bounds(text_at->info, at, &next_at); + text_at->bounds = glyph_bounds; + } + + if(is_newline) + { + next_at.x = 0; + next_at.y += line_advance; + } + else if(glyph_bounds.value_max.x > text_bounds.value_max.x) + { + // look backwards to the last line-break glyph and move everything since to a new line + Sloth_U32 line_break = glyph_i; + for (Sloth_U32 lb_i = glyph_i; lb_i > last_line_break && lb_i < widget->text_len; lb_i--) + { + bool is_space = sloth_glyph_id_matches_charcode(widget->text[lb_i].glyph_id, ' '); + bool is_newline = sloth_glyph_id_matches_charcode(widget->text[lb_i].glyph_id, '\n'); + if (is_space || is_newline) + { + line_break = lb_i + 1; + break; + } + } + + if (!sloth_has_flag(widget->style.text_style, Sloth_TextStyle_NoWrapText)) + { + at.x = 0; + at.y += line_advance; + + if (line_break == last_line_break) + { + // since there was nowhere on this line acceptable for + // a line break, advance the current glyph to the next + // line since its the first glyph that will overflow + line_break = glyph_i; + } + + text[line_break].is_line_start = true; + if (text[line_break].glyph_id.family != text[last_line_break].glyph_id.family) + { + active_font = sloth_glyph_to_font(sloth, text_at->glyph_id); + if (active_font) { + line_advance = active_font->metrics.line_height; + } else { + line_advance = text_at->info.glyph.height; + } + } + + for (Sloth_U32 new_line_i = line_break; new_line_i <= glyph_i; new_line_i++) + { + Sloth_Glyph_Layout new_line_glyph = widget->text[new_line_i]; + Sloth_Rect new_bounds = sloth_render_get_glyph_bounds(new_line_glyph.info, at, &next_at); + widget->text[new_line_i].bounds = new_bounds; + at = next_at; + } + last_line_break = line_break; + } + + // TODO: stop creating glyphs if we're at a point where they won't + // appear within text_bounds at all (ie you've moved to the next + // line down, and the new glyph will get completely clipped). + // NOTE: This will involve truncating the later iterations to layout + // glyphs + } + + at = next_at; + } + + // Handle text alignment + // This just adjusts the existing positions given + // during the default layout step above + Sloth_Text_Style_Flags text_style = widget->style.text_style; + // no action necessary for Align_Left + if (sloth_has_flag(text_style, Sloth_TextStyle_Align_Center)) + { + sloth_render_text_apply_align_center(widget, widget->text, widget->text_len, text_bounds); + } + else if (sloth_has_flag(text_style, Sloth_TextStyle_Align_Right)) + { + sloth_render_text_apply_align_right(widget, widget->text, widget->text_len, text_bounds); + } + + Sloth_V2 text_max; sloth_zero_struct_(&text_max); + for (Sloth_U32 glyph_i = 0; glyph_i < widget->text_len; glyph_i++) + { + text_max.x = Sloth_Max(text_max.x, text[glyph_i].bounds.value_max.x); + text_max.y = Sloth_Max(text_max.y, text[glyph_i].bounds.value_max.y); + } + text_dim.x = text_max.x - text_bounds.value_min.x; + text_dim.y = text_max.y - text_bounds.value_min.y; + + return text_dim; +} + +Sloth_Function void +sloth_size_kind_text_contents_layout_text(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + + Sloth_Rect text_bounds; + sloth_zero_struct_(&text_bounds); + Sloth_Widget_Layout l = widget->layout; + if (l.width.kind == Sloth_SizeKind_TextContent) + { + text_bounds.value_max.x = Sloth_R32_Max; + if (l.height.kind == Sloth_SizeKind_Pixels) { + Sloth_R32 margin_t = sloth_size_evaluate_margin(widget, widget->layout.margin.top, 0); + Sloth_R32 margin_b = sloth_size_evaluate_margin(widget, widget->layout.margin.bottom, 0); + text_bounds.value_max.y = Sloth_Max(0, l.height.value - (margin_t + margin_b)); + } else { + text_bounds.value_max.y = Sloth_R32_Max; + } + } + else if (l.width.kind == Sloth_SizeKind_Pixels && + l.height.kind == Sloth_SizeKind_TextContent) + { + Sloth_R32 margin_l = sloth_size_evaluate_margin(widget, widget->layout.margin.left, 0); + Sloth_R32 margin_r = sloth_size_evaluate_margin(widget, widget->layout.margin.right, 0); + text_bounds.value_max.x = Sloth_Max(0, l.width.value - (margin_l + margin_r)); + text_bounds.value_max.y = Sloth_R32_Max; + } + else + { + return; // will be handled later + } + + widget->text_dim = sloth_layout_text_in_widget(sloth, widget, text_bounds); +} + +Sloth_Function void +sloth_percent_parent_width_layout_text(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget_Layout l = widget->layout; + if (l.width.kind != Sloth_SizeKind_PercentOfParent) return; + if (l.height.kind != Sloth_SizeKind_TextContent) return; + + Sloth_R32 margin = sloth_size_evaluate_margin(widget, widget->layout.margin.left, Sloth_Axis_X); + margin += sloth_size_evaluate_margin(widget, widget->layout.margin.right, Sloth_Axis_X); + + Sloth_Rect text_bounds; sloth_zero_struct_(&text_bounds); + text_bounds.value_max.x = Sloth_Max(0, widget->cached->dim.x - margin); + text_bounds.value_max.y = Sloth_R32_Max; + widget->text_dim = sloth_layout_text_in_widget(sloth, widget, text_bounds); + +} + +Sloth_Function void +sloth_child_sum_width_layout_text(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget_Layout l = widget->layout; + if (l.width.kind != Sloth_SizeKind_ChildrenSum) return; + if (l.height.kind != Sloth_SizeKind_TextContent) return; + + Sloth_R32 margin = sloth_size_evaluate_margin(widget, widget->layout.margin.left, Sloth_Axis_X); + margin += sloth_size_evaluate_margin(widget, widget->layout.margin.right, Sloth_Axis_X); + + Sloth_Rect text_bounds; sloth_zero_struct_(&text_bounds); + text_bounds.value_max.x = Sloth_Max(0, widget->cached->dim.x - margin); + text_bounds.value_max.y = Sloth_R32_Max; + widget->text_dim = sloth_layout_text_in_widget(sloth, widget, text_bounds); +} + +Sloth_Function void +sloth_known_size_layout_text(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Widget_Layout l = widget->layout; + Sloth_Size_Kind wk = l.width.kind; + Sloth_Size_Kind hk = l.height.kind; + if (wk == Sloth_SizeKind_TextContent || hk == Sloth_SizeKind_TextContent) return; + + Sloth_R32 margin_x = sloth_size_evaluate_margin(widget, widget->layout.margin.left, Sloth_Axis_X); + margin_x += sloth_size_evaluate_margin(widget, widget->layout.margin.right, Sloth_Axis_X); + + Sloth_R32 margin_y = sloth_size_evaluate_margin(widget, widget->layout.margin.top, Sloth_Axis_Y); + margin_y += sloth_size_evaluate_margin(widget, widget->layout.margin.bottom, Sloth_Axis_Y); + + Sloth_Rect text_bounds; sloth_zero_struct_(&text_bounds); + text_bounds.value_max.x = Sloth_Max(0, widget->cached->dim.x - margin_x); + text_bounds.value_max.y = Sloth_Max(0, widget->cached->dim.y - margin_y); + + widget->text_dim = sloth_layout_text_in_widget(sloth, widget, text_bounds); +} + +Sloth_Function void +sloth_offset_and_clip_text(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + Sloth_V2 offset = widget->cached->offset; + offset.x += sloth_size_evaluate_margin(widget, widget->layout.margin.left, Sloth_Axis_X); + offset.y += sloth_size_evaluate_margin(widget, widget->layout.margin.top, Sloth_Axis_Y); + for (Sloth_U32 i = 0; i < widget->text_len; i++) + { + // offset + widget->text[i].bounds.value_min.x += offset.x; + widget->text[i].bounds.value_min.y += offset.y; + widget->text[i].bounds.value_max.x += offset.x; + widget->text[i].bounds.value_max.y += offset.y; + + // clip + widget->text[i].draw = sloth_render_clip_glyph_layout(sloth, widget->text + i, widget->cached->bounds); + } +} + +Sloth_Function void +sloth_render_text_in_widget(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_Rect text_bounds, Sloth_R32 z) +{ + Sloth_Glyph_ID id; + id.value = 0; + id.id[0] = 1; + Sloth_Glyph_Info white = sloth_glyph_atlas_lookup(&sloth->glyph_atlas, id); + + Sloth_U32 selection_line_start = 0; + Sloth_Rect line_dim; + Sloth_S32 selection_quad_v0 = -1; + for (Sloth_U32 i = 0; i < widget->text_len; i++) + { + if (!widget->text[i].draw) continue; + + Sloth_Glyph_Layout gl = widget->text[i]; + if (gl.selected) + { + if (selection_quad_v0 == -1 || gl.is_line_start) + { + if (selection_quad_v0 >= 0) { + sloth_rect_expand(&line_dim, 4, 4, 4, 4); + sloth_render_update_quad_ptc(&sloth->vibuf, selection_quad_v0, line_dim, z, white.uv.value_min, white.uv.value_max, 0x0088FFFF); + } + selection_line_start = i; + line_dim = gl.bounds; + selection_quad_v0 = (Sloth_S32)sloth_render_quad_ptc(&sloth->vibuf, gl.bounds, z, white.uv.value_min, white.uv.value_max, 0x0088FFFF); + } + else + { + line_dim.value_min.x = Sloth_Min(gl.bounds.value_min.x, line_dim.value_min.x); + line_dim.value_min.y = Sloth_Min(gl.bounds.value_min.y, line_dim.value_min.y); + line_dim.value_max.x = Sloth_Max(gl.bounds.value_max.x, line_dim.value_max.x); + line_dim.value_max.y = Sloth_Max(gl.bounds.value_max.y, line_dim.value_max.y); + } + } + else if (selection_quad_v0 != -1) + { + sloth_rect_expand(&line_dim, 4, 4, 4, 4); + sloth_render_update_quad_ptc(&sloth->vibuf, selection_quad_v0, line_dim, z, white.uv.value_min, white.uv.value_max, 0x0088FFFF); + selection_quad_v0 = -1; + } + + sloth_render_quad_ptc(&sloth->vibuf, gl.bounds, z, gl.info.uv.value_min, gl.info.uv.value_max, gl.color); + } + + if (selection_quad_v0 != -1) + { + sloth_rect_expand(&line_dim, 4, 4, 4, 4); + sloth_render_update_quad_ptc(&sloth->vibuf, selection_quad_v0, line_dim, z, white.uv.value_min, white.uv.value_max, 0x0088FFFF); + selection_quad_v0 = -1; + } +} + +Sloth_Function void +sloth_render_cb(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + // TODO: texture filtering - the calling code should pass in a glyph family via user_Data + // and this function shouldn't render anything that isn't in that family. + // That being said, it should compute layout for those things if they + // influence the layout of other things + // ie. a sprite glyph in the middle of text should still have layout computed here + // due to the fact that it will offset the layout of later characters + // TODO: Figure out if there's a way to cache that info so we don't have to compute + // it multiple times per frame. + + SLOTH_PROFILE_BEGIN; + Sloth_Rect bounds = widget->cached->bounds; + + // TODO: UV Coordinates need to be corrected in the case where the widget + // uses an image or sprite as a background + Sloth_Glyph_ID bg_id = widget->style.bg_glyph; + if (bg_id.value == 0) { + sloth_zero_struct_(&bg_id); + bg_id.id[0] = 1; + } + + Sloth_Glyph_Info bg_glyph = sloth_glyph_atlas_lookup( + &sloth->glyph_atlas, bg_id + ); + Sloth_V2 bg_uv_min = bg_glyph.uv.value_min; + Sloth_V2 bg_uv_max = bg_glyph.uv.value_max; + Sloth_R32 z = widget->layout.position.z; + sloth_render_quad_ptc(&sloth->vibuf, bounds, z, bg_uv_min, bg_uv_max, widget->style.color_bg); + + sloth_render_text_in_widget(sloth, widget, widget->cached->bounds, z); + + if (widget->style.outline_thickness > 0) + { + Sloth_R32 t = widget->style.outline_thickness; + Sloth_U32 c = widget->style.color_outline; + sloth_render_outline_ptc(&sloth->vibuf, widget->cached->bounds, z, t, bg_uv_min, bg_uv_max, c); + } + + if (sloth_ids_equal(sloth->hot_widget, widget->id) || sloth_ids_equal(sloth->active_widget, widget->id)) + { + Sloth_Glyph_ID white_id; sloth_zero_struct_(&white_id); + white_id.id[0] = 1; + Sloth_Glyph_Info white_glyph = sloth_glyph_atlas_lookup( + &sloth->glyph_atlas, white_id + ); + Sloth_U32 color = 0xFF00FFFF; + if (sloth_ids_equal(sloth->active_widget, widget->id)) color = 0x00FFFFFF; + sloth_render_outline_ptc(&sloth->vibuf, widget->cached->bounds, z, 2, white_glyph.uv.value_min, white_glyph.uv.value_max, color); + } + +} + +Sloth_Function void +sloth_find_hot_and_active(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* ud) +{ + if (sloth_has_flag(widget->input.flags, Sloth_WidgetInput_DoNotCaptureMouse)) return; + + // Active + if (sloth_mouse_button_is_down(sloth->mouse_button_l) && + sloth_rect_contains(widget->cached->bounds, sloth->mouse_down_pos)) + { + sloth->active_widget = widget->id; + printf("Active: %s\n", widget->str); + for (Sloth_U32 glyph_i = 0; glyph_i < widget->text_len; glyph_i++) + { + Sloth_Glyph_Layout g = widget->text[glyph_i]; + if (sloth_rect_contains(g.bounds, sloth->mouse_down_pos)) { + sloth->active_widget_selected_glyphs_first = glyph_i; + } + if (sloth_rect_contains(g.bounds, sloth->mouse_pos)) + { + sloth->active_widget_selected_glyphs_one_past_last = glyph_i + 1; + } + + // TODO(PS): what if they drag away from the widget? + } + } + + // Hot + if (sloth_rect_contains(widget->cached->bounds, sloth->mouse_pos)) + { + sloth->hot_widget = widget->id; + } +} + +Sloth_Function void +sloth_frame_prepare(Sloth_Ctx* sloth) +{ + SLOTH_PROFILE_BEGIN; + sloth_assert(sloth->sentinel == SLOTH_DEBUG_DID_CALL_ADVANCE); + + sloth->vibuf.verts_len = 0; + sloth->vibuf.indices_len = 0; + + // Handle this frames input on the visuals rendered at the end + // of last frame + if (sloth->active_widget.value != 0) + { + if (!sloth_ids_equal(sloth->active_widget, sloth->last_active_widget)) + { + sloth->active_widget_selected_glyphs_first = 0; + sloth->active_widget_selected_glyphs_one_past_last = 0; + } + sloth->last_active_widget = sloth->active_widget; + } + sloth->hot_widget.value = 0; + sloth->active_widget.value = 0; + sloth_tree_walk_preorder(sloth, sloth_find_hot_and_active, 0); + + // Fixup + sloth->widget_tree_next_child = sloth->widget_tree_root; + sloth->widget_tree_root = 0; + sloth->widget_tree_last_addition = 0; + sloth->widget_tree_parent_cur = 0; + + // TEMP + sloth->widgets.len = 0; + sloth->widgets.free_list = 0; + + sloth_arena_clear(&sloth->per_frame_memory); + sloth_arena_clear(&sloth->scratch); + + sloth->sentinel = SLOTH_DEBUG_DID_CALL_PREPARE; +} + +// NOTE: I suspect that this will become a pretty hefty function +// It is responsible for: +// - updating each widget's cached sizes +// - laying out the next frames data +// - outputting the vertex and index buffers needed for the +// frame to be rendered +Sloth_Function void +sloth_frame_advance(Sloth_Ctx* sloth) +{ + SLOTH_PROFILE_BEGIN; + sloth_assert(sloth->sentinel == SLOTH_DEBUG_DID_CALL_PREPARE); + Sloth_Layout_Cache lc; + + // Update the atlas_texture if necessary + if (sloth->glyph_atlas.is_dirty && sloth->renderer_atlas_updated) { + sloth->renderer_atlas_updated(sloth); + } + sloth->glyph_atlas.is_dirty = false; + + // Layout text for widgets that will rely on the size of their + // text contents. + sloth_tree_walk_preorder(sloth, sloth_size_kind_text_contents_layout_text, 0); + + // Update widget's cached sizes in the following ways: + // 1. Preorder - Sloth_SizeKind_Pixels & Sloth_SizeKind_TextContent + // can be set outright, don't rely on other information + lc.axis = 0; sloth_tree_walk_preorder(sloth, sloth_size_fixup_cb_fixed_size, (Sloth_U8*)&lc); + lc.axis = 1; sloth_tree_walk_preorder(sloth, sloth_size_fixup_cb_fixed_size, (Sloth_U8*)&lc); + + // 2. Preorder - Calculate sizes that rely on parents + lc.axis = 0; sloth_tree_walk_preorder(sloth, sloth_size_fixup_cb_percent_parent, (Sloth_U8*)&lc); + sloth_tree_walk_preorder(sloth, sloth_percent_parent_width_layout_text, 0); + lc.axis = 1; sloth_tree_walk_preorder(sloth, sloth_size_fixup_cb_percent_parent, (Sloth_U8*)&lc); + + // 3. Postorder - Calculate sizes that rely on size of children + lc.axis = 0; sloth_tree_walk_postorder(sloth, sloth_size_fixup_cb_children_sum, (Sloth_U8*)&lc); + sloth_tree_walk_preorder(sloth, sloth_child_sum_width_layout_text, 0); + lc.axis = 1; sloth_tree_walk_postorder(sloth, sloth_size_fixup_cb_children_sum, (Sloth_U8*)&lc); + + // 4. Preorder - Handle any unhandled cases, including ones that + // might not have a neat solution. + lc.axis = 0; sloth_tree_walk_preorder(sloth, sloth_size_fixup_cb_violations, (Sloth_U8*)&lc); + lc.axis = 1; sloth_tree_walk_preorder(sloth, sloth_size_fixup_cb_violations, (Sloth_U8*)&lc); + + // Layout text for widgets didn't previously layout their text + // for sizing purposes. This procedure also clips text for all widgets + sloth_tree_walk_preorder(sloth, sloth_known_size_layout_text, 0); + + // Set final bounding boxes for all widgets (preorder) + lc.axis = 0; + lc.last_sibling_end = 0; + sloth_tree_walk_preorder(sloth, sloth_layout_cb, (Sloth_U8*)&lc); + lc.axis = 1; + lc.last_sibling_end = 0; + sloth_tree_walk_preorder(sloth, sloth_layout_cb, (Sloth_U8*)&lc); + + sloth_tree_walk_preorder(sloth, sloth_offset_and_clip_text, 0); + + // Begin Render Passes + // Each pass corresponds to a texture lookup. + // First will be a pass with no texture, then passes for each needed texture atlas + sloth_tree_walk_preorder(sloth, sloth_render_cb, 0); + + sloth->sentinel = SLOTH_DEBUG_DID_CALL_ADVANCE; +} + +Sloth_Function void +sloth_vibuffer_set_vert(Sloth_VIBuffer* buf, Sloth_U32 vert_index, Sloth_R32 x, Sloth_R32 y, Sloth_R32 z, Sloth_R32 u, Sloth_R32 v, Sloth_V4 c) +{ + Sloth_U32 vi = vert_index * SLOTH_VERTEX_STRIDE; + buf->verts[vi++] = x; + buf->verts[vi++] = y; + buf->verts[vi++] = z; + buf->verts[vi++] = u; + buf->verts[vi++] = v; + buf->verts[vi++] = c.x; + buf->verts[vi++] = c.y; + buf->verts[vi++] = c.z; + buf->verts[vi++] = c.w; +} + +Sloth_Function Sloth_U32 +sloth_vibuffer_push_vert(Sloth_VIBuffer* buf, Sloth_R32 x, Sloth_R32 y, Sloth_R32 z, Sloth_R32 u, Sloth_R32 v, Sloth_V4 c) +{ + SLOTH_PROFILE_BEGIN; + buf->verts = sloth_array_grow( + buf->verts, + buf->verts_len, + &buf->verts_cap, + SLOTH_VERTEX_STRIDE * 256, + Sloth_R32 + ); + sloth_assert((buf->verts_len % SLOTH_VERTEX_STRIDE) == 0); + + Sloth_U32 vert_index = buf->verts_len / SLOTH_VERTEX_STRIDE; + sloth_vibuffer_set_vert(buf, vert_index, x, y, z, u, v, c); + buf->verts_len += SLOTH_VERTEX_STRIDE; + sloth_assert((buf->verts_len % SLOTH_VERTEX_STRIDE) == 0); + + return vert_index; +} + +Sloth_Function Sloth_U32 +sloth_vibuffer_push_tri(Sloth_VIBuffer* buf, Sloth_U32 a, Sloth_U32 b, Sloth_U32 c) +{ + SLOTH_PROFILE_BEGIN; + buf->indices = sloth_array_grow( + buf->indices, + buf->indices_len, + &buf->indices_cap, + 3 * (256 / 4), + Sloth_U32 + ); + sloth_assert((buf->indices_len % 3) == 0); + Sloth_U32 tri_index = buf->indices_len / 3; + buf->indices[buf->indices_len++] = a; + buf->indices[buf->indices_len++] = b; + buf->indices[buf->indices_len++] = c; + sloth_assert((buf->indices_len % 3) == 0); + return tri_index; +} + +Sloth_Function void +sloth_vibuffer_push_quad(Sloth_VIBuffer* buf, Sloth_U32 a, Sloth_U32 b, Sloth_U32 c, Sloth_U32 d) +{ + SLOTH_PROFILE_BEGIN; + sloth_vibuffer_push_tri(buf, a, b, c); + sloth_vibuffer_push_tri(buf, a, c, d); +} + +Sloth_Function void +sloth_vibuffer_free(Sloth_VIBuffer* buf) +{ + SLOTH_PROFILE_BEGIN; + Sloth_U8* unused; + unused = sloth_realloc(buf->verts, buf->verts_cap * sizeof(Sloth_R32), 0); + unused = sloth_realloc(buf->indices, buf->indices_cap * sizeof(Sloth_U32), 0); +} + +Sloth_Function void +sloth_ctx_free(Sloth_Ctx* sloth) +{ + SLOTH_PROFILE_BEGIN; + sloth_widget_pool_free(&sloth->widgets); + sloth_arena_free(&sloth->per_frame_memory); + sloth_arena_free(&sloth->scratch); + sloth_vibuffer_free(&sloth->vibuf); +} + +typedef struct Sloth_Tree_Print_Data Sloth_Tree_Print_Data; +struct Sloth_Tree_Print_Data +{ + Sloth_U32 indent; + + char* buffer; + Sloth_U32 buffer_size; + Sloth_U32 buffer_used; +}; + +Sloth_Function void +sloth_widget_tree_print_cb(Sloth_Ctx* sloth, Sloth_Widget* widget, Sloth_U8* user_data) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Tree_Print_Data* d = (Sloth_Tree_Print_Data*)user_data; + + Sloth_U32 needed = stbsp_snprintf(0, 0, "%.*s%s\n", + d->indent * 2, " ", + widget->str); + if (d->buffer_used + needed > d->buffer_size) + { + Sloth_U32 buffer_size = Sloth_Max(d->buffer_size * 2, 2048); + d->buffer = (char*)sloth_realloc(d->buffer, d->buffer_size, buffer_size); + d->buffer_size = buffer_size; + } + + d->buffer_used += stbsp_snprintf(d->buffer + d->buffer_used, + d->buffer_size - d->buffer_used, + "%.*s%s\n", + d->indent * 2, " ", + widget->str); + + if (widget->child_first) { + d->indent += 1; + } else if (!widget->sibling_next) { + d->indent -= 1; + } +} + + +Sloth_Function char* +sloth_widget_tree_print(Sloth_Ctx* sloth) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Tree_Print_Data d = { + .indent = 0, + }; + sloth_tree_walk_preorder(sloth, sloth_widget_tree_print_cb, (Sloth_U8*)&d); + return d.buffer; +} + + +/////////////////////////////////////////////////////// +// FONT ATLAS HELPERS +// TODO: Implement this with freetype as well + +#ifdef SLOTH_STBTT_ATLAS + +#ifndef __STB_INCLUDE_STB_TRUETYPE_H__ +# error "You must include stb_truetype.h (and link to it, if not implementing in this compilation unit). +#endif + +typedef struct Sloth_Stbtt_Font Sloth_Stbtt_Font; +struct Sloth_Stbtt_Font +{ + stbtt_fontinfo font; + Sloth_R32 scale; +}; + +Sloth_Function Sloth_U8* +sloth_stbtt_font_init(Sloth_Ctx* sloth, Sloth_Font* font, Sloth_U8* font_memory, Sloth_U32 font_memory_size, Sloth_U32 font_index, Sloth_R32 pixel_height) +{ + Sloth_Stbtt_Font* result = (Sloth_Stbtt_Font*)sloth_realloc(0, 0, sizeof(Sloth_Stbtt_Font)); + sloth_zero_struct_(result); + + stbtt_InitFont(&result->font, font_memory, stbtt_GetFontOffsetForIndex(font_memory, font_index)); + result->scale = stbtt_ScaleForPixelHeight(&result->font, pixel_height); + + Sloth_S32 ascent, descent, line_gap; + stbtt_GetFontVMetrics(&result->font, &ascent, &descent, &line_gap); + font->metrics.line_height = (ascent - descent + line_gap) * result->scale; + + return (Sloth_U8*)result; +} + +Sloth_Function Sloth_Glyph_ID +sloth_stbtt_register_glyph(Sloth_Ctx* sloth, Sloth_Font_ID font_id, Sloth_U32 codepoint) +{ + Sloth_Font* font = sloth_font_get_(sloth, font_id); + Sloth_Stbtt_Font* stb_font = (Sloth_Stbtt_Font*)font->renderer_data; + + Sloth_Glyph_Desc gd; + sloth_zero_struct_(&gd); + gd.family = font->weights[font_id.weight_index].glyph_family; + gd.id = codepoint; + gd.format = Sloth_GlyphData_Alpha8; + + Sloth_S32 advance, lsb, x0, y0, x1, y1; + Sloth_U8* bitmap = stbtt_GetCodepointBitmapSubpixel(&stb_font->font, 0, stb_font->scale, 0, 0, codepoint, (Sloth_S32*)&gd.width, (Sloth_S32*)&gd.height, 0, 0); + stbtt_GetCodepointHMetrics(&stb_font->font, codepoint, &advance, &lsb); + stbtt_GetCodepointBitmapBoxSubpixel(&stb_font->font, codepoint, stb_font->scale, stb_font->scale, 0, 0, &x0, &y0, &x1, &y1); + + gd.id = codepoint; + gd.stride = gd.width; + gd.data = bitmap; + gd.cursor_to_glyph_start_xoff = stb_font->scale * (Sloth_R32)lsb; + gd.cursor_to_next_glyph = stb_font->scale * (Sloth_R32)advance; + gd.baseline_offset_y = y0; + + Sloth_Glyph_ID result = sloth_glyph_atlas_register(&sloth->glyph_atlas, gd); + + // TODO(PS): It might be better if we don't free the bitmap each time + // but use a persistent backbuffer that gets saved in something like + // a Sloth_Stbtt_Ctx thing? + stbtt_FreeBitmap(bitmap, 0); + + return result; +} + +#endif // SLOTH_STBTT_ATLAS + +#ifdef SLOTH_FREETYPE_ATLAS + +#include "freetype/freetype2/ft2build.h" +#include FT_FREETYPE_H + +typedef struct Sloth_FT2_Ctx Sloth_FT2_Ctx; +struct Sloth_FT2_Ctx +{ + FT_Library ft; +}; + +typedef struct Sloth_FT2_Font Sloth_FT2_Font; +struct Sloth_FT2_Font +{ + FT_Face ft_face; +}; + + +Sloth_Function Sloth_U8* +sloth_ft2_font_init(Sloth_Ctx* sloth, Sloth_Font* font, Sloth_U8* font_memory, Sloth_U32 font_memory_size, Sloth_U32 font_index, Sloth_R32 pixel_height) +{ + FT_Error error = 0; + Sloth_FT2_Ctx* ft_ctx = (Sloth_FT2_Ctx*)sloth->font_renderer_data; + if (ft_ctx == 0) + { + ft_ctx = (Sloth_FT2_Ctx*)sloth_realloc(0, 0, sizeof(Sloth_FT2_Ctx)); + error = FT_Init_FreeType(&ft_ctx->ft); + sloth_assert(!error); + sloth->font_renderer_data = (Sloth_U8*)ft_ctx; + } + + Sloth_FT2_Font* result = (Sloth_FT2_Font*)sloth_realloc(0, 0, sizeof(Sloth_FT2_Font)); + error = FT_New_Memory_Face(ft_ctx->ft, font_memory, font_memory_size, font_index, &result->ft_face); + sloth_assert(!error); + + error = FT_Set_Pixel_Sizes(result->ft_face, 0, pixel_height); + Sloth_U32 line_height = (result->ft_face->size->metrics.ascender - result->ft_face->size->metrics.descender); + line_height = line_height >> 6; + font->metrics.line_height = (Sloth_R32)line_height; + + return (Sloth_U8*)result; +} + +// TODO(PS): This currently doesn't do anything with different font weights +Sloth_Function Sloth_Glyph_ID +sloth_ft2_register_glyph(Sloth_Ctx* sloth, Sloth_Font_ID font_id, Sloth_U32 codepoint) +{ + Sloth_FT2_Ctx* ft_ctx = (Sloth_FT2_Ctx*)sloth->font_renderer_data; + sloth_assert(ft_ctx != 0); + + Sloth_Font* font = sloth_font_get_(sloth, font_id); + Sloth_FT2_Font* ft_font = (Sloth_FT2_Font*)font->renderer_data; + + FT_Error error = FT_Set_Pixel_Sizes(ft_font->ft_face, 0, font->metrics.pixel_height); + + FT_UInt glyph_index = FT_Get_Char_Index(ft_font->ft_face, codepoint); + + FT_Int32 load_flags = 0; + error = FT_Load_Glyph(ft_font->ft_face, glyph_index, load_flags); + sloth_assert(!error); + + // Ensure the glyph is rendered + if (ft_font->ft_face->glyph->format != FT_GLYPH_FORMAT_BITMAP) + { + error = FT_Render_Glyph(ft_font->ft_face->glyph, FT_RENDER_MODE_NORMAL); + sloth_assert(!error); + } + + FT_GlyphSlot slot = ft_font->ft_face->glyph; + Sloth_Glyph_Desc gd; + sloth_zero_struct_(&gd); + gd.family = font->weights[font_id.weight_index].glyph_family; + gd.id = codepoint; + gd.format = Sloth_GlyphData_Alpha8; + gd.width = slot->bitmap.width; + gd.height = slot->bitmap.rows; + gd.stride = slot->bitmap.pitch; + gd.data = slot->bitmap.buffer; + gd.cursor_to_glyph_start_xoff = slot->bitmap_left; + gd.cursor_to_next_glyph = slot->advance.x >> 6; + gd.baseline_offset_y = - slot->bitmap_top; + + Sloth_Glyph_ID result = sloth_glyph_atlas_register(&sloth->glyph_atlas, gd); + return result; +} + +#endif + +/////////////////////////////////////////////////////// +// RENDERING IMPLEMENTATIONS + +#ifdef SLOTH_SOKOL_RENDERER + +#ifndef SOKOL_GFX_INCLUDED +# error "The sloth.h sokol renderer backend requires sokol_gfx.h to be included first." +#endif + +#include "./sloth_sokol_shader.glsl.h" + +typedef struct Sloth_Sokol_Data Sloth_Sokol_Data; +struct Sloth_Sokol_Data +{ + // TODO(PS): supporting multiple textures + sg_image atlas_texture; + Sloth_U32 atlas_texture_dim; + + sg_pass_action pass_action; + sg_pipeline pip; + sg_bindings bind; + Sloth_U32 bind_quad_cap; +}; + +Sloth_Function void +sloth_render_sokol_buffers_create(Sloth_Sokol_Data* sd, Sloth_U32 quads) +{ + if (sd->bind.vertex_buffers[0].id != 0) + { + sg_destroy_buffer(sd->bind.vertex_buffers[0]); + sd->bind.vertex_buffers[0].id = 0; + } + if (sd->bind.index_buffer.id != 0) + { + sg_destroy_buffer(sd->bind.index_buffer); + sd->bind.index_buffer.id = 0; + } + + sg_buffer_desc vbd; sloth_zero_struct_(&vbd); + vbd.usage = SG_USAGE_STREAM; + vbd.data.size = quads * 4 * sizeof(Sloth_R32); + vbd.label = "sloth sokol vertices"; + + sg_buffer_desc ibd; sloth_zero_struct_(&ibd); + ibd.usage = SG_USAGE_STREAM; + ibd.type = SG_BUFFERTYPE_INDEXBUFFER; + ibd.data.size = quads * 6 * sizeof(Sloth_U32); + ibd.label = "sloth sokol indices"; + + sd->bind.vertex_buffers[0] = sg_make_buffer(&vbd); + sd->bind.index_buffer = sg_make_buffer(&ibd); + sd->bind_quad_cap = quads; +} + +Sloth_Function void +sloth_renderer_sokol_atlas_updated(Sloth_Ctx* sloth) +{ + Sloth_Sokol_Data* sd = (Sloth_Sokol_Data*)sloth->render_data; + sloth_assert(sd != 0); + + Sloth_Glyph_Atlas atlas = sloth->glyph_atlas; + if (sd->atlas_texture.id == 0 || sd->atlas_texture_dim != atlas.dim) + { + // create + + sg_image_desc atlas_texture_desc = { + .width = atlas.dim, + .height = atlas.dim, + .usage = SG_USAGE_DYNAMIC, + .min_filter = SG_FILTER_NEAREST, //SG_FILTER_LINEAR, + .mag_filter = SG_FILTER_NEAREST, //SG_FILTER_LINEAR, + .label = "sloth atlas texture", + }; + sg_image new_atlas_texture = sg_make_image(&atlas_texture_desc); + + if (sd->atlas_texture.id != 0) + { + sg_destroy_image(sd->atlas_texture); + } + + sd->atlas_texture = new_atlas_texture; + sd->atlas_texture_dim = atlas.dim; + } + + // just update the data of the existing texture since + // the new data still fits + sg_image_data data = { + .subimage[0][0] = { + .ptr = (const char*)atlas.data, + .size = atlas.dim * atlas.dim * sizeof(Sloth_U32), + }, + }; + sg_update_image(sd->atlas_texture, &data); + + sd->bind.fs_images[SLOT_tex] = sd->atlas_texture; +} + +Sloth_Function void +sloth_render_sokol_init(Sloth_Ctx* sloth) +{ + SLOTH_PROFILE_BEGIN; + sloth->render_data = sloth_realloc( + sloth->render_data, + 0, sizeof(Sloth_Sokol_Data) + ); + + Sloth_Sokol_Data* sd = (Sloth_Sokol_Data*)sloth->render_data; + sloth_zero_struct_(sd); + + sloth->renderer_atlas_updated = sloth_renderer_sokol_atlas_updated; + + sg_pass_action pass_action; + sloth_zero_struct_(&pass_action); + pass_action.colors[0].action = SG_ACTION_CLEAR; + pass_action.colors[0].value.r = 0; + pass_action.colors[0].value.g = 0; + pass_action.colors[0].value.b = 0; + pass_action.colors[0].value.a = 1; + sd->pass_action = pass_action; + + sg_pipeline_desc pd; + sloth_zero_struct_(&pd); + pd.shader = sg_make_shader(sloth_viz_shader_desc(sg_query_backend())); + pd.index_type = SG_INDEXTYPE_UINT32; + pd.layout.attrs[ATTR_sloth_viz_vs_position].format = SG_VERTEXFORMAT_FLOAT3; + pd.layout.attrs[ATTR_sloth_viz_vs_uv].format = SG_VERTEXFORMAT_FLOAT2; + pd.layout.attrs[ATTR_sloth_viz_vs_color].format = SG_VERTEXFORMAT_FLOAT4; + pd.label = "sloth sokol pipeline"; + pd.colors[0].blend.enabled = true; + pd.colors[0].blend.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA; + pd.colors[0].blend.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + pd.colors[0].blend.src_factor_alpha = SG_BLENDFACTOR_SRC_ALPHA; + pd.colors[0].blend.dst_factor_alpha = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + sd->pip = sg_make_pipeline(&pd); + + sloth_zero_struct_(&sd->bind); + sloth_render_sokol_buffers_create(sd, 1024); +} + +Sloth_Function void +sloth_render_sokol(Sloth_Ctx* sloth, Sloth_U32 width, Sloth_U32 height) +{ + SLOTH_PROFILE_BEGIN; + Sloth_Sokol_Data* sd = (Sloth_Sokol_Data*)sloth->render_data; + + // Update the bindings + if (sloth->vibuf.verts_len > sd->bind_quad_cap * 4) { + Sloth_U32 new_cap = sd->bind_quad_cap * 2; + while (new_cap * 4 < sloth->vibuf.verts_len) new_cap *= 2; + sloth_render_sokol_buffers_create(sd, new_cap); + } + // TODO: Check if we are about to push a range bigger than the + // buffer's size. If we are, we need to create a new buffer and + // free the old one + sg_range vertex_range; + vertex_range.ptr = (const void*)sloth->vibuf.verts; + vertex_range.size = sloth->vibuf.verts_len * sizeof(Sloth_R32); + sg_update_buffer(sd->bind.vertex_buffers[0], (const sg_range*)&vertex_range); + + sg_range index_range; + index_range.ptr = (const void*)sloth->vibuf.indices; + index_range.size = sloth->vibuf.indices_len * sizeof(Sloth_U32); + sg_update_buffer(sd->bind.index_buffer, (const sg_range*)&index_range); + + // Draw the Frame + sg_begin_default_pass(&sd->pass_action, width, height); + if (sloth->vibuf.indices_len > 0) + { + sg_apply_pipeline(sd->pip); + sg_apply_bindings(&sd->bind); + + sloth_viz_vs_params_t sloth_viz_vs_params = { + .mvp = HMM_Orthographic( + 0, (Sloth_R32)width, + (Sloth_R32)height, 0, + -1, 100 + ) + }; + sg_apply_uniforms( + SG_SHADERSTAGE_VS, + SLOT_sloth_viz_vs_params, + &SG_RANGE(sloth_viz_vs_params) + ); + + sg_draw(0, sloth->vibuf.indices_len, 1); + } + sg_end_pass(); +} + +#endif // SLOTH_SOKOL_RENDERER +#endif // SLOTH_IMPLEMENTATION +#endif // SLOTH_H + + +/* +Copyright 2022 Peter Slattery + +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. +*/ diff --git a/src_v2/libs/sloth/sloth_sokol_shader.glsl b/src_v2/libs/sloth/sloth_sokol_shader.glsl new file mode 100644 index 0000000..6f0bada --- /dev/null +++ b/src_v2/libs/sloth/sloth_sokol_shader.glsl @@ -0,0 +1,42 @@ +#pragma sokol @ctype mat4 hmm_mat4 + +#pragma sokol @vs sloth_viz_vs + +uniform sloth_viz_vs_params { + mat4 mvp; +}; + +in vec3 position; +in vec2 uv; +// TODO: This is really wasteful of data we have to +// send to the gpu every frame but I can't figure out +// how to pass uints to a shader +in vec4 color; + +out vec2 o_uv; +out vec4 o_color; + +void main() +{ + gl_Position = mvp * vec4(position, 1); + o_uv = uv; + o_color = color; +} +#pragma sokol @end + +#pragma sokol @fs sloth_viz_fs + +in vec2 o_uv; +in vec4 o_color; +out vec4 frag_color; + +uniform sampler2D tex; + +void main() +{ + frag_color = texture(tex, o_uv) * o_color; +} + +#pragma sokol @end + +#pragma sokol @program sloth_viz sloth_viz_vs sloth_viz_fs \ No newline at end of file diff --git a/src_v2/libs/sloth/sloth_sokol_shader.glsl.h b/src_v2/libs/sloth/sloth_sokol_shader.glsl.h new file mode 100644 index 0000000..17a1696 --- /dev/null +++ b/src_v2/libs/sloth/sloth_sokol_shader.glsl.h @@ -0,0 +1,589 @@ +#pragma once +/* + #version:1# (machine generated, don't edit!) + + Generated by sokol-shdc (https://github.com/floooh/sokol-tools) + + Cmdline: sokol-shdc --input lib/sloth/sloth_sokol_shader.glsl --output lib/sloth/sloth_sokol_shader.glsl.h --slang glsl330:hlsl5:metal_macos + + Overview: + + Shader program 'sloth_viz': + Get shader desc: sloth_viz_shader_desc(sg_query_backend()); + Vertex shader: sloth_viz_vs + Attribute slots: + ATTR_sloth_viz_vs_position = 0 + ATTR_sloth_viz_vs_uv = 1 + ATTR_sloth_viz_vs_color = 2 + Uniform block 'sloth_viz_vs_params': + C struct: sloth_viz_vs_params_t + Bind slot: SLOT_sloth_viz_vs_params = 0 + Fragment shader: sloth_viz_fs + Image 'tex': + Type: SG_IMAGETYPE_2D + Component Type: SG_SAMPLERTYPE_FLOAT + Bind slot: SLOT_tex = 0 + + + Shader descriptor structs: + + sg_shader sloth_viz = sg_make_shader(sloth_viz_shader_desc(sg_query_backend())); + + Vertex attribute locations for vertex shader 'sloth_viz_vs': + + sg_pipeline pip = sg_make_pipeline(&(sg_pipeline_desc){ + .layout = { + .attrs = { + [ATTR_sloth_viz_vs_position] = { ... }, + [ATTR_sloth_viz_vs_uv] = { ... }, + [ATTR_sloth_viz_vs_color] = { ... }, + }, + }, + ...}); + + Image bind slots, use as index in sg_bindings.vs_images[] or .fs_images[] + + SLOT_tex = 0; + + Bind slot and C-struct for uniform block 'sloth_viz_vs_params': + + sloth_viz_vs_params_t sloth_viz_vs_params = { + .mvp = ...; + }; + sg_apply_uniforms(SG_SHADERSTAGE_[VS|FS], SLOT_sloth_viz_vs_params, &SG_RANGE(sloth_viz_vs_params)); + +*/ +#include <stdint.h> +#include <stdbool.h> +#include <string.h> +#include <stddef.h> +#if !defined(SOKOL_SHDC_ALIGN) + #if defined(_MSC_VER) + #define SOKOL_SHDC_ALIGN(a) __declspec(align(a)) + #else + #define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a))) + #endif +#endif +#define ATTR_sloth_viz_vs_position (0) +#define ATTR_sloth_viz_vs_uv (1) +#define ATTR_sloth_viz_vs_color (2) +#define SLOT_tex (0) +#define SLOT_sloth_viz_vs_params (0) +#pragma pack(push,1) +SOKOL_SHDC_ALIGN(16) typedef struct sloth_viz_vs_params_t { + hmm_mat4 mvp; +} sloth_viz_vs_params_t; +#pragma pack(pop) +/* + #version 330 + + uniform vec4 sloth_viz_vs_params[4]; + layout(location = 0) in vec3 position; + out vec2 o_uv; + layout(location = 1) in vec2 uv; + out vec4 o_color; + layout(location = 2) in vec4 color; + + void main() + { + gl_Position = mat4(sloth_viz_vs_params[0], sloth_viz_vs_params[1], sloth_viz_vs_params[2], sloth_viz_vs_params[3]) * vec4(position, 1.0); + o_uv = uv; + o_color = color; + } + +*/ +static const char sloth_viz_vs_source_glsl330[389] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x73,0x6c,0x6f,0x74,0x68, + 0x5f,0x76,0x69,0x7a,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34, + 0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69, + 0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20, + 0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65, + 0x63,0x32,0x20,0x6f,0x5f,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28, + 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e, + 0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65, + 0x63,0x34,0x20,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, + 0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d, + 0x20,0x6d,0x61,0x74,0x34,0x28,0x73,0x6c,0x6f,0x74,0x68,0x5f,0x76,0x69,0x7a,0x5f, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x73,0x6c, + 0x6f,0x74,0x68,0x5f,0x76,0x69,0x7a,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x5b,0x31,0x5d,0x2c,0x20,0x73,0x6c,0x6f,0x74,0x68,0x5f,0x76,0x69,0x7a,0x5f, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x73,0x6c, + 0x6f,0x74,0x68,0x5f,0x76,0x69,0x7a,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73, + 0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x6f,0x5f,0x75,0x76,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b, + 0x0a,0x7d,0x0a,0x0a,0x00, +}; +/* + #version 330 + + uniform sampler2D tex; + + layout(location = 0) out vec4 frag_color; + in vec2 o_uv; + in vec4 o_color; + + void main() + { + frag_color = texture(tex, o_uv) * o_color; + } + +*/ +static const char sloth_viz_fs_source_glsl330[177] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20, + 0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63, + 0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76, + 0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, + 0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x6f,0x5f,0x75,0x76,0x3b,0x0a,0x69,0x6e, + 0x20,0x76,0x65,0x63,0x34,0x20,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a, + 0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74, + 0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x6f,0x5f,0x75,0x76, + 0x29,0x20,0x2a,0x20,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a, + 0x00, +}; +/* + cbuffer sloth_viz_vs_params : register(b0) + { + row_major float4x4 _21_mvp : packoffset(c0); + }; + + + static float4 gl_Position; + static float3 position; + static float2 o_uv; + static float2 uv; + static float4 o_color; + static float4 color; + + struct SPIRV_Cross_Input + { + float3 position : TEXCOORD0; + float2 uv : TEXCOORD1; + float4 color : TEXCOORD2; + }; + + struct SPIRV_Cross_Output + { + float2 o_uv : TEXCOORD0; + float4 o_color : TEXCOORD1; + float4 gl_Position : SV_Position; + }; + + #line 23 "lib/sloth/sloth_sokol_shader.glsl" + void vert_main() + { + #line 23 "lib/sloth/sloth_sokol_shader.glsl" + gl_Position = mul(float4(position, 1.0f), _21_mvp); + #line 24 "lib/sloth/sloth_sokol_shader.glsl" + o_uv = uv; + #line 25 "lib/sloth/sloth_sokol_shader.glsl" + o_color = color; + } + + SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) + { + position = stage_input.position; + uv = stage_input.uv; + color = stage_input.color; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.o_uv = o_uv; + stage_output.o_color = o_color; + return stage_output; + } +*/ +static const char sloth_viz_vs_source_hlsl5[1121] = { + 0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x73,0x6c,0x6f,0x74,0x68,0x5f,0x76,0x69, + 0x7a,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x3a,0x20,0x72,0x65, + 0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20, + 0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x34,0x78,0x34,0x20,0x5f,0x32,0x31,0x5f,0x6d,0x76,0x70,0x20,0x3a,0x20,0x70,0x61, + 0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b, + 0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34, + 0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74, + 0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x6f,0x73,0x69, + 0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x32,0x20,0x6f,0x5f,0x75,0x76,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a,0x73,0x74,0x61,0x74, + 0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20, + 0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75, + 0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f, + 0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20, + 0x75,0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x32,0x3b,0x0a,0x7d,0x3b, + 0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43, + 0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x6f,0x5f,0x75,0x76,0x20,0x3a,0x20, + 0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20, + 0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b, + 0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x33,0x20,0x22,0x6c, + 0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x5f,0x73, + 0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c, + 0x22,0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e, + 0x28,0x29,0x0a,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x33,0x20,0x22,0x6c, + 0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x5f,0x73, + 0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c, + 0x22,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20, + 0x5f,0x32,0x31,0x5f,0x6d,0x76,0x70,0x29,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20, + 0x32,0x34,0x20,0x22,0x6c,0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x2f,0x73,0x6c, + 0x6f,0x74,0x68,0x5f,0x73,0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68,0x61,0x64,0x65,0x72, + 0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x5f,0x75,0x76,0x20, + 0x3d,0x20,0x75,0x76,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x35,0x20,0x22, + 0x6c,0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x5f, + 0x73,0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73, + 0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56, + 0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61, + 0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49, + 0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74, + 0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20, + 0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x75,0x76, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x73,0x74, + 0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73, + 0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f, + 0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65, + 0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74, + 0x70,0x75,0x74,0x2e,0x6f,0x5f,0x75,0x76,0x20,0x3d,0x20,0x6f,0x5f,0x75,0x76,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75, + 0x74,0x2e,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x6f,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20, + 0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a, + 0x00, +}; +/* + Texture2D<float4> tex : register(t0); + SamplerState _tex_sampler : register(s0); + + static float4 frag_color; + static float2 o_uv; + static float4 o_color; + + struct SPIRV_Cross_Input + { + float2 o_uv : TEXCOORD0; + float4 o_color : TEXCOORD1; + }; + + struct SPIRV_Cross_Output + { + float4 frag_color : SV_Target0; + }; + + #line 15 "lib/sloth/sloth_sokol_shader.glsl" + void frag_main() + { + #line 15 "lib/sloth/sloth_sokol_shader.glsl" + frag_color = tex.Sample(_tex_sampler, o_uv) * o_color; + } + + SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) + { + o_uv = stage_input.o_uv; + o_color = stage_input.o_color; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.frag_color = frag_color; + return stage_output; + } +*/ +static const char sloth_viz_fs_source_hlsl5[727] = { + 0x54,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x34, + 0x3e,0x20,0x74,0x65,0x78,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72, + 0x28,0x74,0x30,0x29,0x3b,0x0a,0x53,0x61,0x6d,0x70,0x6c,0x65,0x72,0x53,0x74,0x61, + 0x74,0x65,0x20,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20, + 0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x73,0x30,0x29,0x3b,0x0a, + 0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66, + 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69, + 0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x6f,0x5f,0x75,0x76,0x3b,0x0a,0x73, + 0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x5f,0x63, + 0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50, + 0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a, + 0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x6f,0x5f,0x75, + 0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,0x7d, + 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f, + 0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74, + 0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x35,0x20, + 0x22,0x6c,0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x2f,0x73,0x6c,0x6f,0x74,0x68, + 0x5f,0x73,0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c, + 0x73,0x6c,0x22,0x0a,0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61, + 0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x35,0x20, + 0x22,0x6c,0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x2f,0x73,0x6c,0x6f,0x74,0x68, + 0x5f,0x73,0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c, + 0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c, + 0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28, + 0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x2c,0x20,0x6f,0x5f, + 0x75,0x76,0x29,0x20,0x2a,0x20,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d, + 0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75, + 0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f, + 0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67, + 0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6f, + 0x5f,0x75,0x76,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75, + 0x74,0x2e,0x6f,0x5f,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75, + 0x74,0x2e,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70, + 0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75, + 0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66, + 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72, + 0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70, + 0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00, +}; +/* + #include <metal_stdlib> + #include <simd/simd.h> + + using namespace metal; + + struct sloth_viz_vs_params + { + float4x4 mvp; + }; + + struct main0_out + { + float2 o_uv [[user(locn0)]]; + float4 o_color [[user(locn1)]]; + float4 gl_Position [[position]]; + }; + + struct main0_in + { + float3 position [[attribute(0)]]; + float2 uv [[attribute(1)]]; + float4 color [[attribute(2)]]; + }; + + #line 23 "lib/sloth/sloth_sokol_shader.glsl" + vertex main0_out main0(main0_in in [[stage_in]], constant sloth_viz_vs_params& _21 [[buffer(0)]]) + { + main0_out out = {}; + #line 23 "lib/sloth/sloth_sokol_shader.glsl" + out.gl_Position = _21.mvp * float4(in.position, 1.0); + #line 24 "lib/sloth/sloth_sokol_shader.glsl" + out.o_uv = in.uv; + #line 25 "lib/sloth/sloth_sokol_shader.glsl" + out.o_color = in.color; + return out; + } + +*/ +static const char sloth_viz_vs_source_metal_macos[811] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x73, + 0x6c,0x6f,0x74,0x68,0x5f,0x76,0x69,0x7a,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61, + 0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78, + 0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63, + 0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x6f,0x5f,0x75,0x76,0x20,0x5b,0x5b, + 0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d, + 0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c, + 0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69, + 0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75, + 0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75, + 0x76,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29, + 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65, + 0x28,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65, + 0x20,0x32,0x33,0x20,0x22,0x6c,0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x2f,0x73, + 0x6c,0x6f,0x74,0x68,0x5f,0x73,0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68,0x61,0x64,0x65, + 0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61, + 0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e, + 0x74,0x20,0x73,0x6c,0x6f,0x74,0x68,0x5f,0x76,0x69,0x7a,0x5f,0x76,0x73,0x5f,0x70, + 0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x31,0x20,0x5b,0x5b,0x62,0x75,0x66, + 0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20, + 0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x33,0x20,0x22,0x6c,0x69, + 0x62,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x5f,0x73,0x6f, + 0x6b,0x6f,0x6c,0x5f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22, + 0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x32,0x31,0x2e,0x6d,0x76,0x70,0x20,0x2a, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65, + 0x20,0x32,0x34,0x20,0x22,0x6c,0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x2f,0x73, + 0x6c,0x6f,0x74,0x68,0x5f,0x73,0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68,0x61,0x64,0x65, + 0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e, + 0x6f,0x5f,0x75,0x76,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x3b,0x0a,0x23,0x6c, + 0x69,0x6e,0x65,0x20,0x32,0x35,0x20,0x22,0x6c,0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74, + 0x68,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x5f,0x73,0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68, + 0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f, + 0x75,0x74,0x2e,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e, + 0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72, + 0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +}; +/* + #include <metal_stdlib> + #include <simd/simd.h> + + using namespace metal; + + struct main0_out + { + float4 frag_color [[color(0)]]; + }; + + struct main0_in + { + float2 o_uv [[user(locn0)]]; + float4 o_color [[user(locn1)]]; + }; + + #line 15 "lib/sloth/sloth_sokol_shader.glsl" + fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler texSmplr [[sampler(0)]]) + { + main0_out out = {}; + #line 15 "lib/sloth/sloth_sokol_shader.glsl" + out.frag_color = tex.sample(texSmplr, in.o_uv) * in.o_color; + return out; + } + +*/ +static const char sloth_viz_fs_source_metal_macos[544] = { + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d, + 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, + 0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20, + 0x6f,0x5f,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, + 0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34, + 0x20,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28, + 0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c, + 0x69,0x6e,0x65,0x20,0x31,0x35,0x20,0x22,0x6c,0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74, + 0x68,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x5f,0x73,0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68, + 0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x66,0x72,0x61,0x67,0x6d, + 0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61, + 0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20, + 0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65, + 0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x74, + 0x65,0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d, + 0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x74,0x65,0x78,0x53,0x6d, + 0x70,0x6c,0x72,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29, + 0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f, + 0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c, + 0x69,0x6e,0x65,0x20,0x31,0x35,0x20,0x22,0x6c,0x69,0x62,0x2f,0x73,0x6c,0x6f,0x74, + 0x68,0x2f,0x73,0x6c,0x6f,0x74,0x68,0x5f,0x73,0x6f,0x6b,0x6f,0x6c,0x5f,0x73,0x68, + 0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f, + 0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20, + 0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x74,0x65,0x78,0x53,0x6d, + 0x70,0x6c,0x72,0x2c,0x20,0x69,0x6e,0x2e,0x6f,0x5f,0x75,0x76,0x29,0x20,0x2a,0x20, + 0x69,0x6e,0x2e,0x6f,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, + +}; +#if !defined(SOKOL_GFX_INCLUDED) + #error "Please include sokol_gfx.h before sloth_sokol_shader.glsl.h" +#endif +static inline const sg_shader_desc* sloth_viz_shader_desc(sg_backend backend) { + if (backend == SG_BACKEND_GLCORE33) { + static sg_shader_desc desc; + static bool valid; + if (!valid) { + valid = true; + desc.attrs[0].name = "position"; + desc.attrs[1].name = "uv"; + desc.attrs[2].name = "color"; + desc.vs.source = sloth_viz_vs_source_glsl330; + desc.vs.entry = "main"; + desc.vs.uniform_blocks[0].size = 64; + desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140; + desc.vs.uniform_blocks[0].uniforms[0].name = "sloth_viz_vs_params"; + desc.vs.uniform_blocks[0].uniforms[0].type = SG_UNIFORMTYPE_FLOAT4; + desc.vs.uniform_blocks[0].uniforms[0].array_count = 4; + desc.fs.source = sloth_viz_fs_source_glsl330; + desc.fs.entry = "main"; + desc.fs.images[0].name = "tex"; + desc.fs.images[0].image_type = SG_IMAGETYPE_2D; + desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT; + desc.label = "sloth_viz_shader"; + } + return &desc; + } + if (backend == SG_BACKEND_D3D11) { + static sg_shader_desc desc; + static bool valid; + if (!valid) { + valid = true; + desc.attrs[0].sem_name = "TEXCOORD"; + desc.attrs[0].sem_index = 0; + desc.attrs[1].sem_name = "TEXCOORD"; + desc.attrs[1].sem_index = 1; + desc.attrs[2].sem_name = "TEXCOORD"; + desc.attrs[2].sem_index = 2; + desc.vs.source = sloth_viz_vs_source_hlsl5; + desc.vs.d3d11_target = "vs_5_0"; + desc.vs.entry = "main"; + desc.vs.uniform_blocks[0].size = 64; + desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140; + desc.fs.source = sloth_viz_fs_source_hlsl5; + desc.fs.d3d11_target = "ps_5_0"; + desc.fs.entry = "main"; + desc.fs.images[0].name = "tex"; + desc.fs.images[0].image_type = SG_IMAGETYPE_2D; + desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT; + desc.label = "sloth_viz_shader"; + } + return &desc; + } + if (backend == SG_BACKEND_METAL_MACOS) { + static sg_shader_desc desc; + static bool valid; + if (!valid) { + valid = true; + desc.vs.source = sloth_viz_vs_source_metal_macos; + desc.vs.entry = "main0"; + desc.vs.uniform_blocks[0].size = 64; + desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140; + desc.fs.source = sloth_viz_fs_source_metal_macos; + desc.fs.entry = "main0"; + desc.fs.images[0].name = "tex"; + desc.fs.images[0].image_type = SG_IMAGETYPE_2D; + desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT; + desc.label = "sloth_viz_shader"; + } + return &desc; + } + return 0; +} diff --git a/src_v2/libs/sloth/sloth_tests.c b/src_v2/libs/sloth/sloth_tests.c new file mode 100644 index 0000000..ce05888 --- /dev/null +++ b/src_v2/libs/sloth/sloth_tests.c @@ -0,0 +1,696 @@ + +#define sloth_test_assert(c) if (!(c)) { do{ *((volatile int*)0) = 0xFFFF; }while(0); } + +#define sloth_r32_equals(a,b) (fabsf((a) - (b)) < 0.001f) + +Sloth_U32 +sloth_test_string_len(char* s) +{ + char* at = s; + while (*at != 0) at++; + return (Sloth_U32)(at - s); +} + +bool +sloth_test_strings_equal(char* a, char* b) +{ + Sloth_U32 a_len = sloth_test_string_len(a); + Sloth_U32 b_len = sloth_test_string_len(b); + if (a_len != b_len) return false; + for (Sloth_U32 i = 0; i < a_len; i++) { + if (a[i] != b[i]) return false; + } + return true; +} + +static Sloth_U32 sloth_test_widget_order_count = 0; +void +sloth_test_widget_order(Sloth_Ctx* ctx, Sloth_Widget* widget, Sloth_U8* user_data) +{ + Sloth_ID* ids = (Sloth_ID*)user_data; + Sloth_ID id_at = ids[sloth_test_widget_order_count++]; + sloth_test_assert(sloth_ids_equal(widget->id, id_at)); +} + +// Naive string sizing +Sloth_V2 +sloth_test_get_text_size(Sloth_Widget* widget) +{ + Sloth_V2 result = { + .x = widget->text_len * 14, + .y = 14, + }; + return result; +} + +// The error this is trying to catch takes place across three frames +// Frame 1: all widgets are drawn +// Frame 2: a widget early in teh tree is removed +// Frame 3: a widget late in the tree is removed +// importantly, this widget comes after a widget that +// has children. ie. The tree must look like: +// root +// <removed on frame 1> +// widget +// child +// <removed on frame 2> +void +sloth_test_multi_frame_removal_frame(Sloth_Ctx* sloth, int num_to_remove) +{ + Sloth_Widget_Desc d = {}; + sloth_frame_prepare(sloth); + + sloth_push_widget(sloth, d, "Root"); // root + { + if (num_to_remove < 1) { + sloth_push_widget(sloth, d, "remove 1"); + sloth_pop_widget(sloth); + } + + sloth_push_widget(sloth, d, "bar_bounds_inner"); + { + sloth_push_widget(sloth, d, "fg_bar"); + sloth_pop_widget(sloth); + } + sloth_pop_widget(sloth); + + if (num_to_remove < 2) { + sloth_push_widget(sloth, d, "remove 2"); + sloth_pop_widget(sloth); + } + } + sloth_pop_widget(sloth); + + sloth_frame_advance(sloth); +} +void +sloth_test_multi_frame_removal_frame_b(Sloth_Ctx* sloth, int num_to_remove) +{ + Sloth_Widget_Desc d = {}; + sloth_frame_prepare(sloth); + + sloth_push_widget(sloth, d, "Root"); // root + { + if (num_to_remove < 1) { + sloth_push_widget(sloth, d, "remove 1"); + sloth_pop_widget(sloth); + } + + sloth_push_widget(sloth, d, "a"); + { + sloth_push_widget(sloth, d, "bar_bounds_inner"); + { + sloth_push_widget(sloth, d, "fg_bar"); + sloth_pop_widget(sloth); + } + sloth_pop_widget(sloth); + + if (num_to_remove < 2) { + sloth_push_widget(sloth, d, "remove 2"); + sloth_pop_widget(sloth); + } + } + sloth_pop_widget(sloth); + } + sloth_pop_widget(sloth); + + sloth_frame_advance(sloth); +} + +void +sloth_test_multi_frame_removal() +{ + Sloth_Ctx sloth = {}; + sloth_test_multi_frame_removal_frame(&sloth, 0); + sloth_test_multi_frame_removal_frame(&sloth, 1); + sloth_test_multi_frame_removal_frame(&sloth, 2); + sloth_ctx_free(&sloth); + + sloth = (Sloth_Ctx){}; + sloth_test_multi_frame_removal_frame_b(&sloth, 0); + sloth_test_multi_frame_removal_frame_b(&sloth, 1); + sloth_test_multi_frame_removal_frame_b(&sloth, 2); + sloth_ctx_free(&sloth); +} + +void +sloth_tests() +{ + + sloth_test_assert(sloth_is_pow2(2048)); + sloth_test_assert(!sloth_is_pow2(1920)); + + // ID Creation Tests + char test_id_str[] = "Test id##53"; + int test_id_str_len = (sizeof(test_id_str) / sizeof(char)) - 1; + + Sloth_ID_Result id0 = sloth_make_id(test_id_str); + sloth_test_assert(id0.id.value != 0); + sloth_test_assert(id0.display_len == test_id_str_len - 4); + + Sloth_ID_Result id1 = sloth_make_id_len(11, "Test id##53"); + sloth_test_assert(id0.id.value == id1.id.value); + + Sloth_ID_Result id2 = sloth_make_id_f("Test id###%d", 53); + sloth_test_assert(id2.id.value != 0); + sloth_test_assert(id2.id.value != id0.id.value); + sloth_test_assert(id2.display_len == 7); + + // Vectors + Sloth_V2 va = { 25, 32.1f }; + Sloth_V2 vb = { 19, 18.1f }; + + Sloth_V2 rv0 = sloth_v2_add(va, vb); + sloth_test_assert(sloth_r32_equals(rv0.x, 44)); + sloth_test_assert(sloth_r32_equals(rv0.y, 50.2f)); + + Sloth_V2 rv1 = sloth_v2_sub(va, vb); + sloth_test_assert(sloth_r32_equals(rv1.x, 6)); + sloth_test_assert(sloth_r32_equals(rv1.y, 14)); + + Sloth_V2 rv2 = sloth_v2_mulf(va, 2); + sloth_test_assert(sloth_r32_equals(rv2.x, 50)); + sloth_test_assert(sloth_r32_equals(rv2.y, 64.2f)); + + // Rects + // baseline rect + Sloth_Rect rect0 = { + .value_min = { 0, 0 }, + .value_max = { 100, 100 }, + }; + // overlaps rect0 to right and top + Sloth_Rect rect1 = { + .value_min = { 50, 50 }, + .value_max = { 150, 150 }, + }; + // overlaps rect1 to the left and bottom + Sloth_Rect rect2 = { + .value_min = { -50, -50 }, + .value_max = { 50, 50 }, + }; + // no overlap with rect0 to the left and bottom + Sloth_Rect rect3 = { + .value_min = { -250, -250 }, + .value_max = { -200, -200 } + }; + // no overlap with rect0 to the right and top + Sloth_Rect rect4 = { + .value_min = { 250, 250 }, + .value_max = { 200, 200 } + }; + // contains rect0 + Sloth_Rect rect5 = { + .value_min = { -50, -50 }, + .value_max = { 200, 200 } + }; + + Sloth_Rect rr0 = sloth_rect_union(rect0, rect1); + sloth_test_assert(rr0.value_min.x == 50 && rr0.value_min.y == 50); + sloth_test_assert(rr0.value_max.x == 100 && rr0.value_max.y == 100); + + Sloth_Rect rr1 = sloth_rect_union(rect0, rect2); + sloth_test_assert(rr1.value_min.x == 0 && rr1.value_min.y == 0); + sloth_test_assert(rr1.value_max.x == 50 && rr1.value_max.y == 50); + + Sloth_Rect rr2 = sloth_rect_union(rect0, rect3); + sloth_test_assert(rr2.value_min.x == 0 && rr2.value_min.y == 0); + sloth_test_assert(rr2.value_max.x == 0 && rr2.value_max.y == 0); + + Sloth_Rect rr3 = sloth_rect_union(rect0, rect4); + sloth_test_assert(rr3.value_min.x == 0 && rr3.value_min.y == 0); + sloth_test_assert(rr3.value_max.x == 0 && rr3.value_max.y == 0); + + Sloth_Rect rr4 = sloth_rect_union(rect0, rect5); + sloth_test_assert(rr4.value_min.x == 0 && rr4.value_min.y == 0); + sloth_test_assert(rr4.value_max.x == 100 && rr4.value_max.y == 100); + + // contained by rect0 + Sloth_V2 rectp0 = { 25, 25 }; + // not contained by rect0 to the right and top + Sloth_V2 rectp1 = { 150, 150 }; + // not contained by rect0 to the left and bottom + Sloth_V2 rectp2 = { -25, -25 }; + + sloth_test_assert(sloth_rect_contains(rect0, rectp0)); + sloth_test_assert(!sloth_rect_contains(rect0, rectp1)); + sloth_test_assert(!sloth_rect_contains(rect0, rectp2)); + + // Hashtable Tests + { + Sloth_Hashtable table = {}; + sloth_hashtable_add(&table, 256, (Sloth_U8*)1); + sloth_hashtable_add(&table, 394, (Sloth_U8*)2); + sloth_hashtable_add(&table, 81932, (Sloth_U8*)3); + + // this should force chaining + sloth_hashtable_add(&table, table.cap + 256, (Sloth_U8*)4); + + Sloth_U64 v0 = (Sloth_U64)sloth_hashtable_get(&table, 256); + sloth_test_assert(v0 == 1); + Sloth_U64 v1 = (Sloth_U64)sloth_hashtable_get(&table, 394); + sloth_test_assert(v1 == 2); + Sloth_U64 v2 = (Sloth_U64)sloth_hashtable_get(&table, 81932); + sloth_test_assert(v2 == 3); + Sloth_U64 v3 = (Sloth_U64)sloth_hashtable_get(&table, table.cap + 256); + sloth_test_assert(v3 == 4); + + // getting a value that's not present + Sloth_U64 vi = (Sloth_U64)sloth_hashtable_get(&table, 3333); + sloth_test_assert(vi == 0); + + Sloth_Bool r0 = sloth_hashtable_rem(&table, 256); + sloth_test_assert(r0); + v0 = (Sloth_U64)sloth_hashtable_get(&table, 256); + sloth_test_assert(v0 == 0); + } + + { // Arena Tests + + Sloth_Arena arena = {}; + Sloth_U32* array_0 = sloth_arena_push_array(&arena, Sloth_U32, 32); + for (Sloth_U32 i = 0; i < 32; i++) array_0[i] = i; + sloth_test_assert(array_0 != 0); + + Sloth_Arena_Loc old_at = sloth_arena_at(&arena); + sloth_test_assert(old_at.bucket_at == sizeof(Sloth_U32) * 32); + + Sloth_U32* array_1 = sloth_arena_push_array(&arena, Sloth_U32, 32); + for (Sloth_U32 i = 0; i < 32; i++) array_1[i] = (i + 32); + sloth_test_assert(array_1 >= (array_0 + 32)); + sloth_test_assert(array_1 != 0); + sloth_test_assert(array_0[31] == 31); + sloth_test_assert(array_1[0] == 32); + + // testing memory reuse after popping + sloth_arena_pop(&arena, old_at); + // test that in debug mode, popped memory is cleared + // NOTE: that if we aren't in debug mode, sloth_test_assert evaluates to + // nothing, so the test won't run + for (Sloth_U32 i = 0; i < 32; i++) sloth_test_assert(array_1[i] == 0); + + Sloth_U32* array_1b = sloth_arena_push_array(&arena, Sloth_U32, 32); + sloth_test_assert(array_1 == array_1b); + + // testing memory reuse after clearing + sloth_arena_clear(&arena); + Sloth_U32* array_0b = sloth_arena_push_array(&arena, Sloth_U32, 32); + sloth_test_assert(array_0 == array_0b); + + sloth_arena_free(&arena); + sloth_test_assert(!arena.buckets); + sloth_test_assert(!arena.buckets_len); + sloth_test_assert(!arena.buckets_cap); + sloth_test_assert(!arena.bucket_cap); + sloth_test_assert(!arena.curr_bucket_len); + } + + { // Gamma correction + Sloth_R32 r_in = 0.2f; + Sloth_R32 g_in = 0.5f; + Sloth_R32 b_in = 0.9f; + Sloth_R32 a_in = 0.1f; + Sloth_U32 color = (((Sloth_U32)(r_in * 255) << 24) | + ((Sloth_U32)(g_in * 255) << 16) | + ((Sloth_U32)(b_in * 255) << 8) | + ((Sloth_U32)(a_in * 255))); + + // gamma = 1, no change + Sloth_U32 color_out0 = sloth_color_apply_gamma(color, 1); + sloth_assert(color_out0 == color); + + // gamma = 2.2, verify changes + Sloth_U32 color_out1 = sloth_color_apply_gamma(color, 2.2f); + Sloth_R32 r = (Sloth_R32)((color_out1 >> 24) & 0xFF) / 255.0f; + Sloth_R32 g = (Sloth_R32)((color_out1 >> 16) & 0xFF) / 255.0f; + Sloth_R32 b = (Sloth_R32)((color_out1 >> 8) & 0xFF) / 255.0f; + Sloth_R32 a = (Sloth_R32)((color_out1 ) & 0xFF) / 255.0f; + + Sloth_R32 delta_r = fabsf(r - powf(r_in, 2.2f)); + Sloth_R32 delta_g = fabsf(g - powf(g_in, 2.2f)); + Sloth_R32 delta_b = fabsf(b - powf(b_in, 2.2f)); + Sloth_R32 delta_a = fabsf(a - powf(a_in, 2.2f)); + + sloth_assert(delta_r < 0.01f); + sloth_assert(delta_g < 0.01f); + sloth_assert(delta_b < 0.01f); + sloth_assert(delta_a < 0.01f); + } + + { // Atlas Tests + Sloth_U32 test_icon[] = { + 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF, 0x000000FF, + 0x000000FF, 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF, + 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF, 0x000000FF, + 0x000000FF, 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF, + }; + + Sloth_Glyph_Atlas atlas = {}; + sloth_glyph_atlas_resize(&atlas, 32); + + Sloth_Glyph_Desc gd0 = { + .family = 1, + .id = 25, + .data = (Sloth_U8*)test_icon, + .width = 4, + .height = 4, + .stride = 4, + .format = Sloth_GlyphData_RGBA8, + }; + Sloth_Glyph_ID id_0 = sloth_glyph_atlas_register(&atlas, gd0); + Sloth_U32 last_glyph = atlas.last_glyph; + sloth_test_assert(atlas.glyphs_table.used == 1); + + // testing adding the same glyph a second time. + Sloth_Glyph_ID id_01 = sloth_glyph_atlas_register(&atlas, gd0); + sloth_test_assert(id_01.value == id_0.value); + sloth_test_assert(atlas.last_glyph == last_glyph); + sloth_test_assert(atlas.glyphs_table.used == 1); // no sprite was added + + Sloth_Glyph_Desc gd2 = gd0; + gd2.id = 26; + Sloth_Glyph_ID id_2 = sloth_glyph_atlas_register(&atlas, gd2); + sloth_test_assert(id_2.value != 0); + + Sloth_Glyph_Desc gd3 = gd0; + gd3.id = 27; + Sloth_Glyph_ID id_3 = sloth_glyph_atlas_register(&atlas, gd3); + sloth_test_assert(id_3.value != 0); + + Sloth_Glyph_Desc gd4 = gd0; + gd4.id = 28; + Sloth_Glyph_ID id_4 = sloth_glyph_atlas_register(&atlas, gd4); + sloth_test_assert(id_4.value != 0); + sloth_test_assert(id_4.family == gd0.family); + sloth_test_assert(id_4.id[0] == 28 && id_4.id[1] == 0 && id_4.id[2] == 0); + + Sloth_Glyph_Desc gd5 = gd0; + gd5.id = 29; + Sloth_Glyph_ID id_5 = sloth_glyph_atlas_register(&atlas, gd5); + sloth_test_assert(id_5.value != 0); + sloth_test_assert(id_5.family == 1); + sloth_test_assert(id_5.id[0] == 29 && id_5.id[1] == 0 && id_5.id[2] == 0); + + sloth_glyph_atlas_free(&atlas); + + // Glyph ID Tests + Sloth_Glyph_ID g_id = sloth_make_glyph_id(24, 'G'); + Sloth_Glyph_ID newline_id = sloth_make_glyph_id(32, '\n'); + Sloth_Glyph_ID space_id = sloth_make_glyph_id(127, ' '); + sloth_test_assert(sloth_glyph_id_matches_charcode(g_id, 'G')); + sloth_test_assert(sloth_glyph_id_matches_charcode(newline_id, '\n')); + sloth_test_assert(sloth_glyph_id_matches_charcode(space_id, ' ')); + } + + { // Sloth_Size tests + + // see @Maintenance tag in Sloth_Size_Box if this fails + Sloth_Size_Box b = { + .left = sloth_size_pixels(0), + .right = sloth_size_pixels(5), + .top = sloth_size_pixels(10), + .bottom = sloth_size_pixels(15), + }; + + // testing to make sure left corresponds to E[Axis_X].min + // and so on + sloth_test_assert(b.E[Sloth_Axis_X].min.value == 0); + sloth_test_assert(b.E[Sloth_Axis_X].max.value == 5); + sloth_test_assert(b.E[Sloth_Axis_Y].min.value == 10); + sloth_test_assert(b.E[Sloth_Axis_Y].max.value == 15); + } + + // Widget Tree Construction + { + Sloth_Ctx sloth = { + .per_frame_memory.name = "pfm", + .scratch.name = "scratch", + }; + + Sloth_Widget_Desc d = {}; // these tests don't depend on the desc at all + Sloth_ID ids0_preorder[] = { + sloth_make_id_f("Root").id, + sloth_make_id_f("W1").id, + sloth_make_id_f("W11").id, + sloth_make_id_f("W12").id, + sloth_make_id_f("W2").id, + sloth_make_id_f("W3").id, + sloth_make_id_f("W31").id + }; + Sloth_ID ids0_postorder[] = { + sloth_make_id_f("W11").id, + sloth_make_id_f("W12").id, + sloth_make_id_f("W1").id, + sloth_make_id_f("W2").id, + sloth_make_id_f("W31").id, + sloth_make_id_f("W3").id, + sloth_make_id_f("Root").id, + }; + printf("Frame 1\n"); + sloth_frame_prepare(&sloth); + sloth_push_widget(&sloth, d, "Root"); // root + sloth_push_widget(&sloth, d, "W1"); + sloth_push_widget(&sloth, d, "W11"); sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W12"); sloth_pop_widget(&sloth); + sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W2"); sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W3"); + sloth_push_widget(&sloth, d, "W31"); sloth_pop_widget(&sloth); + sloth_pop_widget(&sloth); + sloth_pop_widget(&sloth); // root - won't pop + + // walking the tree + sloth_test_assert(sloth.widget_tree_root != 0); + sloth_test_assert(sloth.widget_tree_depth_max == 3); + sloth_test_widget_order_count = 0; // reset test + sloth_tree_walk_preorder(&sloth, sloth_test_widget_order, (Sloth_U8*)&ids0_preorder); + sloth_test_widget_order_count = 0; // reset test + sloth_tree_walk_postorder(&sloth, sloth_test_widget_order, (Sloth_U8*)&ids0_postorder); + //sloth_widget_tree_print(&sloth); + + sloth_frame_advance(&sloth); + printf("Frame 2\n"); + sloth_frame_prepare(&sloth); + + // Same Frame as above + sloth_push_widget(&sloth, d, "Root"); // root + sloth_push_widget(&sloth, d, "W1"); + sloth_push_widget(&sloth, d, "W11"); sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W12"); sloth_pop_widget(&sloth); + sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W2"); sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W3"); + sloth_push_widget(&sloth, d, "W31"); sloth_pop_widget(&sloth); + sloth_pop_widget(&sloth); + sloth_pop_widget(&sloth); // root - won't pop + + // walking the tree + sloth_test_assert(sloth.widget_tree_root != 0); + sloth_test_widget_order_count = 0; // reset test + sloth_tree_walk_preorder(&sloth, sloth_test_widget_order, (Sloth_U8*)&ids0_preorder); + + sloth_frame_advance(&sloth); + sloth_frame_prepare(&sloth); + + // Different frame from above + Sloth_ID ids1[] = { + sloth_make_id_f("Root").id, + sloth_make_id_f("W1").id, + sloth_make_id_f("W11").id, + sloth_make_id_f("W13").id, + sloth_make_id_f("W14").id, + sloth_make_id_f("W12").id, + sloth_make_id_f("W2").id, + sloth_make_id_f("W21").id, + sloth_make_id_f("W3").id, + }; + sloth_push_widget(&sloth, d, "Root"); // root + sloth_push_widget(&sloth, d, "W1"); + sloth_push_widget(&sloth, d, "W11"); sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W13"); sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W14"); sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W12"); sloth_pop_widget(&sloth); + sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W2"); + sloth_push_widget(&sloth, d, "W21"); sloth_pop_widget(&sloth); + sloth_pop_widget(&sloth); + sloth_push_widget(&sloth, d, "W3"); + // old child should get freed + sloth_pop_widget(&sloth); + sloth_pop_widget(&sloth); // root - won't pop + + sloth_test_widget_order_count = 0; // reset test + sloth_tree_walk_preorder(&sloth, sloth_test_widget_order, (Sloth_U8*)&ids1); + + sloth_ctx_free(&sloth); + } + + + // Widget Tree - Removing Expected Next Sibling + sloth_test_multi_frame_removal(); + + // Widget Sizing + { + Sloth_Ctx sloth = { + }; + + sloth_frame_prepare(&sloth); + + Sloth_Widget_Desc ele_desc; + Sloth_Widget_Desc root_desc = { + .layout = { + .width = sloth_size_pixels(800), + .height = sloth_size_pixels(900), + //.margin.top = sloth_size_pixels(32), + .direction = Sloth_LayoutDirection_TopDown, + }, + .style.color_bg = 0x333333FF, + }; + sloth_push_widget(&sloth, root_desc, "root"); + ele_desc = (Sloth_Widget_Desc){ + .layout = { + .width = sloth_size_pixels(850), + .height = sloth_size_pixels(200), + }, + .style.color_bg = 0xFFFFFFFF, + }; + sloth_push_widget(&sloth, ele_desc, "ele0"); sloth_pop_widget(&sloth); + ele_desc.style.color_bg = 0xFF00FFFF; + sloth_push_widget(&sloth, ele_desc, "ele1"); sloth_pop_widget(&sloth); + sloth_pop_widget(&sloth); + + printf("==/==\n"); + sloth_frame_advance(&sloth); + sloth_frame_prepare(&sloth); + + Sloth_Widget* root = sloth.widget_tree_next_child; + sloth_test_assert(root->cached->offset.x == 0 && root->cached->offset.y == 0); + sloth_test_assert(root->cached->dim.x == 800 && root->cached->dim.y == 900); + + Sloth_Widget* ele0 = root->child_first; + sloth_test_assert(ele0->cached->offset.x == 0 && ele0->cached->offset.y == 0); + sloth_test_assert(ele0->cached->dim.x == 800 && ele0->cached->dim.y == 200); + + Sloth_Widget* ele1 = ele0->sibling_next; + sloth_test_assert(ele1->cached->offset.x == 0 && ele1->cached->offset.y == 200); + sloth_test_assert(ele1->cached->dim.x == 800 && ele1->cached->dim.y == 200); + + sloth_ctx_free(&sloth); + } + + return; +} + +bool +sloth_test_button_f(Sloth_Ctx* sloth, char* fmt, ...) +{ + Sloth_Widget_Desc desc = { + .layout = { + .width = sloth_size_text_content(), + .height = sloth_size_text_content(), + .margin = { + .left = sloth_size_pixels(12), + .right = sloth_size_pixels(12), + .top = sloth_size_pixels(0), + .bottom = sloth_size_pixels(8), + }, + }, + .style = { + .color_bg = 0x333333FF, + .color_text = 0xFFFFFFFF, + .color_outline = 0xFFFFFFFF, + .outline_thickness = 1, + .text_style = Sloth_TextStyle_Align_Center, + }, + }; + va_list args; va_start(args, fmt); + Sloth_Widget_Result r = sloth_push_widget_v(sloth, desc, fmt, args); + va_end(args); + sloth_pop_widget(sloth); + + if (r.clicked) { + r.widget->style.color_bg = 0xFFFFFFFF; + r.widget->style.color_text = 0x333333FF; + } + + return r.clicked; +} + +Sloth_R32 +sloth_test_slider_f(Sloth_Ctx* sloth, Sloth_R32 min, Sloth_R32 max, Sloth_R32 v, char* fmt, ...) +{ + Sloth_Widget_Desc desc = { + .layout = { + .width = sloth_size_pixels(128), + .height = sloth_size_pixels(32), + }, + .style = { + .color_bg = 0x333333FF, + .color_outline = 0xFFFFFFFF, + .outline_thickness = 1, + }, + .input.flags = Sloth_WidgetInput_Draggable + }; + + va_list args; va_start(args, fmt); + Sloth_Widget_Result r = sloth_push_widget_v(sloth, desc, fmt, args); + va_end(args); + + // background text + Sloth_Widget_Desc bg_text_desc = { + .layout = { + .width = sloth_size_percent_parent(1), + .height = sloth_size_percent_parent(1), + .position = { + .kind= Sloth_LayoutPosition_FixedInParent, + .left = sloth_size_pixels(0), + .top = sloth_size_pixels(0), + }, + .margin.left = sloth_size_pixels(8), + }, + .style = { + .color_text = 0xFFFFFFFF, + .text_style = Sloth_TextStyle_NoWrapText + }, + .input.flags = Sloth_WidgetInput_DoNotCaptureMouse, + }; + sloth_push_widget_f(sloth, bg_text_desc, "%f###%d_bg", v, r.widget->id.value); + sloth_pop_widget(sloth); + + // slider bar + Sloth_R32 pct = (v - min) / (max - min); + Sloth_Widget_Desc slider_desc = { + .layout = { + .width = sloth_size_percent_parent(pct), + .height = sloth_size_percent_parent(1), + .margin.left = sloth_size_pixels(8), + }, + .style = { + .color_bg = 0x00FFFFFF, + .color_text = 0x000000FF, + .text_style = Sloth_TextStyle_NoWrapText + }, + .input.flags = Sloth_WidgetInput_DoNotCaptureMouse + }; + Sloth_Widget_Result rs = sloth_push_widget_f(sloth, slider_desc, "%f###%d_slider", v, r.widget->id.value); + //printf("%d\n", r.widget->id.value); + sloth_pop_widget(sloth); + + sloth_pop_widget(sloth); + + + if (r.clicked) { + rs.widget->style.color_bg = 0xFFFFFFFF; + } + + Sloth_R32 result = v; + if (r.held) { + Sloth_R32 width = sloth_rect_dim(r.widget->cached->bounds).x; + Sloth_R32 init_pct = (sloth->mouse_down_pos.x - r.widget->cached->bounds.value_min.x) / width; + Sloth_R32 dx = r.drag_offset_pixels.x; + Sloth_R32 px = dx / width; + result = ((px + init_pct) * (max - min)) + min; + result = Sloth_Max(min, Sloth_Min(max, result)); + } + return result; +} + diff --git a/src_v2/libs/sloth/utils/sloth_profiler.c b/src_v2/libs/sloth/utils/sloth_profiler.c new file mode 100644 index 0000000..36d71cd --- /dev/null +++ b/src_v2/libs/sloth/utils/sloth_profiler.c @@ -0,0 +1,913 @@ +#ifndef SLOTH_PROFILER_C +#define SLOTH_PROFILER_C + +////////////////////////////////////////////////////////////////////////////// +// Context Cracking + +#if defined(__clang__) +# define SP_COMPILER_CLANG 1 + +# if defined(__APPLE__) && defined(__MACH__) +# define SP_OS_MAC 1 +# elif defined(__gnu_linux__) +# define SP_OS_LINUX 1 +# elif defined(_WIN32) +# define SP_OS_WINDOWS 1 +# else +# error The compiler/platform combo is not supported +# endif + +#elif defined(__GNUC__) || defined(__GNUG__) +# define SP_COMPILER_GCC 1 + +# if defined(__gnu_linux__) +# define SP_OS_LINUX 1 +# else +# error The compiler/platform combo is not supported +# endif + +#endif + +////////////////////////////////////////////////////////////////////////////// + +#ifndef SLOTH_PROFILER_FUNCTION +# define SLOTH_PROFILER_FUNCTION +#endif + +#ifndef sp_assert +# define sp_assert(v) +#endif + +#ifndef SP_U8 +# define SP_U8 unsigned char +#endif + +#ifndef SP_S32 +# define SP_S32 int +#endif + +#ifndef SP_U32 +# define SP_U32 unsigned int +#endif + +#ifndef SP_U64 +# define SP_U64 unsigned long long int +#endif + +#ifndef SP_R64 +# define SP_R64 double +#endif + +#ifndef SP_MALLOC +# define SP_MALLOC(type, count) (type*)malloc(sizeof(type) * (count)) +#endif + +#ifndef SP_REALLOC +# define SP_REALLOC(base, type, old_count, new_count) (type*)realloc((void*)(base), (new_count) * sizeof(type)) +#endif + +////////////////////////////////////////////////////////////////////////////// +// Scope Instrumentation + +#if !SP_COMPILER_CLANG && !SP_COMPILER_GCC +# error sloth_profiler.c currently relies on a defer implementation that utilizes clang/gcc extensions. +# error The compiler you are using is not supported. +#endif + +#ifndef defer + static inline void defer_cleanup(void (^*b)(void)) { (*b)(); } +# define defer_merge(a,b) a##b +# define defer_varname(a) defer_merge(defer_scopevar_, a) +# define defer __attribute__((cleanup(defer_cleanup))) void (^defer_varname(__COUNTER__))(void) = +#endif + +// Macros for easy #undef if not in debug mode +// NOTE: These are the preferred way to call the sloth_profiler functions +#define SLOTH_PROFILER_FRAME_BEGIN() sp_frame_begin() +#define SLOTH_PROFILER_FRAME_END() sp_frame_end() +#define SLOTH_PROFILER_SCOPE sp_scope_begin((char*)__FUNCTION__, (char*)__FILE__, (SP_S32)__LINE__); defer ^{ sp_scope_end(); }; + +SLOTH_PROFILER_FUNCTION void sp_init(Sloth_Ctx* sloth, SP_U32 frames_cap); +SLOTH_PROFILER_FUNCTION void sp_frame_begin(); +SLOTH_PROFILER_FUNCTION void sp_frame_end(); +SLOTH_PROFILER_FUNCTION void sp_scope_begin(char* function, char* file, SP_S32 line); +SLOTH_PROFILER_FUNCTION void sp_scope_end(); + +SLOTH_PROFILER_FUNCTION void sp_draw(); + +// Platform Time Keeping Implementations + +typedef struct Sloth_Profiler_Ticks Sloth_Profiler_Ticks; +struct Sloth_Profiler_Ticks +{ + SP_U64 value; +}; +SLOTH_PROFILER_FUNCTION void sp_ticks_os_init(); +SLOTH_PROFILER_FUNCTION Sloth_Profiler_Ticks sp_ticks_now(); +SLOTH_PROFILER_FUNCTION Sloth_Profiler_Ticks sp_ticks_elapsed(Sloth_Profiler_Ticks start, Sloth_Profiler_Ticks end); +SLOTH_PROFILER_FUNCTION SP_R64 sp_ticks_to_seconds(Sloth_Profiler_Ticks ticks); +SLOTH_PROFILER_FUNCTION SP_R64 sp_ticks_to_milliseconds(Sloth_Profiler_Ticks ticks); + +////////////////////////////////////////////////////////////////////////////// +// IMPLEMENTATION + +#if defined(SLOTH_PROFILER_IMPLEMENTATION) + +static const SP_U64 SP_NANOS_PER_SEC = 1000000000ULL; + +typedef struct Sloth_Profiler_Scope_Id Sloth_Profiler_Scope_Id; +struct Sloth_Profiler_Scope_Id +{ + SP_U32 value; +}; + +// a record of a single time a scope was called +typedef struct Sloth_Profiler_Scope_Call Sloth_Profiler_Scope_Call; +struct Sloth_Profiler_Scope_Call +{ + Sloth_Profiler_Scope_Id id; + char* name; // temp + Sloth_Profiler_Ticks start; + Sloth_Profiler_Ticks end; + SP_U32 parent; + SP_U32 first_child; + SP_U32 last_child; + SP_U32 next_sibling; +}; + +// A record of a particular scope, across all call so that scope +typedef struct Sloth_Profiler_Scope Sloth_Profiler_Scope; +struct Sloth_Profiler_Scope +{ + char* name; + char* file; + SP_U32 line; + + Sloth_Profiler_Ticks ticks_longest; + Sloth_Profiler_Ticks ticks_shortest; + Sloth_Profiler_Ticks ticks_average; + SP_U64 total_count; + SP_U64 count_last_frame; +}; + +typedef struct Sloth_Profiler_Frame Sloth_Profiler_Frame; +struct Sloth_Profiler_Frame +{ + Sloth_Profiler_Scope_Call* calls; + SP_U32 calls_len; + SP_U32 calls_cap; + SP_U32 parent_cur; + + Sloth_Profiler_Ticks start; + Sloth_Profiler_Ticks end; +}; + +enum { + SlothProfiler_Recording = 0, + SlothProfiler_WaitingToBeginRecording = 1, + SlothProfiler_Paused = 2 +}; + +typedef struct Sloth_Profiler_Ctx Sloth_Profiler_Ctx; +struct Sloth_Profiler_Ctx +{ + // hashtable of scopes + Sloth_Hashtable scope_ids; + Sloth_Profiler_Scope* scopes; + SP_U32 scopes_cap; + SP_U32 scopes_len; + + // ring buffer of stored frames + Sloth_Profiler_Frame* frames; + SP_U32 frames_cap; + SP_U32 frame_at; + + Sloth_U32 depth; + + // UI + SP_U32 ui_frame; + SP_U8 recording; + SP_R64 visible_min; + SP_R64 visible_max; +}; + +// a pointer to the applications Sloth_Ctx +// the profiler doesn't assume it owns this data +static Sloth_Ctx* sp_ctx_; +static Sloth_Profiler_Ctx* sp_pctx_; +static SP_R64 sp_ticks_per_second_; +static SP_R64 sp_ticks_per_millisecond_; + +SLOTH_PROFILER_FUNCTION void +sp_init(Sloth_Ctx* sloth, SP_U32 frames_cap) +{ + sp_ctx_ = sloth; + + sp_pctx_ = SP_MALLOC(Sloth_Profiler_Ctx, 1); + *sp_pctx_ = (Sloth_Profiler_Ctx){ + // Sloth_Hashtable has a default size of 2048 + .scope_ids = {}, + .scopes = SP_MALLOC(Sloth_Profiler_Scope, 2048), + .scopes_cap = 2048, + .scopes_len = 0, + .frames = SP_MALLOC(Sloth_Profiler_Frame, frames_cap), + .frames_cap = frames_cap, + .frame_at = 0, + }; + + for (SP_U32 i = 0; i < sp_pctx_->frames_cap; i++) + { + sp_pctx_->frames[i] = (Sloth_Profiler_Frame){}; + } + + sp_ticks_os_init(); +} + +SLOTH_PROFILER_FUNCTION Sloth_Profiler_Frame* +sp_get_frame_cur() +{ + Sloth_Profiler_Frame* frame = sp_pctx_->frames + sp_pctx_->frame_at; + return frame; +} + +SLOTH_PROFILER_FUNCTION void +sp_begin_recording_force() +{ + sp_pctx_->recording = SlothProfiler_Recording; +} + +SLOTH_PROFILER_FUNCTION void +sp_begin_recording() +{ + sp_pctx_->recording = SlothProfiler_WaitingToBeginRecording; +} + +SLOTH_PROFILER_FUNCTION void +sp_pause_recording() +{ + sp_pctx_->recording = SlothProfiler_Paused; +} + +SLOTH_PROFILER_FUNCTION Sloth_Profiler_Scope_Call* +sp_frame_push_call(Sloth_Profiler_Frame* frame, SP_U32* index_out) +{ + if (frame->calls_len >= frame->calls_cap) { + SP_U32 calls_cap = frame->calls_cap * 2; + if (calls_cap == 0) calls_cap = 1024; + frame->calls = SP_REALLOC(frame->calls, Sloth_Profiler_Scope_Call, frame->calls_cap, calls_cap); + frame->calls_cap = calls_cap; + } + + SP_U32 index = frame->calls_len++; + Sloth_Profiler_Scope_Call* call = frame->calls + index; + if (index_out) *index_out = index; + return call; +} + +#define TEMP_MAX_DEPTH 8 + +SLOTH_PROFILER_FUNCTION void +sp_frame_begin() +{ + if (sp_pctx_->recording == SlothProfiler_Paused) return; + sp_pctx_->recording = SlothProfiler_Recording; + + Sloth_Profiler_Frame* frame = sp_get_frame_cur(); + frame->start = sp_ticks_now(); + frame->calls_len = 0; + frame->parent_cur = 0; + + sp_pctx_->depth = 0; + + SP_U32 index = 1234; // garbage value + Sloth_Profiler_Scope_Call* root = sp_frame_push_call(frame, &index); + *root = (Sloth_Profiler_Scope_Call){ + .name = "root", + .id.value = 0, + .start = sp_ticks_now(), + .parent = 0, + .first_child = 0, + .last_child = 0, + .next_sibling = 0, + }; + sloth_assert(index == 0); +} + +SLOTH_PROFILER_FUNCTION void +sp_frame_end() +{ + if (sp_pctx_->recording != SlothProfiler_Recording) return; + + Sloth_Profiler_Frame* frame = sp_pctx_->frames + sp_pctx_->frame_at; + frame->end = sp_ticks_now(); + frame->calls[0].end = frame->end; + // TODO: Frame Cleanup + + sp_pctx_->frame_at++; + if (sp_pctx_->frame_at >= sp_pctx_->frames_cap) { + sp_pctx_->frame_at = 0; + } +} + +SLOTH_PROFILER_FUNCTION void +sp_scope_begin(char* function, char* file, SP_S32 line) +{ + if (sp_pctx_->recording != SlothProfiler_Recording) return; + + sp_pctx_->depth += 1; + if (sp_pctx_->depth > TEMP_MAX_DEPTH) return; + + + // Hash the function name + // djb2 hash - http://www.cse.yorku.ca/~oz/hash.html + Sloth_Profiler_Scope_Id id = { .value = 5381 }; + for (char* at = function; *at != 0; at++) + { + id.value = ((id.value << 5) + id.value) + (Sloth_U8)at[0]; + } + + // Register the scope if needed + if (!sloth_hashtable_get(&sp_pctx_->scope_ids, id.value)) { + SP_U64 index = (Sloth_U64)sp_pctx_->scopes_len++; + Sloth_Profiler_Scope* scope = sp_pctx_->scopes + index; + *scope = (Sloth_Profiler_Scope){ + .name = function, + .file = file, + .line = line, + .ticks_longest = 0, + .ticks_shortest = 0, + .ticks_average = 0, + .total_count = 0, + .count_last_frame = 0, + }; + + sloth_hashtable_add(&sp_pctx_->scope_ids, id.value, (Sloth_U8*)scope); + } + + Sloth_Profiler_Frame* frame = sp_get_frame_cur(); + SP_U32 index = 0; + Sloth_Profiler_Scope_Call* call = sp_frame_push_call(frame, &index); + *call = (Sloth_Profiler_Scope_Call){ + .id = id, + .name = function, + .start = sp_ticks_now(), + .parent = frame->parent_cur, + .first_child = 0, + .last_child = 0, + .next_sibling = 0, + }; + + if (index > 0) { + Sloth_Profiler_Scope_Call* parent = frame->calls + frame->parent_cur; + if (parent->first_child != 0) { + Sloth_Profiler_Scope_Call* last_sib = frame->calls + parent->last_child; + last_sib->next_sibling = index; + sloth_assert(parent->last_child != index); + } else { + frame->calls[index - 1].first_child = index; + } + parent->last_child = index; + } + frame->parent_cur = index; +} + +SLOTH_PROFILER_FUNCTION void +sp_scope_end() +{ + if (sp_pctx_->recording != SlothProfiler_Recording) return; + sp_pctx_->depth -= 1; + if (sp_pctx_->depth > TEMP_MAX_DEPTH) return; + + Sloth_Profiler_Frame* frame = sp_get_frame_cur(); + Sloth_Profiler_Scope_Call* call = frame->calls + frame->parent_cur; + call->end = sp_ticks_now(); + frame->parent_cur = call->parent; +} + +SLOTH_PROFILER_FUNCTION Sloth_Profiler_Ticks +sp_ticks_elapsed(Sloth_Profiler_Ticks start, Sloth_Profiler_Ticks end) +{ + sloth_assert(end.value >= start.value); + Sloth_Profiler_Ticks result = { + .value = end.value - start.value + }; + return result; +} + +SLOTH_PROFILER_FUNCTION SP_R64 +sp_ticks_to_seconds(Sloth_Profiler_Ticks ticks) +{ + SP_R64 result = (SP_R64)ticks.value / sp_ticks_per_second_; + return result; +} + +SLOTH_PROFILER_FUNCTION SP_R64 +sp_ticks_to_milliseconds(Sloth_Profiler_Ticks ticks) +{ + SP_R64 result = (SP_R64)ticks.value / sp_ticks_per_millisecond_; + return result; +} + +#if defined(SP_OS_MAC) + +static SP_U64 sp_osx_start_time_absolute_ = 0; +static mach_timebase_info_data_t sp_osx_mach_time_info_ = {}; + +SLOTH_PROFILER_FUNCTION void +sp_ticks_os_init() +{ + sp_osx_start_time_absolute_ = mach_absolute_time(); + mach_timebase_info(&sp_osx_mach_time_info_); + + SP_R64 numer = (SP_R64)sp_osx_mach_time_info_.numer; + SP_R64 denom = (SP_R64)sp_osx_mach_time_info_.denom; + SP_R64 nps = (SP_R64)SP_NANOS_PER_SEC; + sp_ticks_per_second_ = (numer / denom) * nps; + sp_ticks_per_millisecond_ = (numer / denom) * 1000 * 1000; +} + +SLOTH_PROFILER_FUNCTION Sloth_Profiler_Ticks +sp_ticks_now() +{ + Sloth_Profiler_Ticks result = { + .value = mach_absolute_time() - sp_osx_start_time_absolute_ + }; + return result; +} + +#elif defined(SP_OS_LINUX) + +SLOTH_PROFILER_FUNCTION Sloth_Profiler_Ticks +sp_ticks_now() +{ +} + +#elif defined(SP_OS_WINDOWS) + +SLOTH_PROFILER_FUNCTION void +sp_ticks_os_init() +{ + LARGE_INTEGER freq; + if (!QueryPerformanceFrequency(&freq)) + { + SLOTH_PROFILER_ERROR("Unable to QueryPerformanceCounter"); + } + sp_ticks_per_second = (SP_U64)freq.QuadPart; +} + +SLOTH_PROFILER_FUNCTION Sloth_Profiler_Ticks +sp_ticks_now() +{ + LARGE_INTEGER t; + if (!QueryPerformanceCounter(&t)) + { + SLOTH_PROFILER_ERROR("Unable to QueryPerformanceCounter"); + } + Sloth_Profiler_Ticks result = { + .value = (SP_U64)t.QuadPart, + }; + return result; +} + +#endif // SP_OS_* + +//////////////////////////////////////////////////////// +// Visualizer Interface + +void +sp_popup_f(char* fmt, ...) +{ + Sloth_Widget_Desc desc = { + .layout = { + .width = sloth_size_text_content(), + .height = sloth_size_text_content(), + .margin = sloth_size_box_uniform_pixels(8), + .position = { + .kind = Sloth_LayoutPosition_FixedOnScreen, + .left = sloth_size_pixels(sp_ctx_->mouse_pos.x), + .top = sloth_size_pixels(sp_ctx_->mouse_pos.y), + .z = -0.5f, + }, + }, + .style = { + .color_bg = 0x000000FF, + .color_text = 0xFFFFFFFF, + }, + .input = { + .flags = Sloth_WidgetInput_DoNotCaptureMouse, + }, + }; + + va_list args; va_start(args, fmt); + sloth_push_widget_v(sp_ctx_, desc, fmt, args); + sloth_pop_widget(sp_ctx_); + va_end(args); +} + +bool +sp_button_f(char* fmt, ...) +{ + bool result = false; + Sloth_Widget_Desc desc = { + .layout = { + .width = sloth_size_text_content(), + .height = sloth_size_text_content(), + .margin = sloth_size_box_uniform_pixels(8), + }, + .style = { + .color_bg = 0x000000FF, + .color_text = 0xFFFFFFFF, + }, + }; + + va_list args; va_start(args, fmt); + Sloth_Widget_Result r = sloth_push_widget_v(sp_ctx_, desc, fmt, args); + if (sloth_ids_equal(r.widget->id, sp_ctx_->hot_widget)) { + r.widget->style.color_bg = 0xFFFFFFFF; + r.widget->style.color_text = 0x000000FF; + } + if (r.clicked) { + result = true; + r.widget->style.color_bg = 0x00FFFFFF; + r.widget->style.color_text = 0x000000FF; + } + sloth_pop_widget(sp_ctx_); + va_end(args); + + return result; +} + +void +sp_h_scope_slider(char* name, SP_R64* cur_min, SP_R64* cur_max) +{ + Sloth_Widget_Desc desc = { + .layout = { + .width = sloth_size_percent_parent(1), + .height = sloth_size_pixels(16), + }, + .style = { + .color_bg = 0x000000FF, + .color_outline = 0xFFFFFFFF, + .outline_thickness = 1, + }, + }; + + Sloth_Widget_Desc handle_desc = { + .layout = { + .width = sloth_size_pixels(16), + .height = sloth_size_pixels(16), + .position.kind = Sloth_LayoutPosition_FixedInParent + }, + .style = { + .color_bg = 0x888888FF, + }, + .input.flags = Sloth_WidgetInput_Draggable + }; + + sloth_push_widget_f(sp_ctx_, desc, "###slider_%s", name); + { + handle_desc.layout.position.left = sloth_size_percent_parent(*cur_min); + Sloth_Widget_Result r0 = sloth_push_widget_f(sp_ctx_, handle_desc, "###slider_%s_min", name); + sloth_pop_widget(sp_ctx_); + if (r0.held) { + r0.widget->style.color_bg = 0x00FFFF00; + SP_R64 new_min_pct = *cur_min + r0.drag_offset_percent_parent.x; + new_min_pct = Sloth_Clamp(0, new_min_pct, 1); + Sloth_Widget_Desc drag_desc = handle_desc; + drag_desc.layout.position.left = sloth_size_percent_parent(new_min_pct); + drag_desc.input.flags = Sloth_WidgetInput_DoNotCaptureMouse; + sloth_push_widget_f(sp_ctx_, drag_desc, "###slider_moving_%s_min", name); + sloth_pop_widget(sp_ctx_); + } + if (r0.released) { + Sloth_R32 new_min_pct = (*cur_min + r0.drag_offset_percent_parent.x); + *cur_min = new_min_pct = Sloth_Clamp(0, new_min_pct, 1); + } + + handle_desc.layout.position.left = (Sloth_Size){}; + handle_desc.layout.position.right = sloth_size_percent_parent(*cur_max); + Sloth_Widget_Result r1 = sloth_push_widget_f(sp_ctx_, handle_desc, "###slider_%s_max", name); + sloth_pop_widget(sp_ctx_); + if (r1.held) { + r1.widget->style.color_bg = 0x00FFFF00; + SP_R64 new_max_pct = *cur_max + r1.drag_offset_percent_parent.x; + new_max_pct = Sloth_Clamp(0, new_max_pct, 1); + Sloth_Widget_Desc drag_desc = handle_desc; + drag_desc.layout.position.right = sloth_size_percent_parent(new_max_pct); + drag_desc.input.flags = Sloth_WidgetInput_DoNotCaptureMouse; + sloth_push_widget_f(sp_ctx_, drag_desc, "###slider_moving_%s_max", name); + sloth_pop_widget(sp_ctx_); + } + if (r1.released) { + Sloth_R32 new_max_pct = (*cur_max + r1.drag_offset_percent_parent.x); + *cur_max = new_max_pct = Sloth_Clamp(0, new_max_pct, 1); + } + + } + sloth_pop_widget(sp_ctx_); +} + +bool +sp_frame_bar(SP_U32 frame_i) +{ + bool pause_recording = false; + + Sloth_Widget_Desc border_desc = { + .layout = { + .width = sloth_size_percent_parent(1), + .height = sloth_size_children_sum(), + .margin = sloth_size_box_uniform_pixels(4), + .direction = Sloth_LayoutDirection_LeftToRight, + // TODO + //.child_h_gap = sloth_size_pixels(4), + }, + .style = { + .color_outline = 0xFFFFFFFF, + .outline_thickness = 4, + }, + }; + Sloth_Widget_Desc frame_box_desc = { + .layout = { + .width = sloth_size_percent_parent(1.0f / sp_pctx_->frames_cap), + .height = sloth_size_pixels(64), + }, + .style = { + .color_bg = 0xFFFFFFFF, + .color_outline = 0x000000FF, + .outline_thickness = 1, + }, + }; + + sloth_push_widget(sp_ctx_, border_desc, "###frame_bar"); + { + Sloth_Widget_Result r; + SP_U32 popup_frame = sp_pctx_->frames_cap; + for (SP_U32 i = 0; i < sp_pctx_->frames_cap; i++) { + r = sloth_push_widget_f(sp_ctx_, frame_box_desc, "###frame_bar_%d", i); + if (i == frame_i) { + r.widget->style.color_bg = 0x00FFFFFF; + } + if (sloth_ids_equal(r.widget->id, sp_ctx_->hot_widget)) { + r.widget->style.color_bg = 0x00FF00FF; + popup_frame = i; + if (sloth_mouse_button_is_down(sp_ctx_->mouse_button_l)) + { + pause_recording = true; + sp_pctx_->ui_frame = i; + } + } + sloth_pop_widget(sp_ctx_); + } + if (popup_frame < sp_pctx_->frames_cap) + { + sp_popup_f("Frame: %d##popup", popup_frame); + } + } + sloth_pop_widget(sp_ctx_); + + border_desc.style.outline_thickness = 0; + sloth_push_widget(sp_ctx_, border_desc, "###frame_bar_btns"); + { + if (sp_button_f("Resume Recording")) { + sp_begin_recording(); + } + if (sp_button_f("Pause Recording")) { + pause_recording = true; + sp_pctx_->ui_frame = sp_pctx_->frame_at - 1; + } + } + sloth_pop_widget(sp_ctx_); + + return pause_recording; +} + +void +sp_frame_header(Sloth_Profiler_Frame* frame, SP_U32 frame_i) +{ + Sloth_Widget_Desc header_desc = { + .layout = { + .width = sloth_size_percent_parent(1), + .height = sloth_size_text_content(), + .margin = sloth_size_box_uniform_pixels(4), + }, + .style = { + .color_outline = 0xFFFFFFFF, + .color_text = 0xFFFFFFFF, + .outline_thickness = 1, + }, + }; + + bool mouse_down = sloth_mouse_button_is_down(sp_ctx_->mouse_button_l); + Sloth_Profiler_Ticks ticks = sp_ticks_elapsed(frame->start, frame->end); + SP_R64 ms = sp_ticks_to_milliseconds(ticks); + sloth_push_widget_f(sp_ctx_, header_desc, "Frame: %d\nCalls: %d\nTicks: %lld\nTime: %fms###profiler_frame_header", + frame_i, frame->calls_len, ticks.value, ms); + sloth_pop_widget(sp_ctx_); +} + +Sloth_U32 sp_calls_visualized = 0; + +void +sp_flame_graph_call(Sloth_Profiler_Frame* frame, SP_U32 call_index, Sloth_R32 visible_width_pixels, + Sloth_Profiler_Ticks visible_start, Sloth_Profiler_Ticks visible_duration, Sloth_U32 depth) +{ + + Sloth_Widget_Desc scope_desc = { + .layout = { + .height = sloth_size_pixels(16), + .position = { + .kind = Sloth_LayoutPosition_FixedInParent, + .top = sloth_size_pixels(16 * depth), + }, + }, + .style = { + .color_outline = 0x00FF00FF, + .outline_thickness = 1, + }, + }; + + Sloth_Profiler_Scope_Id last_unused_id = {}; + Sloth_Profiler_Ticks unused_run_start = {}; + do { + Sloth_Profiler_Scope_Call call = frame->calls[call_index]; + Sloth_Profiler_Scope* scope = (Sloth_Profiler_Scope*)sloth_hashtable_get(&sp_pctx_->scope_ids, call.id.value); + char* name = "root"; + if (scope) name = scope->name; + + bool is_after_visible = call.start.value > (visible_start.value + visible_duration.value); + bool is_before_visible = call.end.value < visible_start.value; + if (is_after_visible || is_before_visible) { + call_index = call.next_sibling; + continue; + } + + Sloth_Profiler_Ticks call_duration = sp_ticks_elapsed(call.start, call.end); + SP_R64 call_pct_visible_duration = (SP_R64)call_duration.value / (SP_R64)visible_duration.value; + + // See if this block is next to more blocks of the same call + // and collapse them if they're too small to see individually + SP_R64 min_draw_pct_width = 0.05f; + if (call_pct_visible_duration <= min_draw_pct_width) + { + bool is_in_run = (last_unused_id.value == call.id.value); + bool is_end_of_run = false; + if (call.next_sibling != 0) + { + Sloth_Profiler_Scope_Call next_call = frame->calls[call.next_sibling]; + is_end_of_run = (next_call.id.value != last_unused_id.value); + } + if (is_in_run && is_end_of_run) + { + call_duration = sp_ticks_elapsed(unused_run_start, call.end); + call_pct_visible_duration = (SP_R64)call_duration.value / (SP_R64)visible_duration.value; + } + if (is_end_of_run) + { + last_unused_id.value = 0; + } + } + + if (call_pct_visible_duration > min_draw_pct_width) + { + Sloth_Profiler_Ticks call_offset_start, call_offset_end; + if (call.start.value > visible_start.value) { + call_offset_start = sp_ticks_elapsed(visible_start, call.start); + } else { + call_offset_start.value = 0; + } + if (call.end.value < visible_start.value + visible_duration.value) { + call_offset_end = sp_ticks_elapsed(visible_start, call.end); + } else { + call_offset_end.value = visible_duration.value; + } + + SP_R64 call_pct_start = (SP_R64)call_offset_start.value / (SP_R64)visible_duration.value; + SP_R64 call_pct_end = (SP_R64)call_offset_end.value / (SP_R64)visible_duration.value; + sloth_assert(call_pct_start >= 0 && call_pct_start <= 1 && + call_pct_end >= 0 && call_pct_end <= 1); + SP_R64 call_pct_duration = call_pct_end - call_pct_start; + + + + scope_desc.layout.width = sloth_size_pixels(visible_width_pixels * call_pct_duration); + scope_desc.layout.position.left = sloth_size_pixels(visible_width_pixels * call_pct_start); + + Sloth_Widget_Desc scope_bar_desc = { + .layout = { + .width = sloth_size_percent_parent(call_pct_duration), + .height = sloth_size_pixels(16), + }, + .style = { + .color_outline = 0x00FF00FF, + .outline_thickness = 1, + }, + }; + + Sloth_Widget_Result r = sloth_push_widget_f(sp_ctx_, scope_desc, "###%s_%d_fg_bar", name, sp_calls_visualized++); + { + if (sloth_ids_equal(r.widget->id, sp_ctx_->hot_widget)) + { + Sloth_Profiler_Ticks t = sp_ticks_elapsed(call.start, call.end); + sp_popup_f("%s - %lld###fg_popup", name, t.value); + } + } + sloth_pop_widget(sp_ctx_); + + if (call.first_child != 0) { + sp_flame_graph_call(frame, call.first_child, visible_width_pixels, visible_start, visible_duration, depth + 1); + } + } + else if (last_unused_id.value != call.id.value) + { + unused_run_start = call.start; + last_unused_id = call.id; + } + + sloth_assert(call.next_sibling == 0 || call.next_sibling > call_index); + sloth_assert(call.next_sibling < frame->calls_len); + call_index = call.next_sibling; + } while (call_index != 0); +} + +void +sp_flame_graph(Sloth_Profiler_Frame* frame, Sloth_R32 pixel_width) +{ + Sloth_Widget_Desc fg_desc = { + .layout = { + .width = sloth_size_percent_parent(1), + .height = sloth_size_pixels(128), + .margin = sloth_size_box_uniform_pixels(4), + }, + .style = { + .color_outline = 0xFFFFFFFF, + .outline_thickness = 1, + }, + }; + + sp_calls_visualized = 0; + Sloth_Profiler_Ticks frame_duration = sp_ticks_elapsed(frame->start, frame->end); + Sloth_Profiler_Ticks frame_start = { + .value = frame->start.value + (frame_duration.value * sp_pctx_->visible_min), + }; + frame_duration.value *= ((1.0f - sp_pctx_->visible_max) - sp_pctx_->visible_min); + sloth_push_widget_f(sp_ctx_, fg_desc, "###profiler_flame_graph"); + if (frame->calls) + { + sp_flame_graph_call(frame, 0, pixel_width, frame_start, frame_duration, 0); + } + sloth_pop_widget(sp_ctx_); + + sp_h_scope_slider("flame_graph_slider", &sp_pctx_->visible_min, &sp_pctx_->visible_max); +} + +SLOTH_PROFILER_FUNCTION void +sp_draw() +{ + if (!sp_pctx_) return; + + SP_U32 frame_i = sp_pctx_->frame_at - 1; + if (sp_pctx_->recording == SlothProfiler_Paused) frame_i = sp_pctx_->ui_frame; + if (frame_i > sp_pctx_->frames_cap) frame_i = sp_pctx_->frames_cap - 1; + + bool pause_recording = false; + bool was_recording = sp_pctx_->recording == SlothProfiler_Recording; + if (was_recording) sp_pause_recording(); + + Sloth_Profiler_Frame* frame = sp_pctx_->frames + frame_i; + + Sloth_Widget_Desc bg_desc = { + .layout = { + .width = sloth_size_pixels(800), + .height = sloth_size_pixels(600), + .margin = sloth_size_box_uniform_pixels(16), + .position = { + .kind = Sloth_LayoutPosition_FixedOnScreen, + .left = sloth_size_pixels(32), + .top = sloth_size_pixels(48), + }, + }, + .style = { + .color_bg = 0x333333FF, + }, + }; + sloth_push_widget(sp_ctx_, bg_desc, "###profiler_root"); + { + pause_recording = sp_frame_bar(frame_i); + sp_frame_header(frame, frame_i); + sp_flame_graph(frame, 800 - 32); + } + sloth_pop_widget(sp_ctx_); + + if (pause_recording) { + sp_pause_recording(); + } + else if (was_recording) + { + sp_begin_recording_force(); + } +} + + +#endif // SLOTH_PROFILER_IMPLEMENTATION + +#endif // SLOTH_PROFILER_C \ No newline at end of file diff --git a/src_v2/libs/stb_sprintf.h b/src_v2/libs/stb_sprintf.h new file mode 100644 index 0000000..64bce7e --- /dev/null +++ b/src_v2/libs/stb_sprintf.h @@ -0,0 +1,1906 @@ +// stb_sprintf - v1.10 - public domain snprintf() implementation +// originally by Jeff Roberts / RAD Game Tools, 2015/10/20 +// http://github.com/nothings/stb +// +// allowed types: sc uidBboXx p AaGgEef n +// lengths : hh h ll j z t I64 I32 I +// +// Contributors: +// Fabian "ryg" Giesen (reformatting) +// github:aganm (attribute format) +// +// Contributors (bugfixes): +// github:d26435 +// github:trex78 +// github:account-login +// Jari Komppa (SI suffixes) +// Rohit Nirmal +// Marcin Wojdyr +// Leonard Ritter +// Stefano Zanotti +// Adam Allison +// Arvid Gerstmann +// Markus Kolb +// +// LICENSE: +// +// See end of file for license information. + +#ifndef STB_SPRINTF_H_INCLUDE +#define STB_SPRINTF_H_INCLUDE + +/* +Single file sprintf replacement. + +Originally written by Jeff Roberts at RAD Game Tools - 2015/10/20. +Hereby placed in public domain. + +This is a full sprintf replacement that supports everything that +the C runtime sprintfs support, including float/double, 64-bit integers, +hex floats, field parameters (%*.*d stuff), length reads backs, etc. + +Why would you need this if sprintf already exists? Well, first off, +it's *much* faster (see below). It's also much smaller than the CRT +versions code-space-wise. We've also added some simple improvements +that are super handy (commas in thousands, callbacks at buffer full, +for example). Finally, the format strings for MSVC and GCC differ +for 64-bit integers (among other small things), so this lets you use +the same format strings in cross platform code. + +It uses the standard single file trick of being both the header file +and the source itself. If you just include it normally, you just get +the header file function definitions. To get the code, you include +it from a C or C++ file and define STB_SPRINTF_IMPLEMENTATION first. + +It only uses va_args macros from the C runtime to do it's work. It +does cast doubles to S64s and shifts and divides U64s, which does +drag in CRT code on most platforms. + +It compiles to roughly 8K with float support, and 4K without. +As a comparison, when using MSVC static libs, calling sprintf drags +in 16K. + +API: +==== +int stbsp_sprintf( char * buf, char const * fmt, ... ) +int stbsp_snprintf( char * buf, int count, char const * fmt, ... ) + Convert an arg list into a buffer. stbsp_snprintf always returns + a zero-terminated string (unlike regular snprintf). + +int stbsp_vsprintf( char * buf, char const * fmt, va_list va ) +int stbsp_vsnprintf( char * buf, int count, char const * fmt, va_list va ) + Convert a va_list arg list into a buffer. stbsp_vsnprintf always returns + a zero-terminated string (unlike regular snprintf). + +int stbsp_vsprintfcb( STBSP_SPRINTFCB * callback, void * user, char * buf, char const * fmt, va_list va ) + typedef char * STBSP_SPRINTFCB( char const * buf, void * user, int len ); + Convert into a buffer, calling back every STB_SPRINTF_MIN chars. + Your callback can then copy the chars out, print them or whatever. + This function is actually the workhorse for everything else. + The buffer you pass in must hold at least STB_SPRINTF_MIN characters. + // you return the next buffer to use or 0 to stop converting + +void stbsp_set_separators( char comma, char period ) + Set the comma and period characters to use. + +FLOATS/DOUBLES: +=============== +This code uses a internal float->ascii conversion method that uses +doubles with error correction (double-doubles, for ~105 bits of +precision). This conversion is round-trip perfect - that is, an atof +of the values output here will give you the bit-exact double back. + +One difference is that our insignificant digits will be different than +with MSVC or GCC (but they don't match each other either). We also +don't attempt to find the minimum length matching float (pre-MSVC15 +doesn't either). + +If you don't need float or doubles at all, define STB_SPRINTF_NOFLOAT +and you'll save 4K of code space. + +64-BIT INTS: +============ +This library also supports 64-bit integers and you can use MSVC style or +GCC style indicators (%I64d or %lld). It supports the C99 specifiers +for size_t and ptr_diff_t (%jd %zd) as well. + +EXTRAS: +======= +Like some GCCs, for integers and floats, you can use a ' (single quote) +specifier and commas will be inserted on the thousands: "%'d" on 12345 +would print 12,345. + +For integers and floats, you can use a "$" specifier and the number +will be converted to float and then divided to get kilo, mega, giga or +tera and then printed, so "%$d" 1000 is "1.0 k", "%$.2d" 2536000 is +"2.53 M", etc. For byte values, use two $:s, like "%$$d" to turn +2536000 to "2.42 Mi". If you prefer JEDEC suffixes to SI ones, use three +$:s: "%$$$d" -> "2.42 M". To remove the space between the number and the +suffix, add "_" specifier: "%_$d" -> "2.53M". + +In addition to octal and hexadecimal conversions, you can print +integers in binary: "%b" for 256 would print 100. + +PERFORMANCE vs MSVC 2008 32-/64-bit (GCC is even slower than MSVC): +=================================================================== +"%d" across all 32-bit ints (4.8x/4.0x faster than 32-/64-bit MSVC) +"%24d" across all 32-bit ints (4.5x/4.2x faster) +"%x" across all 32-bit ints (4.5x/3.8x faster) +"%08x" across all 32-bit ints (4.3x/3.8x faster) +"%f" across e-10 to e+10 floats (7.3x/6.0x faster) +"%e" across e-10 to e+10 floats (8.1x/6.0x faster) +"%g" across e-10 to e+10 floats (10.0x/7.1x faster) +"%f" for values near e-300 (7.9x/6.5x faster) +"%f" for values near e+300 (10.0x/9.1x faster) +"%e" for values near e-300 (10.1x/7.0x faster) +"%e" for values near e+300 (9.2x/6.0x faster) +"%.320f" for values near e-300 (12.6x/11.2x faster) +"%a" for random values (8.6x/4.3x faster) +"%I64d" for 64-bits with 32-bit values (4.8x/3.4x faster) +"%I64d" for 64-bits > 32-bit values (4.9x/5.5x faster) +"%s%s%s" for 64 char strings (7.1x/7.3x faster) +"...512 char string..." ( 35.0x/32.5x faster!) +*/ + +#if defined(__clang__) +#if defined(__has_feature) && defined(__has_attribute) +#if __has_feature(address_sanitizer) +#if __has_attribute(__no_sanitize__) +#define STBSP__ASAN __attribute__((__no_sanitize__("address"))) +#elif __has_attribute(__no_sanitize_address__) +#define STBSP__ASAN __attribute__((__no_sanitize_address__)) +#elif __has_attribute(__no_address_safety_analysis__) +#define STBSP__ASAN __attribute__((__no_address_safety_analysis__)) +#endif +#endif +#endif +#elif defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) +#if defined(__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__ +#define STBSP__ASAN __attribute__((__no_sanitize_address__)) +#endif +#endif + +#ifndef STBSP__ASAN +#define STBSP__ASAN +#endif + +#ifdef STB_SPRINTF_STATIC +#define STBSP__PUBLICDEC static +#define STBSP__PUBLICDEF static STBSP__ASAN +#else +#ifdef __cplusplus +#define STBSP__PUBLICDEC extern "C" +#define STBSP__PUBLICDEF extern "C" STBSP__ASAN +#else +#define STBSP__PUBLICDEC extern +#define STBSP__PUBLICDEF STBSP__ASAN +#endif +#endif + +#if defined(__has_attribute) +#if __has_attribute(format) +#define STBSP__ATTRIBUTE_FORMAT(fmt,va) __attribute__((format(printf,fmt,va))) +#endif +#endif + +#ifndef STBSP__ATTRIBUTE_FORMAT +#define STBSP__ATTRIBUTE_FORMAT(fmt,va) +#endif + +#ifdef _MSC_VER +#define STBSP__NOTUSED(v) (void)(v) +#else +#define STBSP__NOTUSED(v) (void)sizeof(v) +#endif + +#include <stdarg.h> // for va_arg(), va_list() +#include <stddef.h> // size_t, ptrdiff_t + +#ifndef STB_SPRINTF_MIN +#define STB_SPRINTF_MIN 512 // how many characters per callback +#endif +typedef char *STBSP_SPRINTFCB(const char *buf, void *user, int len); + +#ifndef STB_SPRINTF_DECORATE +#define STB_SPRINTF_DECORATE(name) stbsp_##name // define this before including if you want to change the names +#endif + +STBSP__PUBLICDEC int STB_SPRINTF_DECORATE(vsprintf)(char *buf, char const *fmt, va_list va); +STBSP__PUBLICDEC int STB_SPRINTF_DECORATE(vsnprintf)(char *buf, int count, char const *fmt, va_list va); +STBSP__PUBLICDEC int STB_SPRINTF_DECORATE(sprintf)(char *buf, char const *fmt, ...) STBSP__ATTRIBUTE_FORMAT(2,3); +STBSP__PUBLICDEC int STB_SPRINTF_DECORATE(snprintf)(char *buf, int count, char const *fmt, ...) STBSP__ATTRIBUTE_FORMAT(3,4); + +STBSP__PUBLICDEC int STB_SPRINTF_DECORATE(vsprintfcb)(STBSP_SPRINTFCB *callback, void *user, char *buf, char const *fmt, va_list va); +STBSP__PUBLICDEC void STB_SPRINTF_DECORATE(set_separators)(char comma, char period); + +#endif // STB_SPRINTF_H_INCLUDE + +#ifdef STB_SPRINTF_IMPLEMENTATION + +#define stbsp__uint32 unsigned int +#define stbsp__int32 signed int + +#ifdef _MSC_VER +#define stbsp__uint64 unsigned __int64 +#define stbsp__int64 signed __int64 +#else +#define stbsp__uint64 unsigned long long +#define stbsp__int64 signed long long +#endif +#define stbsp__uint16 unsigned short + +#ifndef stbsp__uintptr +#if defined(__ppc64__) || defined(__powerpc64__) || defined(__aarch64__) || defined(_M_X64) || defined(__x86_64__) || defined(__x86_64) || defined(__s390x__) +#define stbsp__uintptr stbsp__uint64 +#else +#define stbsp__uintptr stbsp__uint32 +#endif +#endif + +#ifndef STB_SPRINTF_MSVC_MODE // used for MSVC2013 and earlier (MSVC2015 matches GCC) +#if defined(_MSC_VER) && (_MSC_VER < 1900) +#define STB_SPRINTF_MSVC_MODE +#endif +#endif + +#ifdef STB_SPRINTF_NOUNALIGNED // define this before inclusion to force stbsp_sprintf to always use aligned accesses +#define STBSP__UNALIGNED(code) +#else +#define STBSP__UNALIGNED(code) code +#endif + +#ifndef STB_SPRINTF_NOFLOAT +// internal float utility functions +static stbsp__int32 stbsp__real_to_str(char const **start, stbsp__uint32 *len, char *out, stbsp__int32 *decimal_pos, double value, stbsp__uint32 frac_digits); +static stbsp__int32 stbsp__real_to_parts(stbsp__int64 *bits, stbsp__int32 *expo, double value); +#define STBSP__SPECIAL 0x7000 +#endif + +static char stbsp__period = '.'; +static char stbsp__comma = ','; +static struct +{ + short temp; // force next field to be 2-byte aligned + char pair[201]; +} stbsp__digitpair = +{ + 0, + "00010203040506070809101112131415161718192021222324" + "25262728293031323334353637383940414243444546474849" + "50515253545556575859606162636465666768697071727374" + "75767778798081828384858687888990919293949596979899" +}; + +STBSP__PUBLICDEF void STB_SPRINTF_DECORATE(set_separators)(char pcomma, char pperiod) +{ + stbsp__period = pperiod; + stbsp__comma = pcomma; +} + +#define STBSP__LEFTJUST 1 +#define STBSP__LEADINGPLUS 2 +#define STBSP__LEADINGSPACE 4 +#define STBSP__LEADING_0X 8 +#define STBSP__LEADINGZERO 16 +#define STBSP__INTMAX 32 +#define STBSP__TRIPLET_COMMA 64 +#define STBSP__NEGATIVE 128 +#define STBSP__METRIC_SUFFIX 256 +#define STBSP__HALFWIDTH 512 +#define STBSP__METRIC_NOSPACE 1024 +#define STBSP__METRIC_1024 2048 +#define STBSP__METRIC_JEDEC 4096 + +static void stbsp__lead_sign(stbsp__uint32 fl, char *sign) +{ + sign[0] = 0; + if (fl & STBSP__NEGATIVE) { + sign[0] = 1; + sign[1] = '-'; + } else if (fl & STBSP__LEADINGSPACE) { + sign[0] = 1; + sign[1] = ' '; + } else if (fl & STBSP__LEADINGPLUS) { + sign[0] = 1; + sign[1] = '+'; + } +} + +static STBSP__ASAN stbsp__uint32 stbsp__strlen_limited(char const *s, stbsp__uint32 limit) +{ + char const * sn = s; + + // get up to 4-byte alignment + for (;;) { + if (((stbsp__uintptr)sn & 3) == 0) + break; + + if (!limit || *sn == 0) + return (stbsp__uint32)(sn - s); + + ++sn; + --limit; + } + + // scan over 4 bytes at a time to find terminating 0 + // this will intentionally scan up to 3 bytes past the end of buffers, + // but becase it works 4B aligned, it will never cross page boundaries + // (hence the STBSP__ASAN markup; the over-read here is intentional + // and harmless) + while (limit >= 4) { + stbsp__uint32 v = *(stbsp__uint32 *)sn; + // bit hack to find if there's a 0 byte in there + if ((v - 0x01010101) & (~v) & 0x80808080UL) + break; + + sn += 4; + limit -= 4; + } + + // handle the last few characters to find actual size + while (limit && *sn) { + ++sn; + --limit; + } + + return (stbsp__uint32)(sn - s); +} + +STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(vsprintfcb)(STBSP_SPRINTFCB *callback, void *user, char *buf, char const *fmt, va_list va) +{ + static char hex[] = "0123456789abcdefxp"; + static char hexu[] = "0123456789ABCDEFXP"; + char *bf; + char const *f; + int tlen = 0; + + bf = buf; + f = fmt; + for (;;) { + stbsp__int32 fw, pr, tz; + stbsp__uint32 fl; + + // macros for the callback buffer stuff +#define stbsp__chk_cb_bufL(bytes) \ +{ \ +int len = (int)(bf - buf); \ +if ((len + (bytes)) >= STB_SPRINTF_MIN) { \ +tlen += len; \ +if (0 == (bf = buf = callback(buf, user, len))) \ +goto done; \ +} \ +} +#define stbsp__chk_cb_buf(bytes) \ +{ \ +if (callback) { \ +stbsp__chk_cb_bufL(bytes); \ +} \ +} +#define stbsp__flush_cb() \ +{ \ +stbsp__chk_cb_bufL(STB_SPRINTF_MIN - 1); \ +} // flush if there is even one byte in the buffer +#define stbsp__cb_buf_clamp(cl, v) \ +cl = v; \ +if (callback) { \ +int lg = STB_SPRINTF_MIN - (int)(bf - buf); \ +if (cl > lg) \ +cl = lg; \ +} + + // fast copy everything up to the next % (or end of string) + for (;;) { + while (((stbsp__uintptr)f) & 3) { + schk1: + if (f[0] == '%') + goto scandd; + schk2: + if (f[0] == 0) + goto endfmt; + stbsp__chk_cb_buf(1); + *bf++ = f[0]; + ++f; + } + for (;;) { + // Check if the next 4 bytes contain %(0x25) or end of string. + // Using the 'hasless' trick: + // https://graphics.stanford.edu/~seander/bithacks.html#HasLessInWord + stbsp__uint32 v, c; + v = *(stbsp__uint32 *)f; + c = (~v) & 0x80808080; + if (((v ^ 0x25252525) - 0x01010101) & c) + goto schk1; + if ((v - 0x01010101) & c) + goto schk2; + if (callback) + if ((STB_SPRINTF_MIN - (int)(bf - buf)) < 4) + goto schk1; +#ifdef STB_SPRINTF_NOUNALIGNED + if(((stbsp__uintptr)bf) & 3) { + bf[0] = f[0]; + bf[1] = f[1]; + bf[2] = f[2]; + bf[3] = f[3]; + } else +#endif + { + *(stbsp__uint32 *)bf = v; + } + bf += 4; + f += 4; + } + } + scandd: + + ++f; + + // ok, we have a percent, read the modifiers first + fw = 0; + pr = -1; + fl = 0; + tz = 0; + + // flags + for (;;) { + switch (f[0]) { + // if we have left justify + case '-': + fl |= STBSP__LEFTJUST; + ++f; + continue; + // if we have leading plus + case '+': + fl |= STBSP__LEADINGPLUS; + ++f; + continue; + // if we have leading space + case ' ': + fl |= STBSP__LEADINGSPACE; + ++f; + continue; + // if we have leading 0x + case '#': + fl |= STBSP__LEADING_0X; + ++f; + continue; + // if we have thousand commas + case '\'': + fl |= STBSP__TRIPLET_COMMA; + ++f; + continue; + // if we have kilo marker (none->kilo->kibi->jedec) + case '$': + if (fl & STBSP__METRIC_SUFFIX) { + if (fl & STBSP__METRIC_1024) { + fl |= STBSP__METRIC_JEDEC; + } else { + fl |= STBSP__METRIC_1024; + } + } else { + fl |= STBSP__METRIC_SUFFIX; + } + ++f; + continue; + // if we don't want space between metric suffix and number + case '_': + fl |= STBSP__METRIC_NOSPACE; + ++f; + continue; + // if we have leading zero + case '0': + fl |= STBSP__LEADINGZERO; + ++f; + goto flags_done; + default: goto flags_done; + } + } + flags_done: + + // get the field width + if (f[0] == '*') { + fw = va_arg(va, stbsp__uint32); + ++f; + } else { + while ((f[0] >= '0') && (f[0] <= '9')) { + fw = fw * 10 + f[0] - '0'; + f++; + } + } + // get the precision + if (f[0] == '.') { + ++f; + if (f[0] == '*') { + pr = va_arg(va, stbsp__uint32); + ++f; + } else { + pr = 0; + while ((f[0] >= '0') && (f[0] <= '9')) { + pr = pr * 10 + f[0] - '0'; + f++; + } + } + } + + // handle integer size overrides + switch (f[0]) { + // are we halfwidth? + case 'h': + fl |= STBSP__HALFWIDTH; + ++f; + if (f[0] == 'h') + ++f; // QUARTERWIDTH + break; + // are we 64-bit (unix style) + case 'l': + fl |= ((sizeof(long) == 8) ? STBSP__INTMAX : 0); + ++f; + if (f[0] == 'l') { + fl |= STBSP__INTMAX; + ++f; + } + break; + // are we 64-bit on intmax? (c99) + case 'j': + fl |= (sizeof(size_t) == 8) ? STBSP__INTMAX : 0; + ++f; + break; + // are we 64-bit on size_t or ptrdiff_t? (c99) + case 'z': + fl |= (sizeof(ptrdiff_t) == 8) ? STBSP__INTMAX : 0; + ++f; + break; + case 't': + fl |= (sizeof(ptrdiff_t) == 8) ? STBSP__INTMAX : 0; + ++f; + break; + // are we 64-bit (msft style) + case 'I': + if ((f[1] == '6') && (f[2] == '4')) { + fl |= STBSP__INTMAX; + f += 3; + } else if ((f[1] == '3') && (f[2] == '2')) { + f += 3; + } else { + fl |= ((sizeof(void *) == 8) ? STBSP__INTMAX : 0); + ++f; + } + break; + default: break; + } + + // handle each replacement + switch (f[0]) { +#define STBSP__NUMSZ 512 // big enough for e308 (with commas) or e-307 + char num[STBSP__NUMSZ]; + char lead[8]; + char tail[8]; + char *s; + char const *h; + stbsp__uint32 l, n, cs; + stbsp__uint64 n64; +#ifndef STB_SPRINTF_NOFLOAT + double fv; +#endif + stbsp__int32 dp; + char const *sn; + + case 's': + // get the string + s = va_arg(va, char *); + if (s == 0) + s = (char *)"null"; + // get the length, limited to desired precision + // always limit to ~0u chars since our counts are 32b + l = stbsp__strlen_limited(s, (pr >= 0) ? pr : ~0u); + lead[0] = 0; + tail[0] = 0; + pr = 0; + dp = 0; + cs = 0; + // copy the string in + goto scopy; + + case 'c': // char + // get the character + s = num + STBSP__NUMSZ - 1; + *s = (char)va_arg(va, int); + l = 1; + lead[0] = 0; + tail[0] = 0; + pr = 0; + dp = 0; + cs = 0; + goto scopy; + + case 'n': // weird write-bytes specifier + { + int *d = va_arg(va, int *); + *d = tlen + (int)(bf - buf); + } break; + +#ifdef STB_SPRINTF_NOFLOAT + case 'A': // float + case 'a': // hex float + case 'G': // float + case 'g': // float + case 'E': // float + case 'e': // float + case 'f': // float + va_arg(va, double); // eat it + s = (char *)"No float"; + l = 8; + lead[0] = 0; + tail[0] = 0; + pr = 0; + cs = 0; + STBSP__NOTUSED(dp); + goto scopy; +#else + case 'A': // hex float + case 'a': // hex float + h = (f[0] == 'A') ? hexu : hex; + fv = va_arg(va, double); + if (pr == -1) + pr = 6; // default is 6 + // read the double into a string + if (stbsp__real_to_parts((stbsp__int64 *)&n64, &dp, fv)) + fl |= STBSP__NEGATIVE; + + s = num + 64; + + stbsp__lead_sign(fl, lead); + + if (dp == -1023) + dp = (n64) ? -1022 : 0; + else + n64 |= (((stbsp__uint64)1) << 52); + n64 <<= (64 - 56); + if (pr < 15) + n64 += ((((stbsp__uint64)8) << 56) >> (pr * 4)); + // add leading chars + +#ifdef STB_SPRINTF_MSVC_MODE + *s++ = '0'; + *s++ = 'x'; +#else + lead[1 + lead[0]] = '0'; + lead[2 + lead[0]] = 'x'; + lead[0] += 2; +#endif + *s++ = h[(n64 >> 60) & 15]; + n64 <<= 4; + if (pr) + *s++ = stbsp__period; + sn = s; + + // print the bits + n = pr; + if (n > 13) + n = 13; + if (pr > (stbsp__int32)n) + tz = pr - n; + pr = 0; + while (n--) { + *s++ = h[(n64 >> 60) & 15]; + n64 <<= 4; + } + + // print the expo + tail[1] = h[17]; + if (dp < 0) { + tail[2] = '-'; + dp = -dp; + } else + tail[2] = '+'; + n = (dp >= 1000) ? 6 : ((dp >= 100) ? 5 : ((dp >= 10) ? 4 : 3)); + tail[0] = (char)n; + for (;;) { + tail[n] = '0' + dp % 10; + if (n <= 3) + break; + --n; + dp /= 10; + } + + dp = (int)(s - sn); + l = (int)(s - (num + 64)); + s = num + 64; + cs = 1 + (3 << 24); + goto scopy; + + case 'G': // float + case 'g': // float + h = (f[0] == 'G') ? hexu : hex; + fv = va_arg(va, double); + if (pr == -1) + pr = 6; + else if (pr == 0) + pr = 1; // default is 6 + // read the double into a string + if (stbsp__real_to_str(&sn, &l, num, &dp, fv, (pr - 1) | 0x80000000)) + fl |= STBSP__NEGATIVE; + + // clamp the precision and delete extra zeros after clamp + n = pr; + if (l > (stbsp__uint32)pr) + l = pr; + while ((l > 1) && (pr) && (sn[l - 1] == '0')) { + --pr; + --l; + } + + // should we use %e + if ((dp <= -4) || (dp > (stbsp__int32)n)) { + if (pr > (stbsp__int32)l) + pr = l - 1; + else if (pr) + --pr; // when using %e, there is one digit before the decimal + goto doexpfromg; + } + // this is the insane action to get the pr to match %g semantics for %f + if (dp > 0) { + pr = (dp < (stbsp__int32)l) ? l - dp : 0; + } else { + pr = -dp + ((pr > (stbsp__int32)l) ? (stbsp__int32) l : pr); + } + goto dofloatfromg; + + case 'E': // float + case 'e': // float + h = (f[0] == 'E') ? hexu : hex; + fv = va_arg(va, double); + if (pr == -1) + pr = 6; // default is 6 + // read the double into a string + if (stbsp__real_to_str(&sn, &l, num, &dp, fv, pr | 0x80000000)) + fl |= STBSP__NEGATIVE; + doexpfromg: + tail[0] = 0; + stbsp__lead_sign(fl, lead); + if (dp == STBSP__SPECIAL) { + s = (char *)sn; + cs = 0; + pr = 0; + goto scopy; + } + s = num + 64; + // handle leading chars + *s++ = sn[0]; + + if (pr) + *s++ = stbsp__period; + + // handle after decimal + if ((l - 1) > (stbsp__uint32)pr) + l = pr + 1; + for (n = 1; n < l; n++) + *s++ = sn[n]; + // trailing zeros + tz = pr - (l - 1); + pr = 0; + // dump expo + tail[1] = h[0xe]; + dp -= 1; + if (dp < 0) { + tail[2] = '-'; + dp = -dp; + } else + tail[2] = '+'; +#ifdef STB_SPRINTF_MSVC_MODE + n = 5; +#else + n = (dp >= 100) ? 5 : 4; +#endif + tail[0] = (char)n; + for (;;) { + tail[n] = '0' + dp % 10; + if (n <= 3) + break; + --n; + dp /= 10; + } + cs = 1 + (3 << 24); // how many tens + goto flt_lead; + + case 'f': // float + fv = va_arg(va, double); + doafloat: + // do kilos + if (fl & STBSP__METRIC_SUFFIX) { + double divisor; + divisor = 1000.0f; + if (fl & STBSP__METRIC_1024) + divisor = 1024.0; + while (fl < 0x4000000) { + if ((fv < divisor) && (fv > -divisor)) + break; + fv /= divisor; + fl += 0x1000000; + } + } + if (pr == -1) + pr = 6; // default is 6 + // read the double into a string + if (stbsp__real_to_str(&sn, &l, num, &dp, fv, pr)) + fl |= STBSP__NEGATIVE; + dofloatfromg: + tail[0] = 0; + stbsp__lead_sign(fl, lead); + if (dp == STBSP__SPECIAL) { + s = (char *)sn; + cs = 0; + pr = 0; + goto scopy; + } + s = num + 64; + + // handle the three decimal varieties + if (dp <= 0) { + stbsp__int32 i; + // handle 0.000*000xxxx + *s++ = '0'; + if (pr) + *s++ = stbsp__period; + n = -dp; + if ((stbsp__int32)n > pr) + n = pr; + i = n; + while (i) { + if ((((stbsp__uintptr)s) & 3) == 0) + break; + *s++ = '0'; + --i; + } + while (i >= 4) { + *(stbsp__uint32 *)s = 0x30303030; + s += 4; + i -= 4; + } + while (i) { + *s++ = '0'; + --i; + } + if ((stbsp__int32)(l + n) > pr) + l = pr - n; + i = l; + while (i) { + *s++ = *sn++; + --i; + } + tz = pr - (n + l); + cs = 1 + (3 << 24); // how many tens did we write (for commas below) + } else { + cs = (fl & STBSP__TRIPLET_COMMA) ? ((600 - (stbsp__uint32)dp) % 3) : 0; + if ((stbsp__uint32)dp >= l) { + // handle xxxx000*000.0 + n = 0; + for (;;) { + if ((fl & STBSP__TRIPLET_COMMA) && (++cs == 4)) { + cs = 0; + *s++ = stbsp__comma; + } else { + *s++ = sn[n]; + ++n; + if (n >= l) + break; + } + } + if (n < (stbsp__uint32)dp) { + n = dp - n; + if ((fl & STBSP__TRIPLET_COMMA) == 0) { + while (n) { + if ((((stbsp__uintptr)s) & 3) == 0) + break; + *s++ = '0'; + --n; + } + while (n >= 4) { + *(stbsp__uint32 *)s = 0x30303030; + s += 4; + n -= 4; + } + } + while (n) { + if ((fl & STBSP__TRIPLET_COMMA) && (++cs == 4)) { + cs = 0; + *s++ = stbsp__comma; + } else { + *s++ = '0'; + --n; + } + } + } + cs = (int)(s - (num + 64)) + (3 << 24); // cs is how many tens + if (pr) { + *s++ = stbsp__period; + tz = pr; + } + } else { + // handle xxxxx.xxxx000*000 + n = 0; + for (;;) { + if ((fl & STBSP__TRIPLET_COMMA) && (++cs == 4)) { + cs = 0; + *s++ = stbsp__comma; + } else { + *s++ = sn[n]; + ++n; + if (n >= (stbsp__uint32)dp) + break; + } + } + cs = (int)(s - (num + 64)) + (3 << 24); // cs is how many tens + if (pr) + *s++ = stbsp__period; + if ((l - dp) > (stbsp__uint32)pr) + l = pr + dp; + while (n < l) { + *s++ = sn[n]; + ++n; + } + tz = pr - (l - dp); + } + } + pr = 0; + + // handle k,m,g,t + if (fl & STBSP__METRIC_SUFFIX) { + char idx; + idx = 1; + if (fl & STBSP__METRIC_NOSPACE) + idx = 0; + tail[0] = idx; + tail[1] = ' '; + { + if (fl >> 24) { // SI kilo is 'k', JEDEC and SI kibits are 'K'. + if (fl & STBSP__METRIC_1024) + tail[idx + 1] = "_KMGT"[fl >> 24]; + else + tail[idx + 1] = "_kMGT"[fl >> 24]; + idx++; + // If printing kibits and not in jedec, add the 'i'. + if (fl & STBSP__METRIC_1024 && !(fl & STBSP__METRIC_JEDEC)) { + tail[idx + 1] = 'i'; + idx++; + } + tail[0] = idx; + } + } + }; + + flt_lead: + // get the length that we copied + l = (stbsp__uint32)(s - (num + 64)); + s = num + 64; + goto scopy; +#endif + + case 'B': // upper binary + case 'b': // lower binary + h = (f[0] == 'B') ? hexu : hex; + lead[0] = 0; + if (fl & STBSP__LEADING_0X) { + lead[0] = 2; + lead[1] = '0'; + lead[2] = h[0xb]; + } + l = (8 << 4) | (1 << 8); + goto radixnum; + + case 'o': // octal + h = hexu; + lead[0] = 0; + if (fl & STBSP__LEADING_0X) { + lead[0] = 1; + lead[1] = '0'; + } + l = (3 << 4) | (3 << 8); + goto radixnum; + + case 'p': // pointer + fl |= (sizeof(void *) == 8) ? STBSP__INTMAX : 0; + pr = sizeof(void *) * 2; + fl &= ~STBSP__LEADINGZERO; // 'p' only prints the pointer with zeros + // fall through - to X + + case 'X': // upper hex + case 'x': // lower hex + h = (f[0] == 'X') ? hexu : hex; + l = (4 << 4) | (4 << 8); + lead[0] = 0; + if (fl & STBSP__LEADING_0X) { + lead[0] = 2; + lead[1] = '0'; + lead[2] = h[16]; + } + radixnum: + // get the number + if (fl & STBSP__INTMAX) + n64 = va_arg(va, stbsp__uint64); + else + n64 = va_arg(va, stbsp__uint32); + + s = num + STBSP__NUMSZ; + dp = 0; + // clear tail, and clear leading if value is zero + tail[0] = 0; + if (n64 == 0) { + lead[0] = 0; + if (pr == 0) { + l = 0; + cs = 0; + goto scopy; + } + } + // convert to string + for (;;) { + *--s = h[n64 & ((1 << (l >> 8)) - 1)]; + n64 >>= (l >> 8); + if (!((n64) || ((stbsp__int32)((num + STBSP__NUMSZ) - s) < pr))) + break; + if (fl & STBSP__TRIPLET_COMMA) { + ++l; + if ((l & 15) == ((l >> 4) & 15)) { + l &= ~15; + *--s = stbsp__comma; + } + } + }; + // get the tens and the comma pos + cs = (stbsp__uint32)((num + STBSP__NUMSZ) - s) + ((((l >> 4) & 15)) << 24); + // get the length that we copied + l = (stbsp__uint32)((num + STBSP__NUMSZ) - s); + // copy it + goto scopy; + + case 'u': // unsigned + case 'i': + case 'd': // integer + // get the integer and abs it + if (fl & STBSP__INTMAX) { + stbsp__int64 i64 = va_arg(va, stbsp__int64); + n64 = (stbsp__uint64)i64; + if ((f[0] != 'u') && (i64 < 0)) { + n64 = (stbsp__uint64)-i64; + fl |= STBSP__NEGATIVE; + } + } else { + stbsp__int32 i = va_arg(va, stbsp__int32); + n64 = (stbsp__uint32)i; + if ((f[0] != 'u') && (i < 0)) { + n64 = (stbsp__uint32)-i; + fl |= STBSP__NEGATIVE; + } + } + +#ifndef STB_SPRINTF_NOFLOAT + if (fl & STBSP__METRIC_SUFFIX) { + if (n64 < 1024) + pr = 0; + else if (pr == -1) + pr = 1; + fv = (double)(stbsp__int64)n64; + goto doafloat; + } +#endif + + // convert to string + s = num + STBSP__NUMSZ; + l = 0; + + for (;;) { + // do in 32-bit chunks (avoid lots of 64-bit divides even with constant denominators) + char *o = s - 8; + if (n64 >= 100000000) { + n = (stbsp__uint32)(n64 % 100000000); + n64 /= 100000000; + } else { + n = (stbsp__uint32)n64; + n64 = 0; + } + if ((fl & STBSP__TRIPLET_COMMA) == 0) { + do { + s -= 2; + *(stbsp__uint16 *)s = *(stbsp__uint16 *)&stbsp__digitpair.pair[(n % 100) * 2]; + n /= 100; + } while (n); + } + while (n) { + if ((fl & STBSP__TRIPLET_COMMA) && (l++ == 3)) { + l = 0; + *--s = stbsp__comma; + --o; + } else { + *--s = (char)(n % 10) + '0'; + n /= 10; + } + } + if (n64 == 0) { + if ((s[0] == '0') && (s != (num + STBSP__NUMSZ))) + ++s; + break; + } + while (s != o) + if ((fl & STBSP__TRIPLET_COMMA) && (l++ == 3)) { + l = 0; + *--s = stbsp__comma; + --o; + } else { + *--s = '0'; + } + } + + tail[0] = 0; + stbsp__lead_sign(fl, lead); + + // get the length that we copied + l = (stbsp__uint32)((num + STBSP__NUMSZ) - s); + if (l == 0) { + *--s = '0'; + l = 1; + } + cs = l + (3 << 24); + if (pr < 0) + pr = 0; + + scopy: + // get fw=leading/trailing space, pr=leading zeros + if (pr < (stbsp__int32)l) + pr = l; + n = pr + lead[0] + tail[0] + tz; + if (fw < (stbsp__int32)n) + fw = n; + fw -= n; + pr -= l; + + // handle right justify and leading zeros + if ((fl & STBSP__LEFTJUST) == 0) { + if (fl & STBSP__LEADINGZERO) // if leading zeros, everything is in pr + { + pr = (fw > pr) ? fw : pr; + fw = 0; + } else { + fl &= ~STBSP__TRIPLET_COMMA; // if no leading zeros, then no commas + } + } + + // copy the spaces and/or zeros + if (fw + pr) { + stbsp__int32 i; + stbsp__uint32 c; + + // copy leading spaces (or when doing %8.4d stuff) + if ((fl & STBSP__LEFTJUST) == 0) + while (fw > 0) { + stbsp__cb_buf_clamp(i, fw); + fw -= i; + while (i) { + if ((((stbsp__uintptr)bf) & 3) == 0) + break; + *bf++ = ' '; + --i; + } + while (i >= 4) { + *(stbsp__uint32 *)bf = 0x20202020; + bf += 4; + i -= 4; + } + while (i) { + *bf++ = ' '; + --i; + } + stbsp__chk_cb_buf(1); + } + + // copy leader + sn = lead + 1; + while (lead[0]) { + stbsp__cb_buf_clamp(i, lead[0]); + lead[0] -= (char)i; + while (i) { + *bf++ = *sn++; + --i; + } + stbsp__chk_cb_buf(1); + } + + // copy leading zeros + c = cs >> 24; + cs &= 0xffffff; + cs = (fl & STBSP__TRIPLET_COMMA) ? ((stbsp__uint32)(c - ((pr + cs) % (c + 1)))) : 0; + while (pr > 0) { + stbsp__cb_buf_clamp(i, pr); + pr -= i; + if ((fl & STBSP__TRIPLET_COMMA) == 0) { + while (i) { + if ((((stbsp__uintptr)bf) & 3) == 0) + break; + *bf++ = '0'; + --i; + } + while (i >= 4) { + *(stbsp__uint32 *)bf = 0x30303030; + bf += 4; + i -= 4; + } + } + while (i) { + if ((fl & STBSP__TRIPLET_COMMA) && (cs++ == c)) { + cs = 0; + *bf++ = stbsp__comma; + } else + *bf++ = '0'; + --i; + } + stbsp__chk_cb_buf(1); + } + } + + // copy leader if there is still one + sn = lead + 1; + while (lead[0]) { + stbsp__int32 i; + stbsp__cb_buf_clamp(i, lead[0]); + lead[0] -= (char)i; + while (i) { + *bf++ = *sn++; + --i; + } + stbsp__chk_cb_buf(1); + } + + // copy the string + n = l; + while (n) { + stbsp__int32 i; + stbsp__cb_buf_clamp(i, n); + n -= i; + STBSP__UNALIGNED(while (i >= 4) { + *(stbsp__uint32 volatile *)bf = *(stbsp__uint32 volatile *)s; + bf += 4; + s += 4; + i -= 4; + }) + while (i) { + *bf++ = *s++; + --i; + } + stbsp__chk_cb_buf(1); + } + + // copy trailing zeros + while (tz) { + stbsp__int32 i; + stbsp__cb_buf_clamp(i, tz); + tz -= i; + while (i) { + if ((((stbsp__uintptr)bf) & 3) == 0) + break; + *bf++ = '0'; + --i; + } + while (i >= 4) { + *(stbsp__uint32 *)bf = 0x30303030; + bf += 4; + i -= 4; + } + while (i) { + *bf++ = '0'; + --i; + } + stbsp__chk_cb_buf(1); + } + + // copy tail if there is one + sn = tail + 1; + while (tail[0]) { + stbsp__int32 i; + stbsp__cb_buf_clamp(i, tail[0]); + tail[0] -= (char)i; + while (i) { + *bf++ = *sn++; + --i; + } + stbsp__chk_cb_buf(1); + } + + // handle the left justify + if (fl & STBSP__LEFTJUST) + if (fw > 0) { + while (fw) { + stbsp__int32 i; + stbsp__cb_buf_clamp(i, fw); + fw -= i; + while (i) { + if ((((stbsp__uintptr)bf) & 3) == 0) + break; + *bf++ = ' '; + --i; + } + while (i >= 4) { + *(stbsp__uint32 *)bf = 0x20202020; + bf += 4; + i -= 4; + } + while (i--) + *bf++ = ' '; + stbsp__chk_cb_buf(1); + } + } + break; + + default: // unknown, just copy code + s = num + STBSP__NUMSZ - 1; + *s = f[0]; + l = 1; + fw = fl = 0; + lead[0] = 0; + tail[0] = 0; + pr = 0; + dp = 0; + cs = 0; + goto scopy; + } + ++f; + } + endfmt: + + if (!callback) + *bf = 0; + else + stbsp__flush_cb(); + + done: + return tlen + (int)(bf - buf); +} + +// cleanup +#undef STBSP__LEFTJUST +#undef STBSP__LEADINGPLUS +#undef STBSP__LEADINGSPACE +#undef STBSP__LEADING_0X +#undef STBSP__LEADINGZERO +#undef STBSP__INTMAX +#undef STBSP__TRIPLET_COMMA +#undef STBSP__NEGATIVE +#undef STBSP__METRIC_SUFFIX +#undef STBSP__NUMSZ +#undef stbsp__chk_cb_bufL +#undef stbsp__chk_cb_buf +#undef stbsp__flush_cb +#undef stbsp__cb_buf_clamp + +// ============================================================================ +// wrapper functions + +STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(sprintf)(char *buf, char const *fmt, ...) +{ + int result; + va_list va; + va_start(va, fmt); + result = STB_SPRINTF_DECORATE(vsprintfcb)(0, 0, buf, fmt, va); + va_end(va); + return result; +} + +typedef struct stbsp__context { + char *buf; + int count; + int length; + char tmp[STB_SPRINTF_MIN]; +} stbsp__context; + +static char *stbsp__clamp_callback(const char *buf, void *user, int len) +{ + stbsp__context *c = (stbsp__context *)user; + c->length += len; + + if (len > c->count) + len = c->count; + + if (len) { + if (buf != c->buf) { + const char *s, *se; + char *d; + d = c->buf; + s = buf; + se = buf + len; + do { + *d++ = *s++; + } while (s < se); + } + c->buf += len; + c->count -= len; + } + + if (c->count <= 0) + return c->tmp; + return (c->count >= STB_SPRINTF_MIN) ? c->buf : c->tmp; // go direct into buffer if you can +} + +static char * stbsp__count_clamp_callback( const char * buf, void * user, int len ) +{ + stbsp__context * c = (stbsp__context*)user; + (void) sizeof(buf); + + c->length += len; + return c->tmp; // go direct into buffer if you can +} + +STBSP__PUBLICDEF int STB_SPRINTF_DECORATE( vsnprintf )( char * buf, int count, char const * fmt, va_list va ) +{ + stbsp__context c; + + if ( (count == 0) && !buf ) + { + c.length = 0; + + STB_SPRINTF_DECORATE( vsprintfcb )( stbsp__count_clamp_callback, &c, c.tmp, fmt, va ); + } + else + { + int l; + + c.buf = buf; + c.count = count; + c.length = 0; + + STB_SPRINTF_DECORATE( vsprintfcb )( stbsp__clamp_callback, &c, stbsp__clamp_callback(0,&c,0), fmt, va ); + + // zero-terminate + l = (int)( c.buf - buf ); + if ( l >= count ) // should never be greater, only equal (or less) than count + l = count - 1; + buf[l] = 0; + } + + return c.length; +} + +STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(snprintf)(char *buf, int count, char const *fmt, ...) +{ + int result; + va_list va; + va_start(va, fmt); + + result = STB_SPRINTF_DECORATE(vsnprintf)(buf, count, fmt, va); + va_end(va); + + return result; +} + +STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(vsprintf)(char *buf, char const *fmt, va_list va) +{ + return STB_SPRINTF_DECORATE(vsprintfcb)(0, 0, buf, fmt, va); +} + +// ======================================================================= +// low level float utility functions + +#ifndef STB_SPRINTF_NOFLOAT + +// copies d to bits w/ strict aliasing (this compiles to nothing on /Ox) +#define STBSP__COPYFP(dest, src) \ +{ \ +int cn; \ +for (cn = 0; cn < 8; cn++) \ +((char *)&dest)[cn] = ((char *)&src)[cn]; \ +} + +// get float info +static stbsp__int32 stbsp__real_to_parts(stbsp__int64 *bits, stbsp__int32 *expo, double value) +{ + double d; + stbsp__int64 b = 0; + + // load value and round at the frac_digits + d = value; + + STBSP__COPYFP(b, d); + + *bits = b & ((((stbsp__uint64)1) << 52) - 1); + *expo = (stbsp__int32)(((b >> 52) & 2047) - 1023); + + return (stbsp__int32)((stbsp__uint64) b >> 63); +} + +static double const stbsp__bot[23] = { + 1e+000, 1e+001, 1e+002, 1e+003, 1e+004, 1e+005, 1e+006, 1e+007, 1e+008, 1e+009, 1e+010, 1e+011, + 1e+012, 1e+013, 1e+014, 1e+015, 1e+016, 1e+017, 1e+018, 1e+019, 1e+020, 1e+021, 1e+022 +}; +static double const stbsp__negbot[22] = { + 1e-001, 1e-002, 1e-003, 1e-004, 1e-005, 1e-006, 1e-007, 1e-008, 1e-009, 1e-010, 1e-011, + 1e-012, 1e-013, 1e-014, 1e-015, 1e-016, 1e-017, 1e-018, 1e-019, 1e-020, 1e-021, 1e-022 +}; +static double const stbsp__negboterr[22] = { + -5.551115123125783e-018, -2.0816681711721684e-019, -2.0816681711721686e-020, -4.7921736023859299e-021, -8.1803053914031305e-022, 4.5251888174113741e-023, + 4.5251888174113739e-024, -2.0922560830128471e-025, -6.2281591457779853e-026, -3.6432197315497743e-027, 6.0503030718060191e-028, 2.0113352370744385e-029, + -3.0373745563400371e-030, 1.1806906454401013e-032, -7.7705399876661076e-032, 2.0902213275965398e-033, -7.1542424054621921e-034, -7.1542424054621926e-035, + 2.4754073164739869e-036, 5.4846728545790429e-037, 9.2462547772103625e-038, -4.8596774326570872e-039 +}; +static double const stbsp__top[13] = { + 1e+023, 1e+046, 1e+069, 1e+092, 1e+115, 1e+138, 1e+161, 1e+184, 1e+207, 1e+230, 1e+253, 1e+276, 1e+299 +}; +static double const stbsp__negtop[13] = { + 1e-023, 1e-046, 1e-069, 1e-092, 1e-115, 1e-138, 1e-161, 1e-184, 1e-207, 1e-230, 1e-253, 1e-276, 1e-299 +}; +static double const stbsp__toperr[13] = { + 8388608, + 6.8601809640529717e+028, + -7.253143638152921e+052, + -4.3377296974619174e+075, + -1.5559416129466825e+098, + -3.2841562489204913e+121, + -3.7745893248228135e+144, + -1.7356668416969134e+167, + -3.8893577551088374e+190, + -9.9566444326005119e+213, + 6.3641293062232429e+236, + -5.2069140800249813e+259, + -5.2504760255204387e+282 +}; +static double const stbsp__negtoperr[13] = { + 3.9565301985100693e-040, -2.299904345391321e-063, 3.6506201437945798e-086, 1.1875228833981544e-109, + -5.0644902316928607e-132, -6.7156837247865426e-155, -2.812077463003139e-178, -5.7778912386589953e-201, + 7.4997100559334532e-224, -4.6439668915134491e-247, -6.3691100762962136e-270, -9.436808465446358e-293, + 8.0970921678014997e-317 +}; + +#if defined(_MSC_VER) && (_MSC_VER <= 1200) +static stbsp__uint64 const stbsp__powten[20] = { + 1, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000, + 10000000000, + 100000000000, + 1000000000000, + 10000000000000, + 100000000000000, + 1000000000000000, + 10000000000000000, + 100000000000000000, + 1000000000000000000, + 10000000000000000000U +}; +#define stbsp__tento19th ((stbsp__uint64)1000000000000000000) +#else +static stbsp__uint64 const stbsp__powten[20] = { + 1, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000, + 10000000000ULL, + 100000000000ULL, + 1000000000000ULL, + 10000000000000ULL, + 100000000000000ULL, + 1000000000000000ULL, + 10000000000000000ULL, + 100000000000000000ULL, + 1000000000000000000ULL, + 10000000000000000000ULL +}; +#define stbsp__tento19th (1000000000000000000ULL) +#endif + +#define stbsp__ddmulthi(oh, ol, xh, yh) \ +{ \ +double ahi = 0, alo, bhi = 0, blo; \ +stbsp__int64 bt; \ +oh = xh * yh; \ +STBSP__COPYFP(bt, xh); \ +bt &= ((~(stbsp__uint64)0) << 27); \ +STBSP__COPYFP(ahi, bt); \ +alo = xh - ahi; \ +STBSP__COPYFP(bt, yh); \ +bt &= ((~(stbsp__uint64)0) << 27); \ +STBSP__COPYFP(bhi, bt); \ +blo = yh - bhi; \ +ol = ((ahi * bhi - oh) + ahi * blo + alo * bhi) + alo * blo; \ +} + +#define stbsp__ddtoS64(ob, xh, xl) \ +{ \ +double ahi = 0, alo, vh, t; \ +ob = (stbsp__int64)xh; \ +vh = (double)ob; \ +ahi = (xh - vh); \ +t = (ahi - xh); \ +alo = (xh - (ahi - t)) - (vh + t); \ +ob += (stbsp__int64)(ahi + alo + xl); \ +} + +#define stbsp__ddrenorm(oh, ol) \ +{ \ +double s; \ +s = oh + ol; \ +ol = ol - (s - oh); \ +oh = s; \ +} + +#define stbsp__ddmultlo(oh, ol, xh, xl, yh, yl) ol = ol + (xh * yl + xl * yh); + +#define stbsp__ddmultlos(oh, ol, xh, yl) ol = ol + (xh * yl); + +static void stbsp__raise_to_power10(double *ohi, double *olo, double d, stbsp__int32 power) // power can be -323 to +350 +{ + double ph, pl; + if ((power >= 0) && (power <= 22)) { + stbsp__ddmulthi(ph, pl, d, stbsp__bot[power]); + } else { + stbsp__int32 e, et, eb; + double p2h, p2l; + + e = power; + if (power < 0) + e = -e; + et = (e * 0x2c9) >> 14; /* %23 */ + if (et > 13) + et = 13; + eb = e - (et * 23); + + ph = d; + pl = 0.0; + if (power < 0) { + if (eb) { + --eb; + stbsp__ddmulthi(ph, pl, d, stbsp__negbot[eb]); + stbsp__ddmultlos(ph, pl, d, stbsp__negboterr[eb]); + } + if (et) { + stbsp__ddrenorm(ph, pl); + --et; + stbsp__ddmulthi(p2h, p2l, ph, stbsp__negtop[et]); + stbsp__ddmultlo(p2h, p2l, ph, pl, stbsp__negtop[et], stbsp__negtoperr[et]); + ph = p2h; + pl = p2l; + } + } else { + if (eb) { + e = eb; + if (eb > 22) + eb = 22; + e -= eb; + stbsp__ddmulthi(ph, pl, d, stbsp__bot[eb]); + if (e) { + stbsp__ddrenorm(ph, pl); + stbsp__ddmulthi(p2h, p2l, ph, stbsp__bot[e]); + stbsp__ddmultlos(p2h, p2l, stbsp__bot[e], pl); + ph = p2h; + pl = p2l; + } + } + if (et) { + stbsp__ddrenorm(ph, pl); + --et; + stbsp__ddmulthi(p2h, p2l, ph, stbsp__top[et]); + stbsp__ddmultlo(p2h, p2l, ph, pl, stbsp__top[et], stbsp__toperr[et]); + ph = p2h; + pl = p2l; + } + } + } + stbsp__ddrenorm(ph, pl); + *ohi = ph; + *olo = pl; +} + +// given a float value, returns the significant bits in bits, and the position of the +// decimal point in decimal_pos. +/-INF and NAN are specified by special values +// returned in the decimal_pos parameter. +// frac_digits is absolute normally, but if you want from first significant digits (got %g and %e), or in 0x80000000 +static stbsp__int32 stbsp__real_to_str(char const **start, stbsp__uint32 *len, char *out, stbsp__int32 *decimal_pos, double value, stbsp__uint32 frac_digits) +{ + double d; + stbsp__int64 bits = 0; + stbsp__int32 expo, e, ng, tens; + + d = value; + STBSP__COPYFP(bits, d); + expo = (stbsp__int32)((bits >> 52) & 2047); + ng = (stbsp__int32)((stbsp__uint64) bits >> 63); + if (ng) + d = -d; + + if (expo == 2047) // is nan or inf? + { + *start = (bits & ((((stbsp__uint64)1) << 52) - 1)) ? "NaN" : "Inf"; + *decimal_pos = STBSP__SPECIAL; + *len = 3; + return ng; + } + + if (expo == 0) // is zero or denormal + { + if (((stbsp__uint64) bits << 1) == 0) // do zero + { + *decimal_pos = 1; + *start = out; + out[0] = '0'; + *len = 1; + return ng; + } + // find the right expo for denormals + { + stbsp__int64 v = ((stbsp__uint64)1) << 51; + while ((bits & v) == 0) { + --expo; + v >>= 1; + } + } + } + + // find the decimal exponent as well as the decimal bits of the value + { + double ph, pl; + + // log10 estimate - very specifically tweaked to hit or undershoot by no more than 1 of log10 of all expos 1..2046 + tens = expo - 1023; + tens = (tens < 0) ? ((tens * 617) / 2048) : (((tens * 1233) / 4096) + 1); + + // move the significant bits into position and stick them into an int + stbsp__raise_to_power10(&ph, &pl, d, 18 - tens); + + // get full as much precision from double-double as possible + stbsp__ddtoS64(bits, ph, pl); + + // check if we undershot + if (((stbsp__uint64)bits) >= stbsp__tento19th) + ++tens; + } + + // now do the rounding in integer land + frac_digits = (frac_digits & 0x80000000) ? ((frac_digits & 0x7ffffff) + 1) : (tens + frac_digits); + if ((frac_digits < 24)) { + stbsp__uint32 dg = 1; + if ((stbsp__uint64)bits >= stbsp__powten[9]) + dg = 10; + while ((stbsp__uint64)bits >= stbsp__powten[dg]) { + ++dg; + if (dg == 20) + goto noround; + } + if (frac_digits < dg) { + stbsp__uint64 r; + // add 0.5 at the right position and round + e = dg - frac_digits; + if ((stbsp__uint32)e >= 24) + goto noround; + r = stbsp__powten[e]; + bits = bits + (r / 2); + if ((stbsp__uint64)bits >= stbsp__powten[dg]) + ++tens; + bits /= r; + } + noround:; + } + + // kill long trailing runs of zeros + if (bits) { + stbsp__uint32 n; + for (;;) { + if (bits <= 0xffffffff) + break; + if (bits % 1000) + goto donez; + bits /= 1000; + } + n = (stbsp__uint32)bits; + while ((n % 1000) == 0) + n /= 1000; + bits = n; + donez:; + } + + // convert to string + out += 64; + e = 0; + for (;;) { + stbsp__uint32 n; + char *o = out - 8; + // do the conversion in chunks of U32s (avoid most 64-bit divides, worth it, constant denomiators be damned) + if (bits >= 100000000) { + n = (stbsp__uint32)(bits % 100000000); + bits /= 100000000; + } else { + n = (stbsp__uint32)bits; + bits = 0; + } + while (n) { + out -= 2; + *(stbsp__uint16 *)out = *(stbsp__uint16 *)&stbsp__digitpair.pair[(n % 100) * 2]; + n /= 100; + e += 2; + } + if (bits == 0) { + if ((e) && (out[0] == '0')) { + ++out; + --e; + } + break; + } + while (out != o) { + *--out = '0'; + ++e; + } + } + + *decimal_pos = tens; + *start = out; + *len = e; + return ng; +} + +#undef stbsp__ddmulthi +#undef stbsp__ddrenorm +#undef stbsp__ddmultlo +#undef stbsp__ddmultlos +#undef STBSP__SPECIAL +#undef STBSP__COPYFP + +#endif // STB_SPRINTF_NOFLOAT + +// clean up +#undef stbsp__uint16 +#undef stbsp__uint32 +#undef stbsp__int32 +#undef stbsp__uint64 +#undef stbsp__int64 +#undef STBSP__UNALIGNED + +#endif // STB_SPRINTF_IMPLEMENTATION + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +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. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +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. +------------------------------------------------------------------------------ +*/ \ No newline at end of file diff --git a/src_v2/libs/stb_truetype.h b/src_v2/libs/stb_truetype.h new file mode 100644 index 0000000..3ffe4de --- /dev/null +++ b/src_v2/libs/stb_truetype.h @@ -0,0 +1,4853 @@ +// stb_truetype.h - v1.19 - public domain +// authored from 2009-2016 by Sean Barrett / RAD Game Tools +// +// This library processes TrueType files: +// parse files +// extract glyph metrics +// extract glyph shapes +// render glyphs to one-channel bitmaps with antialiasing (box filter) +// render glyphs to one-channel SDF bitmaps (signed-distance field/function) +// +// Todo: +// non-MS cmaps +// crashproof on bad data +// hinting? (no longer patented) +// cleartype-style AA? +// optimize: use simple memory allocator for intermediates +// optimize: build edge-list directly from curves +// optimize: rasterize directly from curves? +// +// ADDITIONAL CONTRIBUTORS +// +// Mikko Mononen: compound shape support, more cmap formats +// Tor Andersson: kerning, subpixel rendering +// Dougall Johnson: OpenType / Type 2 font handling +// Daniel Ribeiro Maciel: basic GPOS-based kerning +// +// Misc other: +// Ryan Gordon +// Simon Glass +// github:IntellectualKitty +// Imanol Celaya +// Daniel Ribeiro Maciel +// +// Bug/warning reports/fixes: +// "Zer" on mollyrocket Fabian "ryg" Giesen +// Cass Everitt Martins Mozeiko +// stoiko (Haemimont Games) Cap Petschulat +// Brian Hook Omar Cornut +// Walter van Niftrik github:aloucks +// David Gow Peter LaValle +// David Given Sergey Popov +// Ivan-Assen Ivanov Giumo X. Clanjor +// Anthony Pesch Higor Euripedes +// Johan Duparc Thomas Fields +// Hou Qiming Derek Vinyard +// Rob Loach Cort Stratton +// Kenney Phillis Jr. github:oyvindjam +// Brian Costabile github:vassvik +// +// VERSION HISTORY +// +// 1.19 (2018-02-11) GPOS kerning, STBTT_fmod +// 1.18 (2018-01-29) add missing function +// 1.17 (2017-07-23) make more arguments const; doc fix +// 1.16 (2017-07-12) SDF support +// 1.15 (2017-03-03) make more arguments const +// 1.14 (2017-01-16) num-fonts-in-TTC function +// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts +// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual +// 1.11 (2016-04-02) fix unused-variable warning +// 1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef +// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly +// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges +// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; +// variant PackFontRanges to pack and render in separate phases; +// fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); +// fixed an assert() bug in the new rasterizer +// replace assert() with STBTT_assert() in new rasterizer +// +// Full history can be found at the end of this file. +// +// LICENSE +// +// See end of file for license information. +// +// USAGE +// +// Include this file in whatever places neeed to refer to it. In ONE C/C++ +// file, write: +// #define STB_TRUETYPE_IMPLEMENTATION +// before the #include of this file. This expands out the actual +// implementation into that C/C++ file. +// +// To make the implementation private to the file that generates the implementation, +// #define STBTT_STATIC +// +// Simple 3D API (don't ship this, but it's fine for tools and quick start) +// stbtt_BakeFontBitmap() -- bake a font to a bitmap for use as texture +// stbtt_GetBakedQuad() -- compute quad to draw for a given char +// +// Improved 3D API (more shippable): +// #include "stb_rect_pack.h" -- optional, but you really want it +// stbtt_PackBegin() +// stbtt_PackSetOversampling() -- for improved quality on small fonts +// stbtt_PackFontRanges() -- pack and renders +// stbtt_PackEnd() +// stbtt_GetPackedQuad() +// +// "Load" a font file from a memory buffer (you have to keep the buffer loaded) +// stbtt_InitFont() +// stbtt_GetFontOffsetForIndex() -- indexing for TTC font collections +// stbtt_GetNumberOfFonts() -- number of fonts for TTC font collections +// +// Render a unicode codepoint to a bitmap +// stbtt_GetCodepointBitmap() -- allocates and returns a bitmap +// stbtt_MakeCodepointBitmap() -- renders into bitmap you provide +// stbtt_GetCodepointBitmapBox() -- how big the bitmap must be +// +// Character advance/positioning +// stbtt_GetCodepointHMetrics() +// stbtt_GetFontVMetrics() +// stbtt_GetFontVMetricsOS2() +// stbtt_GetCodepointKernAdvance() +// +// Starting with version 1.06, the rasterizer was replaced with a new, +// faster and generally-more-precise rasterizer. The new rasterizer more +// accurately measures pixel coverage for anti-aliasing, except in the case +// where multiple shapes overlap, in which case it overestimates the AA pixel +// coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If +// this turns out to be a problem, you can re-enable the old rasterizer with +// #define STBTT_RASTERIZER_VERSION 1 +// which will incur about a 15% speed hit. +// +// ADDITIONAL DOCUMENTATION +// +// Immediately after this block comment are a series of sample programs. +// +// After the sample programs is the "header file" section. This section +// includes documentation for each API function. +// +// Some important concepts to understand to use this library: +// +// Codepoint +// Characters are defined by unicode codepoints, e.g. 65 is +// uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is +// the hiragana for "ma". +// +// Glyph +// A visual character shape (every codepoint is rendered as +// some glyph) +// +// Glyph index +// A font-specific integer ID representing a glyph +// +// Baseline +// Glyph shapes are defined relative to a baseline, which is the +// bottom of uppercase characters. Characters extend both above +// and below the baseline. +// +// Current Point +// As you draw text to the screen, you keep track of a "current point" +// which is the origin of each character. The current point's vertical +// position is the baseline. Even "baked fonts" use this model. +// +// Vertical Font Metrics +// The vertical qualities of the font, used to vertically position +// and space the characters. See docs for stbtt_GetFontVMetrics. +// +// Font Size in Pixels or Points +// The preferred interface for specifying font sizes in stb_truetype +// is to specify how tall the font's vertical extent should be in pixels. +// If that sounds good enough, skip the next paragraph. +// +// Most font APIs instead use "points", which are a common typographic +// measurement for describing font size, defined as 72 points per inch. +// stb_truetype provides a point API for compatibility. However, true +// "per inch" conventions don't make much sense on computer displays +// since different monitors have different number of pixels per +// inch. For example, Windows traditionally uses a convention that +// there are 96 pixels per inch, thus making 'inch' measurements have +// nothing to do with inches, and thus effectively defining a point to +// be 1.333 pixels. Additionally, the TrueType font data provides +// an explicit scale factor to scale a given font's glyphs to points, +// but the author has observed that this scale factor is often wrong +// for non-commercial fonts, thus making fonts scaled in points +// according to the TrueType spec incoherently sized in practice. +// +// DETAILED USAGE: +// +// Scale: +// Select how high you want the font to be, in points or pixels. +// Call ScaleForPixelHeight or ScaleForMappingEmToPixels to compute +// a scale factor SF that will be used by all other functions. +// +// Baseline: +// You need to select a y-coordinate that is the baseline of where +// your text will appear. Call GetFontBoundingBox to get the baseline-relative +// bounding box for all characters. SF*-y0 will be the distance in pixels +// that the worst-case character could extend above the baseline, so if +// you want the top edge of characters to appear at the top of the +// screen where y=0, then you would set the baseline to SF*-y0. +// +// Current point: +// Set the current point where the first character will appear. The +// first character could extend left of the current point; this is font +// dependent. You can either choose a current point that is the leftmost +// point and hope, or add some padding, or check the bounding box or +// left-side-bearing of the first character to be displayed and set +// the current point based on that. +// +// Displaying a character: +// Compute the bounding box of the character. It will contain signed values +// relative to <current_point, baseline>. I.e. if it returns x0,y0,x1,y1, +// then the character should be displayed in the rectangle from +// <current_point+SF*x0, baseline+SF*y0> to <current_point+SF*x1,baseline+SF*y1). +// +// Advancing for the next character: +// Call GlyphHMetrics, and compute 'current_point += SF * advance'. +// +// +// ADVANCED USAGE +// +// Quality: +// +// - Use the functions with Subpixel at the end to allow your characters +// to have subpixel positioning. Since the font is anti-aliased, not +// hinted, this is very import for quality. (This is not possible with +// baked fonts.) +// +// - Kerning is now supported, and if you're supporting subpixel rendering +// then kerning is worth using to give your text a polished look. +// +// Performance: +// +// - Convert Unicode codepoints to glyph indexes and operate on the glyphs; +// if you don't do this, stb_truetype is forced to do the conversion on +// every call. +// +// - There are a lot of memory allocations. We should modify it to take +// a temp buffer and allocate from the temp buffer (without freeing), +// should help performance a lot. +// +// NOTES +// +// The system uses the raw data found in the .ttf file without changing it +// and without building auxiliary data structures. This is a bit inefficient +// on little-endian systems (the data is big-endian), but assuming you're +// caching the bitmaps or glyph shapes this shouldn't be a big deal. +// +// It appears to be very hard to programmatically determine what font a +// given file is in a general way. I provide an API for this, but I don't +// recommend it. +// +// +// SOURCE STATISTICS (based on v0.6c, 2050 LOC) +// +// Documentation & header file 520 LOC \___ 660 LOC documentation +// Sample code 140 LOC / +// Truetype parsing 620 LOC ---- 620 LOC TrueType +// Software rasterization 240 LOC \ . +// Curve tesselation 120 LOC \__ 550 LOC Bitmap creation +// Bitmap management 100 LOC / +// Baked bitmap interface 70 LOC / +// Font name matching & access 150 LOC ---- 150 +// C runtime library abstraction 60 LOC ---- 60 +// +// +// PERFORMANCE MEASUREMENTS FOR 1.06: +// +// 32-bit 64-bit +// Previous release: 8.83 s 7.68 s +// Pool allocations: 7.72 s 6.34 s +// Inline sort : 6.54 s 5.65 s +// New rasterizer : 5.63 s 5.00 s + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +//// +//// SAMPLE PROGRAMS +//// +// +// Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless +// +#if 0 +#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation +#include "stb_truetype.h" + +unsigned char ttf_buffer[1<<20]; +unsigned char temp_bitmap[512*512]; + +stbtt_bakedchar cdata[96]; // ASCII 32..126 is 95 glyphs +GLuint ftex; + +void my_stbtt_initfont(void) +{ + fread(ttf_buffer, 1, 1<<20, fopen("c:/windows/fonts/times.ttf", "rb")); + stbtt_BakeFontBitmap(ttf_buffer,0, 32.0, temp_bitmap,512,512, 32,96, cdata); // no guarantee this fits! + // can free ttf_buffer at this point + glGenTextures(1, &ftex); + glBindTexture(GL_TEXTURE_2D, ftex); + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 512,512, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap); + // can free temp_bitmap at this point + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); +} + +void my_stbtt_print(float x, float y, char *text) +{ + // assume orthographic projection with units = screen pixels, origin at top left + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, ftex); + glBegin(GL_QUADS); + while (*text) { + if (*text >= 32 && *text < 128) { + stbtt_aligned_quad q; + stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 + glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0); + glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0); + glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1); + glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1); + } + ++text; + } + glEnd(); +} +#endif +// +// +////////////////////////////////////////////////////////////////////////////// +// +// Complete program (this compiles): get a single bitmap, print as ASCII art +// +#if 0 +#include <stdio.h> +#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation +#include "stb_truetype.h" + +char ttf_buffer[1<<25]; + +int main(int argc, char **argv) +{ + stbtt_fontinfo font; + unsigned char *bitmap; + int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20); + + fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb")); + + stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); + bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); + + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) + putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); + putchar('\n'); + } + return 0; +} +#endif +// +// Output: +// +// .ii. +// @@@@@@. +// V@Mio@@o +// :i. V@V +// :oM@@M +// :@@@MM@M +// @@o o@M +// :@@. M@M +// @@@o@@@@ +// :M@@V:@@. +// +////////////////////////////////////////////////////////////////////////////// +// +// Complete program: print "Hello World!" banner, with bugs +// +#if 0 +char buffer[24<<20]; +unsigned char screen[20][79]; + +int main(int arg, char **argv) +{ + stbtt_fontinfo font; + int i,j,ascent,baseline,ch=0; + float scale, xpos=2; // leave a little padding in case the character extends left + char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness + + fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb")); + stbtt_InitFont(&font, buffer, 0); + + scale = stbtt_ScaleForPixelHeight(&font, 15); + stbtt_GetFontVMetrics(&font, &ascent,0,0); + baseline = (int) (ascent*scale); + + while (text[ch]) { + int advance,lsb,x0,y0,x1,y1; + float x_shift = xpos - (float) floor(xpos); + stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); + stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); + stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); + // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong + // because this API is really for baking character bitmaps into textures. if you want to render + // a sequence of characters, you really need to render each bitmap to a temp buffer, then + // "alpha blend" that into the working buffer + xpos += (advance * scale); + if (text[ch+1]) + xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); + ++ch; + } + + for (j=0; j < 20; ++j) { + for (i=0; i < 78; ++i) + putchar(" .:ioVM@"[screen[j][i]>>5]); + putchar('\n'); + } + + return 0; +} +#endif + + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +//// +//// INTEGRATION WITH YOUR CODEBASE +//// +//// The following sections allow you to supply alternate definitions +//// of C library functions used by stb_truetype, e.g. if you don't +//// link with the C runtime library. + +#ifdef STB_TRUETYPE_IMPLEMENTATION +// #define your own (u)stbtt_int8/16/32 before including to override this +#ifndef stbtt_uint8 +typedef unsigned char stbtt_uint8; +typedef signed char stbtt_int8; +typedef unsigned short stbtt_uint16; +typedef signed short stbtt_int16; +typedef unsigned int stbtt_uint32; +typedef signed int stbtt_int32; +#endif + +typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; +typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; + +// e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h +#ifndef STBTT_ifloor +#include <math.h> +#define STBTT_ifloor(x) ((int) floor(x)) +#define STBTT_iceil(x) ((int) ceil(x)) +#endif + +#ifndef STBTT_sqrt +#include <math.h> +#define STBTT_sqrt(x) sqrt(x) +#define STBTT_pow(x,y) pow(x,y) +#endif + +#ifndef STBTT_fmod +#include <math.h> +#define STBTT_fmod(x,y) fmod(x,y) +#endif + +#ifndef STBTT_cos +#include <math.h> +#define STBTT_cos(x) cos(x) +#define STBTT_acos(x) acos(x) +#endif + +#ifndef STBTT_fabs +#include <math.h> +#define STBTT_fabs(x) fabs(x) +#endif + +// #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h +#ifndef STBTT_malloc +#include <stdlib.h> +#define STBTT_malloc(x,u) ((void)(u),malloc(x)) +#define STBTT_free(x,u) ((void)(u),free(x)) +#endif + +#ifndef STBTT_assert +#include <assert.h> +#define STBTT_assert(x) assert(x) +#endif + +#ifndef STBTT_strlen +#include <string.h> +#define STBTT_strlen(x) strlen(x) +#endif + +#ifndef STBTT_memcpy +#include <string.h> +#define STBTT_memcpy memcpy +#define STBTT_memset memset +#endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +//// +//// INTERFACE +//// +//// + +#ifndef __STB_INCLUDE_STB_TRUETYPE_H__ +#define __STB_INCLUDE_STB_TRUETYPE_H__ + +#ifdef STBTT_STATIC +#define STBTT_DEF static +#else +#define STBTT_DEF extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + // private structure + typedef struct + { + unsigned char *data; + int cursor; + int size; + } stbtt__buf; + + ////////////////////////////////////////////////////////////////////////////// + // + // TEXTURE BAKING API + // + // If you use this API, you only have to call two functions ever. + // + + typedef struct + { + unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap + float xoff,yoff,xadvance; + } stbtt_bakedchar; + + STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) + float pixel_height, // height of font in pixels + unsigned char *pixels, int pw, int ph, // bitmap to be filled in + int first_char, int num_chars, // characters to bake + stbtt_bakedchar *chardata); // you allocate this, it's num_chars long + // if return is positive, the first unused row of the bitmap + // if return is negative, returns the negative of the number of characters that fit + // if return is 0, no characters fit and no rows were used + // This uses a very crappy packing. + + typedef struct + { + float x0,y0,s0,t0; // top-left + float x1,y1,s1,t1; // bottom-right + } stbtt_aligned_quad; + + STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above + int char_index, // character to display + float *xpos, float *ypos, // pointers to current position in screen pixel space + stbtt_aligned_quad *q, // output: quad to draw + int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier + // Call GetBakedQuad with char_index = 'character - first_char', and it + // creates the quad you need to draw and advances the current position. + // + // The coordinate system used assumes y increases downwards. + // + // Characters will extend both above and below the current position; + // see discussion of "BASELINE" above. + // + // It's inefficient; you might want to c&p it and optimize it. + + + + ////////////////////////////////////////////////////////////////////////////// + // + // NEW TEXTURE BAKING API + // + // This provides options for packing multiple fonts into one atlas, not + // perfectly but better than nothing. + + typedef struct + { + unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap + float xoff,yoff,xadvance; + float xoff2,yoff2; + } stbtt_packedchar; + + typedef struct stbtt_pack_context stbtt_pack_context; + typedef struct stbtt_fontinfo stbtt_fontinfo; +#ifndef STB_RECT_PACK_VERSION + typedef struct stbrp_rect stbrp_rect; +#endif + + STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context); + // Initializes a packing context stored in the passed-in stbtt_pack_context. + // Future calls using this context will pack characters into the bitmap passed + // in here: a 1-channel bitmap that is width * height. stride_in_bytes is + // the distance from one row to the next (or 0 to mean they are packed tightly + // together). "padding" is the amount of padding to leave between each + // character (normally you want '1' for bitmaps you'll use as textures with + // bilinear filtering). + // + // Returns 0 on failure, 1 on success. + + STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); + // Cleans up the packing context and frees all memory. + +#define STBTT_POINT_SIZE(x) (-(x)) + + STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, + int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); + // Creates character bitmaps from the font_index'th font found in fontdata (use + // font_index=0 if you don't know what that is). It creates num_chars_in_range + // bitmaps for characters with unicode values starting at first_unicode_char_in_range + // and increasing. Data for how to render them is stored in chardata_for_range; + // pass these to stbtt_GetPackedQuad to get back renderable quads. + // + // font_size is the full height of the character from ascender to descender, + // as computed by stbtt_ScaleForPixelHeight. To use a point size as computed + // by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE() + // and pass that result as 'font_size': + // ..., 20 , ... // font max minus min y is 20 pixels tall + // ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall + + typedef struct + { + float font_size; + int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint + int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints + int num_chars; + stbtt_packedchar *chardata_for_range; // output + unsigned char h_oversample, v_oversample; // don't set these, they're used internally + } stbtt_pack_range; + + STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); + // Creates character bitmaps from multiple ranges of characters stored in + // ranges. This will usually create a better-packed bitmap than multiple + // calls to stbtt_PackFontRange. Note that you can call this multiple + // times within a single PackBegin/PackEnd. + + STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample); + // Oversampling a font increases the quality by allowing higher-quality subpixel + // positioning, and is especially valuable at smaller text sizes. + // + // This function sets the amount of oversampling for all following calls to + // stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given + // pack context. The default (no oversampling) is achieved by h_oversample=1 + // and v_oversample=1. The total number of pixels required is + // h_oversample*v_oversample larger than the default; for example, 2x2 + // oversampling requires 4x the storage of 1x1. For best results, render + // oversampled textures with bilinear filtering. Look at the readme in + // stb/tests/oversample for information about oversampled fonts + // + // To use with PackFontRangesGather etc., you must set it before calls + // call to PackFontRangesGatherRects. + + STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above + int char_index, // character to display + float *xpos, float *ypos, // pointers to current position in screen pixel space + stbtt_aligned_quad *q, // output: quad to draw + int align_to_integer); + + STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); + STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects); + STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); + // Calling these functions in sequence is roughly equivalent to calling + // stbtt_PackFontRanges(). If you more control over the packing of multiple + // fonts, or if you want to pack custom data into a font texture, take a look + // at the source to of stbtt_PackFontRanges() and create a custom version + // using these functions, e.g. call GatherRects multiple times, + // building up a single array of rects, then call PackRects once, + // then call RenderIntoRects repeatedly. This may result in a + // better packing than calling PackFontRanges multiple times + // (or it may not). + + // this is an opaque structure that you shouldn't mess with which holds + // all the context needed from PackBegin to PackEnd. + struct stbtt_pack_context { + void *user_allocator_context; + void *pack_info; + int width; + int height; + int stride_in_bytes; + int padding; + unsigned int h_oversample, v_oversample; + unsigned char *pixels; + void *nodes; + }; + + ////////////////////////////////////////////////////////////////////////////// + // + // FONT LOADING + // + // + + STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data); + // This function will determine the number of fonts in a font file. TrueType + // collection (.ttc) files may contain multiple fonts, while TrueType font + // (.ttf) files only contain one font. The number of fonts can be used for + // indexing with the previous function where the index is between zero and one + // less than the total fonts. If an error occurs, -1 is returned. + + STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); + // Each .ttf/.ttc file may have more than one font. Each font has a sequential + // index number starting from 0. Call this function to get the font offset for + // a given index; it returns -1 if the index is out of range. A regular .ttf + // file will only define one font and it always be at offset 0, so it will + // return '0' for index 0, and -1 for all other indices. + + // The following structure is defined publically so you can declare one on + // the stack or as a global or etc, but you should treat it as opaque. + struct stbtt_fontinfo + { + void * userdata; + unsigned char * data; // pointer to .ttf file + int fontstart; // offset of start of font + + int numGlyphs; // number of glyphs, needed for range checking + + int loca,head,glyf,hhea,hmtx,kern,gpos; // table locations as offset from start of .ttf + int index_map; // a cmap mapping for our chosen character encoding + int indexToLocFormat; // format needed to map from glyph index to glyph + + stbtt__buf cff; // cff font data + stbtt__buf charstrings; // the charstring index + stbtt__buf gsubrs; // global charstring subroutines index + stbtt__buf subrs; // private charstring subroutines index + stbtt__buf fontdicts; // array of font dicts + stbtt__buf fdselect; // map from glyph to fontdict + }; + + STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); + // Given an offset into the file that defines a font, this function builds + // the necessary cached info for the rest of the system. You must allocate + // the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't + // need to do anything special to free it, because the contents are pure + // value data with no additional data structures. Returns 0 on failure. + + + ////////////////////////////////////////////////////////////////////////////// + // + // CHARACTER TO GLYPH-INDEX CONVERSIOn + + STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint); + // If you're going to perform multiple operations on the same character + // and you want a speed-up, call this function with the character you're + // going to process, then use glyph-based functions instead of the + // codepoint-based functions. + + + ////////////////////////////////////////////////////////////////////////////// + // + // CHARACTER PROPERTIES + // + + STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels); + // computes a scale factor to produce a font whose "height" is 'pixels' tall. + // Height is measured as the distance from the highest ascender to the lowest + // descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics + // and computing: + // scale = pixels / (ascent - descent) + // so if you prefer to measure height by the ascent only, use a similar calculation. + + STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels); + // computes a scale factor to produce a font whose EM size is mapped to + // 'pixels' tall. This is probably what traditional APIs compute, but + // I'm not positive. + + STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap); + // ascent is the coordinate above the baseline the font extends; descent + // is the coordinate below the baseline the font extends (i.e. it is typically negative) + // lineGap is the spacing between one row's descent and the next row's ascent... + // so you should advance the vertical position by "*ascent - *descent + *lineGap" + // these are expressed in unscaled coordinates, so you must multiply by + // the scale factor for a given size + + STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap); + // analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2 + // table (specific to MS/Windows TTF files). + // + // Returns 1 on success (table present), 0 on failure. + + STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); + // the bounding box around all possible characters + + STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing); + // leftSideBearing is the offset from the current horizontal position to the left edge of the character + // advanceWidth is the offset from the current horizontal position to the next horizontal position + // these are expressed in unscaled coordinates + + STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); + // an additional amount to add to the 'advance' value between ch1 and ch2 + + STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1); + // Gets the bounding box of the visible part of the glyph, in unscaled coordinates + + STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing); + STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); + STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); + // as above, but takes one or more glyph indices for greater efficiency + + + ////////////////////////////////////////////////////////////////////////////// + // + // GLYPH SHAPES (you probably don't need these, but they have to go before + // the bitmaps for C declaration-order reasons) + // + +#ifndef STBTT_vmove // you can predefine these to use different values (but why?) + enum { + STBTT_vmove=1, + STBTT_vline, + STBTT_vcurve, + STBTT_vcubic + }; +#endif + +#ifndef stbtt_vertex // you can predefine this to use different values + // (we share this with other code at RAD) +#define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file + typedef struct + { + stbtt_vertex_type x,y,cx,cy,cx1,cy1; + unsigned char type,padding; + } stbtt_vertex; +#endif + + STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index); + // returns non-zero if nothing is drawn for this glyph + + STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices); + STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices); + // returns # of vertices and fills *vertices with the pointer to them + // these are expressed in "unscaled" coordinates + // + // The shape is a series of countours. Each one starts with + // a STBTT_moveto, then consists of a series of mixed + // STBTT_lineto and STBTT_curveto segments. A lineto + // draws a line from previous endpoint to its x,y; a curveto + // draws a quadratic bezier from previous endpoint to + // its x,y, using cx,cy as the bezier control point. + + STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices); + // frees the data allocated above + + ////////////////////////////////////////////////////////////////////////////// + // + // BITMAP RENDERING + // + + STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata); + // frees the bitmap allocated below + + STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff); + // allocates a large-enough single-channel 8bpp bitmap and renders the + // specified character/glyph at the specified scale into it, with + // antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). + // *width & *height are filled out with the width & height of the bitmap, + // which is stored left-to-right, top-to-bottom. + // + // xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap + + STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff); + // the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel + // shift for the character + + STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint); + // the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap + // in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap + // is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the + // width and height and positioning info for it first. + + STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint); + // same as stbtt_MakeCodepointBitmap, but you can specify a subpixel + // shift for the character + + STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint); + // same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering + // is performed (see stbtt_PackSetOversampling) + + STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); + // get the bbox of the bitmap centered around the glyph origin; so the + // bitmap width is ix1-ix0, height is iy1-iy0, and location to place + // the bitmap top left is (leftSideBearing*scale,iy0). + // (Note that the bitmap uses y-increases-down, but the shape uses + // y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) + + STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); + // same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel + // shift for the character + + // the following functions are equivalent to the above functions, but operate + // on glyph indices instead of Unicode codepoints (for efficiency) + STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff); + STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); + STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); + STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); + STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph); + STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); + STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); + + + // @TODO: don't expose this structure + typedef struct + { + int w,h,stride; + unsigned char *pixels; + } stbtt__bitmap; + + // rasterize a shape with quadratic beziers into a bitmap + STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap to draw into + float flatness_in_pixels, // allowable error of curve in pixels + stbtt_vertex *vertices, // array of vertices defining shape + int num_verts, // number of vertices in above array + float scale_x, float scale_y, // scale applied to input vertices + float shift_x, float shift_y, // translation applied to input vertices + int x_off, int y_off, // another translation applied to input + int invert, // if non-zero, vertically flip shape + void *userdata); // context for to STBTT_MALLOC + + ////////////////////////////////////////////////////////////////////////////// + // + // Signed Distance Function (or Field) rendering + + STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata); + // frees the SDF bitmap allocated below + + STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); + STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); + // These functions compute a discretized SDF field for a single character, suitable for storing + // in a single-channel texture, sampling with bilinear filtering, and testing against + // larger than some threshhold to produce scalable fonts. + // info -- the font + // scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap + // glyph/codepoint -- the character to generate the SDF for + // padding -- extra "pixels" around the character which are filled with the distance to the character (not 0), + // which allows effects like bit outlines + // onedge_value -- value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character) + // pixel_dist_scale -- what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale) + // if positive, > onedge_value is inside; if negative, < onedge_value is inside + // width,height -- output height & width of the SDF bitmap (including padding) + // xoff,yoff -- output origin of the character + // return value -- a 2D array of bytes 0..255, width*height in size + // + // pixel_dist_scale & onedge_value are a scale & bias that allows you to make + // optimal use of the limited 0..255 for your application, trading off precision + // and special effects. SDF values outside the range 0..255 are clamped to 0..255. + // + // Example: + // scale = stbtt_ScaleForPixelHeight(22) + // padding = 5 + // onedge_value = 180 + // pixel_dist_scale = 180/5.0 = 36.0 + // + // This will create an SDF bitmap in which the character is about 22 pixels + // high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled + // shape, sample the SDF at each pixel and fill the pixel if the SDF value + // is greater than or equal to 180/255. (You'll actually want to antialias, + // which is beyond the scope of this example.) Additionally, you can compute + // offset outlines (e.g. to stroke the character border inside & outside, + // or only outside). For example, to fill outside the character up to 3 SDF + // pixels, you would compare against (180-36.0*3)/255 = 72/255. The above + // choice of variables maps a range from 5 pixels outside the shape to + // 2 pixels inside the shape to 0..255; this is intended primarily for apply + // outside effects only (the interior range is needed to allow proper + // antialiasing of the font at *smaller* sizes) + // + // The function computes the SDF analytically at each SDF pixel, not by e.g. + // building a higher-res bitmap and approximating it. In theory the quality + // should be as high as possible for an SDF of this size & representation, but + // unclear if this is true in practice (perhaps building a higher-res bitmap + // and computing from that can allow drop-out prevention). + // + // The algorithm has not been optimized at all, so expect it to be slow + // if computing lots of characters or very large sizes. + + + + ////////////////////////////////////////////////////////////////////////////// + // + // Finding the right font... + // + // You should really just solve this offline, keep your own tables + // of what font is what, and don't try to get it out of the .ttf file. + // That's because getting it out of the .ttf file is really hard, because + // the names in the file can appear in many possible encodings, in many + // possible languages, and e.g. if you need a case-insensitive comparison, + // the details of that depend on the encoding & language in a complex way + // (actually underspecified in truetype, but also gigantic). + // + // But you can use the provided functions in two possible ways: + // stbtt_FindMatchingFont() will use *case-sensitive* comparisons on + // unicode-encoded names to try to find the font you want; + // you can run this before calling stbtt_InitFont() + // + // stbtt_GetFontNameString() lets you get any of the various strings + // from the file yourself and do your own comparisons on them. + // You have to have called stbtt_InitFont() first. + + + STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags); + // returns the offset (not index) of the font that matches, or -1 if none + // if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold". + // if you use any other flag, use a font name like "Arial"; this checks + // the 'macStyle' header field; i don't know if fonts set this consistently +#define STBTT_MACSTYLE_DONTCARE 0 +#define STBTT_MACSTYLE_BOLD 1 +#define STBTT_MACSTYLE_ITALIC 2 +#define STBTT_MACSTYLE_UNDERSCORE 4 +#define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0 + + STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2); + // returns 1/0 whether the first string interpreted as utf8 is identical to + // the second string interpreted as big-endian utf16... useful for strings from next func + + STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID); + // returns the string (which may be big-endian double byte, e.g. for unicode) + // and puts the length in bytes in *length. + // + // some of the values for the IDs are below; for more see the truetype spec: + // http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html + // http://www.microsoft.com/typography/otspec/name.htm + + enum { // platformID + STBTT_PLATFORM_ID_UNICODE =0, + STBTT_PLATFORM_ID_MAC =1, + STBTT_PLATFORM_ID_ISO =2, + STBTT_PLATFORM_ID_MICROSOFT =3 + }; + + enum { // encodingID for STBTT_PLATFORM_ID_UNICODE + STBTT_UNICODE_EID_UNICODE_1_0 =0, + STBTT_UNICODE_EID_UNICODE_1_1 =1, + STBTT_UNICODE_EID_ISO_10646 =2, + STBTT_UNICODE_EID_UNICODE_2_0_BMP=3, + STBTT_UNICODE_EID_UNICODE_2_0_FULL=4 + }; + + enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT + STBTT_MS_EID_SYMBOL =0, + STBTT_MS_EID_UNICODE_BMP =1, + STBTT_MS_EID_SHIFTJIS =2, + STBTT_MS_EID_UNICODE_FULL =10 + }; + + enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes + STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4, + STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5, + STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6, + STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7 + }; + + enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID... + // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs + STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410, + STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411, + STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412, + STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419, + STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409, + STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D + }; + + enum { // languageID for STBTT_PLATFORM_ID_MAC + STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11, + STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23, + STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32, + STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 , + STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 , + STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33, + STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19 + }; + +#ifdef __cplusplus +} +#endif + +#endif // __STB_INCLUDE_STB_TRUETYPE_H__ + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +//// +//// IMPLEMENTATION +//// +//// + +#ifdef STB_TRUETYPE_IMPLEMENTATION + +#ifndef STBTT_MAX_OVERSAMPLE +#define STBTT_MAX_OVERSAMPLE 8 +#endif + +#if STBTT_MAX_OVERSAMPLE > 255 +#error "STBTT_MAX_OVERSAMPLE cannot be > 255" +#endif + +typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1]; + +#ifndef STBTT_RASTERIZER_VERSION +#define STBTT_RASTERIZER_VERSION 2 +#endif + +#ifdef _MSC_VER +#define STBTT__NOTUSED(v) (void)(v) +#else +#define STBTT__NOTUSED(v) (void)sizeof(v) +#endif + +////////////////////////////////////////////////////////////////////////// +// +// stbtt__buf helpers to parse data from file +// + +static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b) +{ + if (b->cursor >= b->size) + return 0; + return b->data[b->cursor++]; +} + +static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) +{ + if (b->cursor >= b->size) + return 0; + return b->data[b->cursor]; +} + +static void stbtt__buf_seek(stbtt__buf *b, int o) +{ + STBTT_assert(!(o > b->size || o < 0)); + b->cursor = (o > b->size || o < 0) ? b->size : o; +} + +static void stbtt__buf_skip(stbtt__buf *b, int o) +{ + stbtt__buf_seek(b, b->cursor + o); +} + +static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) +{ + stbtt_uint32 v = 0; + int i; + STBTT_assert(n >= 1 && n <= 4); + for (i = 0; i < n; i++) + v = (v << 8) | stbtt__buf_get8(b); + return v; +} + +static stbtt__buf stbtt__new_buf(const void *p, size_t size) +{ + stbtt__buf r; + STBTT_assert(size < 0x40000000); + r.data = (stbtt_uint8*) p; + r.size = (int) size; + r.cursor = 0; + return r; +} + +#define stbtt__buf_get16(b) stbtt__buf_get((b), 2) +#define stbtt__buf_get32(b) stbtt__buf_get((b), 4) + +static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s) +{ + stbtt__buf r = stbtt__new_buf(NULL, 0); + if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r; + r.data = b->data + o; + r.size = s; + return r; +} + +static stbtt__buf stbtt__cff_get_index(stbtt__buf *b) +{ + int count, start, offsize; + start = b->cursor; + count = stbtt__buf_get16(b); + if (count) { + offsize = stbtt__buf_get8(b); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(b, offsize * count); + stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); + } + return stbtt__buf_range(b, start, b->cursor - start); +} + +static stbtt_uint32 stbtt__cff_int(stbtt__buf *b) +{ + int b0 = stbtt__buf_get8(b); + if (b0 >= 32 && b0 <= 246) return b0 - 139; + else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108; + else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108; + else if (b0 == 28) return stbtt__buf_get16(b); + else if (b0 == 29) return stbtt__buf_get32(b); + STBTT_assert(0); + return 0; +} + +static void stbtt__cff_skip_operand(stbtt__buf *b) { + int v, b0 = stbtt__buf_peek8(b); + STBTT_assert(b0 >= 28); + if (b0 == 30) { + stbtt__buf_skip(b, 1); + while (b->cursor < b->size) { + v = stbtt__buf_get8(b); + if ((v & 0xF) == 0xF || (v >> 4) == 0xF) + break; + } + } else { + stbtt__cff_int(b); + } +} + +static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) +{ + stbtt__buf_seek(b, 0); + while (b->cursor < b->size) { + int start = b->cursor, end, op; + while (stbtt__buf_peek8(b) >= 28) + stbtt__cff_skip_operand(b); + end = b->cursor; + op = stbtt__buf_get8(b); + if (op == 12) op = stbtt__buf_get8(b) | 0x100; + if (op == key) return stbtt__buf_range(b, start, end-start); + } + return stbtt__buf_range(b, 0, 0); +} + +static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out) +{ + int i; + stbtt__buf operands = stbtt__dict_get(b, key); + for (i = 0; i < outcount && operands.cursor < operands.size; i++) + out[i] = stbtt__cff_int(&operands); +} + +static int stbtt__cff_index_count(stbtt__buf *b) +{ + stbtt__buf_seek(b, 0); + return stbtt__buf_get16(b); +} + +static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i) +{ + int count, offsize, start, end; + stbtt__buf_seek(&b, 0); + count = stbtt__buf_get16(&b); + offsize = stbtt__buf_get8(&b); + STBTT_assert(i >= 0 && i < count); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(&b, i*offsize); + start = stbtt__buf_get(&b, offsize); + end = stbtt__buf_get(&b, offsize); + return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start); +} + +////////////////////////////////////////////////////////////////////////// +// +// accessors to parse data from file +// + +// on platforms that don't allow misaligned reads, if we want to allow +// truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE + +#define ttBYTE(p) (* (stbtt_uint8 *) (p)) +#define ttCHAR(p) (* (stbtt_int8 *) (p)) +#define ttFixed(p) ttLONG(p) + +static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } +static stbtt_int16 ttSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } +static stbtt_uint32 ttULONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } +static stbtt_int32 ttLONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } + +#define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) +#define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3]) + +static int stbtt__isfont(stbtt_uint8 *font) +{ + // check the version number + if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1 + if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this! + if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF + if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0 + if (stbtt_tag(font, "true")) return 1; // Apple specification for TrueType fonts + return 0; +} + +// @OPTIMIZE: binary search +static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag) +{ + stbtt_int32 num_tables = ttUSHORT(data+fontstart+4); + stbtt_uint32 tabledir = fontstart + 12; + stbtt_int32 i; + for (i=0; i < num_tables; ++i) { + stbtt_uint32 loc = tabledir + 16*i; + if (stbtt_tag(data+loc+0, tag)) + return ttULONG(data+loc+8); + } + return 0; +} + +static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index) +{ + // if it's just a font, there's only one valid index + if (stbtt__isfont(font_collection)) + return index == 0 ? 0 : -1; + + // check if it's a TTC + if (stbtt_tag(font_collection, "ttcf")) { + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + stbtt_int32 n = ttLONG(font_collection+8); + if (index >= n) + return -1; + return ttULONG(font_collection+12+index*4); + } + } + return -1; +} + +static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection) +{ + // if it's just a font, there's only one valid font + if (stbtt__isfont(font_collection)) + return 1; + + // check if it's a TTC + if (stbtt_tag(font_collection, "ttcf")) { + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + return ttLONG(font_collection+8); + } + } + return 0; +} + +static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict) +{ + stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 }; + stbtt__buf pdict; + stbtt__dict_get_ints(&fontdict, 18, 2, private_loc); + if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0); + pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]); + stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff); + if (!subrsoff) return stbtt__new_buf(NULL, 0); + stbtt__buf_seek(&cff, private_loc[1]+subrsoff); + return stbtt__cff_get_index(&cff); +} + +static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) +{ + stbtt_uint32 cmap, t; + stbtt_int32 i,numTables; + + info->data = data; + info->fontstart = fontstart; + info->cff = stbtt__new_buf(NULL, 0); + + cmap = stbtt__find_table(data, fontstart, "cmap"); // required + info->loca = stbtt__find_table(data, fontstart, "loca"); // required + info->head = stbtt__find_table(data, fontstart, "head"); // required + info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required + info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required + info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required + info->kern = stbtt__find_table(data, fontstart, "kern"); // not required + info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required + + if (!cmap || !info->head || !info->hhea || !info->hmtx) + return 0; + if (info->glyf) { + // required for truetype + if (!info->loca) return 0; + } else { + // initialization for CFF / Type2 fonts (OTF) + stbtt__buf b, topdict, topdictidx; + stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; + stbtt_uint32 cff; + + cff = stbtt__find_table(data, fontstart, "CFF "); + if (!cff) return 0; + + info->fontdicts = stbtt__new_buf(NULL, 0); + info->fdselect = stbtt__new_buf(NULL, 0); + + // @TODO this should use size from table (not 512MB) + info->cff = stbtt__new_buf(data+cff, 512*1024*1024); + b = info->cff; + + // read the header + stbtt__buf_skip(&b, 2); + stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize + + // @TODO the name INDEX could list multiple fonts, + // but we just use the first one. + stbtt__cff_get_index(&b); // name INDEX + topdictidx = stbtt__cff_get_index(&b); + topdict = stbtt__cff_index_get(topdictidx, 0); + stbtt__cff_get_index(&b); // string INDEX + info->gsubrs = stbtt__cff_get_index(&b); + + stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); + stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); + stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); + stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); + info->subrs = stbtt__get_subrs(b, topdict); + + // we only support Type 2 charstrings + if (cstype != 2) return 0; + if (charstrings == 0) return 0; + + if (fdarrayoff) { + // looks like a CID font + if (!fdselectoff) return 0; + stbtt__buf_seek(&b, fdarrayoff); + info->fontdicts = stbtt__cff_get_index(&b); + info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); + } + + stbtt__buf_seek(&b, charstrings); + info->charstrings = stbtt__cff_get_index(&b); + } + + t = stbtt__find_table(data, fontstart, "maxp"); + if (t) + info->numGlyphs = ttUSHORT(data+t+4); + else + info->numGlyphs = 0xffff; + + // find a cmap encoding table we understand *now* to avoid searching + // later. (todo: could make this installable) + // the same regardless of glyph. + numTables = ttUSHORT(data + cmap + 2); + info->index_map = 0; + for (i=0; i < numTables; ++i) { + stbtt_uint32 encoding_record = cmap + 4 + 8 * i; + // find an encoding we understand: + switch(ttUSHORT(data+encoding_record)) { + case STBTT_PLATFORM_ID_MICROSOFT: + switch (ttUSHORT(data+encoding_record+2)) { + case STBTT_MS_EID_UNICODE_BMP: + case STBTT_MS_EID_UNICODE_FULL: + // MS/Unicode + info->index_map = cmap + ttULONG(data+encoding_record+4); + break; + } + break; + case STBTT_PLATFORM_ID_UNICODE: + // Mac/iOS has these + // all the encodingIDs are unicode, so we don't bother to check it + info->index_map = cmap + ttULONG(data+encoding_record+4); + break; + } + } + if (info->index_map == 0) + return 0; + + info->indexToLocFormat = ttUSHORT(data+info->head + 50); + return 1; +} + +STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) +{ + stbtt_uint8 *data = info->data; + stbtt_uint32 index_map = info->index_map; + + stbtt_uint16 format = ttUSHORT(data + index_map + 0); + if (format == 0) { // apple byte encoding + stbtt_int32 bytes = ttUSHORT(data + index_map + 2); + if (unicode_codepoint < bytes-6) + return ttBYTE(data + index_map + 6 + unicode_codepoint); + return 0; + } else if (format == 6) { + stbtt_uint32 first = ttUSHORT(data + index_map + 6); + stbtt_uint32 count = ttUSHORT(data + index_map + 8); + if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) + return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); + return 0; + } else if (format == 2) { + STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean + return 0; + } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges + stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; + stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; + stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); + stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; + + // do a binary search of the segments + stbtt_uint32 endCount = index_map + 14; + stbtt_uint32 search = endCount; + + if (unicode_codepoint > 0xffff) + return 0; + + // they lie from endCount .. endCount + segCount + // but searchRange is the nearest power of two, so... + if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) + search += rangeShift*2; + + // now decrement to bias correctly to find smallest + search -= 2; + while (entrySelector) { + stbtt_uint16 end; + searchRange >>= 1; + end = ttUSHORT(data + search + searchRange*2); + if (unicode_codepoint > end) + search += searchRange*2; + --entrySelector; + } + search += 2; + + { + stbtt_uint16 offset, start; + stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); + + STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item)); + start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); + if (unicode_codepoint < start) + return 0; + + offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); + if (offset == 0) + return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); + + return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); + } + } else if (format == 12 || format == 13) { + stbtt_uint32 ngroups = ttULONG(data+index_map+12); + stbtt_int32 low,high; + low = 0; high = (stbtt_int32)ngroups; + // Binary search the right group. + while (low < high) { + stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high + stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); + stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); + if ((stbtt_uint32) unicode_codepoint < start_char) + high = mid; + else if ((stbtt_uint32) unicode_codepoint > end_char) + low = mid+1; + else { + stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); + if (format == 12) + return start_glyph + unicode_codepoint-start_char; + else // format == 13 + return start_glyph; + } + } + return 0; // not found + } + // @TODO + STBTT_assert(0); + return 0; +} + +STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) +{ + return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices); +} + +static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy) +{ + v->type = type; + v->x = (stbtt_int16) x; + v->y = (stbtt_int16) y; + v->cx = (stbtt_int16) cx; + v->cy = (stbtt_int16) cy; +} + +static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) +{ + int g1,g2; + + STBTT_assert(!info->cff.size); + + if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range + if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format + + if (info->indexToLocFormat == 0) { + g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; + g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; + } else { + g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); + g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); + } + + return g1==g2 ? -1 : g1; // if length is 0, return -1 +} + +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); + +STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +{ + if (info->cff.size) { + stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); + } else { + int g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 0; + + if (x0) *x0 = ttSHORT(info->data + g + 2); + if (y0) *y0 = ttSHORT(info->data + g + 4); + if (x1) *x1 = ttSHORT(info->data + g + 6); + if (y1) *y1 = ttSHORT(info->data + g + 8); + } + return 1; +} + +STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1) +{ + return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1); +} + +STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) +{ + stbtt_int16 numberOfContours; + int g; + if (info->cff.size) + return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; + g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 1; + numberOfContours = ttSHORT(info->data + g); + return numberOfContours == 0; +} + +static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, + stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) +{ + if (start_off) { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); + } else { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); + else + stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); + } + return num_vertices; +} + +static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + stbtt_int16 numberOfContours; + stbtt_uint8 *endPtsOfContours; + stbtt_uint8 *data = info->data; + stbtt_vertex *vertices=0; + int num_vertices=0; + int g = stbtt__GetGlyfOffset(info, glyph_index); + + *pvertices = NULL; + + if (g < 0) return 0; + + numberOfContours = ttSHORT(data + g); + + if (numberOfContours > 0) { + stbtt_uint8 flags=0,flagcount; + stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; + stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; + stbtt_uint8 *points; + endPtsOfContours = (data + g + 10); + ins = ttUSHORT(data + g + 10 + numberOfContours * 2); + points = data + g + 10 + numberOfContours * 2 + 2 + ins; + + n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); + + m = n + 2*numberOfContours; // a loose bound on how many vertices we might need + vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); + if (vertices == 0) + return 0; + + next_move = 0; + flagcount=0; + + // in first pass, we load uninterpreted data into the allocated array + // above, shifted to the end of the array so we won't overwrite it when + // we create our final data starting from the front + + off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated + + // first load flags + + for (i=0; i < n; ++i) { + if (flagcount == 0) { + flags = *points++; + if (flags & 8) + flagcount = *points++; + } else + --flagcount; + vertices[off+i].type = flags; + } + + // now load x coordinates + x=0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + if (flags & 2) { + stbtt_int16 dx = *points++; + x += (flags & 16) ? dx : -dx; // ??? + } else { + if (!(flags & 16)) { + x = x + (stbtt_int16) (points[0]*256 + points[1]); + points += 2; + } + } + vertices[off+i].x = (stbtt_int16) x; + } + + // now load y coordinates + y=0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + if (flags & 4) { + stbtt_int16 dy = *points++; + y += (flags & 32) ? dy : -dy; // ??? + } else { + if (!(flags & 32)) { + y = y + (stbtt_int16) (points[0]*256 + points[1]); + points += 2; + } + } + vertices[off+i].y = (stbtt_int16) y; + } + + // now convert them to our format + num_vertices=0; + sx = sy = cx = cy = scx = scy = 0; + for (i=0; i < n; ++i) { + flags = vertices[off+i].type; + x = (stbtt_int16) vertices[off+i].x; + y = (stbtt_int16) vertices[off+i].y; + + if (next_move == i) { + if (i != 0) + num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); + + // now start the new one + start_off = !(flags & 1); + if (start_off) { + // if we start off with an off-curve point, then when we need to find a point on the curve + // where we can start, and we need to save some state for when we wraparound. + scx = x; + scy = y; + if (!(vertices[off+i+1].type & 1)) { + // next point is also a curve point, so interpolate an on-point curve + sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; + sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; + } else { + // otherwise just use the next point as our start point + sx = (stbtt_int32) vertices[off+i+1].x; + sy = (stbtt_int32) vertices[off+i+1].y; + ++i; // we're using point i+1 as the starting point, so skip it + } + } else { + sx = x; + sy = y; + } + stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); + was_off = 0; + next_move = 1 + ttUSHORT(endPtsOfContours+j*2); + ++j; + } else { + if (!(flags & 1)) { // if it's a curve + if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); + cx = x; + cy = y; + was_off = 1; + } else { + if (was_off) + stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); + else + stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); + was_off = 0; + } + } + } + num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); + } else if (numberOfContours == -1) { + // Compound shapes. + int more = 1; + stbtt_uint8 *comp = data + g + 10; + num_vertices = 0; + vertices = 0; + while (more) { + stbtt_uint16 flags, gidx; + int comp_num_verts = 0, i; + stbtt_vertex *comp_verts = 0, *tmp = 0; + float mtx[6] = {1,0,0,1,0,0}, m, n; + + flags = ttSHORT(comp); comp+=2; + gidx = ttSHORT(comp); comp+=2; + + if (flags & 2) { // XY values + if (flags & 1) { // shorts + mtx[4] = ttSHORT(comp); comp+=2; + mtx[5] = ttSHORT(comp); comp+=2; + } else { + mtx[4] = ttCHAR(comp); comp+=1; + mtx[5] = ttCHAR(comp); comp+=1; + } + } + else { + // @TODO handle matching point + STBTT_assert(0); + } + if (flags & (1<<3)) { // WE_HAVE_A_SCALE + mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = mtx[2] = 0; + } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE + mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = mtx[2] = 0; + mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO + mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; + mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; + } + + // Find transformation scales. + m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); + n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); + + // Get indexed glyph. + comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); + if (comp_num_verts > 0) { + // Transform vertices. + for (i = 0; i < comp_num_verts; ++i) { + stbtt_vertex* v = &comp_verts[i]; + stbtt_vertex_type x,y; + x=v->x; y=v->y; + v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); + v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); + x=v->cx; y=v->cy; + v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); + v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); + } + // Append vertices. + tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); + if (!tmp) { + if (vertices) STBTT_free(vertices, info->userdata); + if (comp_verts) STBTT_free(comp_verts, info->userdata); + return 0; + } + if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); + STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); + if (vertices) STBTT_free(vertices, info->userdata); + vertices = tmp; + STBTT_free(comp_verts, info->userdata); + num_vertices += comp_num_verts; + } + // More components ? + more = flags & (1<<5); + } + } else if (numberOfContours < 0) { + // @TODO other compound variations? + STBTT_assert(0); + } else { + // numberOfCounters == 0, do nothing + } + + *pvertices = vertices; + return num_vertices; +} + +typedef struct +{ + int bounds; + int started; + float first_x, first_y; + float x, y; + stbtt_int32 min_x, max_x, min_y, max_y; + + stbtt_vertex *pvertices; + int num_vertices; +} stbtt__csctx; + +#define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0} + +static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) +{ + if (x > c->max_x || !c->started) c->max_x = x; + if (y > c->max_y || !c->started) c->max_y = y; + if (x < c->min_x || !c->started) c->min_x = x; + if (y < c->min_y || !c->started) c->min_y = y; + c->started = 1; +} + +static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) +{ + if (c->bounds) { + stbtt__track_vertex(c, x, y); + if (type == STBTT_vcubic) { + stbtt__track_vertex(c, cx, cy); + stbtt__track_vertex(c, cx1, cy1); + } + } else { + stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); + c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; + c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; + } + c->num_vertices++; +} + +static void stbtt__csctx_close_shape(stbtt__csctx *ctx) +{ + if (ctx->first_x != ctx->x || ctx->first_y != ctx->y) + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) +{ + stbtt__csctx_close_shape(ctx); + ctx->first_x = ctx->x = ctx->x + dx; + ctx->first_y = ctx->y = ctx->y + dy; + stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy) +{ + ctx->x += dx; + ctx->y += dy; + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) +{ + float cx1 = ctx->x + dx1; + float cy1 = ctx->y + dy1; + float cx2 = cx1 + dx2; + float cy2 = cy1 + dy2; + ctx->x = cx2 + dx3; + ctx->y = cy2 + dy3; + stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2); +} + +static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) +{ + int count = stbtt__cff_index_count(&idx); + int bias = 107; + if (count >= 33900) + bias = 32768; + else if (count >= 1240) + bias = 1131; + n += bias; + if (n < 0 || n >= count) + return stbtt__new_buf(NULL, 0); + return stbtt__cff_index_get(idx, n); +} + +static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index) +{ + stbtt__buf fdselect = info->fdselect; + int nranges, start, end, v, fmt, fdselector = -1, i; + + stbtt__buf_seek(&fdselect, 0); + fmt = stbtt__buf_get8(&fdselect); + if (fmt == 0) { + // untested + stbtt__buf_skip(&fdselect, glyph_index); + fdselector = stbtt__buf_get8(&fdselect); + } else if (fmt == 3) { + nranges = stbtt__buf_get16(&fdselect); + start = stbtt__buf_get16(&fdselect); + for (i = 0; i < nranges; i++) { + v = stbtt__buf_get8(&fdselect); + end = stbtt__buf_get16(&fdselect); + if (glyph_index >= start && glyph_index < end) { + fdselector = v; + break; + } + start = end; + } + } + if (fdselector == -1) stbtt__new_buf(NULL, 0); + return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector)); +} + +static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c) +{ + int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0; + int has_subrs = 0, clear_stack; + float s[48]; + stbtt__buf subr_stack[10], subrs = info->subrs, b; + float f; + +#define STBTT__CSERR(s) (0) + + // this currently ignores the initial width value, which isn't needed if we have hmtx + b = stbtt__cff_index_get(info->charstrings, glyph_index); + while (b.cursor < b.size) { + i = 0; + clear_stack = 1; + b0 = stbtt__buf_get8(&b); + switch (b0) { + // @TODO implement hinting + case 0x13: // hintmask + case 0x14: // cntrmask + if (in_header) + maskbits += (sp / 2); // implicit "vstem" + in_header = 0; + stbtt__buf_skip(&b, (maskbits + 7) / 8); + break; + + case 0x01: // hstem + case 0x03: // vstem + case 0x12: // hstemhm + case 0x17: // vstemhm + maskbits += (sp / 2); + break; + + case 0x15: // rmoveto + in_header = 0; + if (sp < 2) return STBTT__CSERR("rmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); + break; + case 0x04: // vmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("vmoveto stack"); + stbtt__csctx_rmove_to(c, 0, s[sp-1]); + break; + case 0x16: // hmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("hmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-1], 0); + break; + + case 0x05: // rlineto + if (sp < 2) return STBTT__CSERR("rlineto stack"); + for (; i + 1 < sp; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical + // starting from a different place. + + case 0x07: // vlineto + if (sp < 1) return STBTT__CSERR("vlineto stack"); + goto vlineto; + case 0x06: // hlineto + if (sp < 1) return STBTT__CSERR("hlineto stack"); + for (;;) { + if (i >= sp) break; + stbtt__csctx_rline_to(c, s[i], 0); + i++; + vlineto: + if (i >= sp) break; + stbtt__csctx_rline_to(c, 0, s[i]); + i++; + } + break; + + case 0x1F: // hvcurveto + if (sp < 4) return STBTT__CSERR("hvcurveto stack"); + goto hvcurveto; + case 0x1E: // vhcurveto + if (sp < 4) return STBTT__CSERR("vhcurveto stack"); + for (;;) { + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); + i += 4; + hvcurveto: + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); + i += 4; + } + break; + + case 0x08: // rrcurveto + if (sp < 6) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x18: // rcurveline + if (sp < 8) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp - 2; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + case 0x19: // rlinecurve + if (sp < 8) return STBTT__CSERR("rlinecurve stack"); + for (; i + 1 < sp - 6; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x1A: // vvcurveto + case 0x1B: // hhcurveto + if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); + f = 0.0; + if (sp & 1) { f = s[i]; i++; } + for (; i + 3 < sp; i += 4) { + if (b0 == 0x1B) + stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); + else + stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); + f = 0.0; + } + break; + + case 0x0A: // callsubr + if (!has_subrs) { + if (info->fdselect.size) + subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); + has_subrs = 1; + } + // fallthrough + case 0x1D: // callgsubr + if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); + v = (int) s[--sp]; + if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); + subr_stack[subr_stack_height++] = b; + b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); + if (b.size == 0) return STBTT__CSERR("subr not found"); + b.cursor = 0; + clear_stack = 0; + break; + + case 0x0B: // return + if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); + b = subr_stack[--subr_stack_height]; + clear_stack = 0; + break; + + case 0x0E: // endchar + stbtt__csctx_close_shape(c); + return 1; + + case 0x0C: { // two-byte escape + float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; + float dx, dy; + int b1 = stbtt__buf_get8(&b); + switch (b1) { + // @TODO These "flex" implementations ignore the flex-depth and resolution, + // and always draw beziers. + case 0x22: // hflex + if (sp < 7) return STBTT__CSERR("hflex stack"); + dx1 = s[0]; + dx2 = s[1]; + dy2 = s[2]; + dx3 = s[3]; + dx4 = s[4]; + dx5 = s[5]; + dx6 = s[6]; + stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); + break; + + case 0x23: // flex + if (sp < 13) return STBTT__CSERR("flex stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = s[10]; + dy6 = s[11]; + //fd is s[12] + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + case 0x24: // hflex1 + if (sp < 9) return STBTT__CSERR("hflex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dx4 = s[5]; + dx5 = s[6]; + dy5 = s[7]; + dx6 = s[8]; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); + break; + + case 0x25: // flex1 + if (sp < 11) return STBTT__CSERR("flex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = dy6 = s[10]; + dx = dx1+dx2+dx3+dx4+dx5; + dy = dy1+dy2+dy3+dy4+dy5; + if (STBTT_fabs(dx) > STBTT_fabs(dy)) + dy6 = -dy; + else + dx6 = -dx; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + default: + return STBTT__CSERR("unimplemented"); + } + } break; + + default: + if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) + return STBTT__CSERR("reserved operator"); + + // push immediate + if (b0 == 255) { + f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000; + } else { + stbtt__buf_skip(&b, -1); + f = (float)(stbtt_int16)stbtt__cff_int(&b); + } + if (sp >= 48) return STBTT__CSERR("push stack overflow"); + s[sp++] = f; + clear_stack = 0; + break; + } + if (clear_stack) sp = 0; + } + return STBTT__CSERR("no endchar"); + +#undef STBTT__CSERR +} + +static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + // runs the charstring twice, once to count and once to output (to avoid realloc) + stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); + stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0); + if (stbtt__run_charstring(info, glyph_index, &count_ctx)) { + *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); + output_ctx.pvertices = *pvertices; + if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { + STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); + return output_ctx.num_vertices; + } + } + *pvertices = NULL; + return 0; +} + +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +{ + stbtt__csctx c = STBTT__CSCTX_INIT(1); + int r = stbtt__run_charstring(info, glyph_index, &c); + if (x0) *x0 = r ? c.min_x : 0; + if (y0) *y0 = r ? c.min_y : 0; + if (x1) *x1 = r ? c.max_x : 0; + if (y1) *y1 = r ? c.max_y : 0; + return r ? c.num_vertices : 0; +} + +STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + if (!info->cff.size) + return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); + else + return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); +} + +STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) +{ + stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); + if (glyph_index < numOfLongHorMetrics) { + if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); + if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); + } else { + if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); + if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); + } +} + +static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) +{ + stbtt_uint8 *data = info->data + info->kern; + stbtt_uint32 needle, straw; + int l, r, m; + + // we only look at the first table. it must be 'horizontal' and format 0. + if (!info->kern) + return 0; + if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 + return 0; + if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format + return 0; + + l = 0; + r = ttUSHORT(data+10) - 1; + needle = glyph1 << 16 | glyph2; + while (l <= r) { + m = (l + r) >> 1; + straw = ttULONG(data+18+(m*6)); // note: unaligned read + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else + return ttSHORT(data+22+(m*6)); + } + return 0; +} + +static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph) +{ + stbtt_uint16 coverageFormat = ttUSHORT(coverageTable); + switch(coverageFormat) { + case 1: { + stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2); + + // Binary search. + stbtt_int32 l=0, r=glyphCount-1, m; + int straw, needle=glyph; + while (l <= r) { + stbtt_uint8 *glyphArray = coverageTable + 4; + stbtt_uint16 glyphID; + m = (l + r) >> 1; + glyphID = ttUSHORT(glyphArray + 2 * m); + straw = glyphID; + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else { + return m; + } + } + } break; + + case 2: { + stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2); + stbtt_uint8 *rangeArray = coverageTable + 4; + + // Binary search. + stbtt_int32 l=0, r=rangeCount-1, m; + int strawStart, strawEnd, needle=glyph; + while (l <= r) { + stbtt_uint8 *rangeRecord; + m = (l + r) >> 1; + rangeRecord = rangeArray + 6 * m; + strawStart = ttUSHORT(rangeRecord); + strawEnd = ttUSHORT(rangeRecord + 2); + if (needle < strawStart) + r = m - 1; + else if (needle > strawEnd) + l = m + 1; + else { + stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4); + return startCoverageIndex + glyph - strawStart; + } + } + } break; + + default: { + // There are no other cases. + STBTT_assert(0); + } break; + } + + return -1; +} + +static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph) +{ + stbtt_uint16 classDefFormat = ttUSHORT(classDefTable); + switch(classDefFormat) + { + case 1: { + stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2); + stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4); + stbtt_uint8 *classDef1ValueArray = classDefTable + 6; + + if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount) + return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID)); + + classDefTable = classDef1ValueArray + 2 * glyphCount; + } break; + + case 2: { + stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2); + stbtt_uint8 *classRangeRecords = classDefTable + 4; + + // Binary search. + stbtt_int32 l=0, r=classRangeCount-1, m; + int strawStart, strawEnd, needle=glyph; + while (l <= r) { + stbtt_uint8 *classRangeRecord; + m = (l + r) >> 1; + classRangeRecord = classRangeRecords + 6 * m; + strawStart = ttUSHORT(classRangeRecord); + strawEnd = ttUSHORT(classRangeRecord + 2); + if (needle < strawStart) + r = m - 1; + else if (needle > strawEnd) + l = m + 1; + else + return (stbtt_int32)ttUSHORT(classRangeRecord + 4); + } + + classDefTable = classRangeRecords + 6 * classRangeCount; + } break; + + default: { + // There are no other cases. + STBTT_assert(0); + } break; + } + + return -1; +} + +// Define to STBTT_assert(x) if you want to break on unimplemented formats. +#define STBTT_GPOS_TODO_assert(x) + +static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) +{ + stbtt_uint16 lookupListOffset; + stbtt_uint8 *lookupList; + stbtt_uint16 lookupCount; + stbtt_uint8 *data; + stbtt_int32 i; + + if (!info->gpos) return 0; + + data = info->data + info->gpos; + + if (ttUSHORT(data+0) != 1) return 0; // Major version 1 + if (ttUSHORT(data+2) != 0) return 0; // Minor version 0 + + lookupListOffset = ttUSHORT(data+8); + lookupList = data + lookupListOffset; + lookupCount = ttUSHORT(lookupList); + + for (i=0; i<lookupCount; ++i) { + stbtt_uint16 lookupOffset = ttUSHORT(lookupList + 2 + 2 * i); + stbtt_uint8 *lookupTable = lookupList + lookupOffset; + + stbtt_uint16 lookupType = ttUSHORT(lookupTable); + stbtt_uint16 subTableCount = ttUSHORT(lookupTable + 4); + stbtt_uint8 *subTableOffsets = lookupTable + 6; + switch(lookupType) { + case 2: { // Pair Adjustment Positioning Subtable + stbtt_int32 sti; + for (sti=0; sti<subTableCount; sti++) { + stbtt_uint16 subtableOffset = ttUSHORT(subTableOffsets + 2 * sti); + stbtt_uint8 *table = lookupTable + subtableOffset; + stbtt_uint16 posFormat = ttUSHORT(table); + stbtt_uint16 coverageOffset = ttUSHORT(table + 2); + stbtt_int32 coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1); + if (coverageIndex == -1) continue; + + switch (posFormat) { + case 1: { + stbtt_int32 l, r, m; + int straw, needle; + stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); + stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); + stbtt_int32 valueRecordPairSizeInBytes = 2; + stbtt_uint16 pairSetCount = ttUSHORT(table + 8); + stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex); + stbtt_uint8 *pairValueTable = table + pairPosOffset; + stbtt_uint16 pairValueCount = ttUSHORT(pairValueTable); + stbtt_uint8 *pairValueArray = pairValueTable + 2; + // TODO: Support more formats. + STBTT_GPOS_TODO_assert(valueFormat1 == 4); + if (valueFormat1 != 4) return 0; + STBTT_GPOS_TODO_assert(valueFormat2 == 0); + if (valueFormat2 != 0) return 0; + + STBTT_assert(coverageIndex < pairSetCount); + + needle=glyph2; + r=pairValueCount-1; + l=0; + + // Binary search. + while (l <= r) { + stbtt_uint16 secondGlyph; + stbtt_uint8 *pairValue; + m = (l + r) >> 1; + pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m; + secondGlyph = ttUSHORT(pairValue); + straw = secondGlyph; + if (needle < straw) + r = m - 1; + else if (needle > straw) + l = m + 1; + else { + stbtt_int16 xAdvance = ttSHORT(pairValue + 2); + return xAdvance; + } + } + } break; + + case 2: { + stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); + stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); + + stbtt_uint16 classDef1Offset = ttUSHORT(table + 8); + stbtt_uint16 classDef2Offset = ttUSHORT(table + 10); + int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1); + int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2); + + stbtt_uint16 class1Count = ttUSHORT(table + 12); + stbtt_uint16 class2Count = ttUSHORT(table + 14); + STBTT_assert(glyph1class < class1Count); + STBTT_assert(glyph2class < class2Count); + + // TODO: Support more formats. + STBTT_GPOS_TODO_assert(valueFormat1 == 4); + if (valueFormat1 != 4) return 0; + STBTT_GPOS_TODO_assert(valueFormat2 == 0); + if (valueFormat2 != 0) return 0; + + if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) { + stbtt_uint8 *class1Records = table + 16; + stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count); + stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class); + return xAdvance; + } + } break; + + default: { + // There are no other cases. + STBTT_assert(0); + break; + }; + } + } + break; + }; + + default: + // TODO: Implement other stuff. + break; + } + } + + return 0; +} + +STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2) +{ + int xAdvance = 0; + + if (info->gpos) + xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2); + + if (info->kern) + xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2); + + return xAdvance; +} + +STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) +{ + if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs + return 0; + return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); +} + +STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing) +{ + stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing); +} + +STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap) +{ + if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4); + if (descent) *descent = ttSHORT(info->data+info->hhea + 6); + if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); +} + +STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap) +{ + int tab = stbtt__find_table(info->data, info->fontstart, "OS/2"); + if (!tab) + return 0; + if (typoAscent ) *typoAscent = ttSHORT(info->data+tab + 68); + if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70); + if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72); + return 1; +} + +STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) +{ + *x0 = ttSHORT(info->data + info->head + 36); + *y0 = ttSHORT(info->data + info->head + 38); + *x1 = ttSHORT(info->data + info->head + 40); + *y1 = ttSHORT(info->data + info->head + 42); +} + +STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height) +{ + int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6); + return (float) height / fheight; +} + +STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels) +{ + int unitsPerEm = ttUSHORT(info->data + info->head + 18); + return pixels / unitsPerEm; +} + +STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) +{ + STBTT_free(v, info->userdata); +} + +////////////////////////////////////////////////////////////////////////////// +// +// antialiasing software rasterizer +// + +STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning + if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { + // e.g. space character + if (ix0) *ix0 = 0; + if (iy0) *iy0 = 0; + if (ix1) *ix1 = 0; + if (iy1) *iy1 = 0; + } else { + // move to integral bboxes (treating pixels as little squares, what pixels get touched)? + if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); + if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); + if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); + if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); + } +} + +STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1); +} + +STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1); +} + +STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) +{ + stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1); +} + +////////////////////////////////////////////////////////////////////////////// +// +// Rasterizer + +typedef struct stbtt__hheap_chunk +{ + struct stbtt__hheap_chunk *next; +} stbtt__hheap_chunk; + +typedef struct stbtt__hheap +{ + struct stbtt__hheap_chunk *head; + void *first_free; + int num_remaining_in_head_chunk; +} stbtt__hheap; + +static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) +{ + if (hh->first_free) { + void *p = hh->first_free; + hh->first_free = * (void **) p; + return p; + } else { + if (hh->num_remaining_in_head_chunk == 0) { + int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); + stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); + if (c == NULL) + return NULL; + c->next = hh->head; + hh->head = c; + hh->num_remaining_in_head_chunk = count; + } + --hh->num_remaining_in_head_chunk; + return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk; + } +} + +static void stbtt__hheap_free(stbtt__hheap *hh, void *p) +{ + *(void **) p = hh->first_free; + hh->first_free = p; +} + +static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata) +{ + stbtt__hheap_chunk *c = hh->head; + while (c) { + stbtt__hheap_chunk *n = c->next; + STBTT_free(c, userdata); + c = n; + } +} + +typedef struct stbtt__edge { + float x0,y0, x1,y1; + int invert; +} stbtt__edge; + + +typedef struct stbtt__active_edge +{ + struct stbtt__active_edge *next; +#if STBTT_RASTERIZER_VERSION==1 + int x,dx; + float ey; + int direction; +#elif STBTT_RASTERIZER_VERSION==2 + float fx,fdx,fdy; + float direction; + float sy; + float ey; +#else +#error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif +} stbtt__active_edge; + +#if STBTT_RASTERIZER_VERSION == 1 +#define STBTT_FIXSHIFT 10 +#define STBTT_FIX (1 << STBTT_FIXSHIFT) +#define STBTT_FIXMASK (STBTT_FIX-1) + +static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) +{ + stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); + float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); + STBTT_assert(z != NULL); + if (!z) return z; + + // round dx down to avoid overshooting + if (dxdy < 0) + z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); + else + z->dx = STBTT_ifloor(STBTT_FIX * dxdy); + + z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount + z->x -= off_x * STBTT_FIX; + + z->ey = e->y1; + z->next = 0; + z->direction = e->invert ? 1 : -1; + return z; +} +#elif STBTT_RASTERIZER_VERSION == 2 +static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) +{ + stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); + float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); + STBTT_assert(z != NULL); + //STBTT_assert(e->y0 <= start_point); + if (!z) return z; + z->fdx = dxdy; + z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f; + z->fx = e->x0 + dxdy * (start_point - e->y0); + z->fx -= off_x; + z->direction = e->invert ? 1.0f : -1.0f; + z->sy = e->y0; + z->ey = e->y1; + z->next = 0; + return z; +} +#else +#error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif + +#if STBTT_RASTERIZER_VERSION == 1 +// note: this routine clips fills that extend off the edges... ideally this +// wouldn't happen, but it could happen if the truetype glyph bounding boxes +// are wrong, or if the user supplies a too-small bitmap +static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight) +{ + // non-zero winding fill + int x0=0, w=0; + + while (e) { + if (w == 0) { + // if we're currently at zero, we need to record the edge start point + x0 = e->x; w += e->direction; + } else { + int x1 = e->x; w += e->direction; + // if we went to zero, we need to draw + if (w == 0) { + int i = x0 >> STBTT_FIXSHIFT; + int j = x1 >> STBTT_FIXSHIFT; + + if (i < len && j >= 0) { + if (i == j) { + // x0,x1 are the same pixel, so compute combined coverage + scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT); + } else { + if (i >= 0) // add antialiasing for x0 + scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT); + else + i = -1; // clip + + if (j < len) // add antialiasing for x1 + scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT); + else + j = len; // clip + + for (++i; i < j; ++i) // fill pixels between x0 and x1 + scanline[i] = scanline[i] + (stbtt_uint8) max_weight; + } + } + } + } + + e = e->next; + } +} + +static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) +{ + stbtt__hheap hh = { 0, 0, 0 }; + stbtt__active_edge *active = NULL; + int y,j=0; + int max_weight = (255 / vsubsample); // weight per vertical scanline + int s; // vertical subsample index + unsigned char scanline_data[512], *scanline; + + if (result->w > 512) + scanline = (unsigned char *) STBTT_malloc(result->w, userdata); + else + scanline = scanline_data; + + y = off_y * vsubsample; + e[n].y0 = (off_y + result->h) * (float) vsubsample + 1; + + while (j < result->h) { + STBTT_memset(scanline, 0, result->w); + for (s=0; s < vsubsample; ++s) { + // find center of pixel for this scanline + float scan_y = y + 0.5f; + stbtt__active_edge **step = &active; + + // update all active edges; + // remove all active edges that terminate before the center of this scanline + while (*step) { + stbtt__active_edge * z = *step; + if (z->ey <= scan_y) { + *step = z->next; // delete from list + STBTT_assert(z->direction); + z->direction = 0; + stbtt__hheap_free(&hh, z); + } else { + z->x += z->dx; // advance to position for current scanline + step = &((*step)->next); // advance through list + } + } + + // resort the list if needed + for(;;) { + int changed=0; + step = &active; + while (*step && (*step)->next) { + if ((*step)->x > (*step)->next->x) { + stbtt__active_edge *t = *step; + stbtt__active_edge *q = t->next; + + t->next = q->next; + q->next = t; + *step = q; + changed = 1; + } + step = &(*step)->next; + } + if (!changed) break; + } + + // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline + while (e->y0 <= scan_y) { + if (e->y1 > scan_y) { + stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata); + if (z != NULL) { + // find insertion point + if (active == NULL) + active = z; + else if (z->x < active->x) { + // insert at front + z->next = active; + active = z; + } else { + // find thing to insert AFTER + stbtt__active_edge *p = active; + while (p->next && p->next->x < z->x) + p = p->next; + // at this point, p->next->x is NOT < z->x + z->next = p->next; + p->next = z; + } + } + } + ++e; + } + + // now process all active edges in XOR fashion + if (active) + stbtt__fill_active_edges(scanline, result->w, active, max_weight); + + ++y; + } + STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); + ++j; + } + + stbtt__hheap_cleanup(&hh, userdata); + + if (scanline != scanline_data) + STBTT_free(scanline, userdata); +} + +#elif STBTT_RASTERIZER_VERSION == 2 + +// the edge passed in here does not cross the vertical line at x or the vertical line at x+1 +// (i.e. it has already been clipped to those) +static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1) +{ + if (y0 == y1) return; + STBTT_assert(y0 < y1); + STBTT_assert(e->sy <= e->ey); + if (y0 > e->ey) return; + if (y1 < e->sy) return; + if (y0 < e->sy) { + x0 += (x1-x0) * (e->sy - y0) / (y1-y0); + y0 = e->sy; + } + if (y1 > e->ey) { + x1 += (x1-x0) * (e->ey - y1) / (y1-y0); + y1 = e->ey; + } + + if (x0 == x) + STBTT_assert(x1 <= x+1); + else if (x0 == x+1) + STBTT_assert(x1 >= x); + else if (x0 <= x) + STBTT_assert(x1 <= x); + else if (x0 >= x+1) + STBTT_assert(x1 >= x+1); + else + STBTT_assert(x1 >= x && x1 <= x+1); + + if (x0 <= x && x1 <= x) + scanline[x] += e->direction * (y1-y0); + else if (x0 >= x+1 && x1 >= x+1) + ; + else { + STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1); + scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position + } +} + +static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top) +{ + float y_bottom = y_top+1; + + while (e) { + // brute force every pixel + + // compute intersection points with top & bottom + STBTT_assert(e->ey >= y_top); + + if (e->fdx == 0) { + float x0 = e->fx; + if (x0 < len) { + if (x0 >= 0) { + stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom); + stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom); + } else { + stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom); + } + } + } else { + float x0 = e->fx; + float dx = e->fdx; + float xb = x0 + dx; + float x_top, x_bottom; + float sy0,sy1; + float dy = e->fdy; + STBTT_assert(e->sy <= y_bottom && e->ey >= y_top); + + // compute endpoints of line segment clipped to this scanline (if the + // line segment starts on this scanline. x0 is the intersection of the + // line with y_top, but that may be off the line segment. + if (e->sy > y_top) { + x_top = x0 + dx * (e->sy - y_top); + sy0 = e->sy; + } else { + x_top = x0; + sy0 = y_top; + } + if (e->ey < y_bottom) { + x_bottom = x0 + dx * (e->ey - y_top); + sy1 = e->ey; + } else { + x_bottom = xb; + sy1 = y_bottom; + } + + if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { + // from here on, we don't have to range check x values + + if ((int) x_top == (int) x_bottom) { + float height; + // simple case, only spans one pixel + int x = (int) x_top; + height = sy1 - sy0; + STBTT_assert(x >= 0 && x < len); + scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2) * height; + scanline_fill[x] += e->direction * height; // everything right of this pixel is filled + } else { + int x,x1,x2; + float y_crossing, step, sign, area; + // covers 2+ pixels + if (x_top > x_bottom) { + // flip scanline vertically; signed area is the same + float t; + sy0 = y_bottom - (sy0 - y_top); + sy1 = y_bottom - (sy1 - y_top); + t = sy0, sy0 = sy1, sy1 = t; + t = x_bottom, x_bottom = x_top, x_top = t; + dx = -dx; + dy = -dy; + t = x0, x0 = xb, xb = t; + } + + x1 = (int) x_top; + x2 = (int) x_bottom; + // compute intersection with y axis at x1+1 + y_crossing = (x1+1 - x0) * dy + y_top; + + sign = e->direction; + // area of the rectangle covered from y0..y_crossing + area = sign * (y_crossing-sy0); + // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing) + scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2); + + step = sign * dy; + for (x = x1+1; x < x2; ++x) { + scanline[x] += area + step/2; + area += step; + } + y_crossing += dy * (x2 - (x1+1)); + + STBTT_assert(STBTT_fabs(area) <= 1.01f); + + scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing); + + scanline_fill[x2] += sign * (sy1-sy0); + } + } else { + // if edge goes outside of box we're drawing, we require + // clipping logic. since this does not match the intended use + // of this library, we use a different, very slow brute + // force implementation + int x; + for (x=0; x < len; ++x) { + // cases: + // + // there can be up to two intersections with the pixel. any intersection + // with left or right edges can be handled by splitting into two (or three) + // regions. intersections with top & bottom do not necessitate case-wise logic. + // + // the old way of doing this found the intersections with the left & right edges, + // then used some simple logic to produce up to three segments in sorted order + // from top-to-bottom. however, this had a problem: if an x edge was epsilon + // across the x border, then the corresponding y position might not be distinct + // from the other y segment, and it might ignored as an empty segment. to avoid + // that, we need to explicitly produce segments based on x positions. + + // rename variables to clearly-defined pairs + float y0 = y_top; + float x1 = (float) (x); + float x2 = (float) (x+1); + float x3 = xb; + float y3 = y_bottom; + + // x = e->x + e->dx * (y-y_top) + // (y-y_top) = (x - e->x) / e->dx + // y = (x - e->x) / e->dx + y_top + float y1 = (x - x0) / dx + y_top; + float y2 = (x+1 - x0) / dx + y_top; + + if (x0 < x1 && x3 > x2) { // three segments descending down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else if (x3 < x1 && x0 > x2) { // three segments descending down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); + stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); + } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); + stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); + } else { // one segment + stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3); + } + } + } + } + e = e->next; + } +} + +// directly AA rasterize edges w/o supersampling +static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) +{ + stbtt__hheap hh = { 0, 0, 0 }; + stbtt__active_edge *active = NULL; + int y,j=0, i; + float scanline_data[129], *scanline, *scanline2; + + STBTT__NOTUSED(vsubsample); + + if (result->w > 64) + scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); + else + scanline = scanline_data; + + scanline2 = scanline + result->w; + + y = off_y; + e[n].y0 = (float) (off_y + result->h) + 1; + + while (j < result->h) { + // find center of pixel for this scanline + float scan_y_top = y + 0.0f; + float scan_y_bottom = y + 1.0f; + stbtt__active_edge **step = &active; + + STBTT_memset(scanline , 0, result->w*sizeof(scanline[0])); + STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); + + // update all active edges; + // remove all active edges that terminate before the top of this scanline + while (*step) { + stbtt__active_edge * z = *step; + if (z->ey <= scan_y_top) { + *step = z->next; // delete from list + STBTT_assert(z->direction); + z->direction = 0; + stbtt__hheap_free(&hh, z); + } else { + step = &((*step)->next); // advance through list + } + } + + // insert all edges that start before the bottom of this scanline + while (e->y0 <= scan_y_bottom) { + if (e->y0 != e->y1) { + stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata); + if (z != NULL) { + STBTT_assert(z->ey >= scan_y_top); + // insert at front + z->next = active; + active = z; + } + } + ++e; + } + + // now process all active edges + if (active) + stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top); + + { + float sum = 0; + for (i=0; i < result->w; ++i) { + float k; + int m; + sum += scanline2[i]; + k = scanline[i] + sum; + k = (float) STBTT_fabs(k)*255 + 0.5f; + m = (int) k; + if (m > 255) m = 255; + result->pixels[j*result->stride + i] = (unsigned char) m; + } + } + // advance all the edges + step = &active; + while (*step) { + stbtt__active_edge *z = *step; + z->fx += z->fdx; // advance to position for current scanline + step = &((*step)->next); // advance through list + } + + ++y; + ++j; + } + + stbtt__hheap_cleanup(&hh, userdata); + + if (scanline != scanline_data) + STBTT_free(scanline, userdata); +} +#else +#error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif + +#define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0) + +static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) +{ + int i,j; + for (i=1; i < n; ++i) { + stbtt__edge t = p[i], *a = &t; + j = i; + while (j > 0) { + stbtt__edge *b = &p[j-1]; + int c = STBTT__COMPARE(a,b); + if (!c) break; + p[j] = p[j-1]; + --j; + } + if (i != j) + p[j] = t; + } +} + +static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) +{ + /* threshhold for transitioning to insertion sort */ + while (n > 12) { + stbtt__edge t; + int c01,c12,c,m,i,j; + + /* compute median of three */ + m = n >> 1; + c01 = STBTT__COMPARE(&p[0],&p[m]); + c12 = STBTT__COMPARE(&p[m],&p[n-1]); + /* if 0 >= mid >= end, or 0 < mid < end, then use mid */ + if (c01 != c12) { + /* otherwise, we'll need to swap something else to middle */ + int z; + c = STBTT__COMPARE(&p[0],&p[n-1]); + /* 0>mid && mid<n: 0>n => n; 0<n => 0 */ + /* 0<mid && mid>n: 0>n => 0; 0<n => n */ + z = (c == c12) ? 0 : n-1; + t = p[z]; + p[z] = p[m]; + p[m] = t; + } + /* now p[m] is the median-of-three */ + /* swap it to the beginning so it won't move around */ + t = p[0]; + p[0] = p[m]; + p[m] = t; + + /* partition loop */ + i=1; + j=n-1; + for(;;) { + /* handling of equality is crucial here */ + /* for sentinels & efficiency with duplicates */ + for (;;++i) { + if (!STBTT__COMPARE(&p[i], &p[0])) break; + } + for (;;--j) { + if (!STBTT__COMPARE(&p[0], &p[j])) break; + } + /* make sure we haven't crossed */ + if (i >= j) break; + t = p[i]; + p[i] = p[j]; + p[j] = t; + + ++i; + --j; + } + /* recurse on smaller side, iterate on larger */ + if (j < (n-i)) { + stbtt__sort_edges_quicksort(p,j); + p = p+i; + n = n-i; + } else { + stbtt__sort_edges_quicksort(p+i, n-i); + n = j; + } + } +} + +static void stbtt__sort_edges(stbtt__edge *p, int n) +{ + stbtt__sort_edges_quicksort(p, n); + stbtt__sort_edges_ins_sort(p, n); +} + +typedef struct +{ + float x,y; +} stbtt__point; + +static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata) +{ + float y_scale_inv = invert ? -scale_y : scale_y; + stbtt__edge *e; + int n,i,j,k,m; +#if STBTT_RASTERIZER_VERSION == 1 + int vsubsample = result->h < 8 ? 15 : 5; +#elif STBTT_RASTERIZER_VERSION == 2 + int vsubsample = 1; +#else +#error "Unrecognized value of STBTT_RASTERIZER_VERSION" +#endif + // vsubsample should divide 255 evenly; otherwise we won't reach full opacity + + // now we have to blow out the windings into explicit edge lists + n = 0; + for (i=0; i < windings; ++i) + n += wcount[i]; + + e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel + if (e == 0) return; + n = 0; + + m=0; + for (i=0; i < windings; ++i) { + stbtt__point *p = pts + m; + m += wcount[i]; + j = wcount[i]-1; + for (k=0; k < wcount[i]; j=k++) { + int a=k,b=j; + // skip the edge if horizontal + if (p[j].y == p[k].y) + continue; + // add edge from j to k to the list + e[n].invert = 0; + if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { + e[n].invert = 1; + a=j,b=k; + } + e[n].x0 = p[a].x * scale_x + shift_x; + e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; + e[n].x1 = p[b].x * scale_x + shift_x; + e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; + ++n; + } + } + + // now sort the edges by their highest point (should snap to integer, and then by x) + //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare); + stbtt__sort_edges(e, n); + + // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule + stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); + + STBTT_free(e, userdata); +} + +static void stbtt__add_point(stbtt__point *points, int n, float x, float y) +{ + if (!points) return; // during first pass, it's unallocated + points[n].x = x; + points[n].y = y; +} + +// tesselate until threshhold p is happy... @TODO warped to compensate for non-linear stretching +static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) +{ + // midpoint + float mx = (x0 + 2*x1 + x2)/4; + float my = (y0 + 2*y1 + y2)/4; + // versus directly drawn line + float dx = (x0+x2)/2 - mx; + float dy = (y0+y2)/2 - my; + if (n > 16) // 65536 segments on one curve better be enough! + return 1; + if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA + stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); + } else { + stbtt__add_point(points, *num_points,x2,y2); + *num_points = *num_points+1; + } + return 1; +} + +static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n) +{ + // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough + float dx0 = x1-x0; + float dy0 = y1-y0; + float dx1 = x2-x1; + float dy1 = y2-y1; + float dx2 = x3-x2; + float dy2 = y3-y2; + float dx = x3-x0; + float dy = y3-y0; + float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2)); + float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy); + float flatness_squared = longlen*longlen-shortlen*shortlen; + + if (n > 16) // 65536 segments on one curve better be enough! + return; + + if (flatness_squared > objspace_flatness_squared) { + float x01 = (x0+x1)/2; + float y01 = (y0+y1)/2; + float x12 = (x1+x2)/2; + float y12 = (y1+y2)/2; + float x23 = (x2+x3)/2; + float y23 = (y2+y3)/2; + + float xa = (x01+x12)/2; + float ya = (y01+y12)/2; + float xb = (x12+x23)/2; + float yb = (y12+y23)/2; + + float mx = (xa+xb)/2; + float my = (ya+yb)/2; + + stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); + } else { + stbtt__add_point(points, *num_points,x3,y3); + *num_points = *num_points+1; + } +} + +// returns number of contours +static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) +{ + stbtt__point *points=0; + int num_points=0; + + float objspace_flatness_squared = objspace_flatness * objspace_flatness; + int i,n=0,start=0, pass; + + // count how many "moves" there are to get the contour count + for (i=0; i < num_verts; ++i) + if (vertices[i].type == STBTT_vmove) + ++n; + + *num_contours = n; + if (n == 0) return 0; + + *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata); + + if (*contour_lengths == 0) { + *num_contours = 0; + return 0; + } + + // make two passes through the points so we don't need to realloc + for (pass=0; pass < 2; ++pass) { + float x=0,y=0; + if (pass == 1) { + points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); + if (points == NULL) goto error; + } + num_points = 0; + n= -1; + for (i=0; i < num_verts; ++i) { + switch (vertices[i].type) { + case STBTT_vmove: + // start the next contour + if (n >= 0) + (*contour_lengths)[n] = num_points - start; + ++n; + start = num_points; + + x = vertices[i].x, y = vertices[i].y; + stbtt__add_point(points, num_points++, x,y); + break; + case STBTT_vline: + x = vertices[i].x, y = vertices[i].y; + stbtt__add_point(points, num_points++, x, y); + break; + case STBTT_vcurve: + stbtt__tesselate_curve(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; + case STBTT_vcubic: + stbtt__tesselate_cubic(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].cx1, vertices[i].cy1, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; + } + } + (*contour_lengths)[n] = num_points - start; + } + + return points; + error: + STBTT_free(points, userdata); + STBTT_free(*contour_lengths, userdata); + *contour_lengths = 0; + *num_contours = 0; + return NULL; +} + +STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata) +{ + float scale = scale_x > scale_y ? scale_y : scale_x; + int winding_count = 0; + int *winding_lengths = NULL; + stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata); + if (windings) { + stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); + STBTT_free(winding_lengths, userdata); + STBTT_free(windings, userdata); + } +} + +STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) +{ + STBTT_free(bitmap, userdata); +} + +STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff) +{ + int ix0,iy0,ix1,iy1; + stbtt__bitmap gbm; + stbtt_vertex *vertices; + int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); + + if (scale_x == 0) scale_x = scale_y; + if (scale_y == 0) { + if (scale_x == 0) { + STBTT_free(vertices, info->userdata); + return NULL; + } + scale_y = scale_x; + } + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1); + + // now we get the size + gbm.w = (ix1 - ix0); + gbm.h = (iy1 - iy0); + gbm.pixels = NULL; // in case we error + + if (width ) *width = gbm.w; + if (height) *height = gbm.h; + if (xoff ) *xoff = ix0; + if (yoff ) *yoff = iy0; + + if (gbm.w && gbm.h) { + gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); + if (gbm.pixels) { + gbm.stride = gbm.w; + + stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); + } + } + STBTT_free(vertices, info->userdata); + return gbm.pixels; +} + +STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff); +} + +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph) +{ + int ix0,iy0; + stbtt_vertex *vertices; + int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); + stbtt__bitmap gbm; + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); + gbm.pixels = output; + gbm.w = out_w; + gbm.h = out_h; + gbm.stride = out_stride; + + if (gbm.w && gbm.h) + stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); + + STBTT_free(vertices, info->userdata); +} + +STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph) +{ + stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph); +} + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); +} + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint) +{ + stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint)); +} + +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) +{ + stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint)); +} + +STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); +} + +STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) +{ + stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint); +} + +////////////////////////////////////////////////////////////////////////////// +// +// bitmap baking +// +// This is SUPER-CRAPPY packing to keep source code small + +static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) + float pixel_height, // height of font in pixels + unsigned char *pixels, int pw, int ph, // bitmap to be filled in + int first_char, int num_chars, // characters to bake + stbtt_bakedchar *chardata) +{ + float scale; + int x,y,bottom_y, i; + stbtt_fontinfo f; + f.userdata = NULL; + if (!stbtt_InitFont(&f, data, offset)) + return -1; + STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels + x=y=1; + bottom_y = 1; + + scale = stbtt_ScaleForPixelHeight(&f, pixel_height); + + for (i=0; i < num_chars; ++i) { + int advance, lsb, x0,y0,x1,y1,gw,gh; + int g = stbtt_FindGlyphIndex(&f, first_char + i); + stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb); + stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1); + gw = x1-x0; + gh = y1-y0; + if (x + gw + 1 >= pw) + y = bottom_y, x = 1; // advance to next row + if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row + return -i; + STBTT_assert(x+gw < pw); + STBTT_assert(y+gh < ph); + stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g); + chardata[i].x0 = (stbtt_int16) x; + chardata[i].y0 = (stbtt_int16) y; + chardata[i].x1 = (stbtt_int16) (x + gw); + chardata[i].y1 = (stbtt_int16) (y + gh); + chardata[i].xadvance = scale * advance; + chardata[i].xoff = (float) x0; + chardata[i].yoff = (float) y0; + x = x + gw + 1; + if (y+gh+1 > bottom_y) + bottom_y = y+gh+1; + } + return bottom_y; +} + +STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) +{ + float d3d_bias = opengl_fillrule ? 0 : -0.5f; + float ipw = 1.0f / pw, iph = 1.0f / ph; + const stbtt_bakedchar *b = chardata + char_index; + int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); + int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); + + q->x0 = round_x + d3d_bias; + q->y0 = round_y + d3d_bias; + q->x1 = round_x + b->x1 - b->x0 + d3d_bias; + q->y1 = round_y + b->y1 - b->y0 + d3d_bias; + + q->s0 = b->x0 * ipw; + q->t0 = b->y0 * iph; + q->s1 = b->x1 * ipw; + q->t1 = b->y1 * iph; + + *xpos += b->xadvance; +} + +////////////////////////////////////////////////////////////////////////////// +// +// rectangle packing replacement routines if you don't have stb_rect_pack.h +// + +#ifndef STB_RECT_PACK_VERSION + +typedef int stbrp_coord; + +//////////////////////////////////////////////////////////////////////////////////// +// // +// // +// COMPILER WARNING ?!?!? // +// // +// // +// if you get a compile warning due to these symbols being defined more than // +// once, move #include "stb_rect_pack.h" before #include "stb_truetype.h" // +// // +//////////////////////////////////////////////////////////////////////////////////// + +typedef struct +{ + int width,height; + int x,y,bottom_y; +} stbrp_context; + +typedef struct +{ + unsigned char x; +} stbrp_node; + +struct stbrp_rect +{ + stbrp_coord x,y; + int id,w,h,was_packed; +}; + +static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) +{ + con->width = pw; + con->height = ph; + con->x = 0; + con->y = 0; + con->bottom_y = 0; + STBTT__NOTUSED(nodes); + STBTT__NOTUSED(num_nodes); +} + +static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) +{ + int i; + for (i=0; i < num_rects; ++i) { + if (con->x + rects[i].w > con->width) { + con->x = 0; + con->y = con->bottom_y; + } + if (con->y + rects[i].h > con->height) + break; + rects[i].x = con->x; + rects[i].y = con->y; + rects[i].was_packed = 1; + con->x += rects[i].w; + if (con->y + rects[i].h > con->bottom_y) + con->bottom_y = con->y + rects[i].h; + } + for ( ; i < num_rects; ++i) + rects[i].was_packed = 0; +} +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// bitmap baking +// +// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If +// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy. + +STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) +{ + stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); + int num_nodes = pw - padding; + stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); + + if (context == NULL || nodes == NULL) { + if (context != NULL) STBTT_free(context, alloc_context); + if (nodes != NULL) STBTT_free(nodes , alloc_context); + return 0; + } + + spc->user_allocator_context = alloc_context; + spc->width = pw; + spc->height = ph; + spc->pixels = pixels; + spc->pack_info = context; + spc->nodes = nodes; + spc->padding = padding; + spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw; + spc->h_oversample = 1; + spc->v_oversample = 1; + + stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); + + if (pixels) + STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels + + return 1; +} + +STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc) +{ + STBTT_free(spc->nodes , spc->user_allocator_context); + STBTT_free(spc->pack_info, spc->user_allocator_context); +} + +STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample) +{ + STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); + STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); + if (h_oversample <= STBTT_MAX_OVERSAMPLE) + spc->h_oversample = h_oversample; + if (v_oversample <= STBTT_MAX_OVERSAMPLE) + spc->v_oversample = v_oversample; +} + +#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1) + +static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) +{ + unsigned char buffer[STBTT_MAX_OVERSAMPLE]; + int safe_w = w - kernel_width; + int j; + STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze + for (j=0; j < h; ++j) { + int i; + unsigned int total; + STBTT_memset(buffer, 0, kernel_width); + + total = 0; + + // make kernel_width a constant in common cases so compiler can optimize out the divide + switch (kernel_width) { + case 2: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 2); + } + break; + case 3: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 3); + } + break; + case 4: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 4); + } + break; + case 5: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / 5); + } + break; + default: + for (i=0; i <= safe_w; ++i) { + total += pixels[i] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; + pixels[i] = (unsigned char) (total / kernel_width); + } + break; + } + + for (; i < w; ++i) { + STBTT_assert(pixels[i] == 0); + total -= buffer[i & STBTT__OVER_MASK]; + pixels[i] = (unsigned char) (total / kernel_width); + } + + pixels += stride_in_bytes; + } +} + +static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) +{ + unsigned char buffer[STBTT_MAX_OVERSAMPLE]; + int safe_h = h - kernel_width; + int j; + STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze + for (j=0; j < w; ++j) { + int i; + unsigned int total; + STBTT_memset(buffer, 0, kernel_width); + + total = 0; + + // make kernel_width a constant in common cases so compiler can optimize out the divide + switch (kernel_width) { + case 2: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 2); + } + break; + case 3: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 3); + } + break; + case 4: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 4); + } + break; + case 5: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / 5); + } + break; + default: + for (i=0; i <= safe_h; ++i) { + total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; + buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; + pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); + } + break; + } + + for (; i < h; ++i) { + STBTT_assert(pixels[i*stride_in_bytes] == 0); + total -= buffer[i & STBTT__OVER_MASK]; + pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); + } + + pixels += 1; + } +} + +static float stbtt__oversample_shift(int oversample) +{ + if (!oversample) + return 0.0f; + + // The prefilter is a box filter of width "oversample", + // which shifts phase by (oversample - 1)/2 pixels in + // oversampled space. We want to shift in the opposite + // direction to counter this. + return (float)-(oversample - 1) / (2.0f * (float)oversample); +} + +// rects array must be big enough to accommodate all characters in the given ranges +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +{ + int i,j,k; + + k=0; + for (i=0; i < num_ranges; ++i) { + float fh = ranges[i].font_size; + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); + ranges[i].h_oversample = (unsigned char) spc->h_oversample; + ranges[i].v_oversample = (unsigned char) spc->v_oversample; + for (j=0; j < ranges[i].num_chars; ++j) { + int x0,y0,x1,y1; + int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; + int glyph = stbtt_FindGlyphIndex(info, codepoint); + stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + &x0,&y0,&x1,&y1); + rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); + rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); + ++k; + } + } + + return k; +} + +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph) +{ + stbtt_MakeGlyphBitmapSubpixel(info, + output, + out_w - (prefilter_x - 1), + out_h - (prefilter_y - 1), + out_stride, + scale_x, + scale_y, + shift_x, + shift_y, + glyph); + + if (prefilter_x > 1) + stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x); + + if (prefilter_y > 1) + stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y); + + *sub_x = stbtt__oversample_shift(prefilter_x); + *sub_y = stbtt__oversample_shift(prefilter_y); +} + +// rects array must be big enough to accommodate all characters in the given ranges +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +{ + int i,j,k, return_value = 1; + + // save current values + int old_h_over = spc->h_oversample; + int old_v_over = spc->v_oversample; + + k = 0; + for (i=0; i < num_ranges; ++i) { + float fh = ranges[i].font_size; + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); + float recip_h,recip_v,sub_x,sub_y; + spc->h_oversample = ranges[i].h_oversample; + spc->v_oversample = ranges[i].v_oversample; + recip_h = 1.0f / spc->h_oversample; + recip_v = 1.0f / spc->v_oversample; + sub_x = stbtt__oversample_shift(spc->h_oversample); + sub_y = stbtt__oversample_shift(spc->v_oversample); + for (j=0; j < ranges[i].num_chars; ++j) { + stbrp_rect *r = &rects[k]; + if (r->was_packed) { + stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; + int advance, lsb, x0,y0,x1,y1; + int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; + int glyph = stbtt_FindGlyphIndex(info, codepoint); + stbrp_coord pad = (stbrp_coord) spc->padding; + + // pad on left and top + r->x += pad; + r->y += pad; + r->w -= pad; + r->h -= pad; + stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb); + stbtt_GetGlyphBitmapBox(info, glyph, + scale * spc->h_oversample, + scale * spc->v_oversample, + &x0,&y0,&x1,&y1); + stbtt_MakeGlyphBitmapSubpixel(info, + spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w - spc->h_oversample+1, + r->h - spc->v_oversample+1, + spc->stride_in_bytes, + scale * spc->h_oversample, + scale * spc->v_oversample, + 0,0, + glyph); + + if (spc->h_oversample > 1) + stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w, r->h, spc->stride_in_bytes, + spc->h_oversample); + + if (spc->v_oversample > 1) + stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, + r->w, r->h, spc->stride_in_bytes, + spc->v_oversample); + + bc->x0 = (stbtt_int16) r->x; + bc->y0 = (stbtt_int16) r->y; + bc->x1 = (stbtt_int16) (r->x + r->w); + bc->y1 = (stbtt_int16) (r->y + r->h); + bc->xadvance = scale * advance; + bc->xoff = (float) x0 * recip_h + sub_x; + bc->yoff = (float) y0 * recip_v + sub_y; + bc->xoff2 = (x0 + r->w) * recip_h + sub_x; + bc->yoff2 = (y0 + r->h) * recip_v + sub_y; + } else { + return_value = 0; // if any fail, report failure + } + + ++k; + } + } + + // restore original values + spc->h_oversample = old_h_over; + spc->v_oversample = old_v_over; + + return return_value; +} + +STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects) +{ + stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects); +} + +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) +{ + stbtt_fontinfo info; + int i,j,n, return_value = 1; + //stbrp_context *context = (stbrp_context *) spc->pack_info; + stbrp_rect *rects; + + // flag all characters as NOT packed + for (i=0; i < num_ranges; ++i) + for (j=0; j < ranges[i].num_chars; ++j) + ranges[i].chardata_for_range[j].x0 = + ranges[i].chardata_for_range[j].y0 = + ranges[i].chardata_for_range[j].x1 = + ranges[i].chardata_for_range[j].y1 = 0; + + n = 0; + for (i=0; i < num_ranges; ++i) + n += ranges[i].num_chars; + + rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); + if (rects == NULL) + return 0; + + info.userdata = spc->user_allocator_context; + stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index)); + + n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects); + + stbtt_PackFontRangesPackRects(spc, rects, n); + + return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects); + + STBTT_free(rects, spc->user_allocator_context); + return return_value; +} + +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, + int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) +{ + stbtt_pack_range range; + range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range; + range.array_of_unicode_codepoints = NULL; + range.num_chars = num_chars_in_range; + range.chardata_for_range = chardata_for_range; + range.font_size = font_size; + return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); +} + +STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) +{ + float ipw = 1.0f / pw, iph = 1.0f / ph; + const stbtt_packedchar *b = chardata + char_index; + + if (align_to_integer) { + float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); + float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); + q->x0 = x; + q->y0 = y; + q->x1 = x + b->xoff2 - b->xoff; + q->y1 = y + b->yoff2 - b->yoff; + } else { + q->x0 = *xpos + b->xoff; + q->y0 = *ypos + b->yoff; + q->x1 = *xpos + b->xoff2; + q->y1 = *ypos + b->yoff2; + } + + q->s0 = b->x0 * ipw; + q->t0 = b->y0 * iph; + q->s1 = b->x1 * ipw; + q->t1 = b->y1 * iph; + + *xpos += b->xadvance; +} + +////////////////////////////////////////////////////////////////////////////// +// +// sdf computation +// + +#define STBTT_min(a,b) ((a) < (b) ? (a) : (b)) +#define STBTT_max(a,b) ((a) < (b) ? (b) : (a)) + +static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2]) +{ + float q0perp = q0[1]*ray[0] - q0[0]*ray[1]; + float q1perp = q1[1]*ray[0] - q1[0]*ray[1]; + float q2perp = q2[1]*ray[0] - q2[0]*ray[1]; + float roperp = orig[1]*ray[0] - orig[0]*ray[1]; + + float a = q0perp - 2*q1perp + q2perp; + float b = q1perp - q0perp; + float c = q0perp - roperp; + + float s0 = 0., s1 = 0.; + int num_s = 0; + + if (a != 0.0) { + float discr = b*b - a*c; + if (discr > 0.0) { + float rcpna = -1 / a; + float d = (float) STBTT_sqrt(discr); + s0 = (b+d) * rcpna; + s1 = (b-d) * rcpna; + if (s0 >= 0.0 && s0 <= 1.0) + num_s = 1; + if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) { + if (num_s == 0) s0 = s1; + ++num_s; + } + } + } else { + // 2*b*s + c = 0 + // s = -c / (2*b) + s0 = c / (-2 * b); + if (s0 >= 0.0 && s0 <= 1.0) + num_s = 1; + } + + if (num_s == 0) + return 0; + else { + float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]); + float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2; + + float q0d = q0[0]*rayn_x + q0[1]*rayn_y; + float q1d = q1[0]*rayn_x + q1[1]*rayn_y; + float q2d = q2[0]*rayn_x + q2[1]*rayn_y; + float rod = orig[0]*rayn_x + orig[1]*rayn_y; + + float q10d = q1d - q0d; + float q20d = q2d - q0d; + float q0rd = q0d - rod; + + hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d; + hits[0][1] = a*s0+b; + + if (num_s > 1) { + hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d; + hits[1][1] = a*s1+b; + return 2; + } else { + return 1; + } + } +} + +static int equal(float *a, float *b) +{ + return (a[0] == b[0] && a[1] == b[1]); +} + +static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts) +{ + int i; + float orig[2], ray[2] = { 1, 0 }; + float y_frac; + int winding = 0; + + orig[0] = x; + orig[1] = y; + + // make sure y never passes through a vertex of the shape + y_frac = (float) STBTT_fmod(y, 1.0f); + if (y_frac < 0.01f) + y += 0.01f; + else if (y_frac > 0.99f) + y -= 0.01f; + orig[1] = y; + + // test a ray from (-infinity,y) to (x,y) + for (i=0; i < nverts; ++i) { + if (verts[i].type == STBTT_vline) { + int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y; + int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y; + if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { + float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; + if (x_inter < x) + winding += (y0 < y1) ? 1 : -1; + } + } + if (verts[i].type == STBTT_vcurve) { + int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ; + int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy; + int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ; + int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2)); + int by = STBTT_max(y0,STBTT_max(y1,y2)); + if (y > ay && y < by && x > ax) { + float q0[2],q1[2],q2[2]; + float hits[2][2]; + q0[0] = (float)x0; + q0[1] = (float)y0; + q1[0] = (float)x1; + q1[1] = (float)y1; + q2[0] = (float)x2; + q2[1] = (float)y2; + if (equal(q0,q1) || equal(q1,q2)) { + x0 = (int)verts[i-1].x; + y0 = (int)verts[i-1].y; + x1 = (int)verts[i ].x; + y1 = (int)verts[i ].y; + if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { + float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; + if (x_inter < x) + winding += (y0 < y1) ? 1 : -1; + } + } else { + int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits); + if (num_hits >= 1) + if (hits[0][0] < 0) + winding += (hits[0][1] < 0 ? -1 : 1); + if (num_hits >= 2) + if (hits[1][0] < 0) + winding += (hits[1][1] < 0 ? -1 : 1); + } + } + } + } + return winding; +} + +static float stbtt__cuberoot( float x ) +{ + if (x<0) + return -(float) STBTT_pow(-x,1.0f/3.0f); + else + return (float) STBTT_pow( x,1.0f/3.0f); +} + +// x^3 + c*x^2 + b*x + a = 0 +static int stbtt__solve_cubic(float a, float b, float c, float* r) +{ + float s = -a / 3; + float p = b - a*a / 3; + float q = a * (2*a*a - 9*b) / 27 + c; + float p3 = p*p*p; + float d = q*q + 4*p3 / 27; + if (d >= 0) { + float z = (float) STBTT_sqrt(d); + float u = (-q + z) / 2; + float v = (-q - z) / 2; + u = stbtt__cuberoot(u); + v = stbtt__cuberoot(v); + r[0] = s + u + v; + return 1; + } else { + float u = (float) STBTT_sqrt(-p/3); + float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative + float m = (float) STBTT_cos(v); + float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f; + r[0] = s + u * 2 * m; + r[1] = s - u * (m + n); + r[2] = s - u * (m - n); + + //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? + //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); + //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); + return 3; + } +} + +STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) +{ + float scale_x = scale, scale_y = scale; + int ix0,iy0,ix1,iy1; + int w,h; + unsigned char *data; + + // if one scale is 0, use same scale for both + if (scale_x == 0) scale_x = scale_y; + if (scale_y == 0) { + if (scale_x == 0) return NULL; // if both scales are 0, return NULL + scale_y = scale_x; + } + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1); + + // if empty, return NULL + if (ix0 == ix1 || iy0 == iy1) + return NULL; + + ix0 -= padding; + iy0 -= padding; + ix1 += padding; + iy1 += padding; + + w = (ix1 - ix0); + h = (iy1 - iy0); + + if (width ) *width = w; + if (height) *height = h; + if (xoff ) *xoff = ix0; + if (yoff ) *yoff = iy0; + + // invert for y-downwards bitmaps + scale_y = -scale_y; + + { + int x,y,i,j; + float *precompute; + stbtt_vertex *verts; + int num_verts = stbtt_GetGlyphShape(info, glyph, &verts); + data = (unsigned char *) STBTT_malloc(w * h, info->userdata); + precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata); + + for (i=0,j=num_verts-1; i < num_verts; j=i++) { + if (verts[i].type == STBTT_vline) { + float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; + float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y; + float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); + precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist; + } else if (verts[i].type == STBTT_vcurve) { + float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y; + float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y; + float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y; + float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; + float len2 = bx*bx + by*by; + if (len2 != 0.0f) + precompute[i] = 1.0f / (bx*bx + by*by); + else + precompute[i] = 0.0f; + } else + precompute[i] = 0.0f; + } + + for (y=iy0; y < iy1; ++y) { + for (x=ix0; x < ix1; ++x) { + float val; + float min_dist = 999999.0f; + float sx = (float) x + 0.5f; + float sy = (float) y + 0.5f; + float x_gspace = (sx / scale_x); + float y_gspace = (sy / scale_y); + + int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path + + for (i=0; i < num_verts; ++i) { + float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; + + // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve + float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); + if (dist2 < min_dist*min_dist) + min_dist = (float) STBTT_sqrt(dist2); + + if (verts[i].type == STBTT_vline) { + float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y; + + // coarse culling against bbox + //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && + // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) + float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i]; + STBTT_assert(i != 0); + if (dist < min_dist) { + // check position along line + // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0) + // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy) + float dx = x1-x0, dy = y1-y0; + float px = x0-sx, py = y0-sy; + // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy + // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve + float t = -(px*dx + py*dy) / (dx*dx + dy*dy); + if (t >= 0.0f && t <= 1.0f) + min_dist = dist; + } + } else if (verts[i].type == STBTT_vcurve) { + float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y; + float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y; + float box_x0 = STBTT_min(STBTT_min(x0,x1),x2); + float box_y0 = STBTT_min(STBTT_min(y0,y1),y2); + float box_x1 = STBTT_max(STBTT_max(x0,x1),x2); + float box_y1 = STBTT_max(STBTT_max(y0,y1),y2); + // coarse culling against bbox to avoid computing cubic unnecessarily + if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) { + int num=0; + float ax = x1-x0, ay = y1-y0; + float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; + float mx = x0 - sx, my = y0 - sy; + float res[3],px,py,t,it; + float a_inv = precompute[i]; + if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula + float a = 3*(ax*bx + ay*by); + float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by); + float c = mx*ax+my*ay; + if (a == 0.0) { // if a is 0, it's linear + if (b != 0.0) { + res[num++] = -c/b; + } + } else { + float discriminant = b*b - 4*a*c; + if (discriminant < 0) + num = 0; + else { + float root = (float) STBTT_sqrt(discriminant); + res[0] = (-b - root)/(2*a); + res[1] = (-b + root)/(2*a); + num = 2; // don't bother distinguishing 1-solution case, as code below will still work + } + } + } else { + float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point + float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv; + float d = (mx*ax+my*ay) * a_inv; + num = stbtt__solve_cubic(b, c, d, res); + } + if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) { + t = res[0], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) { + t = res[1], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) { + t = res[2], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + } + } + } + if (winding == 0) + min_dist = -min_dist; // if outside the shape, value is negative + val = onedge_value + pixel_dist_scale * min_dist; + if (val < 0) + val = 0; + else if (val > 255) + val = 255; + data[(y-iy0)*w+(x-ix0)] = (unsigned char) val; + } + } + STBTT_free(precompute, info->userdata); + STBTT_free(verts, info->userdata); + } + return data; +} + +STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff); +} + +STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata) +{ + STBTT_free(bitmap, userdata); +} + +////////////////////////////////////////////////////////////////////////////// +// +// font name matching -- recommended not to use this +// + +// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string +static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) +{ + stbtt_int32 i=0; + + // convert utf16 to utf8 and compare the results while converting + while (len2) { + stbtt_uint16 ch = s2[0]*256 + s2[1]; + if (ch < 0x80) { + if (i >= len1) return -1; + if (s1[i++] != ch) return -1; + } else if (ch < 0x800) { + if (i+1 >= len1) return -1; + if (s1[i++] != 0xc0 + (ch >> 6)) return -1; + if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; + } else if (ch >= 0xd800 && ch < 0xdc00) { + stbtt_uint32 c; + stbtt_uint16 ch2 = s2[2]*256 + s2[3]; + if (i+3 >= len1) return -1; + c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; + if (s1[i++] != 0xf0 + (c >> 18)) return -1; + if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; + s2 += 2; // plus another 2 below + len2 -= 2; + } else if (ch >= 0xdc00 && ch < 0xe000) { + return -1; + } else { + if (i+2 >= len1) return -1; + if (s1[i++] != 0xe0 + (ch >> 12)) return -1; + if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; + if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; + } + s2 += 2; + len2 -= 2; + } + return i; +} + +static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2) +{ + return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2); +} + +// returns results in whatever encoding you request... but note that 2-byte encodings +// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare +STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID) +{ + stbtt_int32 i,count,stringOffset; + stbtt_uint8 *fc = font->data; + stbtt_uint32 offset = font->fontstart; + stbtt_uint32 nm = stbtt__find_table(fc, offset, "name"); + if (!nm) return NULL; + + count = ttUSHORT(fc+nm+2); + stringOffset = nm + ttUSHORT(fc+nm+4); + for (i=0; i < count; ++i) { + stbtt_uint32 loc = nm + 6 + 12 * i; + if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) + && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { + *length = ttUSHORT(fc+loc+8); + return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); + } + } + return NULL; +} + +static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id) +{ + stbtt_int32 i; + stbtt_int32 count = ttUSHORT(fc+nm+2); + stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4); + + for (i=0; i < count; ++i) { + stbtt_uint32 loc = nm + 6 + 12 * i; + stbtt_int32 id = ttUSHORT(fc+loc+6); + if (id == target_id) { + // find the encoding + stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); + + // is this a Unicode encoding? + if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { + stbtt_int32 slen = ttUSHORT(fc+loc+8); + stbtt_int32 off = ttUSHORT(fc+loc+10); + + // check if there's a prefix match + stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); + if (matchlen >= 0) { + // check for target_id+1 immediately following, with same encoding & language + if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { + slen = ttUSHORT(fc+loc+12+8); + off = ttUSHORT(fc+loc+12+10); + if (slen == 0) { + if (matchlen == nlen) + return 1; + } else if (matchlen < nlen && name[matchlen] == ' ') { + ++matchlen; + if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) + return 1; + } + } else { + // if nothing immediately following + if (matchlen == nlen) + return 1; + } + } + } + + // @TODO handle other encodings + } + } + return 0; +} + +static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags) +{ + stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name); + stbtt_uint32 nm,hd; + if (!stbtt__isfont(fc+offset)) return 0; + + // check italics/bold/underline flags in macStyle... + if (flags) { + hd = stbtt__find_table(fc, offset, "head"); + if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; + } + + nm = stbtt__find_table(fc, offset, "name"); + if (!nm) return 0; + + if (flags) { + // if we checked the macStyle flags, then just check the family and ignore the subfamily + if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; + } else { + if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; + if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; + } + + return 0; +} + +static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags) +{ + stbtt_int32 i; + for (i=0;;++i) { + stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); + if (off < 0) return off; + if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) + return off; + } +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" +#endif + +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, + float pixel_height, unsigned char *pixels, int pw, int ph, + int first_char, int num_chars, stbtt_bakedchar *chardata) +{ + return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); +} + +STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index) +{ + return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index); +} + +STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data) +{ + return stbtt_GetNumberOfFonts_internal((unsigned char *) data); +} + +STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset) +{ + return stbtt_InitFont_internal(info, (unsigned char *) data, offset); +} + +STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags) +{ + return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags); +} + +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +{ + return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +#endif // STB_TRUETYPE_IMPLEMENTATION + + +// FULL VERSION HISTORY +// +// 1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod +// 1.18 (2018-01-29) add missing function +// 1.17 (2017-07-23) make more arguments const; doc fix +// 1.16 (2017-07-12) SDF support +// 1.15 (2017-03-03) make more arguments const +// 1.14 (2017-01-16) num-fonts-in-TTC function +// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts +// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual +// 1.11 (2016-04-02) fix unused-variable warning +// 1.10 (2016-04-02) allow user-defined fabs() replacement +// fix memory leak if fontsize=0.0 +// fix warning from duplicate typedef +// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges +// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges +// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; +// allow PackFontRanges to pack and render in separate phases; +// fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); +// fixed an assert() bug in the new rasterizer +// replace assert() with STBTT_assert() in new rasterizer +// 1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine) +// also more precise AA rasterizer, except if shapes overlap +// remove need for STBTT_sort +// 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC +// 1.04 (2015-04-15) typo in example +// 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes +// 1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++ +// 1.01 (2014-12-08) fix subpixel position when oversampling to exactly match +// non-oversampled; STBTT_POINT_SIZE for packed case only +// 1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling +// 0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg) +// 0.9 (2014-08-07) support certain mac/iOS fonts without an MS platformID +// 0.8b (2014-07-07) fix a warning +// 0.8 (2014-05-25) fix a few more warnings +// 0.7 (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back +// 0.6c (2012-07-24) improve documentation +// 0.6b (2012-07-20) fix a few more warnings +// 0.6 (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels, +// stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty +// 0.5 (2011-12-09) bugfixes: +// subpixel glyph renderer computed wrong bounding box +// first vertex of shape can be off-curve (FreeSans) +// 0.4b (2011-12-03) fixed an error in the font baking example +// 0.4 (2011-12-01) kerning, subpixel rendering (tor) +// bugfixes for: +// codepoint-to-glyph conversion using table fmt=12 +// codepoint-to-glyph conversion using table fmt=4 +// stbtt_GetBakedQuad with non-square texture (Zer) +// updated Hello World! sample to use kerning and subpixel +// fixed some warnings +// 0.3 (2009-06-24) cmap fmt=12, compound shapes (MM) +// userdata, malloc-from-userdata, non-zero fill (stb) +// 0.2 (2009-03-11) Fix unsigned/signed char warnings +// 0.1 (2009-03-09) First public release +// + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +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. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +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. +------------------------------------------------------------------------------ +*/ diff --git a/src_v2/lumenarium_bsp.h b/src_v2/lumenarium_bsp.h new file mode 100644 index 0000000..65291bf --- /dev/null +++ b/src_v2/lumenarium_bsp.h @@ -0,0 +1,506 @@ +/* date = April 11th 2022 9:57 am */ + +#ifndef LUMENARIUM_BSP_H +#define LUMENARIUM_BSP_H + +// NOTE(PS): Functionality Notes +// - there must always be a root node that contains the area of the tree as a whole +// - a node with no children has not been split + +#define BTREE_NODE_ID_VALID_BIT (1 << 31) +typedef struct BSP_Node_Id BSP_Node_Id; +struct BSP_Node_Id +{ + u32 value; +}; + +typedef u8 BSP_Split_Kind; +enum +{ + BSPSplit_XAxis = 1, + BSPSplit_YAxis = 0, + BSPSplit_ZAxis = 2, + BSPSplit_None = 3, +}; + +typedef struct BSP_Split BSP_Split; +struct BSP_Split +{ + BSP_Split_Kind kind; + r32 value; +}; + +typedef u8 BSP_Split_Update_Flags; +enum +{ + BSPSplitUpdate_None = 0, + BSPSplitUpdate_FreeZeroAreaChildren = 1, +}; + +typedef u8 BSP_Child_Selector; +enum +{ + // NOTE(PS): these values are intentionally overlapping since + // they access the data structure of the B-Tree in a particular + // way. ie. left and top are the same space in memory as are + // right and bottom + BSPChild_Left = 0, + BSPChild_Top = 0, + + BSPChild_Right = 1, + BSPChild_Bottom = 1, +}; + +typedef struct BSP_Area BSP_Area; +struct BSP_Area +{ + v2 min; + v2 max; +}; + +typedef struct BSP_Node BSP_Node; +struct BSP_Node +{ + union + { + BSP_Node_Id parent; + BSP_Node_Id next_free; + }; + + BSP_Split split; + + union + { + BSP_Node_Id children[2]; + struct + { + union + { + BSP_Node_Id left; + BSP_Node_Id top; + }; + union + { + BSP_Node_Id right; + BSP_Node_Id bottom; + }; + }; + }; + u32 user_data; + + BSP_Area area; +}; + +typedef struct BSP BSP; +struct BSP +{ + BSP_Node* nodes; + u32 nodes_cap; + u32 nodes_len; + + BSP_Node_Id root; + BSP_Node_Id free_first; +}; + +typedef void BSP_Walk_Cb(BSP* tree, BSP_Node_Id id, BSP_Node* node, u8* user_data); + +internal BSP bsp_create(Allocator* allocator, u32 cap); + +internal BSP_Node* bsp_get(BSP* tree, BSP_Node_Id id); +internal BSP_Node_Id bsp_push(BSP* tree, BSP_Node_Id parent, BSP_Area area, u32 user_data); +internal void bsp_free(BSP* tree, BSP_Node_Id id); +internal void bsp_free_cb(BSP* tree, BSP_Node_Id id, BSP_Node* node, u8* user_data); + +typedef union BSP_Split_Result BSP_Split_Result; +union BSP_Split_Result +{ + BSP_Node_Id children[2]; + struct + { + union + { + BSP_Node_Id left; + BSP_Node_Id top; + }; + union + { + BSP_Node_Id right; + BSP_Node_Id bottom; + }; + }; +}; + +internal BSP_Split_Result bsp_split(BSP* tree, BSP_Node_Id id, r32 split, BSP_Split_Kind kind, u32 user_data_0, u32 user_data_1); +internal void bsp_join_recursive(BSP* tree, BSP_Node_Id parent_id, BSP_Child_Selector keep); + +// left, parent, right +internal void bsp_walk_inorder(BSP* tree, BSP_Node_Id first, BSP_Walk_Cb* cb, u8* user_data); +// parent, left right +internal void bsp_walk_preorder(BSP* tree, BSP_Node_Id first, BSP_Walk_Cb* cb, u8* user_data); +// parent, right, parent +internal void bsp_walk_postorder(BSP* tree, BSP_Node_Id first, BSP_Walk_Cb* cb, u8* user_data); + +internal void bsp_node_update_child_areas(BSP* tree, BSP_Node_Id id, BSP_Node* node, u8* user_data); +internal void bsp_node_area_update(BSP* tree, BSP_Node_Id id, BSP_Area new_area); +internal void bsp_child_split_update(BSP* tree, BSP_Node_Id node_id, r32 new_split, BSP_Split_Update_Flags flags); + +/////////////////////////////////////////////////// +// IMPLEMENTATION + + +internal BSP +bsp_create(Allocator* allocator, u32 cap) +{ + BSP result = {}; + zero_struct(result); + result.nodes_cap = cap; + result.nodes = allocator_alloc_array(allocator, BSP_Node, cap); + return result; +} + +#define bsp_node_id_is_valid(id) (has_flag(id.value, BTREE_NODE_ID_VALID_BIT)) +#define bsp_node_id_equals(a,b) (a.value == b.value) +#define bsp_node_id_to_index(id) (id.value & (u32)(~BTREE_NODE_ID_VALID_BIT)) + +internal BSP_Node* +bsp_get(BSP* tree, BSP_Node_Id id) +{ + if (!bsp_node_id_is_valid(id)) return 0; + u32 index = bsp_node_id_to_index(id); + if (index > tree->nodes_len) return 0; + return tree->nodes + index; +} + +internal BSP_Node_Id +bsp_push(BSP* tree, BSP_Node_Id parent_id, BSP_Area area, u32 user_data) +{ + BSP_Node_Id result = (BSP_Node_Id){0}; + BSP_Node* node = 0; + + if (tree->nodes_len >= tree->nodes_cap) + { + if (bsp_node_id_is_valid(tree->free_first)) + { + result = tree->free_first; + node = bsp_get(tree, result); + tree->free_first = node->next_free; + zero_struct(node->parent); + } + } + else + { + result.value = tree->nodes_len++; + assert(!has_flag(result.value, BTREE_NODE_ID_VALID_BIT)); + add_flag(result.value, BTREE_NODE_ID_VALID_BIT); + node = tree->nodes + bsp_node_id_to_index(result); + } + + if (bsp_node_id_is_valid(result)) + { + zero_struct(*node); + node->split.kind = BSPSplit_None; + node->parent = parent_id; + node->area = area; + node->user_data = user_data; + } + + return result; +} + +internal void +bsp_free_(BSP* tree, BSP_Node_Id id, BSP_Node* now_free) +{ + if (bsp_node_id_is_valid(now_free->parent)) + { + BSP_Node* parent = bsp_get(tree, now_free->parent); + if (bsp_node_id_equals(parent->children[0], id)) + { + zero_struct(parent->children[0]); + } + else if (bsp_node_id_equals(parent->children[1], id)) + { + zero_struct(parent->children[1]); + } + else + { + // NOTE(PS): in this case, a child node had a reference to + // a parent that didn't have a reference back to the child + // this means the tree itself is messed up + invalid_code_path; + } + } + + zero_struct(*now_free); + now_free->next_free = tree->free_first; + tree->free_first = id; +} + +internal void +bsp_free(BSP* tree, BSP_Node_Id id) +{ + BSP_Node* now_free = bsp_get(tree, id); + bsp_free_(tree, id, now_free); +} + +internal void +bsp_free_cb(BSP* tree, BSP_Node_Id id, BSP_Node* node, u8* user_data) +{ + bsp_free_(tree, id, node); +} + +internal BSP_Split_Result +bsp_split(BSP* tree, BSP_Node_Id node_id, r32 split, BSP_Split_Kind kind, u32 user_data_0, u32 user_data_1) +{ + BSP_Node* node = bsp_get(tree, node_id); + split = clamp(node->area.min.Elements[kind], split, node->area.max.Elements[kind]); + node->split.value = split; + node->split.kind = kind; + node->children[0] = bsp_push(tree, node_id, (BSP_Area){}, user_data_0); + node->children[1] = bsp_push(tree, node_id, (BSP_Area){}, user_data_1); + bsp_node_update_child_areas(tree, node_id, node, 0); + + BSP_Split_Result result = {}; + result.children[0] = node->children[0]; + result.children[1] = node->children[1]; + return result; +} + +internal void +bsp_join_recursive(BSP* tree, BSP_Node_Id parent_id, BSP_Child_Selector keep) +{ + BSP_Node* parent = bsp_get(tree, parent_id); + BSP_Node keep_node = *bsp_get(tree, parent->children[keep]); + bsp_walk_preorder(tree, parent->children[0], (BSP_Walk_Cb*)bsp_free_cb, 0); + bsp_walk_preorder(tree, parent->children[1], (BSP_Walk_Cb*)bsp_free_cb, 0); + parent->user_data = keep_node.user_data; + zero_struct(parent->children[0]); + zero_struct(parent->children[1]); +} + +// NOTE(PS): the other three walk functions all require allocation of a stack +// while this is fast with our scratch allocator, there are cases where, for +// correctness, we walk a tree that is very likely to be a single node. In +// those cases, we can avoid allocating anything by just visiting the single +// node and returning early. +// This function provides that functionality for all walk functions +internal bool +bsp_walk_single_node_check(BSP* tree, BSP_Node_Id first, BSP_Walk_Cb* visit, u8* user_data) +{ + BSP_Node* node = bsp_get(tree, first); + if (node->split.kind == BSPSplit_None) + { + visit(tree, first, node, user_data); + return true; + } + return false; +} + +// left, parent, right +internal void +bsp_walk_inorder(BSP* tree, BSP_Node_Id first, BSP_Walk_Cb* visit, u8* user_data) +{ + if (!bsp_node_id_is_valid(first)) return; + if (bsp_walk_single_node_check(tree, first, visit, user_data)) return; + scratch_get(scratch); + BSP_Node_Id* stack = allocator_alloc_array(scratch.a, BSP_Node_Id, tree->nodes_len); + u32 stack_len = 0; + memory_zero_array(stack, BSP_Node_Id, tree->nodes_len); + + BSP_Node_Id at = first; + while (true) + { + if (bsp_node_id_is_valid(at)) + { + stack[stack_len++] = at; + BSP_Node* n = bsp_get(tree, at); + at = n->children[0]; + } + else + { + if (stack_len == 0) break; + + at = stack[--stack_len]; + BSP_Node* n = bsp_get(tree, at); + visit(tree, at, n, user_data); + at = n->children[1]; + } + } + scratch_release(scratch); +} + +// parent, left right +internal void +bsp_walk_preorder(BSP* tree, BSP_Node_Id first, BSP_Walk_Cb* visit, u8* user_data) +{ + if (bsp_walk_single_node_check(tree, first, visit, user_data)) return; + scratch_get(scratch); + BSP_Node_Id* stack = allocator_alloc_array(scratch.a, BSP_Node_Id, tree->nodes_len); + u32 stack_len = 0; + memory_zero_array(stack, BSP_Node_Id, tree->nodes_len); + + BSP_Node_Id at = first; + + while (true) + { + while (bsp_node_id_is_valid(at)) + { + BSP_Node* n = bsp_get(tree, at); + visit(tree, at, n, user_data); + stack[stack_len++] = at; + at = n->children[0]; + } + + if (!bsp_node_id_is_valid(at) && stack_len == 0) break; + + at = stack[--stack_len]; + BSP_Node* n = bsp_get(tree, at); + at = n->children[1]; + } + scratch_release(scratch); +} + +// parent, right, parent +internal void +bsp_walk_postorder(BSP* tree, BSP_Node_Id first, BSP_Walk_Cb* visit, u8* user_data) +{ + if (bsp_walk_single_node_check(tree, first, visit, user_data)) return; + scratch_get(scratch); + BSP_Node_Id* stack = allocator_alloc_array(scratch.a, BSP_Node_Id, tree->nodes_len); + u32 stack_len = 0; + memory_zero_array(stack, BSP_Node_Id, tree->nodes_len); + + BSP_Node_Id at = first; + while (true) + { + if (bsp_node_id_is_valid(at)) + { + BSP_Node* n = bsp_get(tree, at); + if (bsp_node_id_is_valid(n->children[1])) stack[stack_len++] = n->children[1]; + stack[stack_len++] = at; + at = n->children[0]; + } + else + { + if (stack_len == 0) break; + + at = stack[--stack_len]; + BSP_Node* n = bsp_get(tree, at); + assert(n != 0); + + if (bsp_node_id_is_valid(n->children[1]) && bsp_node_id_equals(n->children[1], stack[stack_len - 1])) + { + BSP_Node_Id at_temp = stack[stack_len - 1]; + stack[stack_len - 1] = at; + at = at_temp; + } + else + { + visit(tree, at, n, user_data); + zero_struct(at); + } + } + } + scratch_release(scratch); +} + +internal void +bsp_node_update_child_areas(BSP* tree, BSP_Node_Id id, BSP_Node* node, u8* user_data) +{ + // assume that node's area is correct. Using that, clamp its split as appropriate + // and then update its children. If a child has an area of zero, rely on flags + // to determine behavior + + if (node->split.kind == BSPSplit_None) return; + + BSP_Split_Update_Flags flags = (BSP_Split_Update_Flags)0; + if (user_data) flags = *(BSP_Split_Update_Flags*)user_data; + + BSP_Split_Kind kind = node->split.kind; + + BSP_Node* node_min = bsp_get(tree, node->children[0]); + BSP_Node* node_max = bsp_get(tree, node->children[1]); + node_min->area = node->area; + node_max->area = node->area; + node_min->area.max.Elements[kind] = node->split.value; + node_max->area.min.Elements[kind] = node->split.value; + + if (has_flag(flags, BSPSplitUpdate_FreeZeroAreaChildren)) + { + bool free_children = false; + if (node_min->area.max.Elements[kind] <= node_min->area.min.Elements[kind]) + { + node->user_data = node_max->user_data; + free_children= true; + } + else if (node_max->area.max.Elements[kind] <= node_max->area.min.Elements[kind]) + { + node->user_data = node_min->user_data; + free_children= true; + } + + if (free_children) + { + bsp_walk_postorder(tree, node->children[0], bsp_free_cb, 0); + bsp_walk_postorder(tree, node->children[1], bsp_free_cb, 0); + } + + } + + // NOTE(PS): no need to recurse, this function assumes its either being + // called on a particular node or its the callback of one of the tree + // walk functions +} + +internal void +bsp_node_area_update(BSP* tree, BSP_Node_Id node_id, BSP_Area area) +{ + BSP_Node* node = bsp_get(tree, node_id); + node->area = area; + BSP_Split_Update_Flags flags = BSPSplitUpdate_FreeZeroAreaChildren; + bsp_walk_preorder(tree, node_id, bsp_node_update_child_areas, (u8*)&flags); +} + +internal void +bsp_child_split_update(BSP* tree, BSP_Node_Id node_id, r32 new_split, BSP_Split_Update_Flags flags) +{ + BSP_Node* node = bsp_get(tree, node_id); + node->split.value = new_split; + bsp_walk_preorder(tree, node_id, bsp_node_update_child_areas, (u8*)&flags); +} + +#if defined(DEBUG) + +internal void +bsp_tests() +{ + scratch_get(scratch); + BSP tree = bsp_create(scratch.a, 256); + tree.root = bsp_push(&tree, (BSP_Node_Id){0}, (BSP_Area){ (v2){0,0},(v2){512,512}}, 0); + + BSP_Split_Result r0 = bsp_split(&tree, tree.root, 256, BSPSplit_YAxis, 0, 0); + BSP_Node* root = bsp_get(&tree, tree.root); + BSP_Node* n0 = bsp_get(&tree, r0.children[0]); + BSP_Node* n1 = bsp_get(&tree, r0.children[1]); + assert(root != 0 && n0 != 0 && n1 != 0); + assert(HMM_EqualsVec2(n0->area.min, root->area.min)); + assert(n0->area.max.x == 256 && n0->area.max.y == root->area.max.y); + assert(HMM_EqualsVec2(n1->area.max, root->area.max)); + assert(n1->area.min.x == 256 && n0->area.min.y == root->area.min.y); + assert(n0->split.kind == BSPSplit_None); + assert(n1->split.kind == BSPSplit_None); + assert(root->split.kind == BSPSplit_YAxis); + + BSP_Split_Result r1 = bsp_split(&tree, root->children[0], 32, BSPSplit_YAxis, 0, 0); + BSP_Split_Result r2 = bsp_split(&tree, r1.children[1], 64, BSPSplit_XAxis, 0, 0); + + bsp_walk_postorder(&tree, root->children[0], bsp_free_cb, 0); + scratch_release(scratch); +} + +#else + +#define bsp_tests() + +#endif + +#endif //LUMENARIUM_BSP_H diff --git a/src_v2/lumenarium_first.c b/src_v2/lumenarium_first.c new file mode 100644 index 0000000..4939a85 --- /dev/null +++ b/src_v2/lumenarium_first.c @@ -0,0 +1,155 @@ +#include "lumenarium_first.h" +#include "user_space/incenter_user_space.c" + +void +sculpture_updated(App_State* state, r32 scale, r32 led_size) +{ + #if defined(PLATFORM_SUPPORTS_EDITOR) + ed_sculpture_updated(state, scale, led_size); + #endif +} + +internal App_State* +lumenarium_init(Editor_Desc* ed_desc) +{ + App_State* state = 0; + + permanent = bump_allocator_create_reserve(GB(1)); + global_scratch_ = bump_allocator_create_reserve(GB(1)); + + run_tests(); + + //cvtcsv_convert(lit_str("./data/incenter_test_data_clean.csv")); + + scratch_get(scratch); + App_Init_Desc desc = incenter_get_init_desc(); + // TODO(PS): make sure the values make sense in desc + + state = allocator_alloc_struct(permanent, App_State); + add_flag(state->flags, AppState_IsRunning); + +#if !defined(PLATFORM_raspi) + add_flag(state->flags, AppState_RunEditor); +#endif + + add_flag(state->flags, AppState_RunUserSpace); + + state->target_seconds_per_frame = 1.0 / 30.0; + + state->file_async_job_system = os_file_jobs_init(); + open_sockets_init(); + state->input_state = input_state_create(permanent); + + String exe_file_path = os_get_exe_path(scratch.a); + u64 run_tree_start = string_find_substring(exe_file_path, lit_str("run_tree"), 0, StringMatch_FindLast); + if (run_tree_start >= exe_file_path.cap) + { + u64 exe_path_start = string_find_substring(exe_file_path, lit_str("lumenarium"), 0, StringMatch_FindLast); + if (exe_path_start < exe_file_path.cap) + { + String run_tree_path = string_get_prefix(exe_file_path, exe_path_start); + String run_tree_path_nullterm = string_copy(run_tree_path, scratch.a); + os_pwd_set(run_tree_path_nullterm); + } + else + { + printf("Unable to set working directory\n"); + } + } + else + { + u64 run_tree_end = run_tree_start + lit_str("run_tree").len; + String run_tree_path = string_get_prefix(exe_file_path, run_tree_end); + String run_tree_path_nullterm = string_copy(run_tree_path, scratch.a); + os_pwd_set(run_tree_path_nullterm); + } + + + en_init(state, desc); +#if defined(PLATFORM_SUPPORTS_EDITOR) + if (has_flag(state->flags, AppState_RunEditor)) ed_init(state, ed_desc); +#endif + if (has_flag(state->flags, AppState_RunUserSpace)) incenter_init(state); + scratch_release(scratch); + return state; +} + +internal void +lumenarium_frame_prepare(App_State* state) +{ + allocator_clear(global_scratch_); + + input_state_swap_frames(state->input_state); + + en_frame_prepare(state); +#if defined(PLATFORM_SUPPORTS_EDITOR) + if (has_flag(state->flags, AppState_RunEditor)) ed_frame_prepare(state); +#endif + if (has_flag(state->flags, AppState_RunUserSpace)) incenter_frame_prepare(state); + + file_async_jobs_do_work(&state->file_async_job_system, 4, (u8*)state); +} + +internal void +lumenarium_frame(App_State* state) +{ + if (has_flag(state->flags, AppState_RunUserSpace)) incenter_frame(state); + en_frame(state); +#if defined(PLATFORM_SUPPORTS_EDITOR) + if (has_flag(state->flags, AppState_RunEditor)) ed_frame(state); +#endif +} + +internal void +lumenarium_event(Window_Event evt, App_State* state) +{ + Input_Frame* frame = state->input_state->frame_hot; + switch (evt.kind) + { + case WindowEvent_MouseScroll: + { + frame->mouse_scroll = evt.scroll_amt; + } break; + + case WindowEvent_MouseMoved: + { + v2 mouse_pos_old = frame->mouse_pos; + frame->mouse_pos = (v2){ (r32)evt.mouse_x, (r32)evt.mouse_y }; + state->input_state->mouse_pos_delta = HMM_SubtractVec2(frame->mouse_pos, mouse_pos_old); + } break; + + case WindowEvent_ButtonDown: + case WindowEvent_ButtonUp: + { + frame->key_flags[evt.key_code] = evt.key_flags; + if (evt.key_code == KeyCode_MouseLeftButton) + { + state->input_state->mouse_pos_down = (v2){ + (r32)evt.mouse_x, (r32)evt.mouse_y + }; + } + } break; + + case WindowEvent_Char: + { + frame->string_input[frame->string_input_len++] = evt.char_value; + } break; + + case WindowEvent_WindowClosed: + { + rem_flag(state->flags, AppState_IsRunning); + } break; + + invalid_default_case; + } +} + +internal void +lumenarium_cleanup(App_State* state) +{ + if (has_flag(state->flags, AppState_RunUserSpace)) incenter_cleanup(state); + en_cleanup(state); +#if defined(PLATFORM_SUPPORTS_EDITOR) + if (has_flag(state->flags, AppState_RunEditor)) ed_cleanup(state); +#endif +} diff --git a/src_v2/lumenarium_first.h b/src_v2/lumenarium_first.h new file mode 100644 index 0000000..e1037b8 --- /dev/null +++ b/src_v2/lumenarium_first.h @@ -0,0 +1,125 @@ +/* date = March 22nd 2022 2:29 am */ + +#ifndef LUMENARIUM_FIRST_H +#define LUMENARIUM_FIRST_H + +typedef struct App_State App_State; + +// Environment +#include "lumenarium_texture_atlas.c" +#include "lumenarium_geometry.h" + +global Allocator* global_scratch_; // gets reset at frame boundaries +// TODO make sure all scratch_get's have a release +#define scratch_get(ident) Allocator_Scratch ident = allocator_scratch_begin(global_scratch_) +#define scratch_release(ident) allocator_scratch_end(&ident) +#include "lumenarium_bsp.h" + +#include "patterns/patterns_math.h" + +// Engine +typedef struct Assembly_Strip Assembly_Strip; +typedef struct Assembly_Pixel_Buffer Assembly_Pixel_Buffer; +#include "engine/lumenarium_engine_output.h" +#include "engine/lumenarium_engine_assembly.h" +#include "engine/output/lumenarium_output_uart.h" +#include "engine/output/lumenarium_output_sacn.h" + +// Editor +#if defined(PLATFORM_SUPPORTS_EDITOR) +# include "editor/graphics/lumenarium_editor_opengl.h" +# include "editor/graphics/lumenarium_editor_graphics.h" +# include "editor/lumenarium_editor_ui.h" +# include "editor/lumenarium_editor_renderer.h" +# include "editor/lumenarium_editor.h" +#endif // PLATFORM_SUPPORTS_EDITOR + +////////////////////////////////////////////// +// Lumenarium Runtime Environment + +global Allocator* permanent; + +#if defined(DEBUG) +# include "lumenarium_tests.cpp" +#define lumenarium_env_validate() lumenarium_env_validate_() +#else +# define run_tests() +#define lumenarium_env_validate() +#endif + +internal void +lumenarium_env_validate_() +{ + bump_allocator_validate(permanent); + bump_allocator_validate(global_scratch_); + bump_allocator_validate(file_jobs_arena); + + core_socket_tests(); +} + + + +////////////////////////////////////////////// +// Lumenarium State + +typedef b32 App_State_Flags; +enum +{ + AppState_None = 0, + AppState_IsRunning = 1, + AppState_RunEditor = 2, + AppState_RunUserSpace = 4, +}; + +typedef struct App_Init_Desc App_Init_Desc; +struct App_Init_Desc +{ + u32 assembly_cap; +}; + +typedef struct App_State App_State; +struct App_State +{ + r64 target_seconds_per_frame; + App_State_Flags flags; + File_Async_Job_System file_async_job_system; + + Input_State* input_state; + + Assembly_Array assemblies; + Output output; + + #if defined(PLATFORM_SUPPORTS_EDITOR) + Editor* editor; + #endif + + u8* user_space_data; +}; + +typedef struct Editor_Desc Editor_Desc; +struct Editor_Desc +{ + v2 content_scale; + v2 init_window_dim; +}; + +void sculpture_updated(App_State* state, r32 scale, r32 led_size); + +#include "user_space/incenter_user_space.h" +//#include "../run_tree/data/incenter_test_data.c" + +#include "engine/lumenarium_engine_assembly.c" +#include "engine/lumenarium_engine.c" +#include "engine/lumenarium_engine_output.c" +#include "engine/output/lumenarium_output_uart.c" +#include "engine/output/lumenarium_output_sacn.c" + +#if defined(PLATFORM_SUPPORTS_EDITOR) +internal void incenter_sculpture_visualizer_ui(App_State* state, Editor* ed); +# include "editor/lumenarium_editor_ui.c" +# include "editor/lumenarium_editor_renderer.c" +# include "editor/lumenarium_editor_sculpture_visualizer.c" +# include "editor/lumenarium_editor.c" +#endif + +#endif //LUMENARIUM_FIRST_H diff --git a/src_v2/lumenarium_geometry.h b/src_v2/lumenarium_geometry.h new file mode 100644 index 0000000..533ebba --- /dev/null +++ b/src_v2/lumenarium_geometry.h @@ -0,0 +1,315 @@ +/* date = April 11th 2022 3:22 pm */ + +#ifndef LUMENARIUM_GEOMETRY_H +#define LUMENARIUM_GEOMETRY_H + +// Utility functions for working with 3d geometry + +// NOTE(PS): the Buffer vs Buffer_Builder distinction +// lets a static sized buffer exist, and be auto 'exported' or 'available' +// from a larger data structure that also stores enough data to incrementally +// build the buffer + +// NOTE(PS): @IMPORTANT!!! +// at the moment this builder doesn't support allowing for the elements +// of a vertex to be in an order other than position tex color +// and in any other packing than tightly packed +typedef u32 Geo_Vertex_Buffer_Storage; +enum +{ + GeoVertexBufferStorage_None = 0, + GeoVertexBufferStorage_Position = 1, + GeoVertexBufferStorage_TexCoord = 2, + GeoVertexBufferStorage_Color = 4 +}; + +typedef struct Geo_Vertex_Buffer Geo_Vertex_Buffer; +struct Geo_Vertex_Buffer +{ + r32* values; + u32 len; + Geo_Vertex_Buffer_Storage storage; + u32 stride; +}; + +typedef struct Geo_Vertex_Buffer_Builder Geo_Vertex_Buffer_Builder; +struct Geo_Vertex_Buffer_Builder +{ + union + { + Geo_Vertex_Buffer buffer; + struct + { + // NOTE(PS): @Maintainence + // this must always match the layout of Geo_Vertex_Buffer + r32* values; + u32 len; + Geo_Vertex_Buffer_Storage storage; + u32 stride; + }; + }; + u32 cap; +}; + +typedef struct Geo_Index_Buffer Geo_Index_Buffer; +struct Geo_Index_Buffer +{ + u32* values; + u32 len; +}; + +typedef struct Geo_Index_Buffer_Builder Geo_Index_Buffer_Builder; +struct Geo_Index_Buffer_Builder +{ + union + { + Geo_Index_Buffer buffer; + struct + { + // NOTE(PS): @Maintainence + // this must always match the layout of Geo_Index_Buffer + u32* values; + u32 len; + }; + }; + u32 cap; +}; + +typedef struct Geo_Quad_Buffer Geo_Quad_Buffer; +struct Geo_Quad_Buffer +{ + Geo_Vertex_Buffer buffer_vertex; + Geo_Index_Buffer buffer_index; +}; + +typedef struct Geo_Quad_Buffer_Builder Geo_Quad_Buffer_Builder; +struct Geo_Quad_Buffer_Builder +{ + Geo_Vertex_Buffer_Builder buffer_vertex; + Geo_Index_Buffer_Builder buffer_index; +}; + +internal Geo_Vertex_Buffer_Builder geo_vertex_buffer_builder_create(Allocator* a, u32 cap, Geo_Vertex_Buffer_Storage storage); +internal Geo_Index_Buffer_Builder geo_index_buffer_builder_create(Allocator* a, u32 cap); +internal Geo_Quad_Buffer_Builder ggeo_quad_buffer_builder_create(Allocator* a, u32 vertex_cap, Geo_Vertex_Buffer_Storage storage, u32 index_cap); + +// Vertex Buffer +internal u32 geo_vertex_buffer_builder_push_vtc(Geo_Vertex_Buffer_Builder* b, v3 v, v2 t, v4 c); +internal u32 geo_vertex_buffer_builder_push_vt(Geo_Vertex_Buffer_Builder* b, v3 v, v2 t); +internal u32 geo_vertex_buffer_builder_push_v(Geo_Vertex_Buffer_Builder* b, v3 v); + +// Index Buffer +internal u32 geo_index_buffer_builder_push(Geo_Index_Buffer_Builder* b, u32 i); +internal void geo_index_buffer_builder_push_tri(Geo_Index_Buffer_Builder* b, u32 i0, u32 i1, u32 i2); +internal void geo_index_buffer_builder_push_quad(Geo_Index_Buffer_Builder* b, u32 i0, u32 i1, u32 i2, u32 i3); + +// Quad Buffer +internal void geo_quad_buffer_builder_push_vtc(Geo_Quad_Buffer_Builder* b, v3 p0, v3 p1, v3 p2, v3 p3, v2 t0, v2 t1, v2 t2, v2 t3, v4 c); +internal void geo_quad_buffer_builder_push_vt(Geo_Quad_Buffer_Builder* b, v3 p0, v3 p1, v3 p2, v3 p3, v2 t0, v2 t1, v2 t2, v2 t3); +internal void geo_quad_buffer_builder_push_v(Geo_Quad_Buffer_Builder* b, v3 p0, v3 p1, v3 p2, v3 p3); +internal Geo_Quad_Buffer geo_quad_buffer_builder_get_static_buffer(Geo_Quad_Buffer_Builder* b); + +///////////////////////////////////////////// +// Implementation + +internal u32 +geo_vertex_buffer_builder_stride(Geo_Vertex_Buffer_Storage storage) +{ + u32 result = 0; + result += has_flag(storage, GeoVertexBufferStorage_Position) ? 3 : 0; + result += has_flag(storage, GeoVertexBufferStorage_TexCoord) ? 2 : 0; + result += has_flag(storage, GeoVertexBufferStorage_Color) ? 4 : 0; + return result; +} + +#ifdef DEBUG +# define geo_vertex_buffers_validate(g) geo_vertex_buffers_validate_(g) +#else +# define geo_vertex_buffers_validate(g) +#endif + +void +geo_vertex_buffers_validate_(Geo_Vertex_Buffer_Builder* b) +{ + // before start + u32* sentinel = (u32*)(b->values - 2); + assert(sentinel[0] == 0xF0F0F0F0); + assert(sentinel[1] == 0x0F0F0F0F); + + // after end + sentinel = (u32*)(b->values + (b->cap * b->stride)); + assert(sentinel[0] == 0xFFFF000F); + assert(sentinel[1] == 0xF000FFFF); +} + +internal Geo_Vertex_Buffer_Builder +geo_vertex_buffer_builder_create(Allocator* a, u32 cap, Geo_Vertex_Buffer_Storage storage) +{ + u32 stride = geo_vertex_buffer_builder_stride(storage); + u32 size = cap * stride; + u32 alloc_size = size; +#ifdef DEBUG + alloc_size += 4; +#endif + + Geo_Vertex_Buffer_Builder result = {}; + zero_struct(result); + result.cap = cap; + result.storage = storage; + result.stride = stride; + result.values = allocator_alloc_array(a, r32, alloc_size); + +#ifdef DEBUG + + u32* sentinel = (u32*)result.values; + sentinel[0] = 0xF0F0F0F0; + sentinel[1] = 0x0F0F0F0F; + sentinel = (u32*)(result.values + alloc_size - 2); + result.values += 2; + sentinel[0] = 0xFFFF000F; + sentinel[1] = 0xF000FFFF; +#endif + + geo_vertex_buffers_validate(&result); + return result; +} + +internal Geo_Index_Buffer_Builder +geo_index_buffer_builder_create(Allocator* a, u32 cap) +{ + Geo_Index_Buffer_Builder result = {}; + zero_struct(result); + result.cap = cap; + result.values = allocator_alloc_array(a, u32, cap); + return result; +} + +internal Geo_Quad_Buffer_Builder +geo_quad_buffer_builder_create(Allocator* a, u32 vertex_cap, Geo_Vertex_Buffer_Storage storage, u32 index_cap) +{ + Geo_Quad_Buffer_Builder result = {}; + result.buffer_vertex = geo_vertex_buffer_builder_create(a, vertex_cap, storage); + result.buffer_index = geo_index_buffer_builder_create(a, index_cap); + return result; +} + +// Vertex Buffer + +internal u32 +geo_vertex_buffer_builder_push_vtc(Geo_Vertex_Buffer_Builder* b, v3 v, v2 t, v4 c) +{ + geo_vertex_buffers_validate(b); + assert(b->len < b->cap); + u32 result = b->len++; + u32 offset = result * b->stride; + assert((offset + b->stride) <= (b->cap * b->stride)); + r32* at = b->values + offset; + if (has_flag(b->storage, GeoVertexBufferStorage_Position)) + { + *at++ = v.x; + *at++ = v.y; + *at++ = v.z; + } + if (has_flag(b->storage, GeoVertexBufferStorage_TexCoord)) + { + *at++ = t.x; + *at++ = t.y; + } + if (has_flag(b->storage, GeoVertexBufferStorage_Color)) + { + *at++ = c.x; + *at++ = c.y; + *at++ = c.z; + *at++ = c.w; + } + geo_vertex_buffers_validate(b); + return result; +} + +internal u32 +geo_vertex_buffer_builder_push_vt(Geo_Vertex_Buffer_Builder* b, v3 v, v2 t) +{ + return geo_vertex_buffer_builder_push_vtc(b, v, t, (v4){0}); +} + +internal u32 +geo_vertex_buffer_builder_push_v(Geo_Vertex_Buffer_Builder* b, v3 v) +{ + return geo_vertex_buffer_builder_push_vtc(b, v, (v2){0}, (v4){0}); +} + + +// Index Buffer + +internal u32 +geo_index_buffer_builder_push(Geo_Index_Buffer_Builder* b, u32 i) +{ + assert(b->len < b->cap); + u32 result = b->len++; + b->values[result] = i; + return result; +} + +internal void +geo_index_buffer_builder_push_tri(Geo_Index_Buffer_Builder* b, u32 i0, u32 i1, u32 i2) +{ + geo_index_buffer_builder_push(b, i0); + geo_index_buffer_builder_push(b, i1); + geo_index_buffer_builder_push(b, i2); +} + +internal void +geo_index_buffer_builder_push_quad(Geo_Index_Buffer_Builder* b, u32 i0, u32 i1, u32 i2, u32 i3) +{ + geo_index_buffer_builder_push_tri(b, i0, i1, i2); + geo_index_buffer_builder_push_tri(b, i0, i2, i3); +} + + +// Quad Buffer + +internal void +geo_quad_buffer_builder_push_vtc(Geo_Quad_Buffer_Builder* b, v3 p0, v3 p1, v3 p2, v3 p3, v2 t0, v2 t1, v2 t2, v2 t3, v4 c) +{ + u32 i0 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p0, t0, c); + u32 i1 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p1, t1, c); + u32 i2 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p2, t2, c); + u32 i3 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p3, t3, c); + + geo_index_buffer_builder_push_quad(&b->buffer_index, i0, i1, i2, i3); +} + +internal void +geo_quad_buffer_builder_push_vt(Geo_Quad_Buffer_Builder* b, v3 p0, v3 p1, v3 p2, v3 p3, v2 t0, v2 t1, v2 t2, v2 t3) +{ + u32 i0 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p0, t0, (v4){}); + u32 i1 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p1, t1, (v4){}); + u32 i2 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p2, t2, (v4){}); + u32 i3 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p3, t3, (v4){}); + + geo_index_buffer_builder_push_quad(&b->buffer_index, i0, i1, i2, i3); + // u32 base = 2869; + // geo_index_buffer_builder_push_quad(&b->buffer_index, base + 0, base + 1, base + 2, base + 3); +} + +internal void +geo_quad_buffer_builder_push_v(Geo_Quad_Buffer_Builder* b, v3 p0, v3 p1, v3 p2, v3 p3) +{ + u32 i0 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p0, (v2){}, (v4){}); + u32 i1 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p1, (v2){}, (v4){}); + u32 i2 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p2, (v2){}, (v4){}); + u32 i3 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p3, (v2){}, (v4){}); + + geo_index_buffer_builder_push_quad(&b->buffer_index, i0, i1, i2, i3); +} + +internal Geo_Quad_Buffer +geo_quad_buffer_builder_get_static_buffer(Geo_Quad_Buffer_Builder* b) +{ + Geo_Quad_Buffer result = {}; + result.buffer_vertex = b->buffer_vertex.buffer; + result.buffer_index = b->buffer_index.buffer; + return result; +} + +#endif //LUMENARIUM_GEOMETRY_H diff --git a/src_v2/lumenarium_input.cpp b/src_v2/lumenarium_input.cpp new file mode 100644 index 0000000..d983076 --- /dev/null +++ b/src_v2/lumenarium_input.cpp @@ -0,0 +1,102 @@ + + +// TODO(PS) @DEPRECATE - new os layer + +#define INPUT_FRAME_STRING_LENGTH 32 +struct Input_Frame +{ + Platform_Key_Flags key_flags[KeyCode_Count]; + + char string_input[INPUT_FRAME_STRING_LENGTH]; + u32 string_input_len; + + v2 mouse_pos; + s32 mouse_scroll; +}; + +struct Input_State +{ + Input_Frame frames[2]; + Input_Frame* frame_hot; + Input_Frame* frame_cold; + + // cross frame state tracking + v2 mouse_pos_delta; + v2 mouse_pos_down; +}; + +#define key_was_down(key_flags) has_flag((key_flags), KeyFlag_State_WasDown) +#define key_is_down(key_flags) has_flag((key_flags), KeyFlag_State_IsDown) +#define key_was_up(key_flags) (!has_flag((key_flags), KeyFlag_State_WasDown)) +#define key_is_up(key_flags) (!has_flag((key_flags), KeyFlag_State_IsDown)) + +internal Input_State* +input_state_create(Allocator* a) +{ + Input_State* result = allocator_alloc_struct(a, Input_State); + result->frame_hot = result->frames + 0; + result->frame_cold = result->frames + 1; + return result; +} + +internal Platform_Key_Flags +input_key_advance(Platform_Key_Flags flag) +{ + Platform_Key_Flags result = flag; + if (key_is_down(flag)) + { + add_flag(result, KeyFlag_State_WasDown); + } + if (key_is_up(flag)) + { + rem_flag(result, KeyFlag_State_WasDown); + } + return result; +} + +internal void +input_state_swap_frames(Input_State* input_state) +{ + Input_Frame* next_hot = input_state->frame_cold; + input_state->frame_cold = input_state->frame_hot; + input_state->frame_hot = next_hot; + + // Clear the new hot input frame + Platform_Key_Flags* hot_key_flags = input_state->frame_hot->key_flags; + Platform_Key_Flags* cold_key_flags = input_state->frame_cold->key_flags; + for (u32 i = 0; i < KeyCode_Count; i++) + { + hot_key_flags[i] = input_key_advance(cold_key_flags[i]); + } + input_state->frame_hot->string_input_len = 0; +} + +// Key State Queries + +internal bool +input_key_is_down(Input_State* input_state, Platform_Key_Code key) +{ + Platform_Key_Flags flags = input_state->frame_hot->key_flags[key]; + return key_is_down(flags); +} + +internal bool +input_key_went_down(Input_State* input_state, Platform_Key_Code key) +{ + Platform_Key_Flags flags = input_state->frame_hot->key_flags[key]; + return key_is_down(flags) && !key_was_down(flags); +} + +internal bool +input_key_is_up(Input_State* input_state, Platform_Key_Code key) +{ + Platform_Key_Flags flags = input_state->frame_hot->key_flags[key]; + return !key_is_down(flags); +} + +internal bool +input_key_went_up(Input_State* input_state, Platform_Key_Code key) +{ + Platform_Key_Flags flags = input_state->frame_hot->key_flags[key]; + return !key_is_down(flags) && key_was_down(flags); +} diff --git a/src_v2/lumenarium_memory.cpp b/src_v2/lumenarium_memory.cpp new file mode 100644 index 0000000..71e4f94 --- /dev/null +++ b/src_v2/lumenarium_memory.cpp @@ -0,0 +1,568 @@ +// TODO(PS) @DEPRECATE - new os layer + +///////////////////////////////////////// +// Memory Functions + +void +memory_zero_no_simd(u8* base, u64 size) +{ + for (u64 i = 0; i < size; i++) base[i] = 0; +} + +void +memory_copy_no_simd(u8* from, u8* to, u64 size) +{ + for (u64 i = 0; i < size; i++) to[i] = from[i]; +} + +#if defined(PLATFORM_HAS_SIMD) + +// TODO(PS): +// TODO(PS): +// TODO(PS): + +void +memory_zero_simd(u8* base, u64 size) +{ + memory_zero_no_simd(base, size); +} + +void +memory_copy_simd(u8* from, u8* to, u64 size) +{ + memory_copy_no_simd(from, to, size); +} + +# define memory_zero_(b,s) memory_zero_simd((b),(s)) +# define memory_copy_(f,t,s) memory_copy_simd((f),(t),(s)) + +#else +# define memory_zero_(b,s) memory_zero_no_simd((b),(s)) +# define memory_copy_(f,t,s) memory_copy_no_simd((f),(t),(s)) + +#endif // defined(PLATFORM_HAS_SIMD) + +#define zero_struct(s) memory_zero((u8*)(&s), sizeof(s)) + +internal void memory_zero(u8* base, u64 size) { memory_zero_(base, size); } +internal void memory_copy(u8* from, u8* to, u64 size) { + memory_copy_(from, to, size); +} + +u64 +round_size_to_page_multiple(u64 size, u64 page_size) +{ + u64 rem = size % page_size; + if (rem != 0 || size < page_size) + { + u64 grow = page_size - rem; + size += grow; + } + return size; +} + +u64 +round_size_to_page_multiple(u64 size) +{ + u64 page_size = platform_page_size(); + return round_size_to_page_multiple(size, page_size); +} + +///////////////////////////////////////// +// Allocator +// +// A generic interface for any memory-providing construct +// +// To implement a complete allocator, all that is really required +// is to create its Allocator_Alloc function + +internal void +allocator_destroy_(Allocator* allocator, u64 custom_data_size) +{ + zero_struct(*allocator); + u64 size = sizeof(Allocator) + custom_data_size; + platform_mem_decommit((u8*)allocator, size); + platform_mem_release((u8*)allocator, size); +} + +///////////////////////////////////////// +// Bump Allocator + +struct Allocator_Bump +{ + u8* base; + u64 at; + u64 size_committed; + u64 size_reserved; + u64 page_size; + u64 high_water_mark; +}; + +internal u8* +bump_allocator_alloc_inner(Allocator* allocator, Allocator_Bump* bump, u64 size) +{ + u64 at_after = bump->at + size; + // TODO(PS): align up to 8 bytes + + if (at_after >= bump->size_committed) + { + // determine new size of the arena + u64 new_size = bump->size_committed * 2; + if (new_size == 0) + { + if (bump->page_size == 0) bump->page_size = platform_page_size(); + new_size = bump->page_size; + } + if (new_size < at_after) + { + new_size = round_size_to_page_multiple(at_after, bump->page_size); + } + + if (allocator->parent) + { + bump->base = allocator_realloc( + allocator->parent, + bump->base, + bump->size_committed, + new_size + ); + if (bump->base != 0) + { + bump->size_reserved = new_size; + bump->size_committed = new_size; + } + } + else + { + if (new_size <= bump->size_reserved) + { + u64 next_page = round_size_to_page_multiple(bump->at); + if (bump->at == 0 && bump->size_committed == 0) next_page = 0; + u64 commit_amt = new_size - next_page; + u8* new_page = platform_mem_commit(bump->base + next_page, commit_amt); + if (new_page != 0) + { + bump->size_committed = new_size; + } + } + else + { + invalid_code_path; // out of reserved memory + } + } + } + + u8* result = bump->base + bump->at; + bump->at = at_after; + bump->high_water_mark = max(bump->at, bump->high_water_mark); + return result; +} + +internal u8* +bump_allocator_alloc(Allocator* allocator, u64 size) +{ + Allocator_Bump* bump = (Allocator_Bump*)allocator->allocator_data; + u8* result = bump_allocator_alloc_inner(allocator, bump, size); + return result; +} + +internal u8* +bump_allocator_realloc(Allocator* allocator, u8* base, u64 old_size, u64 new_size) +{ + u8* result = bump_allocator_alloc(allocator, new_size); + memory_copy(base, result, old_size); + return result; +} + +internal void +bump_allocator_clear(Allocator* allocator) +{ + if (!allocator->allocator_data) return; + Allocator_Bump* bump = (Allocator_Bump*)allocator->allocator_data; + bump->at = 0; +} + +internal void +bump_allocator_destroy_(Allocator_Bump* bump) +{ + platform_mem_decommit(bump->base, bump->size_committed); + platform_mem_release(bump->base, bump->size_reserved); +} + +internal void +bump_allocator_destroy(Allocator* allocator) +{ + Allocator_Bump* bump = (Allocator_Bump*)allocator->allocator_data; + bump_allocator_destroy_(bump); + allocator_destroy_(allocator, sizeof(Allocator_Bump)); +} + +internal void +bump_allocator_rewind(Allocator* allocator, u64 to_point) +{ + Allocator_Bump* bump = (Allocator_Bump*)allocator->allocator_data; +#if defined(DEBUG) + memory_zero(bump->base + to_point, bump->at - to_point); +#endif + bump->at = to_point; +} + +internal Allocator* +bump_allocator_create_() +{ + u64 size_needed = sizeof(Allocator) + sizeof(Allocator_Bump); + + u8* base = platform_mem_reserve(size_needed); + base = platform_mem_commit(base, size_needed); + + Allocator* result = (Allocator*)base; + zero_struct(*result); + + Allocator_Bump* bump = (Allocator_Bump*)base + sizeof(Allocator); + zero_struct(*bump); + + result->alloc = bump_allocator_alloc; + result->realloc = bump_allocator_realloc; + result->clear = bump_allocator_clear; + result->destroy = bump_allocator_destroy; + result->allocator_data = (u8*)bump; + + return result; +} + +internal Allocator* +bump_allocator_create_reserve(u64 reserve_size) +{ + Allocator* result = bump_allocator_create_(); + Allocator_Bump* bump = (Allocator_Bump*)result->allocator_data; + + u64 reserve_pages = round_size_to_page_multiple(reserve_size); + bump->base = platform_mem_reserve(reserve_pages); + if (bump->base != 0) bump->size_reserved = reserve_pages; + + return result; +} + +internal Allocator* +bump_allocator_create_child(Allocator* parent, u64 init_size) +{ + Allocator* result = bump_allocator_create_(); + result->parent = parent; + + Allocator_Bump* bump = (Allocator_Bump*)result->allocator_data; + zero_struct(*bump); + bump->base = allocator_alloc(result->parent, init_size); + if (bump->base != 0) + { + bump->size_reserved = init_size; + bump->size_committed = init_size; + } + + return result; +} + + +///////////////////////////////////////// +// Scratch Allocator + +struct Allocator_Scratch +{ + Allocator* a; + u64 at_before; + + Allocator_Scratch(Allocator* allocator) + { + this->a = allocator; + Allocator_Bump* bump = (Allocator_Bump*)this->a->allocator_data; + this->at_before = bump->at; + } + + ~Allocator_Scratch() + { + bump_allocator_rewind(this->a, this->at_before); + } +}; + +///////////////////////////////////////// +// Paged Allocator + +struct Allocator_Paged_Free_Region +{ + u64 pages; + Allocator_Paged_Free_Region* prev; + Allocator_Paged_Free_Region* next; +}; + +struct Allocator_Paged +{ + Allocator_Bump bump; + Allocator_Paged_Free_Region* free_first; +}; + +internal u8* +paged_allocator_alloc(Allocator* allocator, u64 size) +{ + // 1. Find the number of pages we need + // 2. Find a run of free pages that we can use + // If found, + // remove those pages from the run they are in + // return those pages of memory + // 3. Commit pages on the end + + Allocator_Paged* paged = (Allocator_Paged*)allocator->allocator_data; + if (paged->bump.page_size == 0) paged->bump.page_size = platform_page_size(); + + u64 rounded_size = round_size_to_page_multiple(size, paged->bump.page_size); + u64 pages_needed = rounded_size / paged->bump.page_size; + + u8* result = 0; + + // Find free pages + if (paged->free_first) + { + Allocator_Paged_Free_Region* found = 0; + for (Allocator_Paged_Free_Region* at = paged->free_first; at != 0; at = at->next) + { + // NOTE(PS): this set of conditions checks to see if is bigger than what + // we need. If it is, we also check to see if this is smaller than any + // region we've found before. And we abort the search if this region + // perfectly fits the size needed. + // + // This should make sure that we are always choosing the closest fit we + // can. I'm not sure this is the best strategy for dealing with fragmentation + // but its a decent first pass + if (at->pages >= pages_needed) + { + if (!found || (found->pages > at->pages)) + { + found = at; + if (found->pages == pages_needed) break; + } + } + } + + if (found) + { + result = (u8*)found; + if (found->pages > pages_needed) + { + Allocator_Paged_Free_Region* region_after = (Allocator_Paged_Free_Region*)(result + rounded_size); + if (found->prev != 0) found->prev->next = region_after; + region_after = found->next; + } + else + { + if (found->prev != 0) found->prev->next = found->next; + } + } + } + + if (!result) + { + result = bump_allocator_alloc_inner(allocator, &paged->bump, size); + } + + return result; +} + +#define region_end(r,page_size) ((u8*)(r) + ((r)->pages * page_size)) + +internal void +paged_region_insert( + Allocator_Paged_Free_Region* before, + Allocator_Paged_Free_Region* new_region, + Allocator_Paged_Free_Region* after, + u64 page_size + ){ + assert(after == 0 || before < after); + assert(before < new_region); + assert(after == 0 || new_region < after); + assert(new_region->prev == 0 && new_region->next == 0); + + u8* before_end = region_end(before, page_size); + u8* new_region_end = region_end(new_region, page_size); + + // Before + if (before_end == (u8*)new_region) + { + // merge the regions + before->pages += new_region->pages; + new_region = before; + assert(new_region_end == region_end(new_region, page_size)); + } + else + { + assert(before_end < (u8*)new_region); + before->next = new_region; + new_region->prev = before; + } + + // After + if (after != 0) + { + if (new_region_end == (u8*)after) + { + // merge the regions + new_region->pages += after->pages; + u8* a = region_end(after, page_size); + u8* b = region_end(new_region, page_size); + assert(a == b); + } + else + { + assert(new_region_end < (u8*)after); + new_region->next = after; + after->prev = new_region; + } + } +} + +internal void +paged_allocator_free(Allocator* allocator, u8* base, u64 size) +{ + // Figure out which page base is the base of, assert its the base + // figure out how many pages size represents. + // create a free range + // stick it in between contiguous free ranges + // if the ranges before or after meet this new one, merge them all + + Allocator_Paged* paged = (Allocator_Paged*)allocator->allocator_data; + + u64 page_base_rel = (base - paged->bump.base); + assert((page_base_rel % paged->bump.page_size) == 0); + u64 page_index = page_base_rel / paged->bump.page_size; + u64 size_pages_mult = round_size_to_page_multiple(size, paged->bump.page_size); + assert((size_pages_mult % paged->bump.page_size) == 0); + u64 page_count = size_pages_mult / paged->bump.page_size; + + Allocator_Paged_Free_Region* region = (Allocator_Paged_Free_Region*)base; + zero_struct(*region); + region->pages = page_count; + + Allocator_Paged_Free_Region* prev = 0; + Allocator_Paged_Free_Region* next = 0; + for (Allocator_Paged_Free_Region* at = paged->free_first; at != 0; at = at->next) + { + if (at < region) + { + prev = at; + next = at->next; + if (next != 0) + { + assert(next > region); + assert((u8*)next >= ((u8*)region + size_pages_mult)); + } + } + } + + if (prev && next) + { + // found a region to insert into + paged_region_insert(prev, region, next, paged->bump.page_size); + } + else if (prev) + { + // got to the end and all were before the free region in memory + paged_region_insert(prev, region, 0, paged->bump.page_size); + } + else + { + // free list is empty + region->next = 0; + paged->free_first = region; + } +} + +internal u8* +paged_allocator_realloc(Allocator* allocator, u8* base, u64 old_size, u64 new_size) +{ + // TODO(PS): + // Process: + // 1. Figure out which page base starts on + // 2. Find if there is a free region after base that is big enough to house + // the new size + // 3. If there is a free region, pull the needed memory out of it + // 4. Otherwise, alloc new_size, copy base into it, and free base + + // TODO(PS): you could do a simple version where you just always alloc, copy, free + return 0; +} + +internal void +paged_allocator_clear(Allocator* allocator) +{ + if (!allocator->allocator_data) return; + Allocator_Paged* paged = (Allocator_Paged*)allocator->allocator_data; + paged->bump.at = 0; + paged->free_first = 0; +} + +internal void +paged_allocator_destroy(Allocator* allocator) +{ + Allocator_Paged* paged = (Allocator_Paged*)allocator->allocator_data; + bump_allocator_destroy_(&paged->bump); + allocator_destroy_(allocator, sizeof(Allocator_Paged)); +} + +internal Allocator* +paged_allocator_create_() +{ + u64 size_needed = sizeof(Allocator) + sizeof(Allocator_Bump); + + u8* base = platform_mem_reserve(size_needed); + base = platform_mem_commit(base, size_needed); + + Allocator* result = (Allocator*)base; + zero_struct(*result); + + Allocator_Bump* bump = (Allocator_Bump*)base + sizeof(Allocator); + zero_struct(*bump); + + result->alloc = paged_allocator_alloc; + result->free = paged_allocator_free; + result->realloc = paged_allocator_realloc; + result->clear = paged_allocator_clear; + result->destroy = paged_allocator_destroy; + result->allocator_data = (u8*)bump; + + return result; +} + +internal Allocator* +paged_allocator_create_reserve(u64 reserve_size, u64 page_size) +{ + Allocator* result = paged_allocator_create_(); + Allocator_Paged* paged = (Allocator_Paged*)result->allocator_data; + + u64 reserve_pages = round_size_to_page_multiple(reserve_size); + paged->bump.page_size = page_size; + paged->bump.base = platform_mem_reserve(reserve_pages); + if (paged->bump.base != 0) paged->bump.size_reserved = reserve_pages; + + return result; +} + +internal Allocator* +paged_allocator_create_reserve(u64 reserve_size) +{ + u64 page_size = platform_page_size(); + return paged_allocator_create_reserve(reserve_size, page_size); +} + +internal Allocator* +paged_allocator_create_child(Allocator* parent, u64 init_size) +{ + Allocator* result = bump_allocator_create_(); + result->parent = parent; + + Allocator_Paged* paged = (Allocator_Paged*)result->allocator_data; + paged->bump.base = allocator_alloc(result->parent, init_size); + if (paged->bump.base != 0) + { + paged->bump.size_reserved = init_size; + paged->bump.size_committed = init_size; + } + + return result; +} diff --git a/src_v2/lumenarium_memory.h b/src_v2/lumenarium_memory.h new file mode 100644 index 0000000..b18a813 --- /dev/null +++ b/src_v2/lumenarium_memory.h @@ -0,0 +1,47 @@ +// TODO(PS) @DEPRECATE - new os layer + +/* date = April 6th 2022 7:55 pm */ + +#ifndef LUMENARIUM_MEMORY_H +#define LUMENARIUM_MEMORY_H + +///////////////////////////////////////// +// Allocator + +typedef struct Allocator Allocator; + +typedef u8* Allocator_Alloc(Allocator* allocator, u64 size); +typedef void Allocator_Free(Allocator* allocator, u8* base, u64 size); +typedef u8* Allocator_Realloc(Allocator* allocator, u8* base, u64 old_size, u64 new_size); +typedef void Allocator_Clear(Allocator* allocator); +typedef void Allocator_Destroy(Allocator* allocator); + +struct Allocator +{ + Allocator_Alloc* alloc; + Allocator_Free* free; + Allocator_Realloc* realloc; + Allocator_Clear* clear; + Allocator_Destroy* destroy; + + Allocator* parent; + + u8* allocator_data; +}; + +#define allocator_alloc(a,s) (a)->alloc((a),(s)) +#define allocator_alloc_struct(a,t) (t*)(a)->alloc((a),sizeof(t)) +#define allocator_alloc_array(a,t,c) (t*)(a)->alloc((a),sizeof(t)*(c)) + +#define allocator_free(a,b,s) (a)->free((a),(b),(s)) +#define allocator_free_struct(a,b,t) (a)->free((a),(b),sizeof(t)) +#define allocator_free_array(a,b,t,c) (a)->free((a),(b),sizeof(t)*(c)) + +#define allocator_realloc(a,b,os,ns) (a)->realloc((a),(b),(os),(ns)) +#define allocator_realloc_array(a,b,t,oc,nc) (t*)(a)->realloc((a),(b),sizeof(t)*(oc),sizeof(t)*(nc)) + +#define allocator_clear(a) (a)->clear(a) +#define allocator_destroy(a) (a)->destroy(a) + +internal Allocator* paged_allocator_create_reserve(u64 reserve_size, u64 page_size); +#endif //LUMENARIUM_MEMORY_H diff --git a/src_v2/lumenarium_tests.cpp b/src_v2/lumenarium_tests.cpp new file mode 100644 index 0000000..f5a48c5 --- /dev/null +++ b/src_v2/lumenarium_tests.cpp @@ -0,0 +1,259 @@ +#include <fcntl.h> +#include <unistd.h> + +Thread_Result +thread_proc(Thread_Data* td) +{ + //Sleep(100); + return (Thread_Result){}; +} + +void +memory_allocator_tests(Allocator* a, bool run_free_tests) +{ + // TestGroup("Allocator Push") + { + for (uint32_t i = 0; i < 3; i++) + { + uint8_t* buf0 = allocator_alloc(a, 256); + buf0[0] = 200; + buf0[255] = 199; + assert(buf0[0] == 200); + assert(buf0[255] == 199); + + uint8_t* buf1 = allocator_alloc(a, 256); + buf1[0] = 201; + buf1[255] = 202; + assert(buf1 >= (buf0 + 256)); + assert(buf0[0] == 200); + assert(buf0[255] == 199); + assert(buf1[0] == 201); + assert(buf1[255] == 202); + + allocator_clear(a); + } + } + + // TestGroup("Allocator Free") + if (run_free_tests) + { + for (uint32_t i = 0; i < 3; i++) + { + uint8_t* buf0 = allocator_alloc(a, KB(4)); + uint8_t* buf1 = allocator_alloc(a, KB(4)); + uint8_t* buf2 = allocator_alloc(a, KB(4)); + uint8_t* buf3 = allocator_alloc(a, KB(4)); + uint8_t* buf4 = allocator_alloc(a, KB(4)); + assert((buf1 - buf0) >= KB(4)); + assert((buf2 - buf0) >= KB(8)); + assert((buf3 - buf0) >= KB(12)); + assert((buf4 - buf0) >= KB(16)); + + allocator_free(a, buf1, KB(4)); + allocator_free(a, buf2, KB(4)); + uint8_t* buf5 = allocator_alloc(a, KB(7)); + // buf5 should get put in the place of buf1 since buf1 and 2 get + // merged + assert(buf5 == buf1); + + allocator_free(a, buf4, KB(4)); + allocator_free(a, buf3, KB(4)); + allocator_free(a, buf0, KB(4)); + uint8_t* buf6 = allocator_alloc(a, KB(4)); + assert(buf0 == buf6); + + allocator_clear(a); + } + } +} + +void +memory_tests() +{ + // TestGroup("Platform Allocation") + { + u64 size = GB(32); +#if defined(PLATFORM_wasm) + size = KB(4); +#elif defined(PLATFORM_raspi) + size = KB(32); +#endif + + uint8_t* base = os_mem_reserve(size); + os_mem_commit(base, KB(4)); + base[4095] = 200; + assert(base[4095] == 200); + os_mem_commit(base + KB(4), KB(4)); + base[5000] = 200; + assert(base[5000] == 200); + os_mem_decommit(base, KB(8)); + os_mem_release(base, size); + } + + Allocator* bump = bump_allocator_create_reserve(KB(32)); + memory_allocator_tests(bump, false); + allocator_destroy(bump); + + Allocator* paged = paged_allocator_create_reserve(KB(32), KB(4)); + memory_allocator_tests(paged, true); + allocator_destroy(paged); +} + +enum test_flags +{ + TestNone = 0, + Test1 = 1, + Test2 = 2, + Test3 = 4, + Test4 = 8, +}; + +static void +run_tests() +{ + scratch_get(scratch); + + // basic + + uint8_t b = TestNone; + assert(!has_flag(b, TestNone)); + assert(!has_flag(b, Test1)); + add_flag(b, Test1); + assert(has_flag(b, Test1)); + assert(!has_flag(b, Test2)); + add_flag(b, Test2); + assert(has_flag(b, Test1)); + assert(has_flag(b, Test2)); + assert(has_flag(b, Test1 | Test2)); + add_flag(b, Test4); + assert(has_flag(b, Test1)); + assert(has_flag(b, Test2)); + assert(has_flag(b, Test4)); + assert(has_flag(b, Test1 | Test2 | Test4)); + assert(!has_flag(b, Test3)); + rem_flag(b, Test2); + assert(has_flag(b, Test1)); + assert(!has_flag(b, Test2)); + assert(has_flag(b, Test4)); + assert(has_flag(b, Test1 | Test4)); + assert(!has_flag(b, Test3)); + + // memory tests + uint8_t* r0 = os_mem_reserve(1024); + uint8_t* r1 = os_mem_commit(r0, 512); + for (uint32_t i = 0; i < 512; i++) r1[i] = i; + os_mem_decommit(r1, 512); + os_mem_release(r0, 1024); + // r0[256] = 100; // this should break if you uncomment + + uint8_t* a0 = allocator_alloc_array(scratch.a, uint8_t, 32); + uint8_t* a1 = allocator_alloc_array(scratch.a, uint8_t, 32); + assert(a0 != a1); + assert((a0 + 32) <= a1); + + a1[0] = 25; + + for (uint32_t i = 0; i < 32; i++) + { + a0[i] = (uint8_t)i; + a1[i] = (uint8_t)(100 + i); + } + + + for (uint32_t i = 0; i < 32; i++) + { + assert(a0[i] == i); + assert(a1[i] == (100 + i)); + } + + + assert(round_up_to_pow2_u32(1) == 1); + assert(round_up_to_pow2_u32(3) == 4); + assert(round_up_to_pow2_u32(29) == 32); + assert(round_up_to_pow2_u32(32) == 32); + assert(round_up_to_pow2_u32(120) == 128); + + + memory_tests(); + bsp_tests(); + +#if defined(PLATFORM_wasm) + // NOTE(PS): the tests below this point don't make sense on a web assembly + // platform + return; +#endif + + // OS Atomics + { + u32 v = 232; + u32 v0 = os_interlocked_increment(&v); + assert(v0 == 233); + assert(v == 233); + + bool ice0 = os_interlocked_cmp_exchg(&v, 232, 235); // fails, old value != v + assert(!ice0); + assert(v == 233); + bool ice1 = os_interlocked_cmp_exchg(&v, 233, 235); + assert(ice1); + assert(v == 235); + } + + + // testing strings and exe path + String exe_file_path = os_get_exe_path(scratch.a); + assert(exe_file_path.str != 0); + u64 run_tree_start = string_find_substring(exe_file_path, lit_str("run_tree"), 0, StringMatch_FindLast); + u64 run_tree_end = run_tree_start + lit_str("run_tree").len; + assert(run_tree_start < exe_file_path.len); + String run_tree_path = string_get_prefix(exe_file_path, run_tree_end); + String run_tree_path_nullterm = string_copy(run_tree_path, scratch.a); + assert(run_tree_path_nullterm.len > 0); + assert(os_pwd_set(run_tree_path_nullterm)); + + String td = lit_str("Testing data"); + + // testing file io + String fp = lit_str("text.txt"); + File_Handle f = os_file_open(fp, FileAccess_Write, FileCreate_OpenAlways); + assert(f.value != 0); + + String s = lit_str("foooooooooobbbbbbaaaarrrrrr"); + Data d1 = { s.str, s.len }; + bool r = os_file_write_all(f, d1); + assert(r); + + os_file_close(f); + f = os_file_open(fp, FileAccess_Read, FileCreate_OpenExisting); + assert(f.value != 0); + + File_Info i = os_file_get_info(f, scratch.a); + + Data d0 = os_file_read_all(f, scratch.a); + assert(d0.size > 0); + + os_file_close(f); + + if (!os_file_delete(fp)) { + invalid_code_path; + } + + +#if 0 + // TODO(PS): these were causing startup problems but you weren't focusing on + // threads/ When you build something multithreaded come back here and + // make tests that actually work + + // testing threads + Platform_Thread_Handle threads[8]; + for (uint32_t j = 0; j < 8; j++) + { + threads[j] = platform_thread_begin(thread_proc, 0); + } + + for (uint32_t j = 0; j < 8; j++) + { + platform_thread_end(threads[j]); + } +#endif + scratch_release(scratch); +} \ No newline at end of file diff --git a/src_v2/lumenarium_texture_atlas.c b/src_v2/lumenarium_texture_atlas.c new file mode 100644 index 0000000..92cc764 --- /dev/null +++ b/src_v2/lumenarium_texture_atlas.c @@ -0,0 +1,190 @@ +/* date = March 31st 2022 8:30 pm */ + +#ifndef LUMENARIUM_TEXTURE_ATLAS_CPP +#define LUMENARIUM_TEXTURE_ATLAS_CPP + +typedef struct Texture_Atlas_Sprite Texture_Atlas_Sprite; +struct Texture_Atlas_Sprite +{ + u16 min_x; + u16 min_y; + u16 max_x; + u16 max_y; + + v2 draw_offset; +}; + +typedef struct Texture_Atlas Texture_Atlas; +struct Texture_Atlas +{ + u8* pixels; + u32 width; + u32 height; + + u32 next_x; + u32 next_y; + u32 y_used; + + u32* ids; + Texture_Atlas_Sprite* sprites; + u32 cap; + u32 used; +}; + +internal Texture_Atlas +texture_atlas_create(u32 width, u32 height, u32 cap, Allocator* allocator) +{ + Texture_Atlas result = {}; + result.pixels = allocator_alloc_array(allocator, u8, width * height * 4); + result.width = (u16)width; + result.height = (u16)height; + for (u32 i = 0; i < width * height; i++) { + u8* base = result.pixels + (i * 4); + *(u32*)base = 0xFF00FFFF; + } + + result.ids = allocator_alloc_array(allocator, u32, cap); + result.sprites = allocator_alloc_array(allocator, Texture_Atlas_Sprite, cap); + result.cap = cap; + hash_table_init(result.ids, cap); + return result; +} + +enum Texture_Atlas_Registration_Flags +{ + TextureAtlasRegistration_None = 0, + TextureAtlasRegistration_PixelFormat_RGBA = 1, + TextureAtlasRegistration_PixelFormat_Alpha = 2, +}; + +internal void +texture_atlas_register(Texture_Atlas* ta, u8* pixels, u32 width, u32 height, u32 id, v2 draw_offset, u32 flags) +{ + if (ta->next_x > ta->width || (ta->next_x + width + 2) > ta->width) + { + ta->next_x = 0; + ta->next_y = ta->y_used; + } + + u32 min_x = ta->next_x + 1; + u32 min_y = ta->next_y + 1; + u32 max_x = min_x + width; + u32 max_y = min_y + height; + + // copy the data + if (has_flag(flags, TextureAtlasRegistration_PixelFormat_RGBA)) + { + for (u32 y = 0; y < height; y++) + { + u32 src_row = (y * width) * 4; + u32 dst_row = (((y + min_y) * ta->width) + min_x) * 4; + for (u32 x = 0; x < width; x++) + { + ta->pixels[dst_row++] = pixels[src_row++]; + ta->pixels[dst_row++] = pixels[src_row++]; + ta->pixels[dst_row++] = pixels[src_row++]; + ta->pixels[dst_row++] = pixels[src_row++]; + } + } + } + else if (has_flag(flags, TextureAtlasRegistration_PixelFormat_Alpha)) + { + for (u32 y = 0; y < height; y++) + { + u32 src_row = y * width; + u32 dst_row = (((y + min_y) * ta->width) + min_x) * 4; + for (u32 x = 0; x < width; x++) + { + ta->pixels[dst_row++] = 0xFF; + ta->pixels[dst_row++] = 0xFF; + ta->pixels[dst_row++] = 0xFF; + ta->pixels[dst_row++] = pixels[src_row++]; + } + } + } + + // copy nearest pixels to the border + u32 pi_width = ta->width; + u32 pi_stride = 4; +#define PIXEL_INDEX(x,y) ((((y) * pi_width) + (x)) * pi_stride) +#define COPY_PIXEL(db,sb) \ +ta->pixels[(db) + 0] = ta->pixels[(sb) + 0]; \ +ta->pixels[(db) + 1] = ta->pixels[(sb) + 1]; \ +ta->pixels[(db) + 2] = ta->pixels[(sb) + 2]; \ +ta->pixels[(db) + 3] = ta->pixels[(sb) + 3]; + + for (u32 x = 0; x < width; x++) + { + u32 top = PIXEL_INDEX(min_x + x, min_y - 1); + u32 top_near = PIXEL_INDEX(min_x + x, min_y); + u32 bot = PIXEL_INDEX(min_x + x, max_y); + u32 bot_near = PIXEL_INDEX(min_x + x, max_y - 1); + COPY_PIXEL(top, top_near); + COPY_PIXEL(bot, bot_near); + } + + for (u32 y = 0; y < height + 2; y++) + { + u32 left = PIXEL_INDEX(min_x - 1, min_y + y - 1); + u32 left_near = PIXEL_INDEX(min_x, min_y + y - 1); + u32 right = PIXEL_INDEX(max_x, min_y + y - 1); + u32 right_near = PIXEL_INDEX(max_x - 1, min_y + y - 1); + COPY_PIXEL(left, left_near); + COPY_PIXEL(right, right_near); + } + +#undef PIXEL_INDEX +#undef COPY_PIXEL + + // register a new slot + u32 index = hash_table_register(ta->ids, ta->cap, id); + + Texture_Atlas_Sprite* sprite = ta->sprites + index; + sprite->min_x = (u16)min_x; + sprite->min_y = (u16)min_y; + sprite->max_x = (u16)max_x; + sprite->max_y = (u16)max_y; + sprite->draw_offset = draw_offset; + + // Prepare for next registration + if (max_y > ta->y_used) + { + ta->y_used = max_y + 2; + } + + ta->next_x = max_x + 2; +} + +internal Texture_Atlas_Sprite +texture_atlas_sprite_get(Texture_Atlas* ta, u32 id) +{ + Texture_Atlas_Sprite result = {}; + u32 index = hash_table_find(ta->ids, ta->cap, id); + if (index == ta->cap) return result; + result = ta->sprites[index]; + return result; +} + +internal v4 +texture_atlas_sprite_get_uvs(Texture_Atlas* ta, Texture_Atlas_Sprite sprite) +{ + v4 result = {}; + + // uv min + result.x = (r32)sprite.min_x / (r32)ta->width; + result.y = (r32)sprite.min_y / (r32)ta->height; + + // uv max + result.z = (r32)sprite.max_x / (r32)ta->width; + result.w = (r32)sprite.max_y / (r32)ta->height; + + return result; +} + +internal v4 +texture_atlas_sprite_id_get_uvs(Texture_Atlas* ta, u32 id) +{ + Texture_Atlas_Sprite sprite = texture_atlas_sprite_get(ta, id); + return texture_atlas_sprite_get_uvs(ta, sprite); +} +#endif //LUMENARIUM_TEXTURE_ATLAS_CPP diff --git a/src_v2/lumenarium_types.h b/src_v2/lumenarium_types.h new file mode 100644 index 0000000..b83427c --- /dev/null +++ b/src_v2/lumenarium_types.h @@ -0,0 +1,361 @@ +// TODO(PS) @DEPRECATE - new os layer + +/* date = March 22nd 2022 2:08 am */ + +#ifndef LUMENARIUM_TYPES_H +#define LUMENARIUM_TYPES_H + +#define internal static +#define local_persist static +#define global static +#define local_const static const +#define global_const static const +#define external extern "C" + +#if defined(GUESS_INTS) +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; +typedef signed long long s64; +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +#else +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +#endif + +typedef s8 b8; +typedef s32 b32; +typedef s64 b64; + +typedef float r32; +typedef double r64; + +#define u8_max 0xFF +#define u16_max 0xFFFF +#define u32_max 0xFFFFFFFF +#define u64_max 0xFFFFFFFFFFFFFFFF + +#define s8_max 127 +#define s16_max 32767 +#define s32_max 2147483647 +#define s64_max 9223372036854775807 + +#define s8_min -127 - 1 +#define s16_min -32767 - 1 +#define s32_min -2147483647 - 1 +#define s64_min -9223372036854775807 - 1 + +#define r32_max 3.402823466e+38f +#define r32_min -3.402823466e+38f +#define r32_smallest_positive 1.1754943508e-38f +#define r32_epsilon 5.96046448e-8f +#define r32_pi 3.14159265359f +#define r32_half_pi 1.5707963267f +#define r32_tau 6.28318530717f + +#define r64_max 1.79769313486231e+308 +#define r64_min -1.79769313486231e+308 +#define r64_smallest_positive 4.94065645841247e-324 +#define r64_epsilon 1.11022302462515650e-16 +#define r64_pi 3.14159265359 +#define r64_half_pi 1.5707963267 +#define r64_tau 6.28318530717 + +#define NanosToSeconds 1 / 10000000.0 +#define SecondsToNanos 10000000.0 + + +#define get_byte(value, byte_index) ((value >> (8 * byte_index)) & 0xFF) + +struct Data +{ + u8* base; + u64 size; +}; + +internal Data +data_create(u8* base, u64 size) +{ + Data result = {}; + result.base = base; + result.size = size; + return result; +} + +#define memory_zero_array(b,t,c) memory_zero((u8*)(b), sizeof(t) * (c)) +internal void memory_zero(u8* base, u64 size); +internal void memory_copy(u8* from, u8* to, u64 size); + +////////////////////////////////////////////// +// Math + +#ifndef max +# define max(a,b) (a) > (b) ? (a) : (b) +#endif + +#ifndef min +# define min(a,b) (a) > (b) ? (b) : (a) +#endif + +// #define lerp(a,t,b) (a) + ((1.0f - (t)) * (b)) +// #define clamp(r0,v,r1) min((r1),max((r0),(v))) +// #define lerp_clamp(a,t,b) clamp((a),lerp((a),(t),(b)),(b)) + +////////////////////////////////////////////// +// String + +// NOTE(PS): even though this has a len and cap, it should always be +// null terminated +struct String +{ + u8* str; + u64 len; + u64 cap; +}; + +internal String string_create(u8* str, u64 len, u64 cap); +internal u64 string_copy_to(String* dest, String src); + +////////////////////////////////////////////// +// Data Writer + +struct Data_Writer +{ + Data data; + u64 at; +}; + +// NOTE(PS): functions ending in _b treat data in the Data_Writer as big endian +// order (network ordering) where functions ending in _l treat data into little +// endian order +// It is always assumed that values not in the Data_Writer (ie the other args +// to the function or the functions return value) are in little endian order + +internal void +dw_put_u8(Data_Writer* w, u8 b) +{ + if (w->at < w->data.size) + { + w->data.base[w->at++] = b; + } +} + +internal u8 +dw_get_u8(Data_Writer* w) +{ + u8 result = 0; + if (w->at < w->data.size) + { + result = w->data.base[w->at]; + } + return result; +} + +internal void +dw_put_u16_b(Data_Writer* w, u16 b) +{ + dw_put_u8(w, get_byte(b, 1)); + dw_put_u8(w, get_byte(b, 0)); +} + +internal void +dw_put_u16_l(Data_Writer* w, u16 b) +{ + dw_put_u8(w, get_byte(b, 0)); + dw_put_u8(w, get_byte(b, 1)); +} + +internal void +dw_put_u32_b(Data_Writer* w, u32 b) +{ + dw_put_u8(w, get_byte(b, 3)); + dw_put_u8(w, get_byte(b, 2)); + dw_put_u8(w, get_byte(b, 1)); + dw_put_u8(w, get_byte(b, 0)); +} + +internal void +dw_put_u32_l(Data_Writer* w, u32 b) +{ + dw_put_u8(w, get_byte(b, 0)); + dw_put_u8(w, get_byte(b, 1)); + dw_put_u8(w, get_byte(b, 2)); + dw_put_u8(w, get_byte(b, 3)); +} + +internal void +dw_put_u64_b(Data_Writer* w, u64 b) +{ + dw_put_u8(w, get_byte(b, 7)); + dw_put_u8(w, get_byte(b, 6)); + dw_put_u8(w, get_byte(b, 5)); + dw_put_u8(w, get_byte(b, 4)); + dw_put_u8(w, get_byte(b, 3)); + dw_put_u8(w, get_byte(b, 2)); + dw_put_u8(w, get_byte(b, 1)); + dw_put_u8(w, get_byte(b, 0)); +} + +internal void +dw_put_u64_l(Data_Writer* w, u64 b) +{ + dw_put_u8(w, get_byte(b, 0)); + dw_put_u8(w, get_byte(b, 1)); + dw_put_u8(w, get_byte(b, 2)); + dw_put_u8(w, get_byte(b, 3)); + dw_put_u8(w, get_byte(b, 4)); + dw_put_u8(w, get_byte(b, 5)); + dw_put_u8(w, get_byte(b, 6)); + dw_put_u8(w, get_byte(b, 7)); +} + +internal void +dw_put_str(Data_Writer* w, String str) +{ + for (u64 i = 0; i < str.len; i++) + { + dw_put_u8(w, str.str[i]); + } +} + +internal void +dw_put_str_min_len(Data_Writer* w, String str, u64 min_len) +{ + u64 start = w->at; + dw_put_str(w, str); + if (str->len < min_len) + { + w->at = start + min_len; + } +} + +internal void +dw_put_str_min_len_nullterm(Data_Writer* w, String str, u64 min_len) +{ + dw_put_str_min_len(w, str, min_len); + w->data.base[w->at - 1] = '\0'; +} + +// TODO(PS): get functions + +#define Bytes(x) (x) +#define KB(x) ((x) << 10) +#define MB(x) ((x) << 20) +#define GB(x) (((u64)x) << 30) +#define TB(x) (((u64)x) << 40) + +#define has_flag(data, flag) (((data) & (flag)) != 0) +#define has_flag_only(data, flag) (((data) & (flag)) == (data)) +#define add_flag(data, flag) ((data) |= (flag)) +#define rem_flag(data, flag) ((data) &= (~(flag))) + +////////////////////////////////////////////// +// List Helper Macros + +#define sll_push(first,last,ele) \ +if (!(first)) { (first) = (ele); }\ +else { (last)->next = (ele); } \ +(last) = (ele); (ele)->next = 0; + +// TODO(PS): Stack, Queue, DLL ops + +////////////////////////////////////////////// +// Hash Table +// +// Rather than define a data structure, to allow the most flexibility, +// this is just a set of functions that can be integrated into other +// routines. +// In general, they expect you to track a u32* of ids and a u32 capacity + +internal void +hash_table_init(u32* ids, u32 cap) +{ + for (u32 i = 0; i < cap; i++) ids[i] = 0; +} + +internal u32 +hash_table_find_(u32* ids, u32 cap, u32 start_id, u32 target_value) +{ + u32 index = start_id % cap; + u32 start = index; + do { + if (ids[index] == target_value) break; + index = (index + 1) % cap; + } while (index != start); + return index; +} + +internal u32 +hash_table_register(u32* ids, u32 cap, u32 new_id) +{ + u32 index = hash_table_find_(ids, cap, new_id, 0); + if (ids[index] != 0) return cap; + ids[index] = new_id; + return index; +} + +internal u32 +hash_table_find(u32* ids, u32 cap, u32 value) +{ + u32 result = hash_table_find_(ids, cap, value, value); + if (ids[result] != value) return cap; + return result; +} + +////////////////////////////////////////////// +// Math + +internal u32 +round_up_to_pow2(u32 v) +{ + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v++; + return v; +} + +////////////////////////////////////////////// +// Vector Extensions + +#define v2_to_v3(xy,z) v3{(xy).x, (xy).y, (z)} +#define v2_floor(v) v2{ floorf(v.x), floorf(v.y) } +#define v3_floor(v) v3{ floorf(v.x), floorf(v.y), floorf(v.z) } + +internal bool +rect2_contains(v2 min, v2 max, v2 point) +{ + return ( + min.x <= point.x && min.y <= point.y && + max.x >= point.x && max.y >= point.y + ); +} + +////////////////////////////////////////////// +// Color Constants + +#define WHITE_V4 v4{1,1,1,1} +#define BLACK_V4 v4{0,0,0,1} +#define RED_V4 v4{1,0,0,1} +#define GREEN_V4 v4{0,1,0,1} +#define BLUE_V4 v4{0,0,1,1} +#define YELLOW_V4 v4{1,1,0,1} +#define TEAL_V4 v4{0,1,1,1} +#define PINK_V4 v4{1,0,1,1} + +typedef struct Allocator Allocator; + + +#endif //LUMENARIUM_TYPES_H diff --git a/src_v2/patterns/patterns_math.h b/src_v2/patterns/patterns_math.h new file mode 100644 index 0000000..b5b434d --- /dev/null +++ b/src_v2/patterns/patterns_math.h @@ -0,0 +1,420 @@ +#ifndef PATTERNS_MATH_H +#define PATTERNS_MATH_H + +r32 fractf(r32 v) { r64 int_part = 0; return (r32)modf((r64)v, &int_part); } + +r32 +pm_smoothstep_r32(r32 t) +{ + r32 r = (t * t * (3 - (2 * t))); + return r; +} + +r32 +pm_smoothstep_range_r32(r32 t, r32 min, r32 max) +{ + r32 tt = pm_smoothstep_r32(t); + r32 r = lerp(min, tt, max); + return r; +} + +v3 +pm_smoothstep_v3(v3 p) +{ + v3 result = { + .x = pm_smoothstep_r32(p.x), + .y = pm_smoothstep_r32(p.y), + .z = pm_smoothstep_r32(p.z), + }; + return result; +} + +r32 +pm_easein_cubic_r32(r32 v) +{ + assert(v >= 0 && v <= 1); + return 4 * v * v * v; +} + +r32 +pm_easeout_cubic_r32(r32 v) +{ + assert(v >= 0 && v <= 1); + r32 a = -2 * v + 2; + r32 a3 = a * a * a; + return 1 - a3 / 2; +} + +r32 +pm_easeinout_cubic_r32(r32 v) +{ + assert(v >= 0 && v <= 1); + // Equation: + // [0,0.5) = 4 * v^3 + // [0.5,1] = 1 - (-2 * v + 2)^3 / 2 + if (v < 0.5f) { + return 4 * v * v * v; + } else { + r32 a = -2 * v + 2; + r32 a3 = a * a * a; + return 1 - a3 / 2; + } +} + +///// vector extensions + +v2 pm_lerp_v2(v2 a, r32 t, v2 b) { + return (v2){ + .x = lerp(a.x, t, b.x), + .y = lerp(a.y, t, b.y), + }; +} +v3 pm_lerp_v3(v3 a, r32 t, v3 b) { + return (v3){ + .x = lerp(a.x, t, b.x), + .y = lerp(a.y, t, b.y), + .z = lerp(a.z, t, b.z), + }; +} +v4 pm_lerp_v4(v4 a, r32 t, v4 b) { + return (v4){ + .x = lerp(a.x, t, b.x), + .y = lerp(a.y, t, b.y), + .z = lerp(a.z, t, b.z), + .w = lerp(a.w, t, b.w), + }; +} + +v2 pm_abs_v2(v2 v) { return (v2){ .x = fabsf(v.x), .y = fabsf(v.y) }; } +v3 pm_abs_v3(v3 v) { return (v3){ .x = fabsf(v.x), .y = fabsf(v.y), .z = fabsf(v.z) }; } +v4 pm_abs_v4(v4 v) { return (v4){ .x = fabsf(v.x), .y = fabsf(v.y), .z = fabsf(v.z), .w = fabsf(v.w) }; } + +v2 pm_floor_v2(v2 v) { return (v2){ .x = floorf(v.x), .y = floorf(v.y) }; } +v3 pm_floor_v3(v3 v) { return (v3){ .x = floorf(v.x), .y = floorf(v.y), .z = floorf(v.z) }; } +v4 pm_floor_v4(v4 v) { return (v4){ .x = floorf(v.x), .y = floorf(v.y), .z = floorf(v.z), .w = floorf(v.w) }; } + +v2 pm_fract_v2(v2 v) { return (v2){ .x = fractf(v.x), .y = fractf(v.y) }; } +v3 pm_fract_v3(v3 v) { return (v3){ .x = fractf(v.x), .y = fractf(v.y), .z = fractf(v.z) }; } +v4 pm_fract_v4(v4 v) { return (v4){ .x = fractf(v.x), .y = fractf(v.y), .z = fractf(v.z), .w = fractf(v.w) }; } + +r32 pm_sinf_01(r32 v) { return 0.5f + (0.5f * sinf(v)); } +r32 pm_cosf_01(r32 v) { return 0.5f + (0.5f * cosf(v)); } + +v2 pm_sin_v2(v2 v) { return (v2){ .x = sinf(v.x), .y = sinf(v.y) }; } +v3 pm_sin_v3(v3 v) { return (v3){ .x = sinf(v.x), .y = sinf(v.y), .z = sinf(v.z) }; } +v4 pm_sin_v4(v4 v) { return (v4){ .x = sinf(v.x), .y = sinf(v.y), .z = sinf(v.z), .w = sinf(v.w) }; } + +v2 pm_cos_v2(v2 v) { return (v2){ .x = cosf(v.x), .y = cosf(v.y) }; } +v3 pm_cos_v3(v3 v) { return (v3){ .x = cosf(v.x), .y = cosf(v.y), .z = cosf(v.z) }; } +v4 pm_cos_v4(v4 v) { return (v4){ .x = cosf(v.x), .y = cosf(v.y), .z = cosf(v.z), .w = cosf(v.w) }; } + +////// hash functions + +r32 +pm_hash_v2_to_r32(v2 p) +{ + v2 r = HMM_MultiplyVec2f(p, 0.3183099f); + r = pm_fract_v2(r); + r = HMM_MultiplyVec2f(r, 50); + r32 result = fractf(r.x * r.y * (r.x + r.y)); + return result; +} + +r32 +pm_hash_r32_to_r32(r32 n) +{ + return fractf(n * 17 * fractf(n * 0.3183099f)); +} + +v2 +pm_hash_r32_to_v2(r32 n) +{ + v2 a = pm_sin_v2((v2){ n, n + 1.0f }); + v2 b = HMM_MultiplyVec2(a, (v2){ 43758.5453123f, 22578.1459123f }); + v2 r = pm_fract_v2(b); + return r; +} + +v2 +pm_hash_v2_to_v2(v2 p) +{ + v2 k = (v2){ 0.3183099f, 0.3678794f }; + v2 kp = (v2){k.y, k.x}; + v2 r0 = HMM_MultiplyVec2(p, k); + v2 r1 = HMM_AddVec2(r0, kp); + r32 f = 16.0f * fractf(p.x * p.y * (p.x + p.y)); + v2 r2 = HMM_MultiplyVec2f(k, f); + v2 r3 = pm_fract_v2(r2); + return r3; +} + +v3 +pm_hash_v2_to_v3(v2 p) +{ + v3 q = (v3){ + .x = HMM_DotVec2(p, (v2){127.1f, 311.7f}), + .y = HMM_DotVec2(p, (v2){267.5f, 183.3f}), + .z = HMM_DotVec2(p, (v2){419.2f, 371.9f}) + }; + v3 r0 = pm_sin_v3(q); + v3 r1 = HMM_MultiplyVec3f(r0, 43758.5453f); + v3 r2 = pm_fract_v3(r1); + return r2; +} + +r32 +pm_hash_v3_to_r32(v3 p) +{ + v3 p0 = HMM_MultiplyVec3f(p, 0.3183099f); + v3 p1 = HMM_AddVec3(p0, (v3){ 0.1f, 0.1f, 0.1f }); + v3 p2 = pm_fract_v3(p1); + v3 p3 = HMM_MultiplyVec3f(p2, 17.0f); + r32 r0 = fractf(p3.x * p3.y * p3.z * (p3.x + p3.y + p3.z)); + return r0; +} + +r32 +pm_random_v2_to_r32(v2 n) +{ + v2 v = (v2){ 12.9898f, 4.1414f }; + r32 r0 = HMM_DotVec2(n, v); + r32 r1 = sinf(r0); + r32 r2 = fractf(r1 * 43758.5453); + return r2; +} + +internal r32 +pm_noise_v3_to_r32(v3 p) +{ + p = pm_abs_v3(p); + v3 p_fl = pm_floor_v3(p); + v3 p_fr = pm_fract_v3(p); + v3 f = pm_smoothstep_v3(p_fr); + + v3 p_fl_0 = p_fl; + v3 p_fl_1 = HMM_AddVec3(p_fl, (v3){1, 0, 0}); + v3 p_fl_2 = HMM_AddVec3(p_fl, (v3){0, 1, 0}); + v3 p_fl_3 = HMM_AddVec3(p_fl, (v3){1, 1, 0}); + v3 p_fl_4 = HMM_AddVec3(p_fl, (v3){0, 0, 1}); + v3 p_fl_5 = HMM_AddVec3(p_fl, (v3){1, 0, 1}); + v3 p_fl_6 = HMM_AddVec3(p_fl, (v3){0, 1, 1}); + v3 p_fl_7 = HMM_AddVec3(p_fl, (v3){1, 1, 1}); + + r32 h0 = pm_hash_v3_to_r32(p_fl_0); + r32 h1 = pm_hash_v3_to_r32(p_fl_1); + r32 h2 = pm_hash_v3_to_r32(p_fl_2); + r32 h3 = pm_hash_v3_to_r32(p_fl_3); + r32 h4 = pm_hash_v3_to_r32(p_fl_4); + r32 h5 = pm_hash_v3_to_r32(p_fl_5); + r32 h6 = pm_hash_v3_to_r32(p_fl_6); + r32 h7 = pm_hash_v3_to_r32(p_fl_7); + + r32 h0_1 = lerp(h0, f.x, h1); + r32 h2_3 = lerp(h2, f.x, h3); + r32 h4_5 = lerp(h4, f.x, h5); + r32 h6_7 = lerp(h6, f.x, h7); + r32 h01_23 = lerp(h0_1, f.y, h2_3); + r32 h45_67 = lerp(h4_5, f.y, h6_7); + // r32 result = lerp( + // lerp( + // lerp(h0, f.x, h1), + // f.y, + // lerp(h2, f.x, h3) + // ), + // f.z, + // lerp( + // lerp(h4, f.x, h5), + // f.y, + // lerp(h6, f.x, h7) + // ) + // ); + r32 result = lerp(h01_23, f.z, h45_67); + + assert(result >= 0 && result <= 1); + return result; +} + +r32 +pm_fmb_3d(v3 x, r32 h) +{ + // r32 G = powf(2, -h); + // r32 f = 1.0f; + // r32 a = 1.0f; + // r32 t = 0.0f; + // for(s32 i = 0; i < 4; i++) + // { + // v3 xx = HMM_MultiplyVec3f(x, f); + // r32 n = pm_noise_v3_to_r32(xx); + // t += a * n; + // f *= 2.0f; + // a *= G; + // } + // return (t - .17f) / 1.2f; + + // float t = 0.0; + // for(s32 i = 0; i < 4; i++) + // { + // r32 f = powf(2.0, (r32)(i)); + // r32 a = powf(f, -h); + // r32 n = pm_noise_v3_to_r32( + // HMM_MultiplyVec3f(x, f) + // ); + // r32 ns = a * n; + // t += ns; + // } + // return t; + + v3 ts = (v3){h, h, h}; + v3 pp = x; + r32 f = 0.0; + + v3 pp0 = HMM_AddVec3(pp, ts); + v3 pp1 = HMM_SubtractVec3(pp, ts); + + f += 0.500000f * pm_noise_v3_to_r32(pp0); pp = HMM_MultiplyVec3f(pp, 2.02); + f += 0.300000f * pm_noise_v3_to_r32(pp1); pp = HMM_MultiplyVec3f(pp, 2.03); + f += 0.125000f * pm_noise_v3_to_r32(pp); pp = HMM_MultiplyVec3f(pp, 2.01); + f += 0.062500f * pm_noise_v3_to_r32(pp0); pp = HMM_MultiplyVec3f(pp, 2.04); + + r32 d = 0.9875f; + f = f / d; + return f; +} + +// internal r32 +// pm_voronoise(v2 p, r32 u, r32 v) +// { +// r32 k = 1.0f + 63.0f + powf(1.0f - v, 6.0f); + +// v2 i = pm_floor_v2(p); +// v2 f = pm_fract_v2(p); + +// v2 a = (v2){0, 0}; +// for (s32 y = -2; y <= 2; y++) +// { +// for (s32 x = -2; x <= 2; x++) +// { +// v2 g = (v2){(r32)x, (r32)y}; +// v2 hi = HMM_AddVec2(g, i); +// v3 h = pm_hash_v2_to_v3(hi); +// v3 o = HMM_MultiplyVec3(h, (v3){ u, u, 1.0f }); +// v2 d0 = HMM_SubtractVec2(g, f); +// v2 d1 = HMM_AddVec2(d0, o.XY); +// r32 d1m = HMM_LengthVec2(d1); +// r32 w = powf(1.0f - pm_smoothstep_range_r32(d1m, 0.0f, 1.414f), k); +// a = HMM_AddVec2(a, (v2){o.z * w, w}); +// } +// } + +// return a.x / a.y; +// } + + +// Color ramps + +typedef struct { + r32 pct; + v3 color; +} Color_Ramp_Anchor; + +typedef struct { + Color_Ramp_Anchor anchors[8]; + u32 anchors_count; +} Color_Ramp; + +Color_Ramp +color_ramp_reverse(Color_Ramp ramp) +{ + Color_Ramp result = { .anchors_count = ramp.anchors_count }; + for (u32 i = 0; i < ramp.anchors_count; i++) + { + u32 new_i = (ramp.anchors_count - 1) - i; + assert(new_i < ramp.anchors_count); + r32 rev_pct = 1.f - ramp.anchors[i].pct; + result.anchors[new_i] = (Color_Ramp_Anchor){ + .color = ramp.anchors[i].color, + .pct = rev_pct, + }; + } + return result; +} + +v3 +color_ramp_eval(Color_Ramp ramp, r32 pct) +{ + pct = clamp(0, pct, 1); + // find nearest two anchors + // TODO: do a binary search and we just have to assume that the anchors + // are in order from least to greatest + Color_Ramp_Anchor nearest_below = { .pct = 0, .color = BLACK_V4.xyz }; + Color_Ramp_Anchor nearest_above = { .pct = 1, .color = BLACK_V4.xyz }; + r32 dist_below = 1; + r32 dist_above = -1; + for (u32 i = 0; i < ramp.anchors_count; i++) { + Color_Ramp_Anchor anchor = ramp.anchors[i]; + r32 dist = pct - anchor.pct; + if (dist >= 0 && dist_below > dist) { + nearest_below = anchor; + dist_below = dist; + } + if (dist <= 0 && dist_above < dist) { + nearest_above = anchor; + dist_above = dist; + } + } + + // interpolate between them + r32 anchor_range = nearest_above.pct - nearest_below.pct; + if (anchor_range == 0) anchor_range = 1; + r32 pct_remapped = (pct - nearest_below.pct) / anchor_range; + v3 result = pm_lerp_v3(nearest_below.color, pct_remapped, nearest_above.color); + return result; +} + +// Common SDFs +// all assume the shape is centered at 0, 0, 0 + +internal r32 +sdf_sphere2_d(r32 radius_squared, r32 dist_squared) +{ + r32 d = radius_squared - dist_squared; + r32 sdf = (d / radius_squared); + return max(0, sdf); +} + +internal r32 +sdf_sphere2(r32 radius_squared, v3 p) +{ + r32 d2 = HMM_LengthSquaredVec3(p); + return sdf_sphere2_d(radius_squared, d2); +} + +internal r32 +sdf_sphere(r32 radius, v3 p) +{ + return sdf_sphere2(radius * radius, p); +} + +internal r32 +sdf_sphere_hull2_d(r32 radius_squared, r32 falloff, r32 dist_squared) +{ + r32 d = fabsf(falloff * (radius_squared - dist_squared)); + r32 sdf = 1.0f - (d / radius_squared); + r32 result = max(0, sdf); + return result; +} + +internal r32 +sdf_sphere_hull2(r32 radius_squared, r32 falloff, v3 p) +{ + r32 d2 = HMM_LengthSquaredVec3(p); + return sdf_sphere_hull2_d(radius_squared, falloff, d2); +} + +internal r32 +sdf_sphere_hull(r32 radius, r32 falloff, v3 p) +{ + return sdf_sphere_hull2(radius * radius, falloff, p); +} + +#endif // PATTERNS_MATH_H \ No newline at end of file diff --git a/src_v2/platform/glcorearb.h b/src_v2/platform/glcorearb.h new file mode 100644 index 0000000..4855b20 --- /dev/null +++ b/src_v2/platform/glcorearb.h @@ -0,0 +1,5991 @@ +#ifndef __gl_glcorearb_h_ +#define __gl_glcorearb_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + + /* + ** Copyright 2013-2020 The Khronos Group Inc. + ** SPDX-License-Identifier: MIT + ** + ** This header is generated from the Khronos OpenGL / OpenGL ES XML + ** API Registry. The current version of the Registry, generator scripts + ** used to make the header, and the header can be found at + ** https://github.com/KhronosGroup/OpenGL-Registry + */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include <windows.h> +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + + /* glcorearb.h is for use with OpenGL core profile implementations. + ** It should should be placed in the same directory as gl.h and + ** included as <GL/glcorearb.h>. + ** + ** glcorearb.h includes only APIs in the latest OpenGL core profile + ** implementation together with APIs in newer ARB extensions which + ** can be supported by the core profile. It does not, and never will + ** include functionality removed from the core profile, such as + ** fixed-function vertex and fragment processing. + ** + ** Do not #include both <GL/glcorearb.h> and either of <GL/gl.h> or + ** <GL/glext.h> in the same source file. + */ + + /* Generated C header for: + * API: gl + * Profile: core + * Versions considered: .* + * Versions emitted: .* + * Default extensions included: glcore + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_VERSION_1_0 +#define GL_VERSION_1_0 1 + typedef void GLvoid; + typedef unsigned int GLenum; +#include "khrplatform.h" + typedef khronos_float_t GLfloat; + typedef int GLint; + typedef int GLsizei; + typedef unsigned int GLbitfield; + typedef double GLdouble; + typedef unsigned int GLuint; + typedef unsigned char GLboolean; + typedef khronos_uint8_t GLubyte; +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_NONE 0 +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_VIEWPORT 0x0BA2 +#define GL_DITHER 0x0BD0 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND 0x0BE2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_READ_BUFFER 0x0C02 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F +#define GL_TEXTURE 0x1702 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_STENCIL_INDEX 0x1901 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_REPEAT 0x2901 + typedef void (APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); + typedef void (APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); + typedef void (APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); + typedef void (APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); + typedef void (APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size); + typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode); + typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLDRAWBUFFERPROC) (GLenum buf); + typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); + typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + typedef void (APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); + typedef void (APIENTRYP PFNGLCLEARDEPTHPROC) (GLdouble depth); + typedef void (APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); + typedef void (APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + typedef void (APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); + typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); + typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); + typedef void (APIENTRYP PFNGLFINISHPROC) (void); + typedef void (APIENTRYP PFNGLFLUSHPROC) (void); + typedef void (APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); + typedef void (APIENTRYP PFNGLLOGICOPPROC) (GLenum opcode); + typedef void (APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); + typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); + typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); + typedef void (APIENTRYP PFNGLPIXELSTOREFPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLREADBUFFERPROC) (GLenum src); + typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); + typedef void (APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); + typedef void (APIENTRYP PFNGLGETDOUBLEVPROC) (GLenum pname, GLdouble *data); + typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); + typedef void (APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); + typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); + typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); + typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); + typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); + typedef void (APIENTRYP PFNGLDEPTHRANGEPROC) (GLdouble n, GLdouble f); + typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCullFace (GLenum mode); + GLAPI void APIENTRY glFrontFace (GLenum mode); + GLAPI void APIENTRY glHint (GLenum target, GLenum mode); + GLAPI void APIENTRY glLineWidth (GLfloat width); + GLAPI void APIENTRY glPointSize (GLfloat size); + GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); + GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); + GLAPI void APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glDrawBuffer (GLenum buf); + GLAPI void APIENTRY glClear (GLbitfield mask); + GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + GLAPI void APIENTRY glClearStencil (GLint s); + GLAPI void APIENTRY glClearDepth (GLdouble depth); + GLAPI void APIENTRY glStencilMask (GLuint mask); + GLAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + GLAPI void APIENTRY glDepthMask (GLboolean flag); + GLAPI void APIENTRY glDisable (GLenum cap); + GLAPI void APIENTRY glEnable (GLenum cap); + GLAPI void APIENTRY glFinish (void); + GLAPI void APIENTRY glFlush (void); + GLAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); + GLAPI void APIENTRY glLogicOp (GLenum opcode); + GLAPI void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); + GLAPI void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); + GLAPI void APIENTRY glDepthFunc (GLenum func); + GLAPI void APIENTRY glPixelStoref (GLenum pname, GLfloat param); + GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); + GLAPI void APIENTRY glReadBuffer (GLenum src); + GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); + GLAPI void APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); + GLAPI void APIENTRY glGetDoublev (GLenum pname, GLdouble *data); + GLAPI GLenum APIENTRY glGetError (void); + GLAPI void APIENTRY glGetFloatv (GLenum pname, GLfloat *data); + GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *data); + GLAPI const GLubyte *APIENTRY glGetString (GLenum name); + GLAPI void APIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + GLAPI void APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); + GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); + GLAPI void APIENTRY glDepthRange (GLdouble n, GLdouble f); + GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_0 */ + +#ifndef GL_VERSION_1_1 +#define GL_VERSION_1_1 1 + typedef khronos_float_t GLclampf; + typedef double GLclampd; +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_DOUBLE 0x140A +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_VERTEX_ARRAY 0x8074 + typedef void (APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); + typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); + typedef void (APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params); + typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); + typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); + typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); + typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); + typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); + GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); + GLAPI void APIENTRY glGetPointerv (GLenum pname, void **params); + GLAPI void APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); + GLAPI void APIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + GLAPI void APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + GLAPI void APIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture); + GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); + GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures); + GLAPI GLboolean APIENTRY glIsTexture (GLuint texture); +#endif +#endif /* GL_VERSION_1_1 */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E + typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); + typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); + GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_2 */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D + typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); + typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glActiveTexture (GLenum texture); + GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); + GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); + typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); + GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); + GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); + GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); + GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); + GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + GLAPI void APIENTRY glBlendEquation (GLenum mode); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 + typedef khronos_ssize_t GLsizeiptr; + typedef khronos_intptr_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 + typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); + typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); + typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); + typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); + typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); + typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); + typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); + typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); + typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); + typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); + typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); + typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); + typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); + typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); + GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); + GLAPI GLboolean APIENTRY glIsQuery (GLuint id); + GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); + GLAPI void APIENTRY glEndQuery (GLenum target); + GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); + GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); + GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); + GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); + GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); + GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); + GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); + GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); + GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); + GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); + GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 + typedef char GLchar; + typedef khronos_int16_t GLshort; + typedef khronos_int8_t GLbyte; + typedef khronos_uint16_t GLushort; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 + typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); + typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); + typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); + typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); + typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); + typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); + typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); + typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); + typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); + typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); + typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); + typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); + typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); + typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); + typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); + typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); + typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); + typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); + typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); + typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); + typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); + typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); + typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); + typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); + typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); + typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); + typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); + typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); + typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); + typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); + typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); + GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); + GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); + GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); + GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); + GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); + GLAPI void APIENTRY glCompileShader (GLuint shader); + GLAPI GLuint APIENTRY glCreateProgram (void); + GLAPI GLuint APIENTRY glCreateShader (GLenum type); + GLAPI void APIENTRY glDeleteProgram (GLuint program); + GLAPI void APIENTRY glDeleteShader (GLuint shader); + GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); + GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); + GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); + GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); + GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); + GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); + GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); + GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); + GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); + GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); + GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); + GLAPI GLboolean APIENTRY glIsProgram (GLuint program); + GLAPI GLboolean APIENTRY glIsShader (GLuint shader); + GLAPI void APIENTRY glLinkProgram (GLuint program); + GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); + GLAPI void APIENTRY glUseProgram (GLuint program); + GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); + GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); + GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); + GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); + GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); + GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glValidateProgram (GLuint program); + GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); + GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); + GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); + GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); + GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); + GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); + GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); + GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); + GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); + GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); + GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); + GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); + GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); + GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 + typedef khronos_uint16_t GLhalf; +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 + typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); + typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); + typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); + typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); + typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); + typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); + typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); + typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); + typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); + typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); + typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); + typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); + typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); + typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); + typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); + typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); + typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); + typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); + typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); + typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); + typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); + typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); + typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); + typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); + typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); + typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); + typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); + typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); + typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); + typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); + typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); + typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); + GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); + GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); + GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); + GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); + GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); + GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); + GLAPI void APIENTRY glEndTransformFeedback (void); + GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); + GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); + GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); + GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); + GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); + GLAPI void APIENTRY glEndConditionalRender (void); + GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); + GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); + GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); + GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); + GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); + GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); + GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); + GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); + GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); + GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); + GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); + GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); + GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); + GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); + GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); + GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); + GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); + GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); + GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); + GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); + GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); + GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); + GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); + GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); + GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); + GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); + GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); + GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); + GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); + GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); + GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); + GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); + GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); + GLAPI void APIENTRY glGenerateMipmap (GLenum target); + GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); + GLAPI void APIENTRY glBindVertexArray (GLuint array); + GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); + GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); + GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); + typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); + typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); + typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); + typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); + typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); + GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); + GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); + GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); + GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); + GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); + GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); + GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); + GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 + typedef struct __GLsync *GLsync; + typedef khronos_uint64_t GLuint64; + typedef khronos_int64_t GLint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 + typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); + typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); + typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); + typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); + typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); + typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); + typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); + typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); + typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); + typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); + typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); + typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); + typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); + GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); + GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); + GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); + GLAPI void APIENTRY glProvokingVertex (GLenum mode); + GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); + GLAPI GLboolean APIENTRY glIsSync (GLsync sync); + GLAPI void APIENTRY glDeleteSync (GLsync sync); + GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); + GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); + GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); + GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); + GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); + GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); + GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); + GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); + GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F + typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); + typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); + typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); + typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); + typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); + typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); + typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); + GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); + GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); + GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); + GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); + GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); + GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); + GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); + GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); + GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); + GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); + GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); + GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); + GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); + GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); + GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); + GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); + GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); + GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); + GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); + GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); + GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 + typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); + typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); + typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); + typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); + typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); + typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); + typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); + typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); + typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); + typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); + typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); + typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); + typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); + typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); + typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); + typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); + typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); + typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); + typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); + typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMinSampleShading (GLfloat value); + GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); + GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); + GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); + GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); + GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); + GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); + GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); + GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); + GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); + GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); + GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); + GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); + GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); + GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); + GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); + GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); + GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); + GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); + GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); + GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); + GLAPI void APIENTRY glPauseTransformFeedback (void); + GLAPI void APIENTRY glResumeTransformFeedback (void); + GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); + GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); + GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); + GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); + GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 + typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); + typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); + typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); + typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); + typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); + typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); + typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); + typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); + typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); + typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); + typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); + typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); + typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); + typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); + typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); + typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); + typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); + typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); + typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); + typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); + typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); + typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glReleaseShaderCompiler (void); + GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); + GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); + GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); + GLAPI void APIENTRY glClearDepthf (GLfloat d); + GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); + GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); + GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); + GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); + GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); + GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); + GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); + GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); + GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); + GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); + GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); + GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); + GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); + GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); + GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); + GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); + GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); + GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); + GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); + GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); + GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); + GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); + GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); + GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); + GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); + GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); + GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); + GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); + GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); + GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); + GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); + GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); + GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); + GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); + GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); + typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); + typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); + typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); + typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); + GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); + GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); + GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); + GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); + GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); + GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); + GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); + GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 + typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_VERTEX_BINDING_BUFFER 0x8F4F + typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); + typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); + typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); + typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); + typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); + typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); + typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); + typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); + typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); + typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); + typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); + typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); + typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); + typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); + typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); + typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); + typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); + typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); + typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); + typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); + typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); + typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); + typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); + GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); + GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); + GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); + GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); + GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); + GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); + GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); + GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); + GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); + GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); + GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); + GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); + GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); + GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); + GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); + GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); + GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); + GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); + GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); + GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); + GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); + GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); + GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); + GLAPI void APIENTRY glPopDebugGroup (void); + GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); + GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); + GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); + GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_VERSION_4_4 +#define GL_VERSION_4_4 1 +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLEAR_TEXTURE 0x9365 +#define GL_LOCATION_COMPONENT 0x934A +#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B +#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C +#define GL_QUERY_BUFFER 0x9192 +#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#define GL_QUERY_BUFFER_BINDING 0x9193 +#define GL_QUERY_RESULT_NO_WAIT 0x9194 +#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 + typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); + typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); + typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); + typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); + typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); + typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); + typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); + GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); + GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); + GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); + GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); + GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); + GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#endif +#endif /* GL_VERSION_4_4 */ + +#ifndef GL_VERSION_4_5 +#define GL_VERSION_4_5 1 +#define GL_CONTEXT_LOST 0x0507 +#define GL_NEGATIVE_ONE_TO_ONE 0x935E +#define GL_ZERO_TO_ONE 0x935F +#define GL_CLIP_ORIGIN 0x935C +#define GL_CLIP_DEPTH_MODE 0x935D +#define GL_QUERY_WAIT_INVERTED 0x8E17 +#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 +#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 +#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A +#define GL_MAX_CULL_DISTANCES 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA +#define GL_TEXTURE_TARGET 0x1006 +#define GL_QUERY_TARGET 0x82EA +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC + typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); + typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); + typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); + typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); + typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); + typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); + typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); + typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); + typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); + typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); + typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); + typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); + typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); + typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); + typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); + typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); + typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); + typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); + typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); + typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); + typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); + typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); + typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); + typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); + typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); + typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); + GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); + GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); + GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); + GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); + GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); + GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); + GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); + GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); + GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); + GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length); + GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); + GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); + GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); + GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); + GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); + GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); + GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); + GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); + GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); + GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); + GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); + GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); + GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); + GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); + GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); + GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); + GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); + GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); + GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); + GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); + GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); + GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); + GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); + GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); + GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); + GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); + GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); + GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); + GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); + GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); + GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); + GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); + GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); + GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); + GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); + GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); + GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); + GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); + GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); + GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); + GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); + GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); + GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); + GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); + GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); + GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); + GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); + GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); + GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); + GLAPI void APIENTRY glTextureBarrier (void); +#endif +#endif /* GL_VERSION_4_5 */ + +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED + typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); + GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_ARB_ES3_1_compatibility +#define GL_ARB_ES3_1_compatibility 1 +#endif /* GL_ARB_ES3_1_compatibility */ + +#ifndef GL_ARB_ES3_2_compatibility +#define GL_ARB_ES3_2_compatibility 1 +#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 + typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_ARB_ES3_2_compatibility */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_bindless_texture +#define GL_ARB_bindless_texture 1 + typedef khronos_uint64_t GLuint64EXT; +#define GL_UNSIGNED_INT64_ARB 0x140F + typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); + typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); + typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); + typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); + typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); + typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); + typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); + typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); + typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); + typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); + typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); + GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); + GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); + GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); + GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); + GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); + GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); + GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); + GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); + GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); + GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); + GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); + GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); + GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); + GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_ARB_bindless_texture */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +#endif /* GL_ARB_buffer_storage */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 + struct _cl_context; + struct _cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 + typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#endif +#endif /* GL_ARB_cl_event */ + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#endif /* GL_ARB_clear_buffer_object */ + +#ifndef GL_ARB_clear_texture +#define GL_ARB_clear_texture 1 +#endif /* GL_ARB_clear_texture */ + +#ifndef GL_ARB_clip_control +#define GL_ARB_clip_control 1 +#endif /* GL_ARB_clip_control */ + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_compute_variable_group_size +#define GL_ARB_compute_variable_group_size 1 +#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 +#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB +#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 +#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF + typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#endif +#endif /* GL_ARB_compute_variable_group_size */ + +#ifndef GL_ARB_conditional_render_inverted +#define GL_ARB_conditional_render_inverted 1 +#endif /* GL_ARB_conditional_render_inverted */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_cull_distance +#define GL_ARB_cull_distance 1 +#endif /* GL_ARB_cull_distance */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 + typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 + typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); + typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); + typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); + GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); + GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_derivative_control +#define GL_ARB_derivative_control 1 +#endif /* GL_ARB_derivative_control */ + +#ifndef GL_ARB_direct_state_access +#define GL_ARB_direct_state_access 1 +#endif /* GL_ARB_direct_state_access */ + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 + typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); + typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); + typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); + GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); + GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); + GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif /* GL_ARB_draw_buffers_blend */ + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); + GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_ARB_draw_instanced */ + +#ifndef GL_ARB_enhanced_layouts +#define GL_ARB_enhanced_layouts 1 +#endif /* GL_ARB_enhanced_layouts */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_fragment_shader_interlock +#define GL_ARB_fragment_shader_interlock 1 +#endif /* GL_ARB_fragment_shader_interlock */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 + typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); + GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); + GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_ARB_geometry_shader4 */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_get_texture_sub_image +#define GL_ARB_get_texture_sub_image 1 +#endif /* GL_ARB_get_texture_sub_image */ + +#ifndef GL_ARB_gl_spirv +#define GL_ARB_gl_spirv 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 + typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#endif +#endif /* GL_ARB_gl_spirv */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_gpu_shader_int64 +#define GL_ARB_gpu_shader_int64 1 +#define GL_INT64_ARB 0x140E +#define GL_INT64_VEC2_ARB 0x8FE9 +#define GL_INT64_VEC3_ARB 0x8FEA +#define GL_INT64_VEC4_ARB 0x8FEB +#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 + typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); + typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); + typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); + typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); + typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); + typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); + typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); + typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); + typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); + typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); + GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); + GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); + GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); + GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); + GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); + GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); + GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); + GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); + GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); + GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); + GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); + GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); + GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); + GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); + GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); + GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); + GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); + GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); + GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); + GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#endif +#endif /* GL_ARB_gpu_shader_int64 */ + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#endif /* GL_ARB_imaging */ + +#ifndef GL_ARB_indirect_parameters +#define GL_ARB_indirect_parameters 1 +#define GL_PARAMETER_BUFFER_ARB 0x80EE +#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_ARB_indirect_parameters */ + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE + typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif +#endif /* GL_ARB_instanced_arrays */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#define GL_VIEW_CLASS_EAC_R11 0x9383 +#define GL_VIEW_CLASS_EAC_RG11 0x9384 +#define GL_VIEW_CLASS_ETC2_RGB 0x9385 +#define GL_VIEW_CLASS_ETC2_RGBA 0x9386 +#define GL_VIEW_CLASS_ETC2_EAC_RGBA 0x9387 +#define GL_VIEW_CLASS_ASTC_4x4_RGBA 0x9388 +#define GL_VIEW_CLASS_ASTC_5x4_RGBA 0x9389 +#define GL_VIEW_CLASS_ASTC_5x5_RGBA 0x938A +#define GL_VIEW_CLASS_ASTC_6x5_RGBA 0x938B +#define GL_VIEW_CLASS_ASTC_6x6_RGBA 0x938C +#define GL_VIEW_CLASS_ASTC_8x5_RGBA 0x938D +#define GL_VIEW_CLASS_ASTC_8x6_RGBA 0x938E +#define GL_VIEW_CLASS_ASTC_8x8_RGBA 0x938F +#define GL_VIEW_CLASS_ASTC_10x5_RGBA 0x9390 +#define GL_VIEW_CLASS_ASTC_10x6_RGBA 0x9391 +#define GL_VIEW_CLASS_ASTC_10x8_RGBA 0x9392 +#define GL_VIEW_CLASS_ASTC_10x10_RGBA 0x9393 +#define GL_VIEW_CLASS_ASTC_12x10_RGBA 0x9394 +#define GL_VIEW_CLASS_ASTC_12x12_RGBA 0x9395 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ + +#ifndef GL_ARB_multi_bind +#define GL_ARB_multi_bind 1 +#endif /* GL_ARB_multi_bind */ + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_parallel_shader_compile +#define GL_ARB_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 +#define GL_COMPLETION_STATUS_ARB 0x91B1 + typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); +#endif +#endif /* GL_ARB_parallel_shader_compile */ + +#ifndef GL_ARB_pipeline_statistics_query +#define GL_ARB_pipeline_statistics_query 1 +#define GL_VERTICES_SUBMITTED_ARB 0x82EE +#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 +#endif /* GL_ARB_pipeline_statistics_query */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ + +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + +#ifndef GL_ARB_post_depth_coverage +#define GL_ARB_post_depth_coverage 1 +#endif /* GL_ARB_post_depth_coverage */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_query_buffer_object +#define GL_ARB_query_buffer_object 1 +#endif /* GL_ARB_query_buffer_object */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 + typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); + typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); + typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); + typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); + typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); + GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); + GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); + GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); + GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); + GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); + GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); + GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_locations +#define GL_ARB_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 +#define GL_SAMPLE_LOCATION_ARB 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 + typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glEvaluateDepthValuesARB (void); +#endif +#endif /* GL_ARB_sample_locations */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 + typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif +#endif /* GL_ARB_sample_shading */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_seamless_cubemap_per_texture +#define GL_ARB_seamless_cubemap_per_texture 1 +#endif /* GL_ARB_seamless_cubemap_per_texture */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counter_ops +#define GL_ARB_shader_atomic_counter_ops 1 +#endif /* GL_ARB_shader_atomic_counter_ops */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_ballot +#define GL_ARB_shader_ballot 1 +#endif /* GL_ARB_shader_ballot */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_clock +#define GL_ARB_shader_clock 1 +#endif /* GL_ARB_shader_clock */ + +#ifndef GL_ARB_shader_draw_parameters +#define GL_ARB_shader_draw_parameters 1 +#endif /* GL_ARB_shader_draw_parameters */ + +#ifndef GL_ARB_shader_group_vote +#define GL_ARB_shader_group_vote 1 +#endif /* GL_ARB_shader_group_vote */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shader_texture_image_samples +#define GL_ARB_shader_texture_image_samples 1 +#endif /* GL_ARB_shader_texture_image_samples */ + +#ifndef GL_ARB_shader_viewport_layer_array +#define GL_ARB_shader_viewport_layer_array 1 +#endif /* GL_ARB_shader_viewport_layer_array */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA + typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); + typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); + typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); + typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); + typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); + typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); + GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); + GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); + GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); + GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); + GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_shading_language_include */ + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_sparse_buffer +#define GL_ARB_sparse_buffer 1 +#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 +#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 + typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); + typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); + typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); + GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); + GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_buffer */ + +#ifndef GL_ARB_sparse_texture +#define GL_ARB_sparse_texture 1 +#define GL_TEXTURE_SPARSE_ARB 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 +#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA +#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 + typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_texture */ + +#ifndef GL_ARB_sparse_texture2 +#define GL_ARB_sparse_texture2 1 +#endif /* GL_ARB_sparse_texture2 */ + +#ifndef GL_ARB_sparse_texture_clamp +#define GL_ARB_sparse_texture_clamp 1 +#endif /* GL_ARB_sparse_texture_clamp */ + +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_barrier +#define GL_ARB_texture_barrier 1 +#endif /* GL_ARB_texture_barrier */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E + typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_ARB_texture_buffer_object */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + +#ifndef GL_ARB_texture_filter_minmax +#define GL_ARB_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 +#define GL_WEIGHTED_AVERAGE_ARB 0x9367 +#endif /* GL_ARB_texture_filter_minmax */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirror_clamp_to_edge +#define GL_ARB_texture_mirror_clamp_to_edge 1 +#endif /* GL_ARB_texture_mirror_clamp_to_edge */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_stencil8 +#define GL_ARB_texture_stencil8 1 +#endif /* GL_ARB_texture_stencil8 */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_transform_feedback_overflow_query +#define GL_ARB_transform_feedback_overflow_query 1 +#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED +#endif /* GL_ARB_transform_feedback_overflow_query */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_type_10f_11f_11f_rev +#define GL_ARB_vertex_type_10f_11f_11f_rev 1 +#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 + typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYDVNVPROC) (GLuint first, GLsizei count, const GLdouble *v); + typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDDNVPROC) (GLuint index, GLdouble n, GLdouble f); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDepthRangeArraydvNV (GLuint first, GLsizei count, const GLdouble *v); + GLAPI void APIENTRY glDepthRangeIndexeddNV (GLuint index, GLdouble n, GLdouble f); +#endif +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 + typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 + typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_shader_subgroup +#define GL_KHR_shader_subgroup 1 +#define GL_SUBGROUP_SIZE_KHR 0x9532 +#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 +#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 +#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 +#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 +#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 +#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 +#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 +#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 +#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 +#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 +#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 +#endif /* GL_KHR_shader_subgroup */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 + typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); + typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); + typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); + typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); + typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); + typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); + typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); + typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); + typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); + typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); + typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); + GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); + GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); + GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); + GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); + GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); + GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); + GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); + GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); + GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); + GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 + typedef void *GLeglImageOES; + typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); + typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); + GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + +#ifndef GL_EXT_EGL_sync +#define GL_EXT_EGL_sync 1 +#endif /* GL_EXT_EGL_sync */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 + typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); + typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); + GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 + typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); + typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); + typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); + GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); + GLAPI void APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F + typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); + typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); + typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); + typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); + typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); + typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); + typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); + typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); + typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); + typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); + typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); + typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); + typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); + typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); + typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); + typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); + typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); + typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); + typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); + typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); + typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); + typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); + typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); + typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); + typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); + typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); + typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); + typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); + typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); + typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); + typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); + typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); + typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); + typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); + typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); + typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); + typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); + typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); + typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); + typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); + GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); + GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); + GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); + GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); + GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); + GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); + GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); + GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); + GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); + GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); + GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); + GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); + GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); + GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); + GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); + GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); + GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); + GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); + GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); + GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); + GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); + GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); + GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); + GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); + GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); + GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); + GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); + GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); + GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); + GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); + GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); + GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); + GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); + GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); + GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); + GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); + GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); + GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); + GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); + GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); + GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); + GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); + GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); + GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); + GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); + GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); + GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); + GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); + GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); + GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); + GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); + GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); + GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); + GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); + GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); + GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); + GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); + GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); + GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); + GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); + GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); + GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); + GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); + GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); + GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); + GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); + GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); + GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); + GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); + GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); + GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); + GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); + GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); + GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); + GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); + GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); + GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); + GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); + GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); + GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); + GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); + GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); + GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); + GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); + GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); + GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); + GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); + GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); + GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); + GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); + GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); + GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); + GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); + GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); + GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); + GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); + GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); + GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); + GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); + GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); + GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_multiview_tessellation_geometry_shader +#define GL_EXT_multiview_tessellation_geometry_shader 1 +#endif /* GL_EXT_multiview_tessellation_geometry_shader */ + +#ifndef GL_EXT_multiview_texture_multisample +#define GL_EXT_multiview_texture_multisample 1 +#endif /* GL_EXT_multiview_texture_multisample */ + +#ifndef GL_EXT_multiview_timer_query +#define GL_EXT_multiview_timer_query 1 +#endif /* GL_EXT_multiview_timer_query */ + +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B + typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C + typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D + typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); + typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); + typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); + GLAPI void APIENTRY glActiveProgramEXT (GLuint program); + GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 + typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + +#ifndef GL_EXT_texture_sRGB_RG8 +#define GL_EXT_texture_sRGB_RG8 1 +#define GL_SRG8_EXT 0x8FBE +#endif /* GL_EXT_texture_sRGB_RG8 */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shadow_lod +#define GL_EXT_texture_shadow_lod 1 +#endif /* GL_EXT_texture_shadow_lod */ + +#ifndef GL_EXT_texture_storage +#define GL_EXT_texture_storage 1 +#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F +#define GL_ALPHA8_EXT 0x803C +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_RGBA32F_EXT 0x8814 +#define GL_RGB32F_EXT 0x8815 +#define GL_ALPHA32F_EXT 0x8816 +#define GL_LUMINANCE32F_EXT 0x8818 +#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 +#define GL_RGBA16F_EXT 0x881A +#define GL_RGB16F_EXT 0x881B +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGB10_EXT 0x8052 +#define GL_BGRA8_EXT 0x93A1 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +#define GL_R16F_EXT 0x822D +#define GL_RG16F_EXT 0x822F + typedef void (APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + GLAPI void APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_EXT_texture_storage */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 + typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 + typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 + typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); + typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); + typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); + typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); + typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); + typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); + typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); + typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); + typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); + typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); + GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); + GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); + GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); + GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); + GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); + GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); + GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); + GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); + GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESA_framebuffer_flip_x +#define GL_MESA_framebuffer_flip_x 1 +#define GL_FRAMEBUFFER_FLIP_X_MESA 0x8BBC +#endif /* GL_MESA_framebuffer_flip_x */ + +#ifndef GL_MESA_framebuffer_flip_y +#define GL_MESA_framebuffer_flip_y 1 +#define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB + typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_MESA_framebuffer_flip_y */ + +#ifndef GL_MESA_framebuffer_swap_xy +#define GL_MESA_framebuffer_swap_xy 1 +#define GL_FRAMEBUFFER_SWAP_XY_MESA 0x8BBD +#endif /* GL_MESA_framebuffer_swap_xy */ + +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); + GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect */ + +#ifndef GL_NV_bindless_multi_draw_indirect_count +#define GL_NV_bindless_multi_draw_indirect_count 1 + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); + GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect_count */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 + typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); + typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); + typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); + typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); + typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); + typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); + typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); + typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); + typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); + typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); + typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); + GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); + GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); + GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); + GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); + GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); + GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); + GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); + GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); + GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); + GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); + GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 + typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); + GLAPI void APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E + typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_command_list +#define GL_NV_command_list 1 +#define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 +#define GL_NOP_COMMAND_NV 0x0001 +#define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 +#define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 +#define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 +#define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 +#define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 +#define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 +#define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 +#define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 +#define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A +#define GL_BLEND_COLOR_COMMAND_NV 0x000B +#define GL_STENCIL_REF_COMMAND_NV 0x000C +#define GL_LINE_WIDTH_COMMAND_NV 0x000D +#define GL_POLYGON_OFFSET_COMMAND_NV 0x000E +#define GL_ALPHA_REF_COMMAND_NV 0x000F +#define GL_VIEWPORT_COMMAND_NV 0x0010 +#define GL_SCISSOR_COMMAND_NV 0x0011 +#define GL_FRONT_FACE_COMMAND_NV 0x0012 + typedef void (APIENTRYP PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint *states); + typedef void (APIENTRYP PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint *states); + typedef GLboolean (APIENTRYP PFNGLISSTATENVPROC) (GLuint state); + typedef void (APIENTRYP PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); + typedef GLuint (APIENTRYP PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); + typedef GLushort (APIENTRYP PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); + typedef void (APIENTRYP PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); + typedef void (APIENTRYP PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); + typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + typedef void (APIENTRYP PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint *lists); + typedef void (APIENTRYP PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint *lists); + typedef GLboolean (APIENTRYP PFNGLISCOMMANDLISTNVPROC) (GLuint list); + typedef void (APIENTRYP PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + typedef void (APIENTRYP PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); + typedef void (APIENTRYP PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); + typedef void (APIENTRYP PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCreateStatesNV (GLsizei n, GLuint *states); + GLAPI void APIENTRY glDeleteStatesNV (GLsizei n, const GLuint *states); + GLAPI GLboolean APIENTRY glIsStateNV (GLuint state); + GLAPI void APIENTRY glStateCaptureNV (GLuint state, GLenum mode); + GLAPI GLuint APIENTRY glGetCommandHeaderNV (GLenum tokenID, GLuint size); + GLAPI GLushort APIENTRY glGetStageIndexNV (GLenum shadertype); + GLAPI void APIENTRY glDrawCommandsNV (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); + GLAPI void APIENTRY glDrawCommandsAddressNV (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); + GLAPI void APIENTRY glDrawCommandsStatesNV (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + GLAPI void APIENTRY glDrawCommandsStatesAddressNV (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + GLAPI void APIENTRY glCreateCommandListsNV (GLsizei n, GLuint *lists); + GLAPI void APIENTRY glDeleteCommandListsNV (GLsizei n, const GLuint *lists); + GLAPI GLboolean APIENTRY glIsCommandListNV (GLuint list); + GLAPI void APIENTRY glListDrawCommandsStatesClientNV (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + GLAPI void APIENTRY glCommandListSegmentsNV (GLuint list, GLuint segments); + GLAPI void APIENTRY glCompileCommandListNV (GLuint list); + GLAPI void APIENTRY glCallCommandListNV (GLuint list); +#endif +#endif /* GL_NV_command_list */ + +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 + typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); + typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); + GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 + typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_conservative_raster_dilate +#define GL_NV_conservative_raster_dilate 1 +#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 +#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A +#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B + typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat value); +#endif +#endif /* GL_NV_conservative_raster_dilate */ + +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F + typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF + typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); + typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); + typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); + GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); + GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 + typedef void (APIENTRY *GLVULKANPROCNV)(void); + typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); + typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); + typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); + typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); + typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); + GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); + GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); + GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); + GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE + typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 + typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); + typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); + typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); + GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); + GLAPI void APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 + typedef khronos_int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB + typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); + typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); + typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); + typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); + typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); + typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); + GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); + GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); + GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); + GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); + GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); + GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); + GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); + GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); + GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); + GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); + GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 + typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD + typedef void (APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); + typedef void (APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); + typedef void (APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); + GLAPI void APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); + GLAPI void APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_memory_object_sparse +#define GL_NV_memory_object_sparse 1 + typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTMEMNVPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); + typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTMEMNVPROC) (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); + typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTMEMNVPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); + typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTMEMNVPROC) (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBufferPageCommitmentMemNV (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); + GLAPI void APIENTRY glTexPageCommitmentMemNV (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); + GLAPI void APIENTRY glNamedBufferPageCommitmentMemNV (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); + GLAPI void APIENTRY glTexturePageCommitmentMemNV (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#endif +#endif /* GL_NV_memory_object_sparse */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F + typedef void (APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); + typedef void (APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); + typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); + GLAPI void APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); + GLAPI void APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); + GLAPI void APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_NV_mesh_shader */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D + typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); + typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); + typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); + typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); + typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); + typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); + typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); + typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); + typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); + typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); + typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); + typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); + typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); + typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); + typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); + typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); + typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); + typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); + typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); + typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); + typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); + typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); + typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); + typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); + typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); + typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); + typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); + typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); + typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); + typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); + typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); + typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); + typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); + typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); + typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); + typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); + typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); + typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); + typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); + GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); + GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); + GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); + GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); + GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); + GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); + GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); + GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); + GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); + GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); + GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); + GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); + GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); + GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); + GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); + GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); + GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); + GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); + GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); + GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); + GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); + GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); + GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); + GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); + GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); + GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); + GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); + GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); + GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); + GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); + GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); + GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); + GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); + GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); + GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); + GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); + GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); + GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); + GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + +#ifndef GL_NV_primitive_shading_rate +#define GL_NV_primitive_shading_rate 1 +#define GL_SHADING_RATE_IMAGE_PER_PRIMITIVE_NV 0x95B1 +#define GL_SHADING_RATE_IMAGE_PALETTE_COUNT_NV 0x95B2 +#endif /* GL_NV_primitive_shading_rate */ + +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 + typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 + typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_atomic_int64 +#define GL_NV_shader_atomic_int64 1 +#endif /* GL_NV_shader_atomic_int64 */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 + typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); + typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); + typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); + typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); + typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); + typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); + typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); + typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); + typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); + GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); + GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); + GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); + GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); + GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); + GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); + GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); + GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); + GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); + GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); + GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); + GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_subgroup_partitioned +#define GL_NV_shader_subgroup_partitioned 1 +#define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 +#endif /* GL_NV_shader_subgroup_partitioned */ + +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + +#ifndef GL_NV_shader_thread_group +#define GL_NV_shader_thread_group 1 +#define GL_WARP_SIZE_NV 0x9339 +#define GL_WARPS_PER_SM_NV 0x933A +#define GL_SM_COUNT_NV 0x933B +#endif /* GL_NV_shader_thread_group */ + +#ifndef GL_NV_shader_thread_shuffle +#define GL_NV_shader_thread_shuffle 1 +#endif /* GL_NV_shader_thread_shuffle */ + +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 + typedef void (APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); + typedef void (APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); + typedef void (APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); + typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); + typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); + typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); + typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBindShadingRateImageNV (GLuint texture); + GLAPI void APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); + GLAPI void APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); + GLAPI void APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); + GLAPI void APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); + GLAPI void APIENTRY glShadingRateSampleOrderNV (GLenum order); + GLAPI void APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 + typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ + +#ifndef GL_NV_uniform_buffer_unified_memory +#define GL_NV_uniform_buffer_unified_memory 1 +#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E +#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F +#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 +#endif /* GL_NV_uniform_buffer_unified_memory */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); + typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); + GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); + GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); + GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); + GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); + GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); + GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); + GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); + GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); + GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); + GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); + GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); + GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); + GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); + GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); + GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 + typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); + typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); + typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); + GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); + GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); + GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); + GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); + GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); + GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); + GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); + GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); + GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); + GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); + GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B + typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview */ + +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/src_v2/platform/glext.h b/src_v2/platform/glext.h new file mode 100644 index 0000000..ece8c51 --- /dev/null +++ b/src_v2/platform/glext.h @@ -0,0 +1,12894 @@ +#ifndef __gl_glext_h_ +#define __gl_glext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + + /* + ** Copyright 2013-2020 The Khronos Group Inc. + ** SPDX-License-Identifier: MIT + ** + ** This header is generated from the Khronos OpenGL / OpenGL ES XML + ** API Registry. The current version of the Registry, generator scripts + ** used to make the header, and the header can be found at + ** https://github.com/KhronosGroup/OpenGL-Registry + */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include <windows.h> +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +#define GL_GLEXT_VERSION 20211115 + +#include "khrplatform.h" + + /* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D + typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); + typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); + GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_2 */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF + typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); + typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); + typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); + typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); + typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); + typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); + typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glActiveTexture (GLenum texture); + GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); + GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); + GLAPI void APIENTRY glClientActiveTexture (GLenum texture); + GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); + GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); + GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); + GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); + GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); + GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); + GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); + GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); + GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); + GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); + GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); + GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); + GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); + GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); + GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); + GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); + GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); + GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); + GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); + GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); + GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); + GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); + GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); + GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); + GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); + GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); + GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); + GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); + GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); + GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); + GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); + GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); + GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); + GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); + GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); + GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); + typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); + typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); + typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); + typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); + typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); + typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); + typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); + typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); + typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); + typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); + typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); + GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); + GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); + GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); + GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); + GLAPI void APIENTRY glFogCoordf (GLfloat coord); + GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); + GLAPI void APIENTRY glFogCoordd (GLdouble coord); + GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); + GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); + GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); + GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); + GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); + GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); + GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); + GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); + GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); + GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); + GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); + GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); + GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); + GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); + GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); + GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); + GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); + GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); + GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); + GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); + GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); + GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); + GLAPI void APIENTRY glWindowPos2iv (const GLint *v); + GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); + GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); + GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); + GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); + GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); + GLAPI void APIENTRY glWindowPos3iv (const GLint *v); + GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); + GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); + GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + GLAPI void APIENTRY glBlendEquation (GLenum mode); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 + typedef khronos_ssize_t GLsizeiptr; + typedef khronos_intptr_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A + typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); + typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); + typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); + typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); + typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); + typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); + typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); + typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); + typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); + typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); + typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); + typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); + typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); + typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); + GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); + GLAPI GLboolean APIENTRY glIsQuery (GLuint id); + GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); + GLAPI void APIENTRY glEndQuery (GLenum target); + GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); + GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); + GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); + GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); + GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); + GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); + GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); + GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); + GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); + GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); + GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 + typedef char GLchar; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 + typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); + typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); + typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); + typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); + typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); + typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); + typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); + typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); + typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); + typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); + typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); + typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); + typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); + typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); + typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); + typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); + typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); + typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); + typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); + typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); + typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); + typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); + typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); + typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); + typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); + typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); + typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); + typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); + typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); + typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); + typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); + GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); + GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); + GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); + GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); + GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); + GLAPI void APIENTRY glCompileShader (GLuint shader); + GLAPI GLuint APIENTRY glCreateProgram (void); + GLAPI GLuint APIENTRY glCreateShader (GLenum type); + GLAPI void APIENTRY glDeleteProgram (GLuint program); + GLAPI void APIENTRY glDeleteShader (GLuint shader); + GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); + GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); + GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); + GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); + GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); + GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); + GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); + GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); + GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); + GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); + GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); + GLAPI GLboolean APIENTRY glIsProgram (GLuint program); + GLAPI GLboolean APIENTRY glIsShader (GLuint shader); + GLAPI void APIENTRY glLinkProgram (GLuint program); + GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); + GLAPI void APIENTRY glUseProgram (GLuint program); + GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); + GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); + GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); + GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); + GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); + GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glValidateProgram (GLuint program); + GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); + GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); + GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); + GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); + GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); + GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); + GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); + GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); + GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); + GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); + GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); + GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); + GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); + GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 + typedef khronos_uint16_t GLhalf; +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 + typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); + typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); + typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); + typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); + typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); + typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); + typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); + typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); + typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); + typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); + typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); + typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); + typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); + typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); + typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); + typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); + typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); + typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); + typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); + typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); + typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); + typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); + typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); + typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); + typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); + typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); + typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); + typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); + typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); + typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); + typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); + typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); + GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); + GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); + GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); + GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); + GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); + GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); + GLAPI void APIENTRY glEndTransformFeedback (void); + GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); + GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); + GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); + GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); + GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); + GLAPI void APIENTRY glEndConditionalRender (void); + GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); + GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); + GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); + GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); + GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); + GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); + GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); + GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); + GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); + GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); + GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); + GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); + GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); + GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); + GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); + GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); + GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); + GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); + GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); + GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); + GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); + GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); + GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); + GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); + GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); + GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); + GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); + GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); + GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); + GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); + GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); + GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); + GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); + GLAPI void APIENTRY glGenerateMipmap (GLenum target); + GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); + GLAPI void APIENTRY glBindVertexArray (GLuint array); + GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); + GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); + GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); + typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); + typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); + typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); + typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); + typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); + GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); + GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); + GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); + GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); + GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); + GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); + GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); + GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 + typedef struct __GLsync *GLsync; + typedef khronos_uint64_t GLuint64; + typedef khronos_int64_t GLint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 + typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); + typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); + typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); + typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); + typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); + typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); + typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); + typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); + typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); + typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); + typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); + typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); + typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); + GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); + GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); + GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); + GLAPI void APIENTRY glProvokingVertex (GLenum mode); + GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); + GLAPI GLboolean APIENTRY glIsSync (GLsync sync); + GLAPI void APIENTRY glDeleteSync (GLsync sync); + GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); + GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); + GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); + GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); + GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); + GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); + GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); + GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); + GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F + typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); + typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); + typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); + typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); + typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); + typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); + typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); + typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); + typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); + typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); + typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); + typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); + typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); + typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); + typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); + typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); + typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); + typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); + typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); + typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); + typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); + typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); + typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); + typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); + typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); + GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); + GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); + GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); + GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); + GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); + GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); + GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); + GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); + GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); + GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); + GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); + GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); + GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); + GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); + GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); + GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); + GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); + GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); + GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); + GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); + GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); + GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); + GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); + GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); + GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); + GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); + GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); + GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); + GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); + GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); + GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); + GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); + GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); + GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); + GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); + GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); + GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); + GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); + GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); + GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); + GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); + GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); + GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); + GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); + GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); + GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); + GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); + GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); + GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); + GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); + GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 + typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); + typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); + typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); + typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); + typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); + typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); + typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); + typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); + typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); + typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); + typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); + typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); + typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); + typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); + typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); + typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); + typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); + typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); + typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); + typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMinSampleShading (GLfloat value); + GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); + GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); + GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); + GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); + GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); + GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); + GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); + GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); + GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); + GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); + GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); + GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); + GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); + GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); + GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); + GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); + GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); + GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); + GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); + GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); + GLAPI void APIENTRY glPauseTransformFeedback (void); + GLAPI void APIENTRY glResumeTransformFeedback (void); + GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); + GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); + GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); + GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); + GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 + typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); + typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); + typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); + typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); + typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); + typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); + typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); + typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); + typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); + typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); + typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); + typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); + typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); + typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); + typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); + typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); + typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); + typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); + typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); + typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); + typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); + typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glReleaseShaderCompiler (void); + GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); + GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); + GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); + GLAPI void APIENTRY glClearDepthf (GLfloat d); + GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); + GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); + GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); + GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); + GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); + GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); + GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); + GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); + GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); + GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); + GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); + GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); + GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); + GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); + GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); + GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); + GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); + GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); + GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); + GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); + GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); + GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); + GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); + GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); + GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); + GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); + GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); + GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); + GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); + GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); + GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); + GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); + GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); + GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); + GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); + typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); + typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); + typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); + typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); + GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); + GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); + GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); + GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); + GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); + GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); + GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); + GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 + typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_DISPLAY_LIST 0x82E7 + typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); + typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); + typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); + typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); + typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); + typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); + typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); + typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); + typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); + typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); + typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); + typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); + typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); + typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); + typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); + typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); + typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); + typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); + typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); + typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); + typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); + typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); + typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); + GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); + GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); + GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); + GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); + GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); + GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); + GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); + GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); + GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); + GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); + GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); + GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); + GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); + GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); + GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); + GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); + GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); + GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); + GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); + GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); + GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); + GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); + GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); + GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); + GLAPI void APIENTRY glPopDebugGroup (void); + GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); + GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); + GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); + GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_VERSION_4_4 +#define GL_VERSION_4_4 1 +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLEAR_TEXTURE 0x9365 +#define GL_LOCATION_COMPONENT 0x934A +#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B +#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C +#define GL_QUERY_BUFFER 0x9192 +#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#define GL_QUERY_BUFFER_BINDING 0x9193 +#define GL_QUERY_RESULT_NO_WAIT 0x9194 +#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 + typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); + typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); + typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); + typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); + typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); + typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); + typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); + GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); + GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); + GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); + GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); + GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); + GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#endif +#endif /* GL_VERSION_4_4 */ + +#ifndef GL_VERSION_4_5 +#define GL_VERSION_4_5 1 +#define GL_CONTEXT_LOST 0x0507 +#define GL_NEGATIVE_ONE_TO_ONE 0x935E +#define GL_ZERO_TO_ONE 0x935F +#define GL_CLIP_ORIGIN 0x935C +#define GL_CLIP_DEPTH_MODE 0x935D +#define GL_QUERY_WAIT_INVERTED 0x8E17 +#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 +#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 +#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A +#define GL_MAX_CULL_DISTANCES 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA +#define GL_TEXTURE_TARGET 0x1006 +#define GL_QUERY_TARGET 0x82EA +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_MINMAX 0x802E +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC + typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); + typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); + typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); + typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); + typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); + typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); + typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); + typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); + typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); + typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); + typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); + typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); + typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); + typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); + typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); + typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); + typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); + typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); + typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); + typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); + typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); + typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); + typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); + typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); + typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); + typedef void (APIENTRYP PFNGLGETNMAPDVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); + typedef void (APIENTRYP PFNGLGETNMAPFVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); + typedef void (APIENTRYP PFNGLGETNMAPIVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); + typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC) (GLenum map, GLsizei bufSize, GLfloat *values); + typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC) (GLenum map, GLsizei bufSize, GLuint *values); + typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC) (GLenum map, GLsizei bufSize, GLushort *values); + typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC) (GLsizei bufSize, GLubyte *pattern); + typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); + typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); + typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); + typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); + typedef void (APIENTRYP PFNGLGETNMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); + typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); + GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); + GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); + GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); + GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); + GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); + GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); + GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); + GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); + GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); + GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length); + GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); + GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); + GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); + GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); + GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); + GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); + GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); + GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); + GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); + GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); + GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); + GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); + GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); + GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); + GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); + GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); + GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); + GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); + GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); + GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); + GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); + GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); + GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); + GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); + GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); + GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); + GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); + GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); + GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); + GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); + GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); + GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); + GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); + GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); + GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); + GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); + GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); + GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); + GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); + GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); + GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); + GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); + GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); + GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); + GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); + GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); + GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); + GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); + GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); + GLAPI void APIENTRY glGetnMapdv (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); + GLAPI void APIENTRY glGetnMapfv (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); + GLAPI void APIENTRY glGetnMapiv (GLenum target, GLenum query, GLsizei bufSize, GLint *v); + GLAPI void APIENTRY glGetnPixelMapfv (GLenum map, GLsizei bufSize, GLfloat *values); + GLAPI void APIENTRY glGetnPixelMapuiv (GLenum map, GLsizei bufSize, GLuint *values); + GLAPI void APIENTRY glGetnPixelMapusv (GLenum map, GLsizei bufSize, GLushort *values); + GLAPI void APIENTRY glGetnPolygonStipple (GLsizei bufSize, GLubyte *pattern); + GLAPI void APIENTRY glGetnColorTable (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); + GLAPI void APIENTRY glGetnConvolutionFilter (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); + GLAPI void APIENTRY glGetnSeparableFilter (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); + GLAPI void APIENTRY glGetnHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); + GLAPI void APIENTRY glGetnMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); + GLAPI void APIENTRY glTextureBarrier (void); +#endif +#endif /* GL_VERSION_4_5 */ + +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED + typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); + GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_ARB_ES3_1_compatibility +#define GL_ARB_ES3_1_compatibility 1 +#endif /* GL_ARB_ES3_1_compatibility */ + +#ifndef GL_ARB_ES3_2_compatibility +#define GL_ARB_ES3_2_compatibility 1 +#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 + typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_ARB_ES3_2_compatibility */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_bindless_texture +#define GL_ARB_bindless_texture 1 + typedef khronos_uint64_t GLuint64EXT; +#define GL_UNSIGNED_INT64_ARB 0x140F + typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); + typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); + typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); + typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); + typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); + typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); + typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); + typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); + typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); + typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); + typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); + GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); + GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); + GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); + GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); + GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); + GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); + GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); + GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); + GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); + GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); + GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); + GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); + GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); + GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_ARB_bindless_texture */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +#endif /* GL_ARB_buffer_storage */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 + struct _cl_context; + struct _cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 + typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#endif +#endif /* GL_ARB_cl_event */ + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#endif /* GL_ARB_clear_buffer_object */ + +#ifndef GL_ARB_clear_texture +#define GL_ARB_clear_texture 1 +#endif /* GL_ARB_clear_texture */ + +#ifndef GL_ARB_clip_control +#define GL_ARB_clip_control 1 +#endif /* GL_ARB_clip_control */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D + typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif +#endif /* GL_ARB_color_buffer_float */ + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_compute_variable_group_size +#define GL_ARB_compute_variable_group_size 1 +#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 +#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB +#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 +#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF + typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#endif +#endif /* GL_ARB_compute_variable_group_size */ + +#ifndef GL_ARB_conditional_render_inverted +#define GL_ARB_conditional_render_inverted 1 +#endif /* GL_ARB_conditional_render_inverted */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_cull_distance +#define GL_ARB_cull_distance 1 +#endif /* GL_ARB_cull_distance */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 + typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 + typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); + typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); + typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); + GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); + GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif /* GL_ARB_depth_texture */ + +#ifndef GL_ARB_derivative_control +#define GL_ARB_derivative_control 1 +#endif /* GL_ARB_derivative_control */ + +#ifndef GL_ARB_direct_state_access +#define GL_ARB_direct_state_access 1 +#endif /* GL_ARB_direct_state_access */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 + typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ARB_draw_buffers */ + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 + typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); + typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); + typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); + GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); + GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); + GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif /* GL_ARB_draw_buffers_blend */ + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); + GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_ARB_draw_instanced */ + +#ifndef GL_ARB_enhanced_layouts +#define GL_ARB_enhanced_layouts 1 +#endif /* GL_ARB_enhanced_layouts */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF + typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); + typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); + typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); + typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); + typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); + typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); + typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); + typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); + typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); + typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); + GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); + GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); + GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); + GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); + GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); + GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); + GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); + GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); + GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); + GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); + GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); + GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); + GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif +#endif /* GL_ARB_fragment_program */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_fragment_shader_interlock +#define GL_ARB_fragment_shader_interlock 1 +#endif /* GL_ARB_fragment_shader_interlock */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 + typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); + GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); + GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_ARB_geometry_shader4 */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_get_texture_sub_image +#define GL_ARB_get_texture_sub_image 1 +#endif /* GL_ARB_get_texture_sub_image */ + +#ifndef GL_ARB_gl_spirv +#define GL_ARB_gl_spirv 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 + typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#endif +#endif /* GL_ARB_gl_spirv */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_gpu_shader_int64 +#define GL_ARB_gpu_shader_int64 1 +#define GL_INT64_ARB 0x140E +#define GL_INT64_VEC2_ARB 0x8FE9 +#define GL_INT64_VEC3_ARB 0x8FEA +#define GL_INT64_VEC4_ARB 0x8FEB +#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 + typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); + typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); + typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); + typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); + typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); + typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); + typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); + typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); + typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); + typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); + GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); + GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); + GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); + GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); + GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); + GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); + GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); + GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); + GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); + GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); + GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); + GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); + GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); + GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); + GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); + GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); + GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); + GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); + GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); + GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); + GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#endif +#endif /* GL_ARB_gpu_shader_int64 */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 + typedef khronos_uint16_t GLhalfARB; +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 + typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); + typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); + typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); + typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); + typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); + typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); + typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); + typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); + typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); + typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); + typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); + typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); + typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); + typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); + typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); + GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); + GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); + GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); + GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); + GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); + GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); + GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); + GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); + GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); + GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); + GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); + GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); + GLAPI void APIENTRY glResetHistogram (GLenum target); + GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif +#endif /* GL_ARB_imaging */ + +#ifndef GL_ARB_indirect_parameters +#define GL_ARB_indirect_parameters 1 +#define GL_PARAMETER_BUFFER_ARB 0x80EE +#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); + GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_ARB_indirect_parameters */ + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE + typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif +#endif /* GL_ARB_instanced_arrays */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#define GL_VIEW_CLASS_EAC_R11 0x9383 +#define GL_VIEW_CLASS_EAC_RG11 0x9384 +#define GL_VIEW_CLASS_ETC2_RGB 0x9385 +#define GL_VIEW_CLASS_ETC2_RGBA 0x9386 +#define GL_VIEW_CLASS_ETC2_EAC_RGBA 0x9387 +#define GL_VIEW_CLASS_ASTC_4x4_RGBA 0x9388 +#define GL_VIEW_CLASS_ASTC_5x4_RGBA 0x9389 +#define GL_VIEW_CLASS_ASTC_5x5_RGBA 0x938A +#define GL_VIEW_CLASS_ASTC_6x5_RGBA 0x938B +#define GL_VIEW_CLASS_ASTC_6x6_RGBA 0x938C +#define GL_VIEW_CLASS_ASTC_8x5_RGBA 0x938D +#define GL_VIEW_CLASS_ASTC_8x6_RGBA 0x938E +#define GL_VIEW_CLASS_ASTC_8x8_RGBA 0x938F +#define GL_VIEW_CLASS_ASTC_10x5_RGBA 0x9390 +#define GL_VIEW_CLASS_ASTC_10x6_RGBA 0x9391 +#define GL_VIEW_CLASS_ASTC_10x8_RGBA 0x9392 +#define GL_VIEW_CLASS_ASTC_10x10_RGBA 0x9393 +#define GL_VIEW_CLASS_ASTC_12x10_RGBA 0x9394 +#define GL_VIEW_CLASS_ASTC_12x12_RGBA 0x9395 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 + typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); + typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); + typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); + typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); + typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); + GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); + GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); + GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); + GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_ARB_matrix_palette */ + +#ifndef GL_ARB_multi_bind +#define GL_ARB_multi_bind 1 +#endif /* GL_ARB_multi_bind */ + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 + typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); +#endif +#endif /* GL_ARB_multisample */ + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); + typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glActiveTextureARB (GLenum texture); + GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); + GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); + GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); + GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); + GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); + GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); + GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); + GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); + GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); + GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); + GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); + GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); + GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); + GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); + GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); + GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); + GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); + GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); + GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); + GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); + GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); + GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); + GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); + GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); + GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); + GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); + GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); + GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); + GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); + GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); + GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); + GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); + GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif +#endif /* GL_ARB_multitexture */ + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 + typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); + typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); + typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); + typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); + typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); + typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); + GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); + GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); + GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); + GLAPI void APIENTRY glEndQueryARB (GLenum target); + GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_ARB_occlusion_query */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_parallel_shader_compile +#define GL_ARB_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 +#define GL_COMPLETION_STATUS_ARB 0x91B1 + typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); +#endif +#endif /* GL_ARB_parallel_shader_compile */ + +#ifndef GL_ARB_pipeline_statistics_query +#define GL_ARB_pipeline_statistics_query 1 +#define GL_VERTICES_SUBMITTED_ARB 0x82EE +#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 +#endif /* GL_ARB_pipeline_statistics_query */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 + typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); + GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_ARB_point_parameters */ + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ + +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + +#ifndef GL_ARB_post_depth_coverage +#define GL_ARB_post_depth_coverage 1 +#endif /* GL_ARB_post_depth_coverage */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_query_buffer_object +#define GL_ARB_query_buffer_object 1 +#endif /* GL_ARB_query_buffer_object */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 + typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); + typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); + typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); + typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); + typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); + typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); + typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); + typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); + typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); + typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); + typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); + typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); + typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); + typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); + typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); + typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); + typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); + typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); + GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); + GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); + GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); + GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); + GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); + GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); + GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); + GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); + GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); + GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); + GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); + GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); + GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); + GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); + GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); + GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); + GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); + GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); + GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_locations +#define GL_ARB_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 +#define GL_SAMPLE_LOCATION_ARB 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 + typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glEvaluateDepthValuesARB (void); +#endif +#endif /* GL_ARB_sample_locations */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 + typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif +#endif /* GL_ARB_sample_shading */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_seamless_cubemap_per_texture +#define GL_ARB_seamless_cubemap_per_texture 1 +#endif /* GL_ARB_seamless_cubemap_per_texture */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counter_ops +#define GL_ARB_shader_atomic_counter_ops 1 +#endif /* GL_ARB_shader_atomic_counter_ops */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_ballot +#define GL_ARB_shader_ballot 1 +#endif /* GL_ARB_shader_ballot */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_clock +#define GL_ARB_shader_clock 1 +#endif /* GL_ARB_shader_clock */ + +#ifndef GL_ARB_shader_draw_parameters +#define GL_ARB_shader_draw_parameters 1 +#endif /* GL_ARB_shader_draw_parameters */ + +#ifndef GL_ARB_shader_group_vote +#define GL_ARB_shader_group_vote 1 +#endif /* GL_ARB_shader_group_vote */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ + typedef void *GLhandleARB; +#else + typedef unsigned int GLhandleARB; +#endif + typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 + typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); + typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); + typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); + typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); + typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); + typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); + typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); + typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); + typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); + typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); + typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); + typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); + typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); + typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); + typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); + typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); + typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); + typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); + typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); + typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); + typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); + typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); + GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); + GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); + GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); + GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); + GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); + GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); + GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); + GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); + GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); + GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); + GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); + GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); + GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); + GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); + GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); + GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); + GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); + GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); + GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); + GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); + GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); + GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif +#endif /* GL_ARB_shader_objects */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shader_texture_image_samples +#define GL_ARB_shader_texture_image_samples 1 +#endif /* GL_ARB_shader_texture_image_samples */ + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ + +#ifndef GL_ARB_shader_viewport_layer_array +#define GL_ARB_shader_viewport_layer_array 1 +#endif /* GL_ARB_shader_viewport_layer_array */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA + typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); + typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); + typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); + typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); + typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); + typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); + GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); + GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); + GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); + GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); + GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_shading_language_include */ + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ + +#ifndef GL_ARB_sparse_buffer +#define GL_ARB_sparse_buffer 1 +#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 +#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 + typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); + typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); + typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); + GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); + GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_buffer */ + +#ifndef GL_ARB_sparse_texture +#define GL_ARB_sparse_texture 1 +#define GL_TEXTURE_SPARSE_ARB 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 +#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA +#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 + typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_texture */ + +#ifndef GL_ARB_sparse_texture2 +#define GL_ARB_sparse_texture2 1 +#endif /* GL_ARB_sparse_texture2 */ + +#ifndef GL_ARB_sparse_texture_clamp +#define GL_ARB_sparse_texture_clamp 1 +#endif /* GL_ARB_sparse_texture_clamp */ + +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_barrier +#define GL_ARB_texture_barrier 1 +#endif /* GL_ARB_texture_barrier */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E + typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_ARB_texture_buffer_object */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); +#endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + +#ifndef GL_ARB_texture_filter_minmax +#define GL_ARB_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 +#define GL_WEIGHTED_AVERAGE_ARB 0x9367 +#endif /* GL_ARB_texture_filter_minmax */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirror_clamp_to_edge +#define GL_ARB_texture_mirror_clamp_to_edge 1 +#endif /* GL_ARB_texture_mirror_clamp_to_edge */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_stencil8 +#define GL_ARB_texture_stencil8 1 +#endif /* GL_ARB_texture_stencil8 */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_transform_feedback_overflow_query +#define GL_ARB_transform_feedback_overflow_query 1 +#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED +#endif /* GL_ARB_transform_feedback_overflow_query */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 + typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); + typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); + typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); + typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); + GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); + GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); + GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif +#endif /* GL_ARB_transpose_matrix */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F + typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); + typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); + typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); + typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); + typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); + typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); + typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); + typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); + typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); + GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); + GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); + GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); + GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); + GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); + GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); + GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); + GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif +#endif /* GL_ARB_vertex_blend */ + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 + typedef khronos_ssize_t GLsizeiptrARB; + typedef khronos_intptr_t GLintptrARB; +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA + typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); + typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); + typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); + typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); + typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); + typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); + typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); + typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); + typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); + GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); + GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); + GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); + GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); + GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); + GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); + GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); + GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); + GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_ARB_vertex_buffer_object */ + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 + typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); + typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); + GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); + GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); + GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); + GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); + GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); + GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); + GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); + GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); + GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); + GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); + GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); + GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); + GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); + GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); + GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); + GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); +#endif +#endif /* GL_ARB_vertex_program */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A + typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); + typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); + typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); + GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); + GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif +#endif /* GL_ARB_vertex_shader */ + +#ifndef GL_ARB_vertex_type_10f_11f_11f_rev +#define GL_ARB_vertex_type_10f_11f_11f_rev 1 +#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 + typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYDVNVPROC) (GLuint first, GLsizei count, const GLdouble *v); + typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDDNVPROC) (GLuint index, GLdouble n, GLdouble f); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDepthRangeArraydvNV (GLuint first, GLsizei count, const GLdouble *v); + GLAPI void APIENTRY glDepthRangeIndexeddNV (GLuint index, GLdouble n, GLdouble f); +#endif +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 + typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); + typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); + typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); + typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); + typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); + typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); + GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); + GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); + GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); + GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); + GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); + GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); + GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); + GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); + GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); + GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); + GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); + GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); + GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 + typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 + typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_shader_subgroup +#define GL_KHR_shader_subgroup 1 +#define GL_SUBGROUP_SIZE_KHR 0x9532 +#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 +#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 +#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 +#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 +#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 +#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 +#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 +#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 +#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 +#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 +#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 +#endif /* GL_KHR_shader_subgroup */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 + typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); + typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); + typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); + typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); + typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); + typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); + typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); + typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); + typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); + typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y); + typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); + typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z); + typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); + typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w); + typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); + GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); + GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); + GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); + GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); + GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); + GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); + GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); + GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); + GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); + GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); + GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); + GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); + GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); + GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); + GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); + GLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y); + GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); + GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z); + GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); + GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w); + GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 + typedef khronos_int32_t GLfixed; +#define GL_FIXED_OES 0x140C + typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); + typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); + typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); + typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); + typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); + typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); + typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); + typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); + typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); + typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); + typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); + typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); + typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); + typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); + typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); + typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); + typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); + typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); + typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); + typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); + typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); + typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); + typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); + typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); + typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); + typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); + typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); + typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); + typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); + typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); + typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); + typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); + typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); + typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); + typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); + typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); + typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); + typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); + typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); + typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); + typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); + typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); + typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); + typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); + typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); + typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); + typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); + typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); + typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); + typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); + typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); + typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); + typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); + typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); + typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); + typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); + typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); + typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); + typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); + typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); + typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); + typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); + typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); + typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); + typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); + typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); + typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); + typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); + typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); + GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); + GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); + GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); + GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); + GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); + GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); + GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); + GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); + GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); + GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); + GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); + GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); + GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); + GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); + GLAPI void APIENTRY glLineWidthxOES (GLfixed width); + GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); + GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); + GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); + GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); + GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); + GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); + GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); + GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); + GLAPI void APIENTRY glPointSizexOES (GLfixed size); + GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); + GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); + GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); + GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); + GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); + GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); + GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); + GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); + GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); + GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); + GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); + GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); + GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); + GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); + GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); + GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); + GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); + GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); + GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); + GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); + GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); + GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); + GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); + GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); + GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); + GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); + GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); + GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); + GLAPI void APIENTRY glIndexxOES (GLfixed component); + GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); + GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); + GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); + GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); + GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); + GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); + GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); + GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); + GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); + GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); + GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); + GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); + GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); + GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); + GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); + GLAPI void APIENTRY glPassThroughxOES (GLfixed token); + GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); + GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); + GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); + GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); + GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); + GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); + GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); + GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); + GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); + GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); + GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); + GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); + GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); + GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); + GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); + GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); + GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); + GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); + GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); + GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); + GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); + GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); + GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); + GLAPI void APIENTRY glVertex2xOES (GLfixed x); + GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); + GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); + GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); + GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); + GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 + typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 + typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); + typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); + typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); + typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); + typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); + typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); + GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); + GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); + GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); + GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); + GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#endif +#endif /* GL_OES_single_precision */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 + typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif +#endif /* GL_3DFX_tbuffer */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 + typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 + typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); + typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); + typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufSize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); + GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); + GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufSize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif +#endif /* GL_AMD_debug_output */ + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 + typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); + typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); + GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); + GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_AMD_draw_buffers_blend */ + +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + +#ifndef GL_AMD_framebuffer_sample_positions +#define GL_AMD_framebuffer_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#define GL_PIXELS_PER_SAMPLE_PATTERN_X_AMD 0x91AE +#define GL_PIXELS_PER_SAMPLE_PATTERN_Y_AMD 0x91AF +#define GL_ALL_PIXELS_AMD 0xFFFFFFFF + typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERFVAMDPROC) (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERFVAMDPROC) (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferSamplePositionsfvAMD (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); + GLAPI void APIENTRY glNamedFramebufferSamplePositionsfvAMD (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); + GLAPI void APIENTRY glGetFramebufferParameterfvAMD (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); + GLAPI void APIENTRY glGetNamedFramebufferParameterfvAMD (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#endif +#endif /* GL_AMD_framebuffer_sample_positions */ + +#ifndef GL_AMD_gcn_shader +#define GL_AMD_gcn_shader 1 +#endif /* GL_AMD_gcn_shader */ + +#ifndef GL_AMD_gpu_shader_half_float +#define GL_AMD_gpu_shader_half_float 1 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_FLOAT16_MAT2_AMD 0x91C5 +#define GL_FLOAT16_MAT3_AMD 0x91C6 +#define GL_FLOAT16_MAT4_AMD 0x91C7 +#define GL_FLOAT16_MAT2x3_AMD 0x91C8 +#define GL_FLOAT16_MAT2x4_AMD 0x91C9 +#define GL_FLOAT16_MAT3x2_AMD 0x91CA +#define GL_FLOAT16_MAT3x4_AMD 0x91CB +#define GL_FLOAT16_MAT4x2_AMD 0x91CC +#define GL_FLOAT16_MAT4x3_AMD 0x91CD +#endif /* GL_AMD_gpu_shader_half_float */ + +#ifndef GL_AMD_gpu_shader_int16 +#define GL_AMD_gpu_shader_int16 1 +#endif /* GL_AMD_gpu_shader_int16 */ + +#ifndef GL_AMD_gpu_shader_int64 +#define GL_AMD_gpu_shader_int64 1 + typedef khronos_int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 + typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); + typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); + typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); + typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); + typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); + typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); + typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); + GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); + GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); + GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); + GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); + GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); + GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); + GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); + GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); + GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); + GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); + GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); + GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); + GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_AMD_gpu_shader_int64 */ + +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 + typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); +#endif +#endif /* GL_AMD_interleaved_elements */ + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); + GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#endif +#endif /* GL_AMD_multi_draw_indirect */ + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 + typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); + typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); + typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); + GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); + GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif +#endif /* GL_AMD_name_gen_delete */ + +#ifndef GL_AMD_occlusion_query_event +#define GL_AMD_occlusion_query_event 1 +#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F +#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 +#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 +#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 +#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 +#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF + typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); +#endif +#endif /* GL_AMD_occlusion_query_event */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 + typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); + typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); + typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); + typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); + typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); + typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); + typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); + typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); + typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); + typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); + typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); + GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); + GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); + GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); + GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); + GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); + GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); + GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); + GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); + GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); + GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 + typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif +#endif /* GL_AMD_sample_positions */ + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifndef GL_AMD_shader_atomic_counter_ops +#define GL_AMD_shader_atomic_counter_ops 1 +#endif /* GL_AMD_shader_atomic_counter_ops */ + +#ifndef GL_AMD_shader_ballot +#define GL_AMD_shader_ballot 1 +#endif /* GL_AMD_shader_ballot */ + +#ifndef GL_AMD_shader_explicit_vertex_parameter +#define GL_AMD_shader_explicit_vertex_parameter 1 +#endif /* GL_AMD_shader_explicit_vertex_parameter */ + +#ifndef GL_AMD_shader_gpu_shader_half_float_fetch +#define GL_AMD_shader_gpu_shader_half_float_fetch 1 +#endif /* GL_AMD_shader_gpu_shader_half_float_fetch */ + +#ifndef GL_AMD_shader_image_load_store_lod +#define GL_AMD_shader_image_load_store_lod 1 +#endif /* GL_AMD_shader_image_load_store_lod */ + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 + typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); + typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); + GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D + typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif +#endif /* GL_AMD_stencil_operation_extended */ + +#ifndef GL_AMD_texture_gather_bias_lod +#define GL_AMD_texture_gather_bias_lod 1 +#endif /* GL_AMD_texture_gather_bias_lod */ + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ + +#ifndef GL_AMD_transform_feedback4 +#define GL_AMD_transform_feedback4 1 +#define GL_STREAM_RASTERIZATION_AMD 0x91A0 +#endif /* GL_AMD_transform_feedback4 */ + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 + typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); + typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); + GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif +#endif /* GL_AMD_vertex_shader_tessellator */ + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E + typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); + typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); + typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); + typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); + GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); + GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); + GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); + GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif +#endif /* GL_APPLE_element_array */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B + typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); + typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); + typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); + typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); + typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); + typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); + typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); + typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); + GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); + GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); + GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); + GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); + GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); + GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); + GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif +#endif /* GL_APPLE_fence */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 + typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_APPLE_flush_buffer_range */ + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D + typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); + typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); + typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); + GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); + GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif +#endif /* GL_APPLE_object_purgeable */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF + typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); + GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_APPLE_texture_range */ + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 + typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); + typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); + typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); + typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); + GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); + GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); + GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif +#endif /* GL_APPLE_vertex_array_object */ + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 + typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); + typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); + typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); + GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); + GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif +#endif /* GL_APPLE_vertex_array_range */ + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 + typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); + typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); + typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); + typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); + typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); + typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); + typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); + GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); + GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); + GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); + GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); + GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); + GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif +#endif /* GL_APPLE_vertex_program_evaluators */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 + typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ATI_draw_buffers */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A + typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); + typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); + typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); + GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); + GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif +#endif /* GL_ATI_element_array */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C + typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); + typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); + typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); + GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); + GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); + GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif +#endif /* GL_ATI_envmap_bumpmap */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 + typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); + typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); + typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); + typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); + typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); + typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); + typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); + typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); + typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); + typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); + typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); + typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); + typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); + typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); + GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); + GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); + GLAPI void APIENTRY glBeginFragmentShaderATI (void); + GLAPI void APIENTRY glEndFragmentShaderATI (void); + GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); + GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); + GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); + GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); + GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); + GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); + GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); + GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); + GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif +#endif /* GL_ATI_fragment_shader */ + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 + typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); + GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif +#endif /* GL_ATI_map_object_buffer */ + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 + typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); + GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_pn_triangles */ + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 + typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif +#endif /* GL_ATI_separate_stencil */ + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 + typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); + typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); + typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); + typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); + typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); + GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); + GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); + GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); + GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); + GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); + GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); + GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_array_object */ + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 + typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); + GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_attrib_array_object */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 + typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); + typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); + typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); + typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); + typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); + typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); + typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); + typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); + typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); + typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); + typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); + typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); + typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); + typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); + typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); + typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); + typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); + typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); + typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); + typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); + typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); + typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); + typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); + typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); + typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); + GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); + GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); + GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); + GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); + GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); + GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); + GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); + GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); + GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); + GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); + GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); + GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); + GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); + GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); + GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); + GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); + GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); + GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); + GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); + GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); + GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); + GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); + GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); + GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); + GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); + GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); + GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); + GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); + GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); + GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); + GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); + GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); + GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); + GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); + GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); + GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); + GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); + GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); + GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); + GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_vertex_streams */ + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ + +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 + typedef void *GLeglImageOES; + typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); + typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); + GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + +#ifndef GL_EXT_EGL_sync +#define GL_EXT_EGL_sync 1 +#endif /* GL_EXT_EGL_sync */ + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF + typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); + typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); + typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); + GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); + GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif +#endif /* GL_EXT_bindable_uniform */ + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 + typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif +#endif /* GL_EXT_blend_color */ + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D + typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_EXT_blend_equation_separate */ + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_EXT_blend_func_separate */ + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 + typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 + typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif +#endif /* GL_EXT_color_subtable */ + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 + typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); + typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); + GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif +#endif /* GL_EXT_compiled_vertex_array */ + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 + typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); + typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); + typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); + typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); + typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); + typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); + typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); + GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); + GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); + GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); + GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); + GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); + GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#endif +#endif /* GL_EXT_convolution */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 + typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); + typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); + typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); + typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); + typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); + typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); + typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); + typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); + typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); + typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); + typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); + typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); + typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); + typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); + typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); + GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); + GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); + GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); + GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); + GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); + GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); + GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); + GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); + GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); + GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); + GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); + GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); + GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); + GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); + GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); + GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); + GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); + GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); + GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); + GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_coordinate_frame */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 + typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_copy_texture */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC + typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); + typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); + GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 + typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); + typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); + GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 + typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); + typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); + typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); + GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); + GLAPI void APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 + typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F + typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); + typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); + typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); + typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); + typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); + typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); + typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); + typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); + typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); + typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); + typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); + typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); + typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); + typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); + typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); + typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); + typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); + typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); + typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); + typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); + typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); + typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); + typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); + typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); + typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); + typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); + typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); + typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); + typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); + typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); + typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); + typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); + typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); + typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); + typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); + typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); + typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); + typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); + typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); + typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); + typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); + GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); + GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); + GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); + GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); + GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); + GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); + GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); + GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); + GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); + GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); + GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); + GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); + GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); + GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); + GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); + GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); + GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); + GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); + GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); + GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); + GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); + GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); + GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); + GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); + GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); + GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); + GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); + GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); + GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); + GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); + GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); + GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); + GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); + GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); + GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); + GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); + GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); + GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); + GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); + GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); + GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); + GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); + GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); + GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); + GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); + GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); + GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); + GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); + GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); + GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); + GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); + GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); + GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); + GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); + GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); + GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); + GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); + GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); + GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); + GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); + GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); + GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); + GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); + GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); + GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); + GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); + GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); + GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); + GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); + GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); + GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); + GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); + GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); + GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); + GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); + GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); + GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); + GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); + GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); + GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); + GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); + GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); + GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); + GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); + GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); + GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); + GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); + GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); + GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); + GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); + GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); + GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); + GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); + GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); + GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); + GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); + GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); + GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); + GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); + GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); + GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); + GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); + GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); + GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); + GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); + GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 + typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#endif +#endif /* GL_EXT_draw_buffers2 */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); + GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 + typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#endif +#endif /* GL_EXT_draw_range_elements */ + +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 + typedef void *GLeglClientBufferEXT; + typedef void (APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); + GLAPI void APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 + typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); + typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); + typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); + typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); + typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); + GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); + GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); + GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); + GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA + typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_framebuffer_multisample */ + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 + typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); + typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); + typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); + typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); + typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); + typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); + typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); + typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); + GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); + GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); + GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); + GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); + GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); + GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); + GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); + GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); + GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); + GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); + GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 + typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif +#endif /* GL_EXT_geometry_shader4 */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); + GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD + typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); + typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); + typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); + typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); + typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); + typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); + typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); + GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); + GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); + GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); + GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); + GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); + GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); + GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); + GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); + GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); + GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); + GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); + GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); + GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); + GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); + GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); + GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); + GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); + GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); + GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 + typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); + typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); + typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); + typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); + typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); + typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); + GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); + GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); + GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); + GLAPI void APIENTRY glResetHistogramEXT (GLenum target); + GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 + typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif +#endif /* GL_EXT_index_func */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA + typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_index_material */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 + typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); + typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); + typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); + GLAPI void APIENTRY glTextureLightEXT (GLenum pname); + GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 + typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); + typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); + typedef void (APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); + typedef GLboolean (APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); + typedef void (APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); + typedef void (APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXSTORAGEMEM1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM1DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); + GLAPI void APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); + GLAPI void APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); + GLAPI GLboolean APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); + GLAPI void APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); + GLAPI void APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); + GLAPI void APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); + GLAPI void APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTexStorageMem1DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTextureStorageMem1DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 + typedef void (APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C + typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); + typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); + GLAPI void APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif /* GL_EXT_misc_attribute */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); + GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 + typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); + typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); + GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_multiview_tessellation_geometry_shader +#define GL_EXT_multiview_tessellation_geometry_shader 1 +#endif /* GL_EXT_multiview_tessellation_geometry_shader */ + +#ifndef GL_EXT_multiview_texture_multisample +#define GL_EXT_multiview_texture_multisample 1 +#endif /* GL_EXT_multiview_texture_multisample */ + +#ifndef GL_EXT_multiview_timer_query +#define GL_EXT_multiview_timer_query 1 +#endif /* GL_EXT_multiview_timer_query */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED + typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); + typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); + typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); + GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); + GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_paletted_texture */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 + typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); + GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_pixel_transform */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 + typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); + GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_EXT_point_parameters */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 + typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif +#endif /* GL_EXT_polygon_offset */ + +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B + typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F + typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C + typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); + typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); + GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); + GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); + GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); + GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); + GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); + GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); + GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); + GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); + GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); + GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); + GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); + GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); + GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); + GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); + GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); + GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 + typedef void (APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); + typedef void (APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); + typedef GLboolean (APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); + typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); + typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); + typedef void (APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); + typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); + GLAPI void APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); + GLAPI GLboolean APIENTRY glIsSemaphoreEXT (GLuint semaphore); + GLAPI void APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); + GLAPI void APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); + GLAPI void APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); + GLAPI void APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 + typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 + typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); + typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); + GLAPI void APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D + typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); + typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); + typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); + GLAPI void APIENTRY glActiveProgramEXT (GLuint program); + GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ + +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 + typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + +#ifndef GL_EXT_shader_image_load_formatted +#define GL_EXT_shader_image_load_formatted 1 +#endif /* GL_EXT_shader_image_load_formatted */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF + typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); + typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); + GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif +#endif /* GL_EXT_shader_image_load_store */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ + +#ifndef GL_EXT_sparse_texture2 +#define GL_EXT_sparse_texture2 1 +#endif /* GL_EXT_sparse_texture2 */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 + typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif +#endif /* GL_EXT_stencil_clear_tag */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 + typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif +#endif /* GL_EXT_stencil_two_side */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 + typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_subtexture */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 + typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E + typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E + typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); + typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); + GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); + GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); + GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif +#endif /* GL_EXT_texture_integer */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A + typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); + typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); + typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); + typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); + typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); + typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); + GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); + GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); + GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); + GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); + GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif +#endif /* GL_EXT_texture_object */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF + typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + +#ifndef GL_EXT_texture_sRGB_RG8 +#define GL_EXT_texture_sRGB_RG8 1 +#define GL_SRG8_EXT 0x8FBE +#endif /* GL_EXT_texture_sRGB_RG8 */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shadow_lod +#define GL_EXT_texture_shadow_lod 1 +#endif /* GL_EXT_texture_shadow_lod */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_storage +#define GL_EXT_texture_storage 1 +#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F +#define GL_RGBA32F_EXT 0x8814 +#define GL_RGB32F_EXT 0x8815 +#define GL_ALPHA32F_EXT 0x8816 +#define GL_LUMINANCE32F_EXT 0x8818 +#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 +#define GL_RGBA16F_EXT 0x881A +#define GL_RGB16F_EXT 0x881B +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_BGRA8_EXT 0x93A1 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +#define GL_R16F_EXT 0x822D +#define GL_RG16F_EXT 0x822F + typedef void (APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + GLAPI void APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + GLAPI void APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_EXT_texture_storage */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#define GL_TIME_ELAPSED_EXT 0x88BF + typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); + GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 + typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); + typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); + typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); + typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); + GLAPI void APIENTRY glEndTransformFeedbackEXT (void); + GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); + GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); + GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); + GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif +#endif /* GL_EXT_transform_feedback */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 + typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); + typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); + typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); + typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); + typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); + typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); + typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); + typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); + typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glArrayElementEXT (GLint i); + GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); + GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); + GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); + GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); + GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); + GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); + GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); + GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); + GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); + GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED + typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); + typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); + typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); + typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); + typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); + typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); + typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); + typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); + typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); + typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); + typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); + typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); + typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); + typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); + typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); + typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); + typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); + typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); + typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); + typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); + typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); + typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); + typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); + typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); + typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); + typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); + typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); + typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); + typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); + typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); + typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); + typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); + typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); + typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); + typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); + typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); + typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); + typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); + typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); + typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); + typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); + typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBeginVertexShaderEXT (void); + GLAPI void APIENTRY glEndVertexShaderEXT (void); + GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); + GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); + GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); + GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); + GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); + GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); + GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); + GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); + GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); + GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); + GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); + GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); + GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); + GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); + GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); + GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); + GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); + GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); + GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); + GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); + GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); + GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); + GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); + GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); + GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); + GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); + GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); + GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); + GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); + GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); + GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); + GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); + GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); + GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); + GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); + GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); + GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); + GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); + GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); + GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 + typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); + typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); + typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); + GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); + GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_vertex_weighting */ + +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 + typedef GLboolean (APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); + typedef GLboolean (APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLboolean APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); + GLAPI GLboolean APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 + typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 + typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif +#endif /* GL_EXT_x11_sync_object */ + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 + typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif +#endif /* GL_GREMEDY_frame_terminator */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 + typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); +#endif +#endif /* GL_GREMEDY_string_marker */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 + typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); + GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_HP_image_transform */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 + typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); + typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); + GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#endif +#endif /* GL_IBM_multimode_draw_arrays */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 + typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 + typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); + typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); + typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); + typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); + typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); + typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); + typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); + typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); + GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); + GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); + GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); + GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); + GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); + GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); + GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#endif +#endif /* GL_IBM_vertex_array_lists */ + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_INGR_blend_func_separate */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ + +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + +#ifndef GL_INTEL_fragment_shader_ordering +#define GL_INTEL_fragment_shader_ordering 1 +#endif /* GL_INTEL_fragment_shader_ordering */ + +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 + typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 + typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); + typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); + typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); + GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); + GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#endif +#endif /* GL_INTEL_map_texture */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 + typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); + typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); + typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); + typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); + GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); + GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); + GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 + typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); + typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); + typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); + typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); + typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); + typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); + typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); + typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); + typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); + typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); + GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); + GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); + GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); + GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); + GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); + GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); + GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); + GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); + GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ + +#ifndef GL_MESA_framebuffer_flip_x +#define GL_MESA_framebuffer_flip_x 1 +#define GL_FRAMEBUFFER_FLIP_X_MESA 0x8BBC +#endif /* GL_MESA_framebuffer_flip_x */ + +#ifndef GL_MESA_framebuffer_flip_y +#define GL_MESA_framebuffer_flip_y 1 +#define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB + typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); + GLAPI void APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_MESA_framebuffer_flip_y */ + +#ifndef GL_MESA_framebuffer_swap_xy +#define GL_MESA_framebuffer_swap_xy 1 +#define GL_FRAMEBUFFER_SWAP_XY_MESA 0x8BBD +#endif /* GL_MESA_framebuffer_swap_xy */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ + +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 + typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_MESA_tile_raster_order +#define GL_MESA_tile_raster_order 1 +#define GL_TILE_RASTER_ORDER_FIXED_MESA 0x8BB8 +#define GL_TILE_RASTER_ORDER_INCREASING_X_MESA 0x8BB9 +#define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA 0x8BBA +#endif /* GL_MESA_tile_raster_order */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 + typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); + typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); + typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); + typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); + typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); + typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); + typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); + typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); + typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); + typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); + typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); + typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); + GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); + GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); + GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); + GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); + GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); + GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); + GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); + GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); + GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); + GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); + GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); + GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); + GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); + GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); + GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); + GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); + GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); + GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); + GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 + typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); + typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); + GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NVX_gpu_memory_info +#define GL_NVX_gpu_memory_info 1 +#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 +#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 +#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 +#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A +#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B +#endif /* GL_NVX_gpu_memory_info */ + +#ifndef GL_NVX_gpu_multicast2 +#define GL_NVX_gpu_multicast2 1 +#define GL_UPLOAD_GPU_MASK_NVX 0x954A + typedef void (APIENTRYP PFNGLUPLOADGPUMASKNVXPROC) (GLbitfield mask); + typedef void (APIENTRYP PFNGLMULTICASTVIEWPORTARRAYVNVXPROC) (GLuint gpu, GLuint first, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLMULTICASTVIEWPORTPOSITIONWSCALENVXPROC) (GLuint gpu, GLuint index, GLfloat xcoeff, GLfloat ycoeff); + typedef void (APIENTRYP PFNGLMULTICASTSCISSORARRAYVNVXPROC) (GLuint gpu, GLuint first, GLsizei count, const GLint *v); + typedef GLuint (APIENTRYP PFNGLASYNCCOPYBUFFERSUBDATANVXPROC) (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *fenceValueArray, GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); + typedef GLuint (APIENTRYP PFNGLASYNCCOPYIMAGESUBDATANVXPROC) (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *waitValueArray, GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glUploadGpuMaskNVX (GLbitfield mask); + GLAPI void APIENTRY glMulticastViewportArrayvNVX (GLuint gpu, GLuint first, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glMulticastViewportPositionWScaleNVX (GLuint gpu, GLuint index, GLfloat xcoeff, GLfloat ycoeff); + GLAPI void APIENTRY glMulticastScissorArrayvNVX (GLuint gpu, GLuint first, GLsizei count, const GLint *v); + GLAPI GLuint APIENTRY glAsyncCopyBufferSubDataNVX (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *fenceValueArray, GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); + GLAPI GLuint APIENTRY glAsyncCopyImageSubDataNVX (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *waitValueArray, GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +#endif +#endif /* GL_NVX_gpu_multicast2 */ + +#ifndef GL_NVX_linked_gpu_multicast +#define GL_NVX_linked_gpu_multicast 1 +#define GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 +#define GL_MAX_LGPU_GPUS_NVX 0x92BA + typedef void (APIENTRYP PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + typedef void (APIENTRYP PFNGLLGPUCOPYIMAGESUBDATANVXPROC) (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLLGPUINTERLOCKNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glLGPUNamedBufferSubDataNVX (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + GLAPI void APIENTRY glLGPUCopyImageSubDataNVX (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); + GLAPI void APIENTRY glLGPUInterlockNVX (void); +#endif +#endif /* GL_NVX_linked_gpu_multicast */ + +#ifndef GL_NVX_progress_fence +#define GL_NVX_progress_fence 1 + typedef GLuint (APIENTRYP PFNGLCREATEPROGRESSFENCENVXPROC) (void); + typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREUI64NVXPROC) (GLuint signalGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); + typedef void (APIENTRYP PFNGLWAITSEMAPHOREUI64NVXPROC) (GLuint waitGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); + typedef void (APIENTRYP PFNGLCLIENTWAITSEMAPHOREUI64NVXPROC) (GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLuint APIENTRY glCreateProgressFenceNVX (void); + GLAPI void APIENTRY glSignalSemaphoreui64NVX (GLuint signalGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); + GLAPI void APIENTRY glWaitSemaphoreui64NVX (GLuint waitGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); + GLAPI void APIENTRY glClientWaitSemaphoreui64NVX (GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +#endif +#endif /* GL_NVX_progress_fence */ + +#ifndef GL_NV_alpha_to_coverage_dither_control +#define GL_NV_alpha_to_coverage_dither_control 1 +#define GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D +#define GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E +#define GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV 0x934F +#define GL_ALPHA_TO_COVERAGE_DITHER_MODE_NV 0x92BF + typedef void (APIENTRYP PFNGLALPHATOCOVERAGEDITHERCONTROLNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glAlphaToCoverageDitherControlNV (GLenum mode); +#endif +#endif /* GL_NV_alpha_to_coverage_dither_control */ + +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); + GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect */ + +#ifndef GL_NV_bindless_multi_draw_indirect_count +#define GL_NV_bindless_multi_draw_indirect_count 1 + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); + GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect_count */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 + typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); + typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); + typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); + typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); + typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); + typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); + typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); + typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); + typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); + typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); + typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); + GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); + GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); + GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); + GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); + GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); + GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); + GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); + GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); + GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); + GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); + GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); + GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 + typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); + GLAPI void APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E + typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_command_list +#define GL_NV_command_list 1 +#define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 +#define GL_NOP_COMMAND_NV 0x0001 +#define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 +#define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 +#define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 +#define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 +#define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 +#define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 +#define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 +#define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 +#define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A +#define GL_BLEND_COLOR_COMMAND_NV 0x000B +#define GL_STENCIL_REF_COMMAND_NV 0x000C +#define GL_LINE_WIDTH_COMMAND_NV 0x000D +#define GL_POLYGON_OFFSET_COMMAND_NV 0x000E +#define GL_ALPHA_REF_COMMAND_NV 0x000F +#define GL_VIEWPORT_COMMAND_NV 0x0010 +#define GL_SCISSOR_COMMAND_NV 0x0011 +#define GL_FRONT_FACE_COMMAND_NV 0x0012 + typedef void (APIENTRYP PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint *states); + typedef void (APIENTRYP PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint *states); + typedef GLboolean (APIENTRYP PFNGLISSTATENVPROC) (GLuint state); + typedef void (APIENTRYP PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); + typedef GLuint (APIENTRYP PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); + typedef GLushort (APIENTRYP PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); + typedef void (APIENTRYP PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); + typedef void (APIENTRYP PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); + typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + typedef void (APIENTRYP PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint *lists); + typedef void (APIENTRYP PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint *lists); + typedef GLboolean (APIENTRYP PFNGLISCOMMANDLISTNVPROC) (GLuint list); + typedef void (APIENTRYP PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + typedef void (APIENTRYP PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); + typedef void (APIENTRYP PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); + typedef void (APIENTRYP PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCreateStatesNV (GLsizei n, GLuint *states); + GLAPI void APIENTRY glDeleteStatesNV (GLsizei n, const GLuint *states); + GLAPI GLboolean APIENTRY glIsStateNV (GLuint state); + GLAPI void APIENTRY glStateCaptureNV (GLuint state, GLenum mode); + GLAPI GLuint APIENTRY glGetCommandHeaderNV (GLenum tokenID, GLuint size); + GLAPI GLushort APIENTRY glGetStageIndexNV (GLenum shadertype); + GLAPI void APIENTRY glDrawCommandsNV (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); + GLAPI void APIENTRY glDrawCommandsAddressNV (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); + GLAPI void APIENTRY glDrawCommandsStatesNV (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + GLAPI void APIENTRY glDrawCommandsStatesAddressNV (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + GLAPI void APIENTRY glCreateCommandListsNV (GLsizei n, GLuint *lists); + GLAPI void APIENTRY glDeleteCommandListsNV (GLsizei n, const GLuint *lists); + GLAPI GLboolean APIENTRY glIsCommandListNV (GLuint list); + GLAPI void APIENTRY glListDrawCommandsStatesClientNV (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); + GLAPI void APIENTRY glCommandListSegmentsNV (GLuint list, GLuint segments); + GLAPI void APIENTRY glCompileCommandListNV (GLuint list); + GLAPI void APIENTRY glCallCommandListNV (GLuint list); +#endif +#endif /* GL_NV_command_list */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 + typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); + typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); + GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 + typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_conservative_raster_dilate +#define GL_NV_conservative_raster_dilate 1 +#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 +#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A +#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B + typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat value); +#endif +#endif /* GL_NV_conservative_raster_dilate */ + +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F + typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 + typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF + typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); + typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); + typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); + GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); + GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 + typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 + typedef void (APIENTRY *GLVULKANPROCNV)(void); + typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); + typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); + typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); + typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); + typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); + GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); + GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); + GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); + GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 + typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); + typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); + typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); + GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); + GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 + typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); + typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); + typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); + GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); + GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 + typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); + typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); + typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); + typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); + typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); + typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); + GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); + GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); + GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); + GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); + GLAPI void APIENTRY glFinishFenceNV (GLuint fence); + GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ + +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE + typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 + typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); + typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); + typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); + typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); + GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); + GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); + GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif +#endif /* GL_NV_fragment_program */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 + typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); + typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); + typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); + GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); + GLAPI void APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 + typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); + GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); + GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_multicast +#define GL_NV_gpu_multicast 1 +#define GL_PER_GPU_STORAGE_BIT_NV 0x0800 +#define GL_MULTICAST_GPUS_NV 0x92BA +#define GL_RENDER_GPU_MASK_NV 0x9558 +#define GL_PER_GPU_STORAGE_NV 0x9548 +#define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 + typedef void (APIENTRYP PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); + typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + typedef void (APIENTRYP PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); + typedef void (APIENTRYP PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + typedef void (APIENTRYP PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLMULTICASTBARRIERNVPROC) (void); + typedef void (APIENTRYP PFNGLMULTICASTWAITSYNCNVPROC) (GLuint signalGpu, GLbitfield waitGpuMask); + typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); + typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glRenderGpuMaskNV (GLbitfield mask); + GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + GLAPI void APIENTRY glMulticastCopyBufferSubDataNV (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + GLAPI void APIENTRY glMulticastCopyImageSubDataNV (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); + GLAPI void APIENTRY glMulticastBlitFramebufferNV (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + GLAPI void APIENTRY glMulticastFramebufferSampleLocationsfvNV (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glMulticastBarrierNV (void); + GLAPI void APIENTRY glMulticastWaitSyncNV (GLuint signalGpu, GLbitfield waitGpuMask); + GLAPI void APIENTRY glMulticastGetQueryObjectivNV (GLuint gpu, GLuint id, GLenum pname, GLint *params); + GLAPI void APIENTRY glMulticastGetQueryObjectuivNV (GLuint gpu, GLuint id, GLenum pname, GLuint *params); + GLAPI void APIENTRY glMulticastGetQueryObjecti64vNV (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); + GLAPI void APIENTRY glMulticastGetQueryObjectui64vNV (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_NV_gpu_multicast */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); + typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); + typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); + GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); + GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); + GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); + GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); + GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); + GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); + GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); + GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); + GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); + GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); + GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); + GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); + GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 + typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); + GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif +#endif /* GL_NV_gpu_program5 */ + +#ifndef GL_NV_gpu_program5_mem_extended +#define GL_NV_gpu_program5_mem_extended 1 +#endif /* GL_NV_gpu_program5_mem_extended */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 + typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B + typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); + typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); + typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); + typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); + typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); + typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); + typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); + typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); + typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); + typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); + typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); + typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); + typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); + typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); + typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); + typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); + typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); + typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); + typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); + GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); + GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); + GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); + GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); + GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); + GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); + GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); + GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); + GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); + GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); + GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); + GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); + GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); + GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); + GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); + GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); + GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); + GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); + GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); + GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); + GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); + GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); + GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); + GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); + GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); + GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); + GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); + GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); + GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); + GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); + GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); + GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); + GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); + GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); + GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 + typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD + typedef void (APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); + typedef void (APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); + typedef void (APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); + typedef void (APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); + GLAPI void APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); + GLAPI void APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); + GLAPI void APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_memory_object_sparse +#define GL_NV_memory_object_sparse 1 + typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTMEMNVPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); + typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTMEMNVPROC) (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); + typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTMEMNVPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); + typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTMEMNVPROC) (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBufferPageCommitmentMemNV (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); + GLAPI void APIENTRY glTexPageCommitmentMemNV (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); + GLAPI void APIENTRY glNamedBufferPageCommitmentMemNV (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); + GLAPI void APIENTRY glTexturePageCommitmentMemNV (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#endif +#endif /* GL_NV_memory_object_sparse */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F + typedef void (APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); + typedef void (APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); + typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); + GLAPI void APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); + GLAPI void APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); + GLAPI void APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_NV_mesh_shader */ + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif /* GL_NV_multisample_coverage */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 + typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); + typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); + typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); + typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); + typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); + typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); + GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); + GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); + GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); + GLAPI void APIENTRY glEndOcclusionQueryNV (void); + GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_occlusion_query */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 + typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); + typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); + typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); + GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); + GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_2_BYTES_NV 0x1407 +#define GL_3_BYTES_NV 0x1408 +#define GL_4_BYTES_NV 0x1409 +#define GL_EYE_LINEAR_NV 0x2400 +#define GL_OBJECT_LINEAR_NV 0x2401 +#define GL_CONSTANT_NV 0x8576 +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D + typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); + typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); + typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); + typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); + typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); + typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); + typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); + typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); + typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); + typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); + typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); + typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); + typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); + typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); + typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); + typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); + typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); + typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); + typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); + typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); + typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); + typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); + typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); + typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); + typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); + typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); + typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); + typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); + typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); + typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); + typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); + typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); + typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); + typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); + typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); + typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); + typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); + typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); + typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); + typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); + typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); + typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); + typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); + typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); + typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); + typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); + typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); + GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); + GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); + GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); + GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); + GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); + GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); + GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); + GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); + GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); + GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); + GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); + GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); + GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); + GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); + GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); + GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); + GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); + GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); + GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); + GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); + GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); + GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); + GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); + GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); + GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); + GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); + GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); + GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); + GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); + GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); + GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); + GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); + GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); + GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); + GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); + GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); + GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); + GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); + GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); + GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); + GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); + GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); + GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); + GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); + GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); + GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); + GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); + GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); + GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D + typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); + typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); + GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif +#endif /* GL_NV_pixel_data_range */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 + typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); + GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B + typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); + typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); + typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); + typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); + typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); + GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); + GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); + GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); + GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_NV_present_video */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 + typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); + typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPrimitiveRestartNV (void); + GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_primitive_shading_rate +#define GL_NV_primitive_shading_rate 1 +#define GL_SHADING_RATE_IMAGE_PER_PRIMITIVE_NV 0x95B1 +#define GL_SHADING_RATE_IMAGE_PALETTE_COUNT_NV 0x95B2 +#endif /* GL_NV_primitive_shading_rate */ + +#ifndef GL_NV_query_resource +#define GL_NV_query_resource 1 +#define GL_QUERY_RESOURCE_TYPE_VIDMEM_ALLOC_NV 0x9540 +#define GL_QUERY_RESOURCE_MEMTYPE_VIDMEM_NV 0x9542 +#define GL_QUERY_RESOURCE_SYS_RESERVED_NV 0x9544 +#define GL_QUERY_RESOURCE_TEXTURE_NV 0x9545 +#define GL_QUERY_RESOURCE_RENDERBUFFER_NV 0x9546 +#define GL_QUERY_RESOURCE_BUFFEROBJECT_NV 0x9547 + typedef GLint (APIENTRYP PFNGLQUERYRESOURCENVPROC) (GLenum queryType, GLint tagId, GLuint count, GLint *buffer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLint APIENTRY glQueryResourceNV (GLenum queryType, GLint tagId, GLuint count, GLint *buffer); +#endif +#endif /* GL_NV_query_resource */ + +#ifndef GL_NV_query_resource_tag +#define GL_NV_query_resource_tag 1 + typedef void (APIENTRYP PFNGLGENQUERYRESOURCETAGNVPROC) (GLsizei n, GLint *tagIds); + typedef void (APIENTRYP PFNGLDELETEQUERYRESOURCETAGNVPROC) (GLsizei n, const GLint *tagIds); + typedef void (APIENTRYP PFNGLQUERYRESOURCETAGNVPROC) (GLint tagId, const GLchar *tagString); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGenQueryResourceTagNV (GLsizei n, GLint *tagIds); + GLAPI void APIENTRY glDeleteQueryResourceTagNV (GLsizei n, const GLint *tagIds); + GLAPI void APIENTRY glQueryResourceTagNV (GLint tagId, const GLchar *tagString); +#endif +#endif /* GL_NV_query_resource_tag */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 + typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); + typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); + typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); + typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); + GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); + GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); + GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); + GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); + GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); + GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 + typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + +#ifndef GL_NV_robustness_video_memory_purge +#define GL_NV_robustness_video_memory_purge 1 +#define GL_PURGED_CONTEXT_RESET_NV 0x92BB +#endif /* GL_NV_robustness_video_memory_purge */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 + typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 + typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_atomic_int64 +#define GL_NV_shader_atomic_int64 1 +#endif /* GL_NV_shader_atomic_int64 */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 + typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); + typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); + typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); + typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); + typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); + typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); + typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); + typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); + typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); + typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); + GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); + GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); + GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); + GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); + GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); + GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); + GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); + GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); + GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); + GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); + GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); + GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_shader_subgroup_partitioned +#define GL_NV_shader_subgroup_partitioned 1 +#define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 +#endif /* GL_NV_shader_subgroup_partitioned */ + +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + +#ifndef GL_NV_shader_thread_group +#define GL_NV_shader_thread_group 1 +#define GL_WARP_SIZE_NV 0x9339 +#define GL_WARPS_PER_SM_NV 0x933A +#define GL_SM_COUNT_NV 0x933B +#endif /* GL_NV_shader_thread_group */ + +#ifndef GL_NV_shader_thread_shuffle +#define GL_NV_shader_thread_shuffle 1 +#endif /* GL_NV_shader_thread_shuffle */ + +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 + typedef void (APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); + typedef void (APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); + typedef void (APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); + typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); + typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); + typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); + typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBindShadingRateImageNV (GLuint texture); + GLAPI void APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); + GLAPI void APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); + GLAPI void APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); + GLAPI void APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); + GLAPI void APIENTRY glShadingRateSampleOrderNV (GLenum order); + GLAPI void APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 + typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 + typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif +#endif /* GL_NV_texture_multisample */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_timeline_semaphore +#define GL_NV_timeline_semaphore 1 +#define GL_TIMELINE_SEMAPHORE_VALUE_NV 0x9595 +#define GL_SEMAPHORE_TYPE_NV 0x95B3 +#define GL_SEMAPHORE_TYPE_BINARY_NV 0x95B4 +#define GL_SEMAPHORE_TYPE_TIMELINE_NV 0x95B5 +#define GL_MAX_TIMELINE_SEMAPHORE_VALUE_DIFFERENCE_NV 0x95B6 + typedef void (APIENTRYP PFNGLCREATESEMAPHORESNVPROC) (GLsizei n, GLuint *semaphores); + typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glCreateSemaphoresNV (GLsizei n, GLuint *semaphores); + GLAPI void APIENTRY glSemaphoreParameterivNV (GLuint semaphore, GLenum pname, const GLint *params); + GLAPI void APIENTRY glGetSemaphoreParameterivNV (GLuint semaphore, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_timeline_semaphore */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 + typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); + typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLenum bufferMode); + typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); + typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); + typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); + typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); + typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); + GLAPI void APIENTRY glEndTransformFeedbackNV (void); + GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLsizei count, const GLint *attribs, GLenum bufferMode); + GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); + GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); + GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); + GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); + GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); + GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); + GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); + GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif +#endif /* GL_NV_transform_feedback */ + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 + typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); + typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); + typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); + typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); + typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); + typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); + GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); + GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); + GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); + GLAPI void APIENTRY glPauseTransformFeedbackNV (void); + GLAPI void APIENTRY glResumeTransformFeedbackNV (void); + GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif +#endif /* GL_NV_transform_feedback2 */ + +#ifndef GL_NV_uniform_buffer_unified_memory +#define GL_NV_uniform_buffer_unified_memory 1 +#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E +#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F +#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 +#endif /* GL_NV_uniform_buffer_unified_memory */ + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 + typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE + typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); + typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); + typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); + typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); + typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); + typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); + typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei count, GLsizei *length, GLint *values); + typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); + typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); + typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); + GLAPI void APIENTRY glVDPAUFiniNV (void); + GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); + GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); + GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); + GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); + GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei count, GLsizei *length, GLint *values); + GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); + GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); + GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif +#endif /* GL_NV_vdpau_interop */ + +#ifndef GL_NV_vdpau_interop2 +#define GL_NV_vdpau_interop2 1 + typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACEWITHPICTURESTRUCTURENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceWithPictureStructureNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#endif +#endif /* GL_NV_vdpau_interop2 */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 + typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); + typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); + GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); +#endif +#endif /* GL_NV_vertex_array_range */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); + typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); + GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); + GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); + GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); + GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); + GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); + GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); + GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); + GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); + GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); + GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); + GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); + GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); + GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); + GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); + GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); + GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); + GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); + GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 + typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); + typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); + typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); + typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); + GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); + GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); + GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); + GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); + GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); + GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); + GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); + GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); + GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); + GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); + GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F + typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); + typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); + typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); + typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); + typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); + typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); + typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); + typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); + typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); + typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); + typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); + typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); + typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); + typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); + GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); + GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); + GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); + GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); + GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); + GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); + GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); + GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); + GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); + GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); + GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); + GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); + GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); + GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); + GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); + GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); + GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); + GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); + GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); + GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); + GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); + GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); + GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); + GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); + GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); + GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); + GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); + GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); + GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); + GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); + GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); + GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); + GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); + GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); + GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif +#endif /* GL_NV_vertex_program */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif /* GL_NV_vertex_program4 */ + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C + typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); + typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); + typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); + typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); + typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); + typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); + typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); + GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); + GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); + GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); + GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); + GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); + GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); + GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif +#endif /* GL_NV_video_capture */ + +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B + typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ + +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview */ + +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 + typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif +#endif /* GL_PGI_misc_hints */ + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C + typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); + typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); + GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_detail_texture */ + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C + typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); + typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); + GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif +#endif /* GL_SGIS_fog_function */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC + typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); + typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); + GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif +#endif /* GL_SGIS_multisample */ + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 + typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); + GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); + GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); + GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); + GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif +#endif /* GL_SGIS_pixel_texture */ + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 + typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); + GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_SGIS_point_parameters */ + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 + typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); + typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); + GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_sharpen_texture */ + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F + typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_SGIS_texture4D */ + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF + typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif +#endif /* GL_SGIS_texture_color_mask */ + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 + typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); + typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); + GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif +#endif /* GL_SGIS_texture_filter4 */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 + typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); + typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); + typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); + typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); + typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); + typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); + GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); + GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); + GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); + GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); + GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif +#endif /* GL_SGIX_async */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 + typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif +#endif /* GL_SGIX_flush_raster */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 + typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); + typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); + GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); + GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); + GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); + GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); + GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); + GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); + GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); + GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); + GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); + GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); + GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); + GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif +#endif /* GL_SGIX_fragment_lighting */ + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D + typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif +#endif /* GL_SGIX_framezoom */ + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 + typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); +#endif +#endif /* GL_SGIX_igloo_interface */ + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 + typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); + typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); + typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); + typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); + typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); + typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); + GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); + GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); + GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); + GLAPI void APIENTRY glStartInstrumentsSGIX (void); + GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif +#endif /* GL_SGIX_instruments */ + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 + typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); + GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); + GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); + GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_list_priority */ + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B + typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif +#endif /* GL_SGIX_pixel_texture */ + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 + typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); + typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); + typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); + typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); + GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); + GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); + GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif +#endif /* GL_SGIX_polynomial_ffd */ + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E + typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif +#endif /* GL_SGIX_reference_plane */ + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842E +#define GL_UNPACK_RESAMPLE_SGIX 0x842F +#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E + typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); + GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); + GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_sprite */ + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 + typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif +#endif /* GL_SGIX_tag_sample_buffer */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF + typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); + typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); + typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); + typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); + GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); + GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); + GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); + GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); + GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_SGI_color_table */ + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 + typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif +#endif /* GL_SUNX_constant_data */ + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA + typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); + typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); + typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); + typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); + typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); + typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); + typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); + typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); + GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); + GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); + GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); + GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); + GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); + GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); + GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif +#endif /* GL_SUN_global_alpha */ + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 + typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif +#endif /* GL_SUN_mesh_array */ + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); + GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); + GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); + GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); + GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); + GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); + GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); +#endif +#endif /* GL_SUN_triangle_list */ + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 + typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); + typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); + typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); + typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); + typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); + typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); + typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); + typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); + typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); + typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); + typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); + typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); + typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#ifdef GL_GLEXT_PROTOTYPES + GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); + GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); + GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); + GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); + GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); + GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); + GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); + GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); + GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); + GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); + GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); + GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); + GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); + GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); + GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); + GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); + GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); + GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); + GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); + GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); + GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); + GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif +#endif /* GL_SUN_vertex */ + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/src_v2/platform/khrplatform.h b/src_v2/platform/khrplatform.h new file mode 100644 index 0000000..0c320b1 --- /dev/null +++ b/src_v2/platform/khrplatform.h @@ -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_ */ \ No newline at end of file diff --git a/src_v2/platform/linux/lumenarium_linux_file.h b/src_v2/platform/linux/lumenarium_linux_file.h new file mode 100644 index 0000000..f0df869 --- /dev/null +++ b/src_v2/platform/linux/lumenarium_linux_file.h @@ -0,0 +1,261 @@ +#ifndef LUMENARIUM_LINUX_FILE_H +#define LUMENARIUM_LINUX_FILE_H 1 + +File_Async_Job_System +os_file_jobs_init() +{ + open_files_init(); + File_Async_Job_System result = file_async_jobs_init(os_file_async_work_on_job); + return result; +} + +File_Handle +os_file_open(String path, File_Access_Flags flags_access, File_Create_Flags flags_create) +{ + File_Handle result = {}; + + mode_t mode = 0; + + s32 flags = 0; + if(has_flag_exact(flags_access, (FileAccess_Read | FileAccess_Write))) + { + add_flag(flags, O_RDWR); + } + else + { + if (has_flag(flags_access, FileAccess_Read)) { + add_flag(flags, O_RDONLY); + } + else if (has_flag(flags_access, FileAccess_Write)) + { + add_flag(flags, O_WRONLY); + } + else + { + return result; + } + } + + // This additional argument is required if we're creating a file + // if we want this process to be able to open it again later. + mode_t create_flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + + switch (flags_create) + { + case FileCreate_New: + { + add_flag(flags, O_CREAT | O_EXCL ); + mode = create_flags; + } break; + case FileCreate_OpenExisting: { /* add_flag(flags, O_); */ } break; + case FileCreate_CreateAlways: + case FileCreate_OpenAlways: + { + add_flag(flags, O_CREAT); + mode = create_flags; + } break; + invalid_default_case; + } + + s32 file_handle = open((char*)path.str, flags, mode); + if (file_handle >= 0) + { + result = open_files_put_handle(file_handle, path); + } + else + { + s32 errsv = errno; + printf("Error: os_file_open - %d\n", errsv); + printf("\tAttempting to open: %.*s\n", str_varg(path)); + printf("\tFlags: %u %u\n", flags_access, flags_create); + } + return result; +} + +void +os_file_close(File_Handle file_handle) +{ + s32 os_handle = open_files_get_handle(file_handle); + if (close(os_handle) != -1) + { + open_files_rem_file(file_handle); + } + else + { + s32 errsv = errno; + printf("Error: os_file_close - %d\n", errsv); + } +} + +bool +os_file_delete(String file_path) +{ + if (remove((char*)file_path.str) != 0) { + perror("Error deleting file\n"); + return false; + } + return true; +} + +File_Info +os_file_get_info(File_Handle file_handle, Allocator* allocator) +{ + File_Info info = {}; + s32 os_handle = open_files_get_handle(file_handle); + if (os_handle != -1) + { + String path = open_files_get_path(file_handle); + + struct stat os_info = {}; + if (fstat(os_handle, &os_info) != -1) + { + info.path = string_copy(path, allocator); + info.path_abs = allocator_alloc_string(allocator, PATH_MAX); + if (realpath((char*)path.str, (char*)info.path_abs.str) != 0) + { + info.path_abs.len = c_str_len((char*)info.path_abs.str); + } + else + { + s32 errsv = errno; + printf("Error - os_file_get_info - %d - realpath\n", errsv); + } + info.size = (u64)os_info.st_size; + if (S_ISDIR(os_info.st_mode)) + { + add_flag(info.flags, FileFlag_IsDir); + } + else if (!S_ISREG(os_info.st_mode)) + { + printf("Error - os_file_get_info - stat-ing a handle that is not a directory or a file\n"); + } + } + else + { + s32 errsv = errno; + printf("Error: os_file_get_info - %d\n", errsv); + } + } + return info; +} + +Data +os_file_read_all(File_Handle file_handle, Allocator* allocator) +{ + Data result = {}; + s32 os_handle = open_files_get_handle(file_handle); + if (os_handle == -1) return result; + + // get file size + s32 offset = lseek(os_handle, 0, SEEK_END); + if (offset == -1) + { + s32 errsv = errno; + printf("Error: os_file_read_all:lseek - %d\n", errsv); + return result; + } + lseek(os_handle, 0, SEEK_SET); + + result.base = allocator_alloc(allocator, offset + 1); + result.size = offset + 1; + + s32 bytes_read = read(os_handle, result.base, result.size); + if (bytes_read == (result.size - 1)) + { + result.base[bytes_read] = 0; // null term + } + else if (bytes_read >= 0) + { + printf("Error: os_file_read:read - whole file not read.\n"); + } + else if (bytes_read == -1) + { + s32 errsv = errno; + printf("Error: os_file_read_all:read - %d\n", errsv); + } + + return result; +} + +bool +os_file_write_(s32 os_handle, Data file_data) +{ + s32 size_written = write(os_handle, file_data.base, file_data.size); + if (size_written > 0 && size_written != file_data.size) + { + printf("Error: os_file_write_all:write - whole file not written\n"); + return true; + } + else if (size_written < 0) + { + linux_err_print("write"); + return false; + } + + return true; +} + +bool +os_file_write_all(File_Handle file_handle, Data file_data) +{ + s32 os_handle = open_files_get_handle(file_handle); + if (os_handle == -1) return false; + + lseek(os_handle, 0, SEEK_SET); + return os_file_write_(os_handle, file_data); +} + +bool +os_file_write(File_Handle file_handle, Data file_data) +{ + s32 os_handle = open_files_get_handle(file_handle); + if (os_handle == -1) return false; + + return os_file_write_(os_handle, file_data); +} + + +String +os_get_exe_path(Allocator* allocator) +{ + String result = {}; + char buf[PATH_MAX + 1]; + s32 r = readlink("/proc/self/exe", buf, PATH_MAX); + if (r != -1) + { + u64 needed = c_str_len(buf); + result = allocator_alloc_string(allocator, needed + 1); + memory_copy((u8*)buf, result.str, needed); + result.len = needed; + result.str[result.len] = 0; + } + return result; +} + +bool +os_pwd_set(String path) +{ + s32 result = chdir((char*)path.str); + if (result == -1) + { + linux_err_print("chdir"); + return false; + } + return true; +} + + +File_Info_List +os_dir_enum(String path, Platform_Enum_Dir_Flags flags, Allocator* allocator) +{ + invalid_code_path; + return (File_Info_List){}; +} + +void +os_file_async_work_on_job(File_Async_Job* job) +{ + +} + +#endif // LUMENARIUM_LINUX_FILE_H \ No newline at end of file diff --git a/src_v2/platform/linux/lumenarium_linux_memory.h b/src_v2/platform/linux/lumenarium_linux_memory.h new file mode 100644 index 0000000..c4e086d --- /dev/null +++ b/src_v2/platform/linux/lumenarium_linux_memory.h @@ -0,0 +1,74 @@ +#ifndef LUMENARIUM_LINUX_MEMORY_H +#define LUMENARIUM_LINUX_MEMORY_H 1 + +static uint64_t linux_page_size_cache_ = 0; + +// https://stackoverflow.com/questions/3351940/detecting-the-memory-page-size +uint64_t +os_page_size() +{ + if (linux_page_size_cache_ == 0) + { + long page_size = sysconf(_SC_PAGE_SIZE); + linux_page_size_cache_ = (uint64_t)page_size; + } + return linux_page_size_cache_; +} + +#define OS_MEM_PAGE_SIZE os_page_size() + +#ifdef DEBUG +# define linux_memory_assert_always (*((volatile int*)0) = 0xFFFF) +# define linux_memory_assert(c) do { \ + if (!(c)) { \ + linux_memory_assert_always;\ + }} while(false) +#else +# define linux_memory_assert(c) +#endif // DEBUG + +#define SIZE_T_MAX_U64 (uint64_t)((size_t)0 - 1) + +size_t +linux_round_to_page_size(uint64_t size) +{ + uint64_t m = SIZE_T_MAX_U64; + linux_memory_assert(size < SIZE_T_MAX_U64); + uint64_t rem = size % os_page_size(); + if (rem != 0 || size < os_page_size()) + { + uint64_t grow = os_page_size() - rem; + size += grow; + } + return (size_t)size; +} + +uint8_t* +os_mem_reserve(uint64_t size) +{ + size_t size_cvt = linux_round_to_page_size(size); + uint8_t* result = (uint8_t*)malloc(size_cvt); + return result; +} + +uint8_t* +os_mem_commit(uint8_t* base, uint64_t size) +{ + return base; +} + +bool +os_mem_decommit(uint8_t* base, uint64_t size) +{ + return 1; // true +} + +bool +os_mem_release(uint8_t* base, uint64_t size) +{ + free(base); + return 1; // true +} + + +#endif // LUMENARIUM_LINUX_MEMORY_H \ No newline at end of file diff --git a/src_v2/platform/linux/lumenarium_linux_network.h b/src_v2/platform/linux/lumenarium_linux_network.h new file mode 100644 index 0000000..934fea6 --- /dev/null +++ b/src_v2/platform/linux/lumenarium_linux_network.h @@ -0,0 +1,96 @@ +#ifndef LUMENARIUM_LINUX_NETWORK_H +#define LUMENARIUM_LINUX_NETWORK_H 1 + +Socket_Handle +os_socket_create(s32 domain, s32 type, s32 protocol) +{ + Socket_Handle result = {}; + OS_SOCKET_TYPE sock = socket(domain, type, protocol); + if (sock == -1) { + perror("Error: os_socket_create\n"); + return result; + } + + result = open_sockets_put(sock); + if (result.value == 0) + { + fprintf(stderr, "Error: os_socket_create = not enough room in open_sockets\n"); + } + return result; +} + +bool +os_socket_bind() +{ + invalid_code_path; + return false; +} + +bool +os_socket_connect() +{ + invalid_code_path; + return false; +} + +bool +os_socket_close(Socket_Handle handle) +{ + OS_SOCKET_TYPE sock = open_sockets_get(handle); + close(sock); + return true; +} + +Data +os_socket_recv() +{ + invalid_code_path; + return (Data){}; +} + +s32 +os_socket_set_listening() +{ + invalid_code_path; + return 0; +} + +s32 +os_socket_send() +{ + invalid_code_path; + return 0; +} + +s32 +os_socket_send_to(Socket_Handle handle, u32 addr, u32 port, Data data, s32 flags) +{ + OS_SOCKET_TYPE sock = open_sockets_get(handle); + + struct sockaddr_in dst = { + .sin_family = AF_INET, + .sin_port = hton_u16(port), + .sin_addr.s_addr = hton_u32(addr), + }; + struct sockaddr* dst_ptr = (struct sockaddr*)&dst; + s32 len_sent = sendto(sock, data.base, data.size, flags, dst_ptr, sizeof(struct sockaddr_in)); + if (len_sent == -1) + { + perror("Error: os_socket_send_to\n"); + return 0; + } + return len_sent; +} + +s32 +os_socket_set_opt(Socket_Handle handle, int level, int option_name, u8* option_value, s32 option_len) +{ + OS_SOCKET_TYPE sock = open_sockets_get(handle); + s32 err = setsockopt(sock, level, option_name, (void*)option_value, (socklen_t)option_len); + if (err) { + fprintf(stderr, "Error: setsockopt - %d\n\targs: %d %d %.*s\n", err, level, option_name, option_len, (char*)option_value); + } + return 0; +} + +#endif // LUMENARIUM_LINUX_NETWORK_H \ No newline at end of file diff --git a/src_v2/platform/linux/lumenarium_linux_thread.h b/src_v2/platform/linux/lumenarium_linux_thread.h new file mode 100644 index 0000000..76693da --- /dev/null +++ b/src_v2/platform/linux/lumenarium_linux_thread.h @@ -0,0 +1,116 @@ +#ifndef LUMENARIUM_RASPI_THREADS_H +#define LUMENARIUM_RASPI_THREADS_H 1 + +typedef struct Os_Linux_Thread Os_Linux_Thread; +struct Os_Linux_Thread +{ + pthread_t thread; + Thread_Proc* proc; + u8* user_data; + Thread_Result result; +}; + +#define LINUX_THREAD_CAP 8 +global Os_Linux_Thread linux_threads_[LINUX_THREAD_CAP]; +global u32 linux_threads_len_; + +Thread_Handle +os_thread_begin(Thread_Proc* proc, u8* user_data) +{ + // Call the actual thread function + // This is essentially a blocking call for the rest of this function + Os_Linux_Thread* thread_data = (Os_Linux_Thread*)arg; + thread_data->result = thread_data->proc(thread_data->user_data); + + // Clean up this threads thread slot so other threads + // can use it + thread_data->proc = 0; + thread_data->user_data = 0; + + pthread_exit(&thread_data->result); +} + +void +os_thread_end(Thread_Handle thread_handle) +{ + // Find an unused thread slot + Thread_Handle result = { .value = 0 }; + if (linux_threads_len_ < OSX_THREAD_CAP) + { + result = (Thread_Handle){ .value = linux_threads_len_++ }; + } + else + { + bool found = false; + for (u32 i = 0; i < OSX_THREAD_CAP; i++) + { + if (linux_threads_[i].proc == 0) + { + result.value = i; + found = true; + } + } + + if (!found) { + printf("ERROR: Unable to create thread.\n"); + invalid_code_path; + } + } + + // Initialize Thread Slot + Os_Linux_Thread* t = linux_threads_ + result.value; + *t = (Os_Linux_Thread){ + .proc = proc, + .user_data = user_data + }; + + // Create PThread + s32 create_error = pthread_create(&t->thread, + NULL, // use default attrs + (void * _Nullable (* _Nonnull)(void * _Nullable))proc, + user_data + ); + + if (create_error) + { + switch (create_error) { + case EAGAIN: { + } break; + + case EINVAL: { + } break; + + // case ELEMULTITHREADFORK: { + // } break; + + case ENOMEM: { + } break; + } + } + + return result; +} + +void +os_thread_end(Thread_Handle thread_handle) +{ + Os_Linux_Thread* t = linux_threads_ + thread_handle.value; + pthread_kill(t->thread, 0); +} + +u32 +os_interlocked_increment(volatile u32* value) +{ + invalid_code_path; + return 0; +} + +bool +os_interlocked_cmp_exchg(volatile u32* dest, u32 old_value, u32 new_value) +{ + invalid_code_path; + return 0; +} + + +#endif // LUMENARIUM_RASPI_THREADS_H \ No newline at end of file diff --git a/src_v2/platform/linux/lumenarium_linux_time.h b/src_v2/platform/linux/lumenarium_linux_time.h new file mode 100644 index 0000000..7acecd3 --- /dev/null +++ b/src_v2/platform/linux/lumenarium_linux_time.h @@ -0,0 +1,26 @@ +#ifndef LUMENARIUM_LINUX_TIME_H +#define LUMENARIUM_LINUX_TIME_H 1 + +#define NANOS_PER_SECOND 1000000000 +Ticks +os_get_ticks() +{ + struct timespec ts = {}; + s32 r = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); + assert(r == 0); + s64 nanos = (s64)ts.tv_sec * NANOS_PER_SECOND; + nanos += (s64)ts.tv_nsec; + + Ticks result = { + .value = nanos + }; + return result; +} + +r64 +os_get_ticks_per_second() +{ + return NANOS_PER_SECOND; +} + +#endif // LUMENARIUM_LINUX_TIME_H \ No newline at end of file diff --git a/src_v2/platform/lumenarium_assert.h b/src_v2/platform/lumenarium_assert.h new file mode 100644 index 0000000..9210788 --- /dev/null +++ b/src_v2/platform/lumenarium_assert.h @@ -0,0 +1,60 @@ +/* date = March 26th 2022 3:42 pm */ + +#ifndef LUMENARIUM_ASSERT_H +#define LUMENARIUM_ASSERT_H + +#if defined(PRINT_ASSERTS) +# include <stdio.h> +# define err_write(s,...) err_write_(s,__VA_ARGS__) +static FILE* file_err; +void err_write_(char* fmt, ...) { + if (!file_err) return; + va_list args; + va_start(args, fmt); + vfprintf(file_err, fmt, args); + va_end(args); +} +void open_err_file() { file_err = fopen("./err.txt", "wb"); } +void close_err_file() { fclose(file_err); } +#else +# define err_write(s,...) +void open_err_file() {} +void close_err_file() {} +#endif + +#if !defined(PLATFORM_wasm) + +// this assert works by simply trying to write to an invalid address +// (in this case, 0x0), which will crash in most debuggers +# define assert_always (*((volatile int*)0) = 0xFFFF) + +#else +WASM_EXTERN void wasm_assert_always(char* file, unsigned int file_len, unsigned int line); +# define assert_always wasm_assert_always(__FILE__, sizeof(__FILE__), __LINE__) +#endif // defined(PLATFORM_WASM) + +#ifdef USE_ASSERTS +# define assert(c) do { \ +if (!(c)) { \ +err_write("Assert Hit: %s:%u\n", __FILE__, (u32)__LINE__); \ +close_err_file(); \ +assert_always; \ +} \ +} while(false) + +// useful for catching cases that you aren't sure you'll hit, but +// want to be alerted when they happen +# define invalid_code_path assert(0); + +// useful for switch statements on enums that might grow. You'll +// break in the debugger the first time the default case is hit +// with a new enum value +# define invalid_default_case default: { assert(0); } break; + +#else +# define assert(c) +# define invalid_code_path +# define invalid_default_case default: { } break; +#endif + +#endif //LUMENARIUM_ASSERT_H diff --git a/src_v2/platform/lumenarium_compiler_flags.h b/src_v2/platform/lumenarium_compiler_flags.h new file mode 100644 index 0000000..fa9475f --- /dev/null +++ b/src_v2/platform/lumenarium_compiler_flags.h @@ -0,0 +1,17 @@ +/* date = March 22nd 2022 2:09 am */ + +#ifndef LUMENARIUM_COMPILER_FLAGS_H +#define LUMENARIUM_COMPILER_FLAGS_H + +#if defined(__clang__) +# pragma GCC diagnostic ignored "-Wunused-value" +# pragma GCC diagnostic ignored "-Wvarargs" +# pragma GCC diagnostic ignored "-Wwritable-strings" +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + +#if defined(DEBUG) +# define USE_ASSERTS 1 +#endif + +#endif //LUMENARIUM_COMPILER_FLAGS_H diff --git a/src_v2/platform/lumenarium_os.h b/src_v2/platform/lumenarium_os.h new file mode 100644 index 0000000..f0f7f03 --- /dev/null +++ b/src_v2/platform/lumenarium_os.h @@ -0,0 +1,68 @@ +#if !defined(LUMENARIUM_OS) +#define LUMENARIUM_OS + +/////////////////////////////////////// +// Memory + +u8* os_mem_reserve(u64 size); +u8* os_mem_commit(u8* base, u64 size); +bool os_mem_decommit(u8* base, u64 size); +bool os_mem_release(u8* base, u64 size); + +/////////////////////////////////////// +// File I/O + +File_Async_Job_System os_file_jobs_init(); +File_Handle os_file_open(String path, File_Access_Flags flags_access, File_Create_Flags flags_create); +void os_file_close(File_Handle file_handle); +bool os_file_delete(String path); +File_Info os_file_get_info(File_Handle file_handle, Allocator* allocator); +Data os_file_read_all(File_Handle file_handle, Allocator* allocator); +bool os_file_write_all(File_Handle file_handle, Data file_data); +bool os_file_write(File_Handle file_handle, Data file_data); + +String os_get_exe_path(Allocator* allocator); +bool os_pwd_set(String path); + +File_Info_List os_dir_enum(String path, Platform_Enum_Dir_Flags flags, Allocator* allocator); + +// Asnyc Jobs +void os_file_async_work_on_job(File_Async_Job* job); + +/////////////////////////////////////// +// Time + +Ticks os_get_ticks(); +r64 os_get_ticks_per_second(); + +/////////////////////////////////////// +// Threads + +Thread_Handle os_thread_begin(Thread_Proc* proc, u8* user_data); +void os_thread_end(Thread_Handle thread_handle); + +// returns the new value of the provided variable +u32 os_interlocked_increment(volatile u32* value); + +// returns true if dest was equal to old_value, and the exchange was successful, +// returns false otherwise +bool os_interlocked_cmp_exchg(volatile u32* dest, u32 old_value, u32 new_value); + +/////////////////////////////////////// +// Network Access + +Socket_Handle os_socket_create(s32 domain, s32 type, s32 protocol); +bool os_socket_bind(); +bool os_socket_connect(); +bool os_socket_close(Socket_Handle handle); +Data os_socket_recv(); +Data os_socket_recvfrom(Socket_Handle handle, u8* buffer, u32 buffer_size, Socket_Error* err_out); +s32 os_socket_set_listening(); +s32 os_socket_send(); +s32 os_socket_send_to(Socket_Handle handle, u32 addr, u32 port, Data data, s32 flags); +s32 os_socket_set_opt(Socket_Handle handle, int level, int option_name, + u8* option_value, s32 option_len); + +void open_sockets_init(); + +#endif // LUMENARIUM_OS \ No newline at end of file diff --git a/src_v2/platform/lumenarium_platform.h b/src_v2/platform/lumenarium_platform.h new file mode 100644 index 0000000..fff914d --- /dev/null +++ b/src_v2/platform/lumenarium_platform.h @@ -0,0 +1,496 @@ +/* date = March 22nd 2022 2:05 am */ + +#ifndef LUMENARIUM_PLATFORM_H +#define LUMENARIUM_PLATFORM_H + +// This is a file that defines the things that every platform +// must expose to the entire program + +/////////////////////////////////////// +// Memory + +u64 platform_page_size(); + +u8* platform_mem_reserve(u64 size); +u8* platform_mem_commit(u8* base, u64 size); +bool platform_mem_decommit(u8* base, u64 size); +bool platform_mem_release(u8* base, u64 size); + +/////////////////////////////////////// +// File I/O + +struct Platform_File_Handle +{ + u64 value; +}; + +typedef u32 Platform_File_Access_Flags; +enum +{ + FileAccess_None = 0, + FileAccess_Read = 1, + FileAccess_Write = 2, +}; + +typedef u32 Platform_File_Create_Flags; +enum +{ + // these match https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea + FileCreate_None = 0, + FileCreate_New = 1, + FileCreate_CreateAlways = 2, + FileCreate_OpenExisting = 3, + FileCreate_OpenAlways = 4, +}; + +typedef u32 Platform_File_Flags; +enum +{ + FileFlag_IsFile = 0, + FileFlag_IsDir = 1, +}; + +struct Platform_File_Info +{ + String path; + String path_abs; + u64 size; + u64 time_created; + u64 time_last_write; + Platform_File_Flags flags; +}; + +struct Platform_File_Info_List_Ele +{ + Platform_File_Info info; + Platform_File_Info_List_Ele* next; +}; + +struct Platform_File_Info_List +{ + Platform_File_Info_List_Ele* first; + Platform_File_Info_List_Ele* last; +}; + +Platform_File_Handle platform_file_open(String path, Platform_File_Access_Flags flags_access, Platform_File_Create_Flags flags_create); +void platform_file_close(Platform_File_Handle file_handle); +Platform_File_Info platform_file_get_info(Platform_File_Handle file_handle, Allocator* allocator); +Data platform_file_read_all(Platform_File_Handle file_handle, Allocator* allocator); +bool platform_file_write_all(Platform_File_Handle file_handle, Data file_data); +String platform_get_exe_path(Allocator* allocator); +bool platform_pwd_set(String path); + +// For Cross Platform File Operations use these: + +typedef u32 Platform_File_Async_Job_Flags; +enum +{ + PlatformFileAsyncJob_Invalid = 0, + PlatformFileAsyncJob_Read = 1 << 0, + PlatformFileAsyncJob_Write = 1 << 1, + PlatformFileAsyncJob_InFlight = 1 << 2, + PlatformFileAsyncJob_Success = 1 << 3, + PlatformFileAsyncJob_Failed = 1 << 4, +}; + +struct Platform_File_Async_Job_Args +{ + String path; + Data data; + Platform_File_Async_Job_Flags flags; + u32 error; +}; + +typedef void Platform_File_Async_Cb(Platform_File_Async_Job_Args args, u8* user_data); + +struct Platform_File_Async_Job +{ + Data job_memory; + Platform_File_Async_Job_Args args; + Platform_File_Async_Cb* cb; +}; + +global Allocator* platform_file_jobs_arena = 0; +#define PLATFORM_FILE_ASYNC_MAX_JOBS 32 +global Platform_File_Async_Job platform_file_async_jobs[PLATFORM_FILE_ASYNC_MAX_JOBS]; +global u32 platform_file_async_jobs_len = 0; + +void +platform_file_jobs_init() +{ + platform_file_jobs_arena = paged_allocator_create_reserve(MB(4), 256); +} + +bool +platform_file_async_job_add(Platform_File_Async_Job job) +{ + if (platform_file_async_jobs_len >= PLATFORM_FILE_ASYNC_MAX_JOBS) return false; + + // Copy data to job local memory + u64 size_needed = job.args.path.len + job.args.data.size + 1; + u8* job_mem = allocator_alloc(platform_file_jobs_arena, size_needed); + String job_path = string_create(job_mem, 0, job.args.path.len + 1); + u64 copied = string_copy_to(&job_path, job.args.path); + Data job_data = data_create(job_mem + job_path.cap + 1, size_needed - (job_path.cap + 1)); + memory_copy(job.args.data.base, job_data.base, job.args.data.size); + job.args.path = job_path; + job.args.data = job_data; + job.job_memory = data_create(job_mem, size_needed); + + platform_file_async_jobs[platform_file_async_jobs_len++] = job; + return true; +} + +Platform_File_Async_Job +platform_file_async_job_rem(u64 index) +{ + assert(index < platform_file_async_jobs_len); + Platform_File_Async_Job result = platform_file_async_jobs[index]; + + platform_file_async_jobs_len -= 1; + if (platform_file_async_jobs_len > 0) + { + u32 last_job = platform_file_async_jobs_len; + platform_file_async_jobs[index] = platform_file_async_jobs[last_job]; + } + + return result; +} + +bool +platform_file_async_read(String path, Platform_File_Async_Cb* cb) +{ + Platform_File_Async_Job job = {}; + job.args.path = path; + job.args.flags = ( + PlatformFileAsyncJob_Read | + PlatformFileAsyncJob_InFlight + ); + job.cb = cb; + bool result = platform_file_async_job_add(job); + return result; +} + +bool +platform_file_async_write(String path, Data data, Platform_File_Async_Cb* cb) +{ + Platform_File_Async_Job job = {}; + job.args.path = path; + job.args.data = data; + job.args.flags = ( + PlatformFileAsyncJob_Write | + PlatformFileAsyncJob_InFlight + ); + job.cb = cb; + bool result = platform_file_async_job_add(job); + return result; +} + +void +platform_file_async_job_complete(Platform_File_Async_Job* job, u8* user_data) +{ + job->cb(job->args, user_data); + allocator_free(platform_file_jobs_arena, job->job_memory.base, job->job_memory.size); + if (has_flag(job->args.flags, PlatformFileAsyncJob_Write)) + { + allocator_free(platform_file_jobs_arena, job->args.data.base, job->args.data.size); + } +} + +void platform_file_async_work_on_job(Platform_File_Async_Job* job); + +void +platform_file_async_jobs_do_work(u64 max_jobs, u8* user_data) +{ + u64 to_do = max_jobs; + if (max_jobs > platform_file_async_jobs_len) to_do = platform_file_async_jobs_len; + + Platform_File_Async_Job_Flags completed = ( + PlatformFileAsyncJob_Success | + PlatformFileAsyncJob_Failed + ); + + for (u64 i = to_do - 1; i < to_do; i--) + { + Platform_File_Async_Job* job = platform_file_async_jobs + i; + platform_file_async_work_on_job(job); + if (has_flag(job->args.flags, completed)) + { + platform_file_async_job_complete(job, user_data); + platform_file_async_job_rem(i); + } + } +} + +typedef u32 Platform_Enum_Dir_Flags; +enum +{ + EnumDir_Recursive = 1, + EnumDir_IncludeDirectories = 2, +}; + +Platform_File_Info_List platform_dir_enum(String path, Platform_Enum_Dir_Flags flags, Allocator* allocator); + +String platform_get_exe_path(Allocator* allocator); +bool platform_pwd_set(String path); + +/////////////////////////////////////// +// Windows & Events + +enum Platform_Window_Event_Kind +{ + WindowEvent_Invalid = 0, + + WindowEvent_MouseScroll, + WindowEvent_MouseMoved, + WindowEvent_ButtonDown, + WindowEvent_ButtonUp, + WindowEvent_Char, + WindowEvent_WindowClosed, + + WindowEvent_Count, +}; + +typedef u32 Platform_Key_Code; +enum +{ + KeyCode_Invalid = 0, + + KeyCode_Esc, + + KeyCode_Space, + KeyCode_Tab, + KeyCode_CapsLock, + KeyCode_LeftShift, KeyCode_RightShift, + KeyCode_LeftCtrl, KeyCode_RightCtrl, + KeyCode_Fn, + KeyCode_Alt, + KeyCode_PageUp, KeyCode_PageDown, + KeyCode_Backspace, KeyCode_Delete, + KeyCode_Enter, + + // Function Keys + KeyCode_F0, KeyCode_F1, KeyCode_F2, KeyCode_F3, KeyCode_F4, KeyCode_F5, KeyCode_F6, KeyCode_F7, + KeyCode_F8, KeyCode_F9, KeyCode_F10, KeyCode_F11, KeyCode_F12, + + // Letters + KeyCode_a, KeyCode_b, KeyCode_c, KeyCode_d, KeyCode_e, KeyCode_f, KeyCode_g, KeyCode_h, + KeyCode_i, KeyCode_j, KeyCode_k, KeyCode_l, KeyCode_m, KeyCode_n, KeyCode_o, KeyCode_p, + KeyCode_q, KeyCode_r, KeyCode_s, KeyCode_t, KeyCode_u, KeyCode_v, KeyCode_w, KeyCode_x, + KeyCode_y, KeyCode_z, + + KeyCode_A, KeyCode_B, KeyCode_C, KeyCode_D, KeyCode_E, KeyCode_F, KeyCode_G, KeyCode_H, + KeyCode_I, KeyCode_J, KeyCode_K, KeyCode_L, KeyCode_M, KeyCode_N, KeyCode_O, KeyCode_P, + KeyCode_Q, KeyCode_R, KeyCode_S, KeyCode_T, KeyCode_U, KeyCode_V, KeyCode_W, KeyCode_X, + KeyCode_Y, KeyCode_Z, + + // Numbers + KeyCode_0, KeyCode_1, KeyCode_2, KeyCode_3, KeyCode_4, KeyCode_5, KeyCode_6, KeyCode_7, + KeyCode_8, KeyCode_9, + + KeyCode_Num0, KeyCode_Num1, KeyCode_Num2, KeyCode_Num3, KeyCode_Num4, KeyCode_Num5, + KeyCode_Num6, KeyCode_Num7, KeyCode_Num8, KeyCode_Num9, + + // Symbols + KeyCode_Bang, KeyCode_At, KeyCode_Pound, KeyCode_Dollar, KeyCode_Percent, KeyCode_Carrot, + KeyCode_Ampersand, KeyCode_Star, KeyCode_LeftParen, KeyCode_RightParen, KeyCode_Minus, KeyCode_Plus, + KeyCode_Equals, KeyCode_Underscore, KeyCode_LeftBrace, KeyCode_RightBrace, KeyCode_LeftBracket, + KeyCode_RightBracket, KeyCode_Colon, KeyCode_SemiColon, KeyCode_SingleQuote, KeyCode_DoubleQuote, + KeyCode_ForwardSlash, KeyCode_Backslash, KeyCode_Pipe, KeyCode_Comma, KeyCode_Period, + KeyCode_QuestionMark, KeyCode_LessThan, KeyCode_GreaterThan, KeyCode_Tilde, KeyCode_BackQuote, + + // Arrows + KeyCode_UpArrow, + KeyCode_DownArrow, + KeyCode_LeftArrow, + KeyCode_RightArrow, + + // Mouse + // NOTE(Peter): Including this here so we can utilize the same KeyDown, KeyUp etc. functions + KeyCode_MouseLeftButton, + KeyCode_MouseMiddleButton, + KeyCode_MouseRightButton, + + KeyCode_Count, +}; + +typedef u8 Platform_Key_Flags; +enum +{ + KeyFlag_None = 0, + + KeyFlag_Mod_Shift = 1, + KeyFlag_Mod_Ctrl = 2, + KeyFlag_Mod_Alt = 4, + KeyFlag_Mod_Sys = 8, + + KeyFlag_State_WasDown = 16, + KeyFlag_State_IsDown = 32, +}; + +struct Platform_Window_Event +{ + Platform_Window_Event_Kind kind; + Platform_Key_Code key_code; + Platform_Key_Flags key_flags; + s32 mouse_x; + s32 mouse_y; + s32 scroll_amt; + char char_value; +}; + +enum Platform_Cursor_Kind +{ + Cursor_Arrow, + Cursor_Pointer, + Cursor_Loading, + Cursor_HArrows, + Cursor_VArrows, + Cursor_DTopLeftArrows, + Cursor_DTopRightArrows, + Cursor_Count, +}; + +/////////////////////////////////////// +// Time + +global r64 target_seconds_per_frame = 1.0 / 30.0f; + +struct Platform_Ticks +{ + s64 value; +}; + +Platform_Ticks platform_get_ticks(); +r64 platform_ticks_to_seconds(Platform_Ticks ticks); + +Platform_Ticks +get_ticks_elapsed(Platform_Ticks start, Platform_Ticks end) +{ + Platform_Ticks result = {}; + result.value = end.value - start.value; + return result; +} + +r64 +get_seconds_elapsed(Platform_Ticks start, Platform_Ticks end) +{ + Platform_Ticks diff = get_ticks_elapsed(start, end); + return platform_ticks_to_seconds(diff); +} + +// TODO(PS): we have some stuff in v1 around system time, probably +// for timestamps etc. + +/////////////////////////////////////// +// Threads + +struct Platform_Thread_Handle +{ + u64 value; +}; + +struct Platform_Thread_Result +{ + u32 code; +}; + +typedef struct Platform_Thread_Data Platform_Thread_Data; +typedef Platform_Thread_Result Platform_Thread_Proc(Platform_Thread_Data* thread_data); + +struct Platform_Thread_Data +{ + Platform_Thread_Handle thread_handle; + u32 thread_id; + Platform_Thread_Proc* thread_proc; + Allocator* thread_memory; + u8* user_data; +}; + +Platform_Thread_Handle platform_thread_begin(Platform_Thread_Proc* proc, u8* user_data); +void platform_thread_end(Platform_Thread_Handle thread_handle); + +u32 platform_interlocked_increment(volatile u32* value); +u32 platform_interlocked_cmp_exchg(volatile u32* dest, u32 new_value, u32 old_value); + +/////////////////////////////////////// +// Network Access + +// TODO(PS): + +struct Platform_Socket_Handle +{ + u64 value; +}; + +Platform_Socket_Handle platform_socket_create(); +bool platform_socket_bind(); +bool platform_socket_connect(); +bool platform_socket_close(); +Data platform_socket_recv(); +s32 platform_Socket_set_listening(); +s32 platform_Socket_send(); +s32 platform_Socket_send_to(); +s32 platform_Socket_set_opt(); + +/////////////////////////////////////// +// Graphics Integration + +#define PLATFORM_SHADER_MAX_ATTRS 8 +#define PLATFORM_SHADER_ATTR_LAST (u32)(1 << 31) +struct Platform_Shader +{ + u32 id; + u32 attrs[PLATFORM_SHADER_MAX_ATTRS]; + u32 uniforms[PLATFORM_SHADER_MAX_ATTRS]; +}; + +struct Platform_Geometry_Buffer +{ + u32 buffer_id_vao; + u32 buffer_id_vertices; + u32 buffer_id_indices; + u32 vertices_len; + u32 indices_len; +}; + +struct Platform_Texture +{ + u32 id; + + u32 w, h, s; +}; + +struct Platform_Graphics_Frame_Desc +{ + v4 clear_color; + v2 viewport_min; + v2 viewport_max; +}; + +void platform_frame_begin(Platform_Graphics_Frame_Desc desc); +void platform_frame_clear(); + +// Geometry +Platform_Geometry_Buffer platform_geometry_buffer_create(r32* vertices, u32 vertices_len, u32* indices, u32 indices_len); +Platform_Shader platform_shader_create( + String code_vert, String code_frag, String* attribs, u32 attribs_len, String* uniforms, u32 uniforms_len + ); +void platform_geometry_buffer_update(Platform_Geometry_Buffer* buffer, r32* verts, u32 verts_offset, u32 verts_len, u32* indices, u32 indices_offset, u32 indices_len); + +// Shaders +void platform_geometry_bind(Platform_Geometry_Buffer geo); +void platform_shader_bind(Platform_Shader shader); +void platform_geometry_draw(Platform_Geometry_Buffer geo, u32 indices); +void platform_geometry_draw(Platform_Geometry_Buffer geo); +void platform_vertex_attrib_pointer( + Platform_Geometry_Buffer geo, Platform_Shader shader, u32 count, u32 attr_index, u32 stride, u32 offset + ); +void platform_set_uniform(Platform_Shader shader, u32 index, m44 u); + +// Textures +Platform_Texture platform_texture_create(u8* pixels, u32 width, u32 height, u32 stride); +void platform_texture_bind(Platform_Texture tex); +void platform_texture_update(Platform_Texture tex, u8* new_pixels, u32 width, u32 height, u32 stride); + +#endif //LUMENARIUM_PLATFORM_H diff --git a/src_v2/platform/lumenarium_platform_common_includes.h b/src_v2/platform/lumenarium_platform_common_includes.h new file mode 100644 index 0000000..f6e0496 --- /dev/null +++ b/src_v2/platform/lumenarium_platform_common_includes.h @@ -0,0 +1,41 @@ +/* date = March 22nd 2022 2:12 am */ + +#ifndef LUMENARIUM_PLATFORM_COMMON_INCLUDES_H +#define LUMENARIUM_PLATFORM_COMMON_INCLUDES_H + +#include <stdarg.h> + +#if !defined(GUESS_INTS) +# include <stdint.h> +#endif // !defined(GUESS_INTS) + +#include <math.h> + +#include "lumenarium_assert.h" + +#define STB_TRUETYPE_IMPLEMENTATION +#define STBTT_assert(x) assert(x) +#include "../libs/stb_truetype.h" + +#define STB_SPRINTF_IMPLEMENTATION +#include "../libs/stb_sprintf.h" + +// NOTE(PS): only need the opengl extension headers +// when running on a platform that is using opengl 3.3+ +#if !defined(PLATFORM_wasm) +# include "glcorearb.h" +# include "glext.h" +# include "wglext.h" +#endif + +#define HANDMADE_MATH_IMPLEMENTATION +#define HANDMADE_MATH_CPP_MODE +#define HANDMADE_MATH_STATIC +#include "../libs/HandmadeMath.h" + +typedef hmm_v2 v2; +typedef hmm_v3 v3; +typedef hmm_v4 v4; +typedef hmm_mat4 m44; + +#endif //LUMENARIUM_PLATFORM_COMMON_INCLUDES_H diff --git a/src_v2/platform/osx/lumenarium_first_osx.c b/src_v2/platform/osx/lumenarium_first_osx.c new file mode 100644 index 0000000..5d13b4f --- /dev/null +++ b/src_v2/platform/osx/lumenarium_first_osx.c @@ -0,0 +1,348 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <stdint.h> +#include <math.h> +#include <stdbool.h> + +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#include <OpenGL/gl.h> + +#include <sys/socket.h> +#include <netinet/in.h> + +#include "lumenarium_osx_memory.h" +#include "../../core/lumenarium_core.h" +#include "../lumenarium_os.h" + +#define PLATFORM_SUPPORTS_EDITOR 1 +#include "../../lumenarium_first.c" + +#undef internal +#undef external + +#include <errno.h> +#include <sys/syslimits.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <string.h> +#include <mach-o/dyld.h> +#include <mach/mach_time.h> +#include <libkern/OSAtomic.h> +#include <pthread.h> + +#include "../../libs/glfw_osx/include/GLFW/glfw3.h" + +#define osx_err_print(sub_proc) osx_err_print_((char*)__FUNCTION__, (char*)(sub_proc), errno) +void +osx_err_print_(char* proc, char* sub_proc, s32 errsv) +{ + printf("Error: %s:%s - %d\n\t%s\n\n", proc, sub_proc, errsv, strerror(errsv)); +} + +#define OS_FILE_HANDLE_TYPE s32 +#define OS_FILE_MAX_PATH PATH_MAX +#define OS_FILE_INVALID_HANDLE -1 +#define OS_SOCKET_TYPE s32 +#define OS_SOCKET_INVALID_HANDLE -1 +#include "../shared/lumenarium_shared_file_tracker.h" +#include "../shared/lumenarium_shared_file_async_work_on_job.h" +#include "../shared/lumenarium_shared_network.h" +#include "lumenarium_osx_file.h" +#include "lumenarium_osx_time.h" +#include "lumenarium_osx_graphics.h" +#include "lumenarium_osx_network.h" +#include "lumenarium_osx_thread.h" + +void +glfw_error_callback(int error, const char* description) +{ + fprintf(stderr, "Error: %s\n", description); +} + +global u8* app_state_data = 0; + +global Key_Code glfw_key_translation_table[] = { + [GLFW_KEY_SPACE] = KeyCode_Space, + [GLFW_KEY_APOSTROPHE] = KeyCode_SingleQuote, + [GLFW_KEY_COMMA] = KeyCode_Comma, + [GLFW_KEY_MINUS] = KeyCode_Minus, + [GLFW_KEY_PERIOD] = KeyCode_Period, + [GLFW_KEY_SLASH] = KeyCode_ForwardSlash, + [GLFW_KEY_0] = KeyCode_0, + [GLFW_KEY_1] = KeyCode_1, + [GLFW_KEY_2] = KeyCode_2, + [GLFW_KEY_3] = KeyCode_3, + [GLFW_KEY_4] = KeyCode_4, + [GLFW_KEY_5] = KeyCode_5, + [GLFW_KEY_6] = KeyCode_6, + [GLFW_KEY_7] = KeyCode_7, + [GLFW_KEY_8] = KeyCode_8, + [GLFW_KEY_9] = KeyCode_9, + [GLFW_KEY_SEMICOLON] = KeyCode_SemiColon, + [GLFW_KEY_EQUAL] = KeyCode_Equals, + [GLFW_KEY_A] = KeyCode_A, + [GLFW_KEY_B] = KeyCode_B, + [GLFW_KEY_C] = KeyCode_C, + [GLFW_KEY_D] = KeyCode_D, + [GLFW_KEY_E] = KeyCode_E, + [GLFW_KEY_F] = KeyCode_F, + [GLFW_KEY_G] = KeyCode_G, + [GLFW_KEY_H] = KeyCode_H, + [GLFW_KEY_I] = KeyCode_I, + [GLFW_KEY_J] = KeyCode_J, + [GLFW_KEY_K] = KeyCode_K, + [GLFW_KEY_L] = KeyCode_L, + [GLFW_KEY_M] = KeyCode_M, + [GLFW_KEY_N] = KeyCode_N, + [GLFW_KEY_O] = KeyCode_O, + [GLFW_KEY_P] = KeyCode_P, + [GLFW_KEY_Q] = KeyCode_Q, + [GLFW_KEY_R] = KeyCode_R, + [GLFW_KEY_S] = KeyCode_S, + [GLFW_KEY_T] = KeyCode_T, + [GLFW_KEY_U] = KeyCode_U, + [GLFW_KEY_V] = KeyCode_V, + [GLFW_KEY_W] = KeyCode_W, + [GLFW_KEY_X] = KeyCode_X, + [GLFW_KEY_Y] = KeyCode_Y, + [GLFW_KEY_Z] = KeyCode_Z, + [GLFW_KEY_LEFT_BRACKET] = KeyCode_LeftBracket, + [GLFW_KEY_BACKSLASH] = KeyCode_Backslash, + [GLFW_KEY_RIGHT_BRACKET] = KeyCode_RightBrace, + [GLFW_KEY_GRAVE_ACCENT] = KeyCode_Invalid, + [GLFW_KEY_WORLD_1] = KeyCode_Invalid, + [GLFW_KEY_WORLD_2] = KeyCode_Invalid, + [GLFW_KEY_ESCAPE] = KeyCode_Esc, + [GLFW_KEY_ENTER] = KeyCode_Enter, + [GLFW_KEY_TAB] = KeyCode_Tab, + [GLFW_KEY_BACKSPACE] = KeyCode_Backspace, + [GLFW_KEY_INSERT] = KeyCode_Invalid, + [GLFW_KEY_DELETE] = KeyCode_Delete, + [GLFW_KEY_RIGHT] = KeyCode_RightArrow, + [GLFW_KEY_LEFT] = KeyCode_LeftArrow, + [GLFW_KEY_DOWN] = KeyCode_DownArrow, + [GLFW_KEY_UP] = KeyCode_UpArrow, + [GLFW_KEY_PAGE_UP] = KeyCode_PageUp, + [GLFW_KEY_PAGE_DOWN] = KeyCode_PageDown, + [GLFW_KEY_HOME] = KeyCode_Invalid, + [GLFW_KEY_END] = KeyCode_Invalid, + [GLFW_KEY_CAPS_LOCK] = KeyCode_CapsLock, + [GLFW_KEY_SCROLL_LOCK] = KeyCode_Invalid, + [GLFW_KEY_NUM_LOCK] = KeyCode_Invalid, + [GLFW_KEY_PRINT_SCREEN] = KeyCode_Invalid, + [GLFW_KEY_PAUSE] = KeyCode_Invalid, + [GLFW_KEY_F1] = KeyCode_F1, + [GLFW_KEY_F2] = KeyCode_F2, + [GLFW_KEY_F3] = KeyCode_F3, + [GLFW_KEY_F4] = KeyCode_F4, + [GLFW_KEY_F5] = KeyCode_F5, + [GLFW_KEY_F6] = KeyCode_F6, + [GLFW_KEY_F7] = KeyCode_F7, + [GLFW_KEY_F8] = KeyCode_F8, + [GLFW_KEY_F9] = KeyCode_F9, + [GLFW_KEY_F10] = KeyCode_Invalid, + [GLFW_KEY_F11] = KeyCode_Invalid, + [GLFW_KEY_F12] = KeyCode_Invalid, + [GLFW_KEY_F13] = KeyCode_Invalid, + [GLFW_KEY_F14] = KeyCode_Invalid, + [GLFW_KEY_F15] = KeyCode_Invalid, + [GLFW_KEY_F16] = KeyCode_Invalid, + [GLFW_KEY_F17] = KeyCode_Invalid, + [GLFW_KEY_F18] = KeyCode_Invalid, + [GLFW_KEY_F19] = KeyCode_Invalid, + [GLFW_KEY_F20] = KeyCode_Invalid, + [GLFW_KEY_F21] = KeyCode_Invalid, + [GLFW_KEY_F22] = KeyCode_Invalid, + [GLFW_KEY_F23] = KeyCode_Invalid, + [GLFW_KEY_F24] = KeyCode_Invalid, + [GLFW_KEY_F25] = KeyCode_Invalid, + [GLFW_KEY_KP_0] = KeyCode_Invalid, + [GLFW_KEY_KP_1] = KeyCode_Invalid, + [GLFW_KEY_KP_2] = KeyCode_Invalid, + [GLFW_KEY_KP_3] = KeyCode_Invalid, + [GLFW_KEY_KP_4] = KeyCode_Invalid, + [GLFW_KEY_KP_5] = KeyCode_Invalid, + [GLFW_KEY_KP_6] = KeyCode_Invalid, + [GLFW_KEY_KP_7] = KeyCode_Invalid, + [GLFW_KEY_KP_8] = KeyCode_Invalid, + [GLFW_KEY_KP_9] = KeyCode_Invalid, + [GLFW_KEY_KP_DECIMAL] = KeyCode_Invalid, + [GLFW_KEY_KP_DIVIDE] = KeyCode_Invalid, + [GLFW_KEY_KP_MULTIPLY] = KeyCode_Invalid, + [GLFW_KEY_KP_SUBTRACT] = KeyCode_Invalid, + [GLFW_KEY_KP_ADD] = KeyCode_Invalid, + [GLFW_KEY_KP_ENTER] = KeyCode_Invalid, + [GLFW_KEY_KP_EQUAL] = KeyCode_Invalid, + [GLFW_KEY_LEFT_SHIFT] = KeyCode_LeftShift, + [GLFW_KEY_LEFT_CONTROL] = KeyCode_LeftCtrl, + [GLFW_KEY_LEFT_ALT] = KeyCode_Alt, + [GLFW_KEY_LEFT_SUPER] = KeyCode_Invalid, + [GLFW_KEY_RIGHT_SHIFT] = KeyCode_RightShift, + [GLFW_KEY_RIGHT_CONTROL] = KeyCode_RightCtrl, + [GLFW_KEY_RIGHT_ALT] = KeyCode_Alt, + [GLFW_KEY_RIGHT_SUPER] = KeyCode_Invalid, + [GLFW_KEY_MENU] = KeyCode_Invalid, + +}; + +Key_Code +osx_translate_key(int glfw_key) +{ + // TODO: turn this into an actual key_code + return glfw_key_translation_table[glfw_key]; +} + +Key_Code +osx_translate_mouse_button(int glfw_button) +{ + switch (glfw_button) + { + case GLFW_MOUSE_BUTTON_LEFT: return KeyCode_MouseLeftButton; break; + case GLFW_MOUSE_BUTTON_RIGHT: return KeyCode_MouseRightButton; break; + case GLFW_MOUSE_BUTTON_MIDDLE: return KeyCode_MouseMiddleButton; break; + invalid_default_case; + } + return 0; +} + +void +button_event(Key_Code key, int action, int mods) +{ + Window_Event evt = { + .kind = WindowEvent_ButtonDown, + .key_code = key, + }; + + if (has_flag(mods, GLFW_MOD_SHIFT)) add_flag(evt.key_flags, KeyFlag_Mod_Shift); + if (has_flag(mods, GLFW_MOD_CONTROL)) add_flag(evt.key_flags, KeyFlag_Mod_Shift); + if (has_flag(mods, GLFW_MOD_ALT)) add_flag(evt.key_flags, KeyFlag_Mod_Shift); + + switch (action) + { + case GLFW_PRESS: { evt.key_flags = KeyFlag_State_IsDown; } break; + case GLFW_REPEAT: { + evt.key_flags = KeyFlag_State_IsDown | KeyFlag_State_WasDown; + } break; + case GLFW_RELEASE: { + evt.key_flags = KeyFlag_State_WasDown; + } break; + invalid_default_case; + } + lumenarium_event(evt, (App_State*)app_state_data); +} + +void +key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) +{ + Key_Code kc = osx_translate_key(key); + button_event(kc, action, mods); +} + +void +cursor_position_callback(GLFWwindow* window, double xpos, double ypos) +{ + Window_Event evt = { + .kind = WindowEvent_MouseMoved, + .mouse_x = (u32)xpos, + .mouse_y = (u32)ypos, + }; + lumenarium_event(evt, (App_State*)app_state_data); +} + +void +mouse_button_callback(GLFWwindow* window, int button, int action, int mods) +{ + Key_Code kc = osx_translate_mouse_button(button); + button_event(kc, action, mods); +} + +void +scroll_callback(GLFWwindow* window, double xoffset, double yoffset) +{ + Window_Event evt = {}; + evt.kind = WindowEvent_MouseScroll; + evt.scroll_amt = xoffset; + lumenarium_event(evt, (App_State*)app_state_data); +} + +int main (int arg_count, char** args) +{ + if (!glfwInit()) + { + printf("Error: Could not initialize glfw.\n"); + return 1; + } + glfwSetErrorCallback(glfw_error_callback); + + s32 init_window_width = 1400 / 2; + s32 init_window_height = 700 / 2; + + glfwWindowHint(GLFW_DOUBLEBUFFER, true); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, 1); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + GLFWwindow* window = glfwCreateWindow(init_window_width, init_window_height, "Lumenarium", NULL, NULL); + if (!window) + { + printf("Error: Unable to create a glfw window\n"); + return 1; + } + glfwMakeContextCurrent(window); + glfwSwapInterval(1); + gl = osx_load_opengl_ext(); + + // Input Callbacks + glfwSetKeyCallback(window, key_callback); + glfwSetMouseButtonCallback(window, mouse_button_callback); + glfwSetCursorPosCallback(window, cursor_position_callback); + glfwSetScrollCallback(window, scroll_callback); + + Editor_Desc ed_desc = {}; + float xscale, yscale; + glfwGetWindowContentScale(window, &xscale, &yscale); + ed_desc.content_scale = (v2){ xscale, yscale }; + ed_desc.init_window_dim = (v2){init_window_width, init_window_height}; + + App_State* state = lumenarium_init(&ed_desc); + app_state_data = (u8*)state; + + bool running = true; + r64 target_seconds_per_frame = state->target_seconds_per_frame; + Ticks ticks_start = os_get_ticks(); + while(!glfwWindowShouldClose(window) && running && has_flag(state->flags, AppState_IsRunning)) { + lumenarium_frame_prepare(state); + glfwPollEvents(); + + if (has_flag(state->flags, AppState_RunEditor)) + { + s32 w, h; + glfwGetWindowSize(window, &w, &h); + state->editor->window_dim = (v2){ (r32)w, (r32)h }; + } + + lumenarium_frame(state); + lumenarium_env_validate(); + + glfwSwapBuffers(window); + + Ticks ticks_end = os_get_ticks(); + r64 seconds_elapsed = get_seconds_elapsed(ticks_start, ticks_end, os_get_ticks_per_second()); + while (seconds_elapsed < target_seconds_per_frame) + { + u32 sleep_time = (u32)(1000000.0f * (target_seconds_per_frame - seconds_elapsed)); + usleep(sleep_time); + + ticks_end = os_get_ticks(); + seconds_elapsed = get_seconds_elapsed(ticks_start, ticks_end, os_get_ticks_per_second()); + } + ticks_start = ticks_end; + } + + lumenarium_cleanup(state); + glfwDestroyWindow(window); + glfwTerminate(); + return 0; +} \ No newline at end of file diff --git a/src_v2/platform/osx/lumenarium_osx_file.h b/src_v2/platform/osx/lumenarium_osx_file.h new file mode 100644 index 0000000..4fc6124 --- /dev/null +++ b/src_v2/platform/osx/lumenarium_osx_file.h @@ -0,0 +1,265 @@ +File_Async_Job_System +os_file_jobs_init() +{ + open_files_init(); + File_Async_Job_System result = file_async_jobs_init(os_file_async_work_on_job); + return result; +} + +File_Handle +os_file_open(String path, File_Access_Flags flags_access, File_Create_Flags flags_create) +{ + File_Handle result = {}; + + mode_t mode = 0; + + s32 flags = 0; + if (has_flag_exact(flags_access, (FileAccess_Read | FileAccess_Write))) + { + add_flag(flags, O_RDWR); + } + else + { + if (has_flag(flags_access, FileAccess_Read)) + { + add_flag(flags, O_RDONLY); + } + else if (has_flag(flags_access, FileAccess_Write)) + { + add_flag(flags, O_WRONLY); + } + else + { + return result; + } + } + + // This additional argument is required if we're creating a file + // if we want this process to be able to open it again later. + mode_t create_flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + + switch (flags_create) + { + case FileCreate_New: + { + add_flag(flags, O_CREAT | O_EXCL ); + mode = create_flags; + } break; + case FileCreate_OpenExisting: { /* add_flag(flags, O_); */ } break; + case FileCreate_CreateAlways: + case FileCreate_OpenAlways: + { + add_flag(flags, O_CREAT); + mode = create_flags; + } break; + invalid_default_case; + } + + s32 file_handle = open((char*)path.str, flags, mode); + if (file_handle >= 0) + { + result = open_files_put_handle(file_handle, path); + } + else + { + s32 errsv = errno; + printf("Error: os_file_open - %d - ", errsv); + switch (errsv) { + case EACCES: printf("EACCESS\n"); break; + case EBADF: printf("EBADF\n"); break; + case EBUSY: printf("EBUSY\n"); break; + case EDQUOT: printf("EDQUOT\n"); break; + case EEXIST: printf("EEXIST\n"); break; + case EFAULT: printf("EFAULT\n"); break; + case EFBIG: printf("EFBIG\n"); break; + case ENOMEM: printf("ENOMEM\n"); break; + case ENFILE: printf("ENFILE\n"); break; + case EINVAL: printf("EINVAL\n"); break; + default: printf("Unregistered error\n"); break; + } + printf("\tAttempting to open: %.*s\n", str_varg(path)); + printf("\tFlags: %u %u\n", flags_access, flags_create); + } + return result; +} + +void +os_file_close(File_Handle file_handle) +{ + s32 os_handle = open_files_get_handle(file_handle); + if (close(os_handle) != -1) + { + open_files_rem_file(file_handle); + } + else + { + s32 errsv = errno; + printf("Error: os_file_close - %d\n", errsv); + } +} + +bool +os_file_delete(String file_path) +{ + if (remove((char*)file_path.str) != 0) { + perror("Error deleting file\n"); + return false; + } + return true; +} + +File_Info +os_file_get_info(File_Handle file_handle, Allocator* allocator) +{ + File_Info info = {}; + s32 os_handle = open_files_get_handle(file_handle); + if (os_handle != -1) + { + String path = open_files_get_path(file_handle); + + struct stat os_info = {}; + if (fstat(os_handle, &os_info) != -1) + { + info.path = string_copy(path, allocator); + info.path_abs = allocator_alloc_string(allocator, PATH_MAX); + if (realpath((char*)path.str, (char*)info.path_abs.str) != 0) + { + info.path_abs.len = c_str_len((char*)info.path_abs.str); + } + else + { + s32 errsv = errno; + printf("Error - os_file_get_info - %d - realpath\n", errsv); + } + info.size = (u64)os_info.st_size; + if (S_ISDIR(os_info.st_mode)) + { + add_flag(info.flags, FileFlag_IsDir); + } + else if (!S_ISREG(os_info.st_mode)) + { + printf("Error - os_file_get_info - stat-ing a handle that is not a directory or a file\n"); + } + } + else + { + s32 errsv = errno; + printf("Error: os_file_get_info - %d\n", errsv); + } + } + return info; +} + +Data +os_file_read_all(File_Handle file_handle, Allocator* allocator) +{ + Data result = {}; + s32 os_handle = open_files_get_handle(file_handle); + if (os_handle == -1) return result; + + // get file size + s32 offset = lseek(os_handle, 0, SEEK_END); + if (offset == -1) + { + s32 errsv = errno; + printf("Error: os_file_read_all:lseek - %d\n", errsv); + return result; + } + lseek(os_handle, 0, SEEK_SET); + + result.base = allocator_alloc(allocator, offset + 1); + result.size = offset + 1; + + s32 bytes_read = read(os_handle, result.base, result.size); + if (bytes_read == (result.size - 1)) + { + result.base[bytes_read] = 0; // null term + } + else if (bytes_read >= 0) + { + printf("Error: os_file_read:read - whole file not read.\n"); + } + else if (bytes_read == -1) + { + s32 errsv = errno; + printf("Error: os_file_read_all:read - %d\n", errsv); + } + + return result; +} + +bool +os_file_write_(s32 os_handle, Data file_data) +{ + s32 size_written = write(os_handle, file_data.base, file_data.size); + if (size_written > 0 && size_written != file_data.size) + { + printf("Error: os_file_write_all:write - whole file not written\n"); + return true; + } + else if (size_written < 0) + { + osx_err_print("write"); + return false; + } + + return true; +} + +bool +os_file_write_all(File_Handle file_handle, Data file_data) +{ + s32 os_handle = open_files_get_handle(file_handle); + if (os_handle == -1) return false; + + lseek(os_handle, 0, SEEK_SET); + return os_file_write_(os_handle, file_data); +} + +bool +os_file_write(File_Handle file_handle, Data file_data) +{ + s32 os_handle = open_files_get_handle(file_handle); + if (os_handle == -1) return false; + + return os_file_write_(os_handle, file_data); +} + +String +os_get_exe_path(Allocator* allocator) +{ + u32 needed = 0; + _NSGetExecutablePath(0, &needed); + + String result = allocator_alloc_string(allocator, needed + 1); + + u32 cap = (u64)result.cap; + s32 r = _NSGetExecutablePath((char*)result.str, &cap); + if (r == 0) + { + result.len = cap; + result.str[result.len] = 0; + } + + return result; +} + +bool +os_pwd_set(String path) +{ + s32 result = chdir((char*)path.str); + if (result == -1) + { + osx_err_print("chdir"); + return false; + } + return true; +} + +#if 0 +File_Info_List +os_dir_enum(String path, Platform_Enum_Dir_Flags flags, Allocator* allocator) +{ + +} +#endif diff --git a/src_v2/platform/osx/lumenarium_osx_graphics.h b/src_v2/platform/osx/lumenarium_osx_graphics.h new file mode 100644 index 0000000..289051f --- /dev/null +++ b/src_v2/platform/osx/lumenarium_osx_graphics.h @@ -0,0 +1,58 @@ +#define OSX_GL_ERROR_CASE(e) case e: { result = #e; } break +char* +osx_gl_error_to_string(u32 error) +{ + char* result = 0; + switch (error) + { + OSX_GL_ERROR_CASE(GL_INVALID_VALUE); + OSX_GL_ERROR_CASE(GL_INVALID_ENUM ); + OSX_GL_ERROR_CASE(GL_INVALID_OPERATION); + default: { result = "unknown"; } + } + return result; +} + +void +os_gl_no_error_(char* file, u32 line) { + u32 error = glGetError(); + char* str = 0; + if (error) { + str = osx_gl_error_to_string(error); + } + if (error != 0) + { + fprintf(stderr, "OpenGL error: %s:%d\n\t%s :: %d\n", file, line, str, error); + invalid_code_path; + } +} + +#define load_ext(r,n) r.n = (proc_##n*)glfwGetProcAddress(#n); assert((r.n) != 0) +OpenGL_Extensions +osx_load_opengl_ext() +{ + OpenGL_Extensions result = {}; + load_ext(result, glGenVertexArrays); + load_ext(result, glBindVertexArray); + load_ext(result, glGenBuffers); + load_ext(result, glBindBuffer); + load_ext(result, glBufferData); + load_ext(result, glBufferSubData); + load_ext(result, glCreateShader); + load_ext(result, glShaderSource); + load_ext(result, glCompileShader); + load_ext(result, glCreateProgram); + load_ext(result, glAttachShader); + load_ext(result, glLinkProgram); + load_ext(result, glUseProgram); + load_ext(result, glGetAttribLocation); + load_ext(result, glVertexAttribPointer); + load_ext(result, glEnableVertexAttribArray); + load_ext(result, glGetShaderiv); + load_ext(result, glGetShaderInfoLog); + load_ext(result, glGetProgramiv); + load_ext(result, glGetProgramInfoLog); + load_ext(result, glGetUniformLocation); + load_ext(result, glUniformMatrix4fv); + return result; +} \ No newline at end of file diff --git a/src_v2/platform/osx/lumenarium_osx_memory.h b/src_v2/platform/osx/lumenarium_osx_memory.h new file mode 100644 index 0000000..388b9f9 --- /dev/null +++ b/src_v2/platform/osx/lumenarium_osx_memory.h @@ -0,0 +1,41 @@ +// TODO(PS): come back and do this properly +#define OS_MEM_PAGE_SIZE 4096 + +size_t +osx_round_to_page_size(uint64_t size) +{ + uint64_t rem = size % OS_MEM_PAGE_SIZE; + if (rem != 0 || size < OS_MEM_PAGE_SIZE) + { + uint64_t grow = OS_MEM_PAGE_SIZE - rem; + size += grow; + } + return (size_t)size; +} + +uint8_t* +os_mem_reserve(uint64_t size) +{ + size_t size_cvt = osx_round_to_page_size(size); + uint8_t* result = (uint8_t*)malloc(size_cvt); + return result; +} + +uint8_t* +os_mem_commit(uint8_t* base, uint64_t size) +{ + return base; +} + +bool +os_mem_decommit(uint8_t* base, uint64_t size) +{ + return 1; // true +} + +bool +os_mem_release(uint8_t* base, uint64_t size) +{ + free(base); + return 1; // true +} \ No newline at end of file diff --git a/src_v2/platform/osx/lumenarium_osx_network.h b/src_v2/platform/osx/lumenarium_osx_network.h new file mode 100644 index 0000000..929b0a8 --- /dev/null +++ b/src_v2/platform/osx/lumenarium_osx_network.h @@ -0,0 +1,171 @@ +static Socket_Error os_osx_socket_error_translation_table[] = { + [EAGAIN] = SocketError_EAGAIN, + [EBADF] = SocketError_EBADF, + [ECONNREFUSED] = SocketError_ECONNREFUSED, + [EFAULT] = SocketError_EFAULT, + [EINTR] = SocketError_EINTR, + [EINVAL] = SocketError_EINVAL, + [ENOMEM] = SocketError_ENOMEM, + [ENOTCONN] = SocketError_ENOTCONN, + [ENOTSOCK] = SocketError_ENOTSOCK, +}; + +Socket_Handle +os_socket_create(s32 domain, s32 type, s32 protocol) +{ + Socket_Handle result = {}; + OS_SOCKET_TYPE sock = socket(domain, type, protocol); + if (sock == -1) { + perror("Error: os_socket_create\n"); + return result; + } + + result = open_sockets_put(sock); + if (result.value == 0) + { + fprintf(stderr, "Error: os_socket_create - not enough room in open_sockets\n"); + } + return result; +} + +bool +os_socket_bind(Socket_Handle socket, u32 port) +{ + OS_SOCKET_TYPE sock = open_sockets_get(socket); + struct sockaddr_in addr = { + .sin_family = AF_INET, + .sin_addr.s_addr = INADDR_ANY, + .sin_port = htons(port), + }; + s32 bind_res = bind(sock, (struct sockaddr*)&addr, sizeof(addr)); + if (bind_res < 0) { + printf("ERROR: os_socket_bind - %d\n", bind_res); + return false; + } + + return true; +} + +bool +os_socket_connect() +{ + return false; +} + +bool +os_socket_close(Socket_Handle handle) +{ + OS_SOCKET_TYPE sock = open_sockets_get(handle); + close(sock); + return true; +} + +Data +os_socket_recv() +{ + return (Data){}; +} + +Data +os_socket_recvfrom(Socket_Handle handle, u8* buffer, u32 buffer_size, Socket_Error* err_out) +{ + OS_SOCKET_TYPE sock = open_sockets_get(handle); + + Data result = { + .base = buffer, + .size = buffer_size, + }; + + struct sockaddr from = {}; + s32 from_len = sizeof(from); + + // TODO: Look into MSG_PEEK - there might be a way to determine + // the size of the packet without losing it, even on UDP/SOCK_DGRAM + // connections + s32 flags = 0; + + s32 r = recvfrom( + sock, + result.base, + result.size, + flags, + &from, + (socklen_t*)&from_len + ); + if (r < 0) { + if (err_out) { + *err_out = os_osx_socket_error_translation_table[errno]; + } else { + printf("UNHANDLED ERROR: os_socket_recvfrom\n\t"); + switch (errno) + { + case EAGAIN: printf("EAGAIN\n"); break; + case EBADF: printf("EBADF\n"); break; + case ECONNREFUSED: printf("ECONNREFUSED\n"); break; + case EFAULT: printf("EFAULT\n"); break; + case EINTR: printf("EINTR\n"); break; + case EINVAL: printf("EINVAL\n"); break; + case ENOMEM: printf("ENOMEM\n"); break; + case ENOTCONN: printf("ENOTCONN\n"); break; + case ENOTSOCK: printf("ENOTSOCK\n"); break; + default: { printf("%d\n", errno); } break; + } + } + } + + result.size = r; + return result; +} + +s32 +os_socket_set_listening() +{ + return 0; +} + +s32 +os_socket_send() +{ + return 0; +} + +s32 +os_socket_send_to(Socket_Handle handle, u32 addr, u32 port, Data data, s32 flags) +{ + OS_SOCKET_TYPE sock = open_sockets_get(handle); + + struct sockaddr_in dst = { + .sin_family = AF_INET, + .sin_port = hton_u16(port), + .sin_addr.s_addr = hton_u32(addr), + }; + +#define PRINT_EVERY_SEND_ADDR 0 +#if PRINT_EVERY_SEND_ADDR + printf("Sending To:\n\tFamily: %d\n\tPort: %d\n\tAddr: %d\n", + dst.sin_family, dst.sin_port, dst.sin_addr.s_addr + ); +#endif + + struct sockaddr* dst_ptr = (struct sockaddr*)&dst; + s32 len_sent = sendto(sock, data.base, data.size, flags, dst_ptr, sizeof(struct sockaddr_in)); + if (len_sent == -1) + { + perror("Error: os_socket_send_to\n"); + return 0; + } + + return len_sent; +} + +s32 +os_socket_set_opt(Socket_Handle handle, int level, int option_name, +u8* option_value, s32 option_len) +{ + OS_SOCKET_TYPE sock = open_sockets_get(handle); + s32 err = setsockopt(sock, level, option_name, (void*)option_value, (socklen_t)option_len); + if (err) { + fprintf(stderr, "Error: setsockopt - %d\n\targs: %d %d %.*s\n", err, level, option_name, option_len, (char*)option_value); + } + return 0; +} diff --git a/src_v2/platform/osx/lumenarium_osx_thread.h b/src_v2/platform/osx/lumenarium_osx_thread.h new file mode 100644 index 0000000..0cb8781 --- /dev/null +++ b/src_v2/platform/osx/lumenarium_osx_thread.h @@ -0,0 +1,142 @@ +/* date = August 13th 2022 1:57 pm */ + +#ifndef LUMENARIUM_OSX_THREAD_H +#define LUMENARIUM_OSX_THREAD_H + +typedef struct Os_Osx_Thread Os_Osx_Thread; +struct Os_Osx_Thread +{ + pthread_t thread; + Thread_Proc* proc; + u8* user_data; + Thread_Result result; +}; + +#define OSX_THREAD_CAP 8 +global Os_Osx_Thread osx_threads_[OSX_THREAD_CAP]; +global u32 osx_threads_len_; + +void* +os_thread_proc_wrapper(void* arg) +{ + // Call the actual thread function + // This is essentially a blocking call for the rest of this function + Os_Osx_Thread* thread_data = (Os_Osx_Thread*)arg; + thread_data->result = thread_data->proc(thread_data->user_data); + + // Clean up this threads thread slot so other threads + // can use it + thread_data->proc = 0; + thread_data->user_data = 0; + + pthread_exit(&thread_data->result); +} + +Thread_Handle +os_thread_begin(Thread_Proc* proc, u8* user_data) +{ + // Find an unused thread slot + Thread_Handle result = { .value = 0 }; + if (osx_threads_len_ < OSX_THREAD_CAP) + { + result = (Thread_Handle){ .value = osx_threads_len_++ }; + } + else + { + bool found = false; + for (u32 i = 0; i < OSX_THREAD_CAP; i++) + { + if (osx_threads_[i].proc == 0) + { + result.value = i; + found = true; + } + } + + if (!found) { + printf("ERROR: Unable to create thread.\n"); + invalid_code_path; + } + } + + // Initialize Thread Slot + Os_Osx_Thread* t = osx_threads_ + result.value; + *t = (Os_Osx_Thread){ + .proc = proc, + .user_data = user_data + }; + + // Create PThread + s32 create_error = pthread_create( + &t->thread, + NULL, // use default attrs + (void * _Nullable (* _Nonnull)(void * _Nullable))proc, + user_data + ); + + if (create_error) + { + switch (create_error) { + case EAGAIN: { + } break; + + case EINVAL: { + } break; + + // case ELEMULTITHREADFORK: { + // } break; + + case ENOMEM: { + } break; + } + } + + return result; +} + +void +os_thread_end(Thread_Handle thread_handle) +{ + Os_Osx_Thread* t = osx_threads_ + thread_handle.value; + //pthread_kill(t->thread, 0); +} + +#if defined(PLATFORM_osx) + +u32 +os_interlocked_increment(volatile u32* value) +{ + assert(*value <= s32_max); + u32 result = OSAtomicIncrement32((volatile s32*)value); + return result; +} + +bool +os_interlocked_cmp_exchg(volatile u32* dest, u32 old_value, u32 new_value) +{ + assert(*dest <= s32_max); + bool result = OSAtomicCompareAndSwapInt((s32)old_value, (s32)new_value, (volatile s32*)dest); + return result; +} + +#else +u32 +os_interlocked_increment(volatile u32* value) +{ + *value += 1; + return *value; +} + +bool +os_interlocked_cmp_exchg(volatile u32* dest, u32 old_value, u32 new_value) +{ + assert(*dest <= s32_max); + if (*dest == old_value) { + *dest = new_value; + return true; + } + return false; +} +#endif + +#endif //LUMENARIUM_OSX_THREAD_H diff --git a/src_v2/platform/osx/lumenarium_osx_time.h b/src_v2/platform/osx/lumenarium_osx_time.h new file mode 100644 index 0000000..f8dbbd7 --- /dev/null +++ b/src_v2/platform/osx/lumenarium_osx_time.h @@ -0,0 +1,24 @@ + +// I think this SO post might be helpful +// https://stackoverflow.com/questions/30575995/multi-platform-equivalent-to-queryperformancecounter + +Ticks +os_get_ticks() +{ + Ticks result = { + .value = mach_absolute_time() + }; + return result; +} + +global mach_timebase_info_data_t osx_timebase_info; + +r64 +os_get_ticks_per_second() +{ + if (osx_timebase_info.denom == 0) { + mach_timebase_info(&osx_timebase_info); + } + r64 to_secs = ((r64)osx_timebase_info.denom * 1e9) / (r64)osx_timebase_info.numer; + return to_secs; +} \ No newline at end of file diff --git a/src_v2/platform/raspi/lumenarium_first_raspi.c b/src_v2/platform/raspi/lumenarium_first_raspi.c new file mode 100644 index 0000000..5052ee7 --- /dev/null +++ b/src_v2/platform/raspi/lumenarium_first_raspi.c @@ -0,0 +1,89 @@ +#include <stdlib.h> +#include <stdio.h> +#include <stdint.h> +#include <unistd.h> +#include <stdbool.h> +#include <math.h> + +#include <sys/socket.h> +#include <netinet/in.h> + +#include "../linux/lumenarium_linux_memory.h" +#include "../../core/lumenarium_core.h" +#include "../lumenarium_os.h" +#include "../../lumenarium_first.c" + +#undef internal +#undef external + +#include <errno.h> +#include <linux/limits.h> +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <time.h> + +#include <pthread.h> + +#define linux_err_print(sub_proc) linux_err_print_((char*)__FUNCTION__, (char*)(sub_proc), errno) +void +linux_err_print_(char* proc, char* sub_proc, s32 errsv) +{ + printf("Error: %s:%s - %d\n\t%s\n\n", proc, sub_proc, errsv, strerror(errsv)); +} + +#define OS_FILE_HANDLE_TYPE s32 +#define OS_FILE_MAX_PATH PATH_MAX +#define OS_FILE_INVALID_HANDLE -1 +#define OS_SOCKET_TYPE s32 +#define OS_SOCKET_INVALID_HANDLE -1 +#include "../shared/lumenarium_shared_file_tracker.h" +#include "../shared/lumenarium_shared_file_async_work_on_job.h" +#include "../shared/lumenarium_shared_network.h" +#include "../linux/lumenarium_linux_file.h" +#include "../linux/lumenarium_linux_time.h" +#include "../osx/lumenarium_osx_network.h" +#include "../osx/lumenarium_osx_thread.h" + + +int main (int arg_count, char** args) +{ + // INIT APPLICATION + Editor_Desc ed_desc = { + }; + App_State* state = lumenarium_init(&ed_desc); + + time_t t = time(NULL); + struct tm* lt = localtime(&t); + // lt.tm_sec, tm_min, tm_hour, tm_mday, etc. + printf("Local Time: %s\n", asctime(lt)); + + bool running = true; + Ticks ticks_start = os_get_ticks(); + while (has_flag(state->flags, AppState_IsRunning)) + { + lumenarium_frame_prepare(state); + + lumenarium_frame(state); + lumenarium_env_validate(); + + Ticks ticks_end = os_get_ticks(); + usleep((1.f / 30.f) * 1000000); + + // r64 seconds_elapsed = (r64)(ticks_end.value - ticks_start.value) / (r64)1e+9; + // //get_seconds_elapsed(ticks_start, ticks_end, os_get_ticks_per_second()); + // while (seconds_elapsed < state->target_seconds_per_frame) + // { + // printf("Sleeping\n"); + // u32 sleep_time = (u32)(1000000.0f * (state->target_seconds_per_frame - seconds_elapsed)); + + // ticks_end = os_get_ticks(); + // seconds_elapsed = (r64)(ticks_end.value - ticks_start.value) / (r64)1e+9; //get_seconds_elapsed(ticks_start, ticks_end, os_get_ticks_per_second()); + // } + ticks_start = ticks_end; + } + + lumenarium_cleanup(state); + return 0; +} \ No newline at end of file diff --git a/src_v2/platform/raspi/lumenarium_raspi_tests.c b/src_v2/platform/raspi/lumenarium_raspi_tests.c new file mode 100644 index 0000000..d110596 --- /dev/null +++ b/src_v2/platform/raspi/lumenarium_raspi_tests.c @@ -0,0 +1,5 @@ +void +lumenarium_raspi_tests() +{ + printf("Hi there\n"); +} \ No newline at end of file diff --git a/src_v2/platform/shared/lumenarium_shared_file_async_work_on_job.h b/src_v2/platform/shared/lumenarium_shared_file_async_work_on_job.h new file mode 100644 index 0000000..cfe29f6 --- /dev/null +++ b/src_v2/platform/shared/lumenarium_shared_file_async_work_on_job.h @@ -0,0 +1,36 @@ +#if defined(PLATFORM_win32) || defined(PLATFORM_osx) + +void +os_file_async_work_on_job(File_Async_Job* job) +{ + File_Handle file = {}; + if (has_flag(job->args.flags, FileAsyncJob_Read)) + { + file = os_file_open(job->args.path, FileAccess_Read, FileCreate_OpenExisting); + Data result = os_file_read_all(file, file_jobs_arena); + if (result.base != 0) + { + job->args.data = result; + add_flag(job->args.flags, FileAsyncJob_Success); + } + else + { + add_flag(job->args.flags, FileAsyncJob_Failed); + } + } + else if (has_flag(job->args.flags, FileAsyncJob_Write)) + { + file = os_file_open(job->args.path, FileAccess_Write, FileCreate_OpenAlways); + if (os_file_write_all(file, job->args.data)) + { + add_flag(job->args.flags, FileAsyncJob_Success); + } + else + { + add_flag(job->args.flags, FileAsyncJob_Failed); + } + } + os_file_close(file); +} + +#endif // defined(win32) || defined(osx) \ No newline at end of file diff --git a/src_v2/platform/shared/lumenarium_shared_file_tracker.h b/src_v2/platform/shared/lumenarium_shared_file_tracker.h new file mode 100644 index 0000000..779e445 --- /dev/null +++ b/src_v2/platform/shared/lumenarium_shared_file_tracker.h @@ -0,0 +1,106 @@ +#if !defined(LUMENARIUM_SHARED_FILE_TRACKER_H) +#define LUMENARIUM_SHARED_FILE_TRACKER_H + +#if !defined(OS_FILE_HANDLE_TYPE) +# error "You must define an OS_FILE_HANDLE_TYPE" +#endif + +#if !defined(OS_FILE_MAX_PATH) +# error "You must define an OS_FILE_MAX_PATH" +#endif + +#if !defined(OS_FILE_INVALID_HANDLE) +# error "You must define an OS_FILE_INVALID_HANDLE" +#endif + +#define open_files_cap 32 +global u64 open_files_len = 1; // zero is invalid +global char open_file_paths[open_files_cap][OS_FILE_MAX_PATH]; +global u64 open_file_paths_len[open_files_cap]; +global OS_FILE_HANDLE_TYPE open_files[open_files_cap]; + +void open_files_init(); +bool open_files_has_room(); +OS_FILE_HANDLE_TYPE open_files_get_handle(File_Handle handle); +String open_files_get_path(File_Handle handle); +File_Handle open_files_put_handle(OS_FILE_HANDLE_TYPE os_handle, String path); +void open_files_rem_file(File_Handle handle); + +//////////////////////////////////////////////// +// IMPLEMENTATION + +void +open_files_init() +{ + for (u32 i = 0; i < open_files_cap; i++) + { + open_files[i] = OS_FILE_INVALID_HANDLE; + } +} + +bool open_files_has_room() { return open_files_len < open_files_cap; } + +OS_FILE_HANDLE_TYPE +open_files_get_handle(File_Handle handle) +{ + assert(handle.value < open_files_len); + return open_files[handle.value]; +} + +String +open_files_get_path(File_Handle handle) +{ + assert(handle.value < open_files_len); + String result = { + .str = (u8*)open_file_paths[handle.value], + .len = open_file_paths_len[handle.value], + .cap = open_file_paths_len[handle.value], + }; + return result; +} + +File_Handle +open_files_put_handle(OS_FILE_HANDLE_TYPE os_handle, String path) +{ + assert(path.len < OS_FILE_MAX_PATH); + + File_Handle result = {}; + if (os_handle != OS_FILE_INVALID_HANDLE) + { + if (open_files_has_room()) + { + result.value = open_files_len++; + } + else + { + // search for emtpy index + for (u32 i = 1; i < open_files_cap; i++) + { + if (open_files[i] == OS_FILE_INVALID_HANDLE) + { + result.value = i; + } + } + } + + if (result.value != 0) + { + open_files[result.value] = os_handle; + memory_copy(path.str, (u8*)open_file_paths[result.value], path.len); + open_file_paths[result.value][path.len] = 0; // null term + open_file_paths_len[result.value] = path.len; + } + } + return result; +} + +void +open_files_rem_file(File_Handle handle) +{ + assert(handle.value < open_files_len); + open_files[handle.value] = OS_FILE_INVALID_HANDLE;; +} + + + +#endif // LUMENARIUM_SHARED_FILE_TRACKER_H \ No newline at end of file diff --git a/src_v2/platform/shared/lumenarium_shared_network.h b/src_v2/platform/shared/lumenarium_shared_network.h new file mode 100644 index 0000000..1d64d97 --- /dev/null +++ b/src_v2/platform/shared/lumenarium_shared_network.h @@ -0,0 +1,67 @@ +#if !defined(OS_SOCKET_TYPE) +# error "You must define an OS_SOCKET_TYPE" +#endif + +#if !defined(OS_SOCKET_INVALID_HANDLE) +# error "You must define an OS_SOCKET_INVALID_HANDLE" +#endif + +#define open_sockets_cap 3 +global u32 open_sockets_len = 1; +global OS_SOCKET_TYPE open_sockets[open_sockets_cap]; + +void open_sockets_init(); +s32 open_sockets_next_free(); +bool open_sockets_has_room(); +OS_SOCKET_TYPE open_sockets_get(Socket_Handle handle); +Socket_Handle open_sockets_put(OS_SOCKET_TYPE socket); +void open_sockets_rem(Socket_Handle handle); + +//////////////////////////////////////////////// +// IMPLEMENTATION + +void +open_sockets_init() +{ + for (u32 i = 0; i < open_sockets_cap; i++) + { + open_sockets[i] = OS_SOCKET_INVALID_HANDLE; + } +} + +s32 +open_sockets_next_free() +{ + if (open_sockets_len < open_sockets_cap) return open_sockets_len++; + for (u32 i = 1; i < open_sockets_len; i++) + { + if (open_sockets[i] == OS_SOCKET_INVALID_HANDLE) return i; + } + return 0; +} + +OS_SOCKET_TYPE +open_sockets_get(Socket_Handle handle) +{ + assert(handle.value < open_sockets_len); + return open_sockets[handle.value]; +} + +Socket_Handle +open_sockets_put(OS_SOCKET_TYPE socket) +{ + Socket_Handle result = { .value = open_sockets_next_free() }; + assert(result.value != 0); + open_sockets[result.value] = socket; + return result; +} + +void +open_sockets_rem(Socket_Handle handle) +{ + assert(handle.value < open_sockets_len); + open_sockets[handle.value] = OS_SOCKET_INVALID_HANDLE; + if (handle.value + 1 == open_sockets_len) { + open_sockets_len -= 1; + } +} diff --git a/src_v2/platform/sokol_gfx.h b/src_v2/platform/sokol_gfx.h new file mode 100644 index 0000000..94c780c --- /dev/null +++ b/src_v2/platform/sokol_gfx.h @@ -0,0 +1,16066 @@ +#if defined(SOKOL_IMPL) && !defined(SOKOL_GFX_IMPL) +#define SOKOL_GFX_IMPL +#endif +#ifndef SOKOL_GFX_INCLUDED +/* + sokol_gfx.h -- simple 3D API wrapper + + Project URL: https://github.com/floooh/sokol + + Example code: https://github.com/floooh/sokol-samples + + Do this: + #define SOKOL_IMPL or + #define SOKOL_GFX_IMPL + before you include this file in *one* C or C++ file to create the + implementation. + + In the same place define one of the following to select the rendering + backend: + #define SOKOL_GLCORE33 + #define SOKOL_GLES2 + #define SOKOL_GLES3 + #define SOKOL_D3D11 + #define SOKOL_METAL + #define SOKOL_WGPU + #define SOKOL_DUMMY_BACKEND + + I.e. for the GL 3.3 Core Profile it should look like this: + + #include ... + #include ... + #define SOKOL_IMPL + #define SOKOL_GLCORE33 + #include "sokol_gfx.h" + + The dummy backend replaces the platform-specific backend code with empty + stub functions. This is useful for writing tests that need to run on the + command line. + + Optionally provide the following defines with your own implementations: + + SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) + SOKOL_MALLOC(s) - your own malloc function (default: malloc(s)) + SOKOL_FREE(p) - your own free function (default: free(p)) + SOKOL_LOG(msg) - your own logging function (default: puts(msg)) + SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false)) + SOKOL_GFX_API_DECL - public function declaration prefix (default: extern) + SOKOL_API_DECL - same as SOKOL_GFX_API_DECL + SOKOL_API_IMPL - public function implementation prefix (default: -) + SOKOL_TRACE_HOOKS - enable trace hook callbacks (search below for TRACE HOOKS) + SOKOL_EXTERNAL_GL_LOADER - indicates that you're using your own GL loader, in this case + sokol_gfx.h will not include any platform GL headers and disable + the integrated Win32 GL loader + + If sokol_gfx.h is compiled as a DLL, define the following before + including the declaration or implementation: + + SOKOL_DLL + + On Windows, SOKOL_DLL will define SOKOL_GFX_API_DECL as __declspec(dllexport) + or __declspec(dllimport) as needed. + + If you want to compile without deprecated structs and functions, + define: + + SOKOL_NO_DEPRECATED + + Optionally define the following to force debug checks and validations + even in release mode: + + SOKOL_DEBUG - by default this is defined if _DEBUG is defined + + sokol_gfx DOES NOT: + =================== + - create a window or the 3D-API context/device, you must do this + before sokol_gfx is initialized, and pass any required information + (like 3D device pointers) to the sokol_gfx initialization call + + - present the rendered frame, how this is done exactly usually depends + on how the window and 3D-API context/device was created + + - provide a unified shader language, instead 3D-API-specific shader + source-code or shader-bytecode must be provided (for the "official" + offline shader cross-compiler, see here: + https://github.com/floooh/sokol-tools/blob/master/docs/sokol-shdc.md) + + STEP BY STEP + ============ + --- to initialize sokol_gfx, after creating a window and a 3D-API + context/device, call: + + sg_setup(const sg_desc*) + + --- create resource objects (at least buffers, shaders and pipelines, + and optionally images and passes): + + sg_buffer sg_make_buffer(const sg_buffer_desc*) + sg_image sg_make_image(const sg_image_desc*) + sg_shader sg_make_shader(const sg_shader_desc*) + sg_pipeline sg_make_pipeline(const sg_pipeline_desc*) + sg_pass sg_make_pass(const sg_pass_desc*) + + --- start rendering to the default frame buffer with: + + sg_begin_default_pass(const sg_pass_action* action, int width, int height) + + ...or alternatively with: + + sg_begin_default_passf(const sg_pass_action* action, float width, float height) + + ...which takes the framebuffer width and height as float values. + + --- or start rendering to an offscreen framebuffer with: + + sg_begin_pass(sg_pass pass, const sg_pass_action* action) + + --- set the pipeline state for the next draw call with: + + sg_apply_pipeline(sg_pipeline pip) + + --- fill an sg_bindings struct with the resource bindings for the next + draw call (1..N vertex buffers, 0 or 1 index buffer, 0..N image objects + to use as textures each on the vertex-shader- and fragment-shader-stage + and then call + + sg_apply_bindings(const sg_bindings* bindings) + + to update the resource bindings + + --- optionally update shader uniform data with: + + sg_apply_uniforms(sg_shader_stage stage, int ub_index, const sg_range* data) + + Read the section 'UNIFORM DATA LAYOUT' to learn about the expected memory layout + of the uniform data passed into sg_apply_uniforms(). + + --- kick off a draw call with: + + sg_draw(int base_element, int num_elements, int num_instances) + + The sg_draw() function unifies all the different ways to render primitives + in a single call (indexed vs non-indexed rendering, and instanced vs non-instanced + rendering). In case of indexed rendering, base_element and num_element specify + indices in the currently bound index buffer. In case of non-indexed rendering + base_element and num_elements specify vertices in the currently bound + vertex-buffer(s). To perform instanced rendering, the rendering pipeline + must be setup for instancing (see sg_pipeline_desc below), a separate vertex buffer + containing per-instance data must be bound, and the num_instances parameter + must be > 1. + + --- finish the current rendering pass with: + + sg_end_pass() + + --- when done with the current frame, call + + sg_commit() + + --- at the end of your program, shutdown sokol_gfx with: + + sg_shutdown() + + --- if you need to destroy resources before sg_shutdown(), call: + + sg_destroy_buffer(sg_buffer buf) + sg_destroy_image(sg_image img) + sg_destroy_shader(sg_shader shd) + sg_destroy_pipeline(sg_pipeline pip) + sg_destroy_pass(sg_pass pass) + + --- to set a new viewport rectangle, call + + sg_apply_viewport(int x, int y, int width, int height, bool origin_top_left) + + ...or if you want to specifiy the viewport rectangle with float values: + + sg_apply_viewportf(float x, float y, float width, float height, bool origin_top_left) + + --- to set a new scissor rect, call: + + sg_apply_scissor_rect(int x, int y, int width, int height, bool origin_top_left) + + ...or with float values: + + sg_apply_scissor_rectf(float x, float y, float width, float height, bool origin_top_left) + + Both sg_apply_viewport() and sg_apply_scissor_rect() must be called + inside a rendering pass + + Note that sg_begin_default_pass() and sg_begin_pass() will reset both the + viewport and scissor rectangles to cover the entire framebuffer. + + --- to update (overwrite) the content of buffer and image resources, call: + + sg_update_buffer(sg_buffer buf, const sg_range* data) + sg_update_image(sg_image img, const sg_image_data* data) + + Buffers and images to be updated must have been created with + SG_USAGE_DYNAMIC or SG_USAGE_STREAM + + Only one update per frame is allowed for buffer and image resources when + using the sg_update_*() functions. The rationale is to have a simple + countermeasure to avoid the CPU scribbling over data the GPU is currently + using, or the CPU having to wait for the GPU + + Buffer and image updates can be partial, as long as a rendering + operation only references the valid (updated) data in the + buffer or image. + + --- to append a chunk of data to a buffer resource, call: + + int sg_append_buffer(sg_buffer buf, const sg_range* data) + + The difference to sg_update_buffer() is that sg_append_buffer() + can be called multiple times per frame to append new data to the + buffer piece by piece, optionally interleaved with draw calls referencing + the previously written data. + + sg_append_buffer() returns a byte offset to the start of the + written data, this offset can be assigned to + sg_bindings.vertex_buffer_offsets[n] or + sg_bindings.index_buffer_offset + + Code example: + + for (...) { + const void* data = ...; + const int num_bytes = ...; + int offset = sg_append_buffer(buf, &(sg_range) { .ptr=data, .size=num_bytes }); + bindings.vertex_buffer_offsets[0] = offset; + sg_apply_pipeline(pip); + sg_apply_bindings(&bindings); + sg_apply_uniforms(...); + sg_draw(...); + } + + A buffer to be used with sg_append_buffer() must have been created + with SG_USAGE_DYNAMIC or SG_USAGE_STREAM. + + If the application appends more data to the buffer then fits into + the buffer, the buffer will go into the "overflow" state for the + rest of the frame. + + Any draw calls attempting to render an overflown buffer will be + silently dropped (in debug mode this will also result in a + validation error). + + You can also check manually if a buffer is in overflow-state by calling + + bool sg_query_buffer_overflow(sg_buffer buf) + + NOTE: Due to restrictions in underlying 3D-APIs, appended chunks of + data will be 4-byte aligned in the destination buffer. This means + that there will be gaps in index buffers containing 16-bit indices + when the number of indices in a call to sg_append_buffer() is + odd. This isn't a problem when each call to sg_append_buffer() + is associated with one draw call, but will be problematic when + a single indexed draw call spans several appended chunks of indices. + + --- to check at runtime for optional features, limits and pixelformat support, + call: + + sg_features sg_query_features() + sg_limits sg_query_limits() + sg_pixelformat_info sg_query_pixelformat(sg_pixel_format fmt) + + --- if you need to call into the underlying 3D-API directly, you must call: + + sg_reset_state_cache() + + ...before calling sokol_gfx functions again + + --- you can inspect the original sg_desc structure handed to sg_setup() + by calling sg_query_desc(). This will return an sg_desc struct with + the default values patched in instead of any zero-initialized values + + --- you can inspect various internal resource attributes via: + + sg_buffer_info sg_query_buffer_info(sg_buffer buf) + sg_image_info sg_query_image_info(sg_image img) + sg_shader_info sg_query_shader_info(sg_shader shd) + sg_pipeline_info sg_query_pipeline_info(sg_pipeline pip) + sg_pass_info sg_query_pass_info(sg_pass pass) + + ...please note that the returned info-structs are tied quite closely + to sokol_gfx.h internals, and may change more often than other + public API functions and structs. + + --- you can ask at runtime what backend sokol_gfx.h has been compiled + for, or whether the GLES3 backend had to fall back to GLES2 with: + + sg_backend sg_query_backend(void) + + --- you can query the default resource creation parameters through the functions + + sg_buffer_desc sg_query_buffer_defaults(const sg_buffer_desc* desc) + sg_image_desc sg_query_image_defaults(const sg_image_desc* desc) + sg_shader_desc sg_query_shader_defaults(const sg_shader_desc* desc) + sg_pipeline_desc sg_query_pipeline_defaults(const sg_pipeline_desc* desc) + sg_pass_desc sg_query_pass_defaults(const sg_pass_desc* desc) + + These functions take a pointer to a desc structure which may contain + zero-initialized items for default values. These zero-init values + will be replaced with their concrete values in the returned desc + struct. + + ON INITIALIZATION: + ================== + When calling sg_setup(), a pointer to an sg_desc struct must be provided + which contains initialization options. These options provide two types + of information to sokol-gfx: + + (1) upper bounds and limits needed to allocate various internal + data structures: + - the max number of resources of each type that can + be alive at the same time, this is used for allocating + internal pools + - the max overall size of uniform data that can be + updated per frame, including a worst-case alignment + per uniform update (this worst-case alignment is 256 bytes) + - the max size of all dynamic resource updates (sg_update_buffer, + sg_append_buffer and sg_update_image) per frame + - the max number of entries in the texture sampler cache + (how many unique texture sampler can exist at the same time) + Not all of those limit values are used by all backends, but it is + good practice to provide them none-the-less. + + (2) 3D-API "context information" (sometimes also called "bindings"): + sokol_gfx.h doesn't create or initialize 3D API objects which are + closely related to the presentation layer (this includes the "rendering + device", the swapchain, and any objects which depend on the + swapchain). These API objects (or callback functions to obtain + them, if those objects might change between frames), must + be provided in a nested sg_context_desc struct inside the + sg_desc struct. If sokol_gfx.h is used together with + sokol_app.h, have a look at the sokol_glue.h header which provides + a convenience function to get a sg_context_desc struct filled out + with context information provided by sokol_app.h + + See the documention block of the sg_desc struct below for more information. + + + UNIFORM DATA LAYOUT: + ==================== + NOTE: if you use the sokol-shdc shader compiler tool, you don't need to worry + about the following details. + + The data that's passed into the sg_apply_uniforms() function must adhere to + specific layout rules so that the GPU shader finds the uniform block + items at the right offset. + + For the D3D11 and Metal backends, sokol-gfx only cares about the size of uniform + blocks, but not about the internal layout. The data will just be copied into + a uniform/constant buffer in a single operation and it's up you to arrange the + CPU-side layout so that it matches the GPU side layout. This also means that with + the D3D11 and Metal backends you are not limited to a 'cross-platform' subset + of uniform variable types. + + If you ever only use one of the D3D11, Metal *or* WebGPU backend, you can stop reading here. + + For the GL backends, the internal layout of uniform blocks matters though, + and you are limited to a small number of uniform variable types. This is + because sokol-gfx must be able to locate the uniform block members in order + to upload them to the GPU with glUniformXXX() calls. + + To describe the uniform block layout to sokol-gfx, the following information + must be passed to the sg_make_shader() call in the sg_shader_desc struct: + + - a hint about the used packing rule (either SG_UNIFORMLAYOUT_NATIVE or + SG_UNIFORMLAYOUT_STD140) + - a list of the uniform block members types in the correct order they + appear on the CPU side + + For example if the GLSL shader has the following uniform declarations: + + uniform mat4 mvp; + uniform vec2 offset0; + uniform vec2 offset1; + uniform vec2 offset2; + + ...and on the CPU side, there's a similar C struct: + + typedef struct { + float mvp[16]; + float offset0[2]; + float offset1[2]; + float offset2[2]; + } params_t; + + ...the uniform block description in the sg_shader_desc must look like this: + + sg_shader_desc desc = { + .vs.uniform_blocks[0] = { + .size = sizeof(params_t), + .layout = SG_UNIFORMLAYOUT_NATIVE, // this is the default and can be omitted + .uniforms = { + // order must be the same as in 'params_t': + [0] = { .name = "mvp", .type = SG_UNIFORMTYPE_MAT4 }, + [1] = { .name = "offset0", .type = SG_UNIFORMTYPE_VEC2 }, + [2] = { .name = "offset1", .type = SG_UNIFORMTYPE_VEC2 }, + [3] = { .name = "offset2", .type = SG_UNIFORMTYPE_VEC2 }, + } + } + }; + + With this information sokol-gfx can now compute the correct offsets of the data items + within the uniform block struct. + + The SG_UNIFORMLAYOUT_NATIVE packing rule works fine if only the GL backends are used, + but for proper D3D11/Metal/GL a subset of the std140 layout must be used which is + described in the next section: + + + CROSS-BACKEND COMMON UNIFORM DATA LAYOUT + ======================================== + For cross-platform / cross-3D-backend code it is important that the same uniform block + layout on the CPU side can be used for all sokol-gfx backends. To achieve this, + a common subset of the std140 layout must be used: + + - The uniform block layout hint in sg_shader_desc must be explicitely set to + SG_UNIFORMLAYOUT_STD140. + - Only the following GLSL uniform types can be used (with their associated sokol-gfx enums): + - float => SG_UNIFORMTYPE_FLOAT + - vec2 => SG_UNIFORMTYPE_FLOAT2 + - vec3 => SG_UNIFORMTYPE_FLOAT3 + - vec4 => SG_UNIFORMTYPE_FLOAT4 + - int => SG_UNIFORMTYPE_INT + - ivec2 => SG_UNIFORMTYPE_INT2 + - ivec3 => SG_UNIFORMTYPE_INT3 + - ivec4 => SG_UNIFORMTYPE_INT4 + - mat4 => SG_UNIFORMTYPE_MAT4 + - Alignment for those types must be as follows (in bytes): + - float => 4 + - vec2 => 8 + - vec3 => 16 + - vec4 => 16 + - int => 4 + - ivec2 => 8 + - ivec3 => 16 + - ivec4 => 16 + - mat4 => 16 + - Arrays are only allowed for the following types: vec4, int4, mat4. + + Note that the HLSL cbuffer layout rules are slightly different from the + std140 layout rules, this means that the cbuffer declarations in HLSL code + must be tweaked so that the layout is compatible with std140. + + The by far easiest way to tacke the common uniform block layout problem is + to use the sokol-shdc shader cross-compiler tool! + + + BACKEND-SPECIFIC TOPICS: + ======================== + --- The GL backends need to know about the internal structure of uniform + blocks, and the texture sampler-name and -type. The uniform layout details + are described in the UNIFORM DATA LAYOUT section above. + + // uniform block structure and texture image definition in sg_shader_desc: + sg_shader_desc desc = { + // uniform block description (size and internal structure) + .vs.uniform_blocks[0] = { + ... + }, + // one texture on the fragment-shader-stage, GLES2/WebGL needs name and image type + .fs.images[0] = { .name="tex", .type=SG_IMAGETYPE_ARRAY } + ... + }; + + --- the Metal and D3D11 backends only need to know the size of uniform blocks, + not their internal member structure, and they only need to know + the type of a texture sampler, not its name: + + sg_shader_desc desc = { + .vs.uniform_blocks[0].size = sizeof(params_t), + .fs.images[0].type = SG_IMAGETYPE_ARRAY, + ... + }; + + --- when creating a shader object, GLES2/WebGL need to know the vertex + attribute names as used in the vertex shader: + + sg_shader_desc desc = { + .attrs = { + [0] = { .name="position" }, + [1] = { .name="color1" } + } + }; + + The vertex attribute names provided when creating a shader will be + used later in sg_create_pipeline() for matching the vertex layout + to vertex shader inputs. + + --- on D3D11 you need to provide a semantic name and semantic index in the + shader description struct instead (see the D3D11 documentation on + D3D11_INPUT_ELEMENT_DESC for details): + + sg_shader_desc desc = { + .attrs = { + [0] = { .sem_name="POSITION", .sem_index=0 } + [1] = { .sem_name="COLOR", .sem_index=1 } + } + }; + + The provided semantic information will be used later in sg_create_pipeline() + to match the vertex layout to vertex shader inputs. + + --- on D3D11, and when passing HLSL source code (instead of byte code) to shader + creation, you can optionally define the shader model targets on the vertex + stage: + + sg_shader_Desc desc = { + .vs = { + ... + .d3d11_target = "vs_5_0" + }, + .fs = { + ... + .d3d11_target = "ps_5_0" + } + }; + + The default targets are "ps_4_0" and "fs_4_0". Note that those target names + are only used when compiling shaders from source. They are ignored when + creating a shader from bytecode. + + --- on Metal, GL 3.3 or GLES3/WebGL2, you don't need to provide an attribute + name or semantic name, since vertex attributes can be bound by their slot index + (this is mandatory in Metal, and optional in GL): + + sg_pipeline_desc desc = { + .layout = { + .attrs = { + [0] = { .format=SG_VERTEXFORMAT_FLOAT3 }, + [1] = { .format=SG_VERTEXFORMAT_FLOAT4 } + } + } + }; + + WORKING WITH CONTEXTS + ===================== + sokol-gfx allows to switch between different rendering contexts and + associate resource objects with contexts. This is useful to + create GL applications that render into multiple windows. + + A rendering context keeps track of all resources created while + the context is active. When the context is destroyed, all resources + "belonging to the context" are destroyed as well. + + A default context will be created and activated implicitly in + sg_setup(), and destroyed in sg_shutdown(). So for a typical application + which *doesn't* use multiple contexts, nothing changes, and calling + the context functions isn't necessary. + + Three functions have been added to work with contexts: + + --- sg_context sg_setup_context(): + This must be called once after a GL context has been created and + made active. + + --- void sg_activate_context(sg_context ctx) + This must be called after making a different GL context active. + Apart from 3D-API-specific actions, the call to sg_activate_context() + will internally call sg_reset_state_cache(). + + --- void sg_discard_context(sg_context ctx) + This must be called right before a GL context is destroyed and + will destroy all resources associated with the context (that + have been created while the context was active) The GL context must be + active at the time sg_discard_context(sg_context ctx) is called. + + Also note that resources (buffers, images, shaders and pipelines) must + only be used or destroyed while the same GL context is active that + was also active while the resource was created (an exception is + resource sharing on GL, such resources can be used while + another context is active, but must still be destroyed under + the same context that was active during creation). + + For more information, check out the multiwindow-glfw sample: + + https://github.com/floooh/sokol-samples/blob/master/glfw/multiwindow-glfw.c + + TRACE HOOKS: + ============ + sokol_gfx.h optionally allows to install "trace hook" callbacks for + each public API functions. When a public API function is called, and + a trace hook callback has been installed for this function, the + callback will be invoked with the parameters and result of the function. + This is useful for things like debugging- and profiling-tools, or + keeping track of resource creation and destruction. + + To use the trace hook feature: + + --- Define SOKOL_TRACE_HOOKS before including the implementation. + + --- Setup an sg_trace_hooks structure with your callback function + pointers (keep all function pointers you're not interested + in zero-initialized), optionally set the user_data member + in the sg_trace_hooks struct. + + --- Install the trace hooks by calling sg_install_trace_hooks(), + the return value of this function is another sg_trace_hooks + struct which contains the previously set of trace hooks. + You should keep this struct around, and call those previous + functions pointers from your own trace callbacks for proper + chaining. + + As an example of how trace hooks are used, have a look at the + imgui/sokol_gfx_imgui.h header which implements a realtime + debugging UI for sokol_gfx.h on top of Dear ImGui. + + A NOTE ON PORTABLE PACKED VERTEX FORMATS: + ========================================= + There are two things to consider when using packed + vertex formats like UBYTE4, SHORT2, etc which need to work + across all backends: + + - D3D11 can only convert *normalized* vertex formats to + floating point during vertex fetch, normalized formats + have a trailing 'N', and are "normalized" to a range + -1.0..+1.0 (for the signed formats) or 0.0..1.0 (for the + unsigned formats): + + - SG_VERTEXFORMAT_BYTE4N + - SG_VERTEXFORMAT_UBYTE4N + - SG_VERTEXFORMAT_SHORT2N + - SG_VERTEXFORMAT_USHORT2N + - SG_VERTEXFORMAT_SHORT4N + - SG_VERTEXFORMAT_USHORT4N + + D3D11 will not convert *non-normalized* vertex formats to floating point + vertex shader inputs, those can only be uses with the *ivecn* vertex shader + input types when D3D11 is used as backend (GL and Metal can use both formats) + + - SG_VERTEXFORMAT_BYTE4, + - SG_VERTEXFORMAT_UBYTE4 + - SG_VERTEXFORMAT_SHORT2 + - SG_VERTEXFORMAT_SHORT4 + + - WebGL/GLES2 cannot use integer vertex shader inputs (int or ivecn) + + - SG_VERTEXFORMAT_UINT10_N2 is not supported on WebGL/GLES2 + + So for a vertex input layout which works on all platforms, only use the following + vertex formats, and if needed "expand" the normalized vertex shader + inputs in the vertex shader by multiplying with 127.0, 255.0, 32767.0 or + 65535.0: + + - SG_VERTEXFORMAT_FLOAT, + - SG_VERTEXFORMAT_FLOAT2, + - SG_VERTEXFORMAT_FLOAT3, + - SG_VERTEXFORMAT_FLOAT4, + - SG_VERTEXFORMAT_BYTE4N, + - SG_VERTEXFORMAT_UBYTE4N, + - SG_VERTEXFORMAT_SHORT2N, + - SG_VERTEXFORMAT_USHORT2N + - SG_VERTEXFORMAT_SHORT4N, + - SG_VERTEXFORMAT_USHORT4N + + TODO: + ==== + - talk about asynchronous resource creation + + zlib/libpng license + + Copyright (c) 2018 Andre Weissflog + + 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 SOKOL_GFX_INCLUDED (1) +#include <stddef.h> // size_t +#include <stdint.h> +#include <stdbool.h> + +#if defined(SOKOL_API_DECL) && !defined(SOKOL_GFX_API_DECL) +#define SOKOL_GFX_API_DECL SOKOL_API_DECL +#endif +#ifndef SOKOL_GFX_API_DECL +#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_GFX_IMPL) +#define SOKOL_GFX_API_DECL __declspec(dllexport) +#elif defined(_WIN32) && defined(SOKOL_DLL) +#define SOKOL_GFX_API_DECL __declspec(dllimport) +#else +#define SOKOL_GFX_API_DECL extern +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /* + Resource id typedefs: + + sg_buffer: vertex- and index-buffers + sg_image: textures and render targets + sg_shader: vertex- and fragment-shaders, uniform blocks + sg_pipeline: associated shader and vertex-layouts, and render states + sg_pass: a bundle of render targets and actions on them + sg_context: a 'context handle' for switching between 3D-API contexts + + Instead of pointers, resource creation functions return a 32-bit + number which uniquely identifies the resource object. + + The 32-bit resource id is split into a 16-bit pool index in the lower bits, + and a 16-bit 'unique counter' in the upper bits. The index allows fast + pool lookups, and combined with the unique-mask it allows to detect + 'dangling accesses' (trying to use an object which no longer exists, and + its pool slot has been reused for a new object) + + The resource ids are wrapped into a struct so that the compiler + can complain when the wrong resource type is used. + */ + typedef struct sg_buffer { uint32_t id; } sg_buffer; + typedef struct sg_image { uint32_t id; } sg_image; + typedef struct sg_shader { uint32_t id; } sg_shader; + typedef struct sg_pipeline { uint32_t id; } sg_pipeline; + typedef struct sg_pass { uint32_t id; } sg_pass; + typedef struct sg_context { uint32_t id; } sg_context; + + /* + sg_range is a pointer-size-pair struct used to pass memory blobs into + sokol-gfx. When initialized from a value type (array or struct), you can + use the SG_RANGE() macro to build an sg_range struct. For functions which + take either a sg_range pointer, or a (C++) sg_range reference, use the + SG_RANGE_REF macro as a solution which compiles both in C and C++. + */ + typedef struct sg_range { + const void* ptr; + size_t size; + } sg_range; + + // disabling this for every includer isn't great, but the warnings are also quite pointless +#if defined(_MSC_VER) +#pragma warning(disable:4221) /* /W4 only: nonstandard extension used: 'x': cannot be initialized using address of automatic variable 'y' */ +#pragma warning(disable:4204) /* VS2015: nonstandard extension used: non-constant aggregate initializer */ +#endif +#if defined(__cplusplus) +#define SG_RANGE(x) sg_range{ &x, sizeof(x) } +#define SG_RANGE_REF(x) sg_range{ &x, sizeof(x) } +#else +#define SG_RANGE(x) (sg_range){ &x, sizeof(x) } +#define SG_RANGE_REF(x) &(sg_range){ &x, sizeof(x) } +#endif + + // various compile-time constants + enum { + SG_INVALID_ID = 0, + SG_NUM_SHADER_STAGES = 2, + SG_NUM_INFLIGHT_FRAMES = 2, + SG_MAX_COLOR_ATTACHMENTS = 4, + SG_MAX_SHADERSTAGE_BUFFERS = 8, + SG_MAX_SHADERSTAGE_IMAGES = 12, + SG_MAX_SHADERSTAGE_UBS = 4, + SG_MAX_UB_MEMBERS = 16, + SG_MAX_VERTEX_ATTRIBUTES = 16, /* NOTE: actual max vertex attrs can be less on GLES2, see sg_limits! */ + SG_MAX_MIPMAPS = 16, + SG_MAX_TEXTUREARRAY_LAYERS = 128 + }; + + /* + sg_color + + An RGBA color value. + */ + typedef struct sg_color { float r, g, b, a; } sg_color; + + /* + sg_backend + + The active 3D-API backend, use the function sg_query_backend() + to get the currently active backend. + + NOTE that SG_BACKEND_GLES2 will be returned if sokol-gfx was + compiled with SOKOL_GLES3, but the runtime platform doesn't support + GLES3/WebGL2 and sokol-gfx had to fallback to GLES2/WebGL. + */ + typedef enum sg_backend { + SG_BACKEND_GLCORE33, + SG_BACKEND_GLES2, + SG_BACKEND_GLES3, + SG_BACKEND_D3D11, + SG_BACKEND_METAL_IOS, + SG_BACKEND_METAL_MACOS, + SG_BACKEND_METAL_SIMULATOR, + SG_BACKEND_WGPU, + SG_BACKEND_DUMMY, + } sg_backend; + + /* + sg_pixel_format + + sokol_gfx.h basically uses the same pixel formats as WebGPU, since these + are supported on most newer GPUs. GLES2 and WebGL only supports a much + smaller subset of actually available pixel formats. Call + sg_query_pixelformat() to check at runtime if a pixel format supports the + desired features. + + A pixelformat name consist of three parts: + + - components (R, RG, RGB or RGBA) + - bit width per component (8, 16 or 32) + - component data type: + - unsigned normalized (no postfix) + - signed normalized (SN postfix) + - unsigned integer (UI postfix) + - signed integer (SI postfix) + - float (F postfix) + + Not all pixel formats can be used for everything, call sg_query_pixelformat() + to inspect the capabilities of a given pixelformat. The function returns + an sg_pixelformat_info struct with the following bool members: + + - sample: the pixelformat can be sampled as texture at least with + nearest filtering + - filter: the pixelformat can be samples as texture with linear + filtering + - render: the pixelformat can be used for render targets + - blend: blending is supported when using the pixelformat for + render targets + - msaa: multisample-antialiasing is supported when using the + pixelformat for render targets + - depth: the pixelformat can be used for depth-stencil attachments + + When targeting GLES2/WebGL, the only safe formats to use + as texture are SG_PIXELFORMAT_R8 and SG_PIXELFORMAT_RGBA8. For rendering + in GLES2/WebGL, only SG_PIXELFORMAT_RGBA8 is safe. All other formats + must be checked via sg_query_pixelformats(). + + The default pixel format for texture images is SG_PIXELFORMAT_RGBA8. + + The default pixel format for render target images is platform-dependent: + - for Metal and D3D11 it is SG_PIXELFORMAT_BGRA8 + - for GL backends it is SG_PIXELFORMAT_RGBA8 + + This is mainly because of the default framebuffer which is setup outside + of sokol_gfx.h. On some backends, using BGRA for the default frame buffer + allows more efficient frame flips. For your own offscreen-render-targets, + use whatever renderable pixel format is convenient for you. + */ + typedef enum sg_pixel_format { + _SG_PIXELFORMAT_DEFAULT, /* value 0 reserved for default-init */ + SG_PIXELFORMAT_NONE, + + SG_PIXELFORMAT_R8, + SG_PIXELFORMAT_R8SN, + SG_PIXELFORMAT_R8UI, + SG_PIXELFORMAT_R8SI, + + SG_PIXELFORMAT_R16, + SG_PIXELFORMAT_R16SN, + SG_PIXELFORMAT_R16UI, + SG_PIXELFORMAT_R16SI, + SG_PIXELFORMAT_R16F, + SG_PIXELFORMAT_RG8, + SG_PIXELFORMAT_RG8SN, + SG_PIXELFORMAT_RG8UI, + SG_PIXELFORMAT_RG8SI, + + SG_PIXELFORMAT_R32UI, + SG_PIXELFORMAT_R32SI, + SG_PIXELFORMAT_R32F, + SG_PIXELFORMAT_RG16, + SG_PIXELFORMAT_RG16SN, + SG_PIXELFORMAT_RG16UI, + SG_PIXELFORMAT_RG16SI, + SG_PIXELFORMAT_RG16F, + SG_PIXELFORMAT_RGBA8, + SG_PIXELFORMAT_RGBA8SN, + SG_PIXELFORMAT_RGBA8UI, + SG_PIXELFORMAT_RGBA8SI, + SG_PIXELFORMAT_BGRA8, + SG_PIXELFORMAT_RGB10A2, + SG_PIXELFORMAT_RG11B10F, + + SG_PIXELFORMAT_RG32UI, + SG_PIXELFORMAT_RG32SI, + SG_PIXELFORMAT_RG32F, + SG_PIXELFORMAT_RGBA16, + SG_PIXELFORMAT_RGBA16SN, + SG_PIXELFORMAT_RGBA16UI, + SG_PIXELFORMAT_RGBA16SI, + SG_PIXELFORMAT_RGBA16F, + + SG_PIXELFORMAT_RGBA32UI, + SG_PIXELFORMAT_RGBA32SI, + SG_PIXELFORMAT_RGBA32F, + + SG_PIXELFORMAT_DEPTH, + SG_PIXELFORMAT_DEPTH_STENCIL, + + SG_PIXELFORMAT_BC1_RGBA, + SG_PIXELFORMAT_BC2_RGBA, + SG_PIXELFORMAT_BC3_RGBA, + SG_PIXELFORMAT_BC4_R, + SG_PIXELFORMAT_BC4_RSN, + SG_PIXELFORMAT_BC5_RG, + SG_PIXELFORMAT_BC5_RGSN, + SG_PIXELFORMAT_BC6H_RGBF, + SG_PIXELFORMAT_BC6H_RGBUF, + SG_PIXELFORMAT_BC7_RGBA, + SG_PIXELFORMAT_PVRTC_RGB_2BPP, + SG_PIXELFORMAT_PVRTC_RGB_4BPP, + SG_PIXELFORMAT_PVRTC_RGBA_2BPP, + SG_PIXELFORMAT_PVRTC_RGBA_4BPP, + SG_PIXELFORMAT_ETC2_RGB8, + SG_PIXELFORMAT_ETC2_RGB8A1, + SG_PIXELFORMAT_ETC2_RGBA8, + SG_PIXELFORMAT_ETC2_RG11, + SG_PIXELFORMAT_ETC2_RG11SN, + + _SG_PIXELFORMAT_NUM, + _SG_PIXELFORMAT_FORCE_U32 = 0x7FFFFFFF + } sg_pixel_format; + + /* + Runtime information about a pixel format, returned + by sg_query_pixelformat(). + */ + typedef struct sg_pixelformat_info { + bool sample; // pixel format can be sampled in shaders + bool filter; // pixel format can be sampled with filtering + bool render; // pixel format can be used as render target + bool blend; // alpha-blending is supported + bool msaa; // pixel format can be used as MSAA render target + bool depth; // pixel format is a depth format +#if defined(SOKOL_ZIG_BINDINGS) + uint32_t __pad[3]; +#endif + } sg_pixelformat_info; + + /* + Runtime information about available optional features, + returned by sg_query_features() + */ + typedef struct sg_features { + bool instancing; // hardware instancing supported + bool origin_top_left; // framebuffer and texture origin is in top left corner + bool multiple_render_targets; // offscreen render passes can have multiple render targets attached + bool msaa_render_targets; // offscreen render passes support MSAA antialiasing + bool imagetype_3d; // creation of SG_IMAGETYPE_3D images is supported + bool imagetype_array; // creation of SG_IMAGETYPE_ARRAY images is supported + bool image_clamp_to_border; // border color and clamp-to-border UV-wrap mode is supported + bool mrt_independent_blend_state; // multiple-render-target rendering can use per-render-target blend state + bool mrt_independent_write_mask; // multiple-render-target rendering can use per-render-target color write masks +#if defined(SOKOL_ZIG_BINDINGS) + uint32_t __pad[3]; +#endif + } sg_features; + + /* + Runtime information about resource limits, returned by sg_query_limit() + */ + typedef struct sg_limits { + int max_image_size_2d; // max width/height of SG_IMAGETYPE_2D images + int max_image_size_cube; // max width/height of SG_IMAGETYPE_CUBE images + int max_image_size_3d; // max width/height/depth of SG_IMAGETYPE_3D images + int max_image_size_array; // max width/height of SG_IMAGETYPE_ARRAY images + int max_image_array_layers; // max number of layers in SG_IMAGETYPE_ARRAY images + int max_vertex_attrs; // <= SG_MAX_VERTEX_ATTRIBUTES or less (on some GLES2 impls) + int gl_max_vertex_uniform_vectors; // <= GL_MAX_VERTEX_UNIFORM_VECTORS (only on GL backends) + } sg_limits; + + /* + sg_resource_state + + The current state of a resource in its resource pool. + Resources start in the INITIAL state, which means the + pool slot is unoccupied and can be allocated. When a resource is + created, first an id is allocated, and the resource pool slot + is set to state ALLOC. After allocation, the resource is + initialized, which may result in the VALID or FAILED state. The + reason why allocation and initialization are separate is because + some resource types (e.g. buffers and images) might be asynchronously + initialized by the user application. If a resource which is not + in the VALID state is attempted to be used for rendering, rendering + operations will silently be dropped. + + The special INVALID state is returned in sg_query_xxx_state() if no + resource object exists for the provided resource id. + */ + typedef enum sg_resource_state { + SG_RESOURCESTATE_INITIAL, + SG_RESOURCESTATE_ALLOC, + SG_RESOURCESTATE_VALID, + SG_RESOURCESTATE_FAILED, + SG_RESOURCESTATE_INVALID, + _SG_RESOURCESTATE_FORCE_U32 = 0x7FFFFFFF + } sg_resource_state; + + /* + sg_usage + + A resource usage hint describing the update strategy of + buffers and images. This is used in the sg_buffer_desc.usage + and sg_image_desc.usage members when creating buffers + and images: + + SG_USAGE_IMMUTABLE: the resource will never be updated with + new data, instead the content of the + resource must be provided on creation + SG_USAGE_DYNAMIC: the resource will be updated infrequently + with new data (this could range from "once + after creation", to "quite often but not + every frame") + SG_USAGE_STREAM: the resource will be updated each frame + with new content + + The rendering backends use this hint to prevent that the + CPU needs to wait for the GPU when attempting to update + a resource that might be currently accessed by the GPU. + + Resource content is updated with the functions sg_update_buffer() or + sg_append_buffer() for buffer objects, and sg_update_image() for image + objects. For the sg_update_*() functions, only one update is allowed per + frame and resource object, while sg_append_buffer() can be called + multiple times per frame on the same buffer. The application must update + all data required for rendering (this means that the update data can be + smaller than the resource size, if only a part of the overall resource + size is used for rendering, you only need to make sure that the data that + *is* used is valid). + + The default usage is SG_USAGE_IMMUTABLE. + */ + typedef enum sg_usage { + _SG_USAGE_DEFAULT, /* value 0 reserved for default-init */ + SG_USAGE_IMMUTABLE, + SG_USAGE_DYNAMIC, + SG_USAGE_STREAM, + _SG_USAGE_NUM, + _SG_USAGE_FORCE_U32 = 0x7FFFFFFF + } sg_usage; + + /* + sg_buffer_type + + This indicates whether a buffer contains vertex- or index-data, + used in the sg_buffer_desc.type member when creating a buffer. + + The default value is SG_BUFFERTYPE_VERTEXBUFFER. + */ + typedef enum sg_buffer_type { + _SG_BUFFERTYPE_DEFAULT, /* value 0 reserved for default-init */ + SG_BUFFERTYPE_VERTEXBUFFER, + SG_BUFFERTYPE_INDEXBUFFER, + _SG_BUFFERTYPE_NUM, + _SG_BUFFERTYPE_FORCE_U32 = 0x7FFFFFFF + } sg_buffer_type; + + /* + sg_index_type + + Indicates whether indexed rendering (fetching vertex-indices from an + index buffer) is used, and if yes, the index data type (16- or 32-bits). + This is used in the sg_pipeline_desc.index_type member when creating a + pipeline object. + + The default index type is SG_INDEXTYPE_NONE. + */ + typedef enum sg_index_type { + _SG_INDEXTYPE_DEFAULT, /* value 0 reserved for default-init */ + SG_INDEXTYPE_NONE, + SG_INDEXTYPE_UINT16, + SG_INDEXTYPE_UINT32, + _SG_INDEXTYPE_NUM, + _SG_INDEXTYPE_FORCE_U32 = 0x7FFFFFFF + } sg_index_type; + + /* + sg_image_type + + Indicates the basic type of an image object (2D-texture, cubemap, + 3D-texture or 2D-array-texture). 3D- and array-textures are not supported + on the GLES2/WebGL backend (use sg_query_features().imagetype_3d and + sg_query_features().imagetype_array to check for support). The image type + is used in the sg_image_desc.type member when creating an image, and + in sg_shader_image_desc when describing a shader's texture sampler binding. + + The default image type when creating an image is SG_IMAGETYPE_2D. + */ + typedef enum sg_image_type { + _SG_IMAGETYPE_DEFAULT, /* value 0 reserved for default-init */ + SG_IMAGETYPE_2D, + SG_IMAGETYPE_CUBE, + SG_IMAGETYPE_3D, + SG_IMAGETYPE_ARRAY, + _SG_IMAGETYPE_NUM, + _SG_IMAGETYPE_FORCE_U32 = 0x7FFFFFFF + } sg_image_type; + + /* + sg_sampler_type + + Indicates the basic data type of a shader's texture sampler which + can be float , unsigned integer or signed integer. The sampler + type is used in the sg_shader_image_desc to describe the + sampler type of a shader's texture sampler binding. + + The default sampler type is SG_SAMPLERTYPE_FLOAT. + */ + typedef enum sg_sampler_type { + _SG_SAMPLERTYPE_DEFAULT, /* value 0 reserved for default-init */ + SG_SAMPLERTYPE_FLOAT, + SG_SAMPLERTYPE_SINT, + SG_SAMPLERTYPE_UINT, + } sg_sampler_type; + + /* + sg_cube_face + + The cubemap faces. Use these as indices in the sg_image_desc.content + array. + */ + typedef enum sg_cube_face { + SG_CUBEFACE_POS_X, + SG_CUBEFACE_NEG_X, + SG_CUBEFACE_POS_Y, + SG_CUBEFACE_NEG_Y, + SG_CUBEFACE_POS_Z, + SG_CUBEFACE_NEG_Z, + SG_CUBEFACE_NUM, + _SG_CUBEFACE_FORCE_U32 = 0x7FFFFFFF + } sg_cube_face; + + /* + sg_shader_stage + + There are 2 shader stages: vertex- and fragment-shader-stage. + Each shader stage consists of: + + - one slot for a shader function (provided as source- or byte-code) + - SG_MAX_SHADERSTAGE_UBS slots for uniform blocks + - SG_MAX_SHADERSTAGE_IMAGES slots for images used as textures by + the shader function + */ + typedef enum sg_shader_stage { + SG_SHADERSTAGE_VS, + SG_SHADERSTAGE_FS, + _SG_SHADERSTAGE_FORCE_U32 = 0x7FFFFFFF + } sg_shader_stage; + + /* + sg_primitive_type + + This is the common subset of 3D primitive types supported across all 3D + APIs. This is used in the sg_pipeline_desc.primitive_type member when + creating a pipeline object. + + The default primitive type is SG_PRIMITIVETYPE_TRIANGLES. + */ + typedef enum sg_primitive_type { + _SG_PRIMITIVETYPE_DEFAULT, /* value 0 reserved for default-init */ + SG_PRIMITIVETYPE_POINTS, + SG_PRIMITIVETYPE_LINES, + SG_PRIMITIVETYPE_LINE_STRIP, + SG_PRIMITIVETYPE_TRIANGLES, + SG_PRIMITIVETYPE_TRIANGLE_STRIP, + _SG_PRIMITIVETYPE_NUM, + _SG_PRIMITIVETYPE_FORCE_U32 = 0x7FFFFFFF + } sg_primitive_type; + + /* + sg_filter + + The filtering mode when sampling a texture image. This is + used in the sg_image_desc.min_filter and sg_image_desc.mag_filter + members when creating an image object. + + The default filter mode is SG_FILTER_NEAREST. + */ + typedef enum sg_filter { + _SG_FILTER_DEFAULT, /* value 0 reserved for default-init */ + SG_FILTER_NEAREST, + SG_FILTER_LINEAR, + SG_FILTER_NEAREST_MIPMAP_NEAREST, + SG_FILTER_NEAREST_MIPMAP_LINEAR, + SG_FILTER_LINEAR_MIPMAP_NEAREST, + SG_FILTER_LINEAR_MIPMAP_LINEAR, + _SG_FILTER_NUM, + _SG_FILTER_FORCE_U32 = 0x7FFFFFFF + } sg_filter; + + /* + sg_wrap + + The texture coordinates wrapping mode when sampling a texture + image. This is used in the sg_image_desc.wrap_u, .wrap_v + and .wrap_w members when creating an image. + + The default wrap mode is SG_WRAP_REPEAT. + + NOTE: SG_WRAP_CLAMP_TO_BORDER is not supported on all backends + and platforms. To check for support, call sg_query_features() + and check the "clamp_to_border" boolean in the returned + sg_features struct. + + Platforms which don't support SG_WRAP_CLAMP_TO_BORDER will silently fall back + to SG_WRAP_CLAMP_TO_EDGE without a validation error. + + Platforms which support clamp-to-border are: + + - all desktop GL platforms + - Metal on macOS + - D3D11 + + Platforms which do not support clamp-to-border: + + - GLES2/3 and WebGL/WebGL2 + - Metal on iOS + */ + typedef enum sg_wrap { + _SG_WRAP_DEFAULT, /* value 0 reserved for default-init */ + SG_WRAP_REPEAT, + SG_WRAP_CLAMP_TO_EDGE, + SG_WRAP_CLAMP_TO_BORDER, + SG_WRAP_MIRRORED_REPEAT, + _SG_WRAP_NUM, + _SG_WRAP_FORCE_U32 = 0x7FFFFFFF + } sg_wrap; + + /* + sg_border_color + + The border color to use when sampling a texture, and the UV wrap + mode is SG_WRAP_CLAMP_TO_BORDER. + + The default border color is SG_BORDERCOLOR_OPAQUE_BLACK + */ + typedef enum sg_border_color { + _SG_BORDERCOLOR_DEFAULT, /* value 0 reserved for default-init */ + SG_BORDERCOLOR_TRANSPARENT_BLACK, + SG_BORDERCOLOR_OPAQUE_BLACK, + SG_BORDERCOLOR_OPAQUE_WHITE, + _SG_BORDERCOLOR_NUM, + _SG_BORDERCOLOR_FORCE_U32 = 0x7FFFFFFF + } sg_border_color; + + /* + sg_vertex_format + + The data type of a vertex component. This is used to describe + the layout of vertex data when creating a pipeline object. + */ + typedef enum sg_vertex_format { + SG_VERTEXFORMAT_INVALID, + SG_VERTEXFORMAT_FLOAT, + SG_VERTEXFORMAT_FLOAT2, + SG_VERTEXFORMAT_FLOAT3, + SG_VERTEXFORMAT_FLOAT4, + SG_VERTEXFORMAT_BYTE4, + SG_VERTEXFORMAT_BYTE4N, + SG_VERTEXFORMAT_UBYTE4, + SG_VERTEXFORMAT_UBYTE4N, + SG_VERTEXFORMAT_SHORT2, + SG_VERTEXFORMAT_SHORT2N, + SG_VERTEXFORMAT_USHORT2N, + SG_VERTEXFORMAT_SHORT4, + SG_VERTEXFORMAT_SHORT4N, + SG_VERTEXFORMAT_USHORT4N, + SG_VERTEXFORMAT_UINT10_N2, + _SG_VERTEXFORMAT_NUM, + _SG_VERTEXFORMAT_FORCE_U32 = 0x7FFFFFFF + } sg_vertex_format; + + /* + sg_vertex_step + + Defines whether the input pointer of a vertex input stream is advanced + 'per vertex' or 'per instance'. The default step-func is + SG_VERTEXSTEP_PER_VERTEX. SG_VERTEXSTEP_PER_INSTANCE is used with + instanced-rendering. + + The vertex-step is part of the vertex-layout definition + when creating pipeline objects. + */ + typedef enum sg_vertex_step { + _SG_VERTEXSTEP_DEFAULT, /* value 0 reserved for default-init */ + SG_VERTEXSTEP_PER_VERTEX, + SG_VERTEXSTEP_PER_INSTANCE, + _SG_VERTEXSTEP_NUM, + _SG_VERTEXSTEP_FORCE_U32 = 0x7FFFFFFF + } sg_vertex_step; + + /* + sg_uniform_type + + The data type of a uniform block member. This is used to + describe the internal layout of uniform blocks when creating + a shader object. + */ + typedef enum sg_uniform_type { + SG_UNIFORMTYPE_INVALID, + SG_UNIFORMTYPE_FLOAT, + SG_UNIFORMTYPE_FLOAT2, + SG_UNIFORMTYPE_FLOAT3, + SG_UNIFORMTYPE_FLOAT4, + SG_UNIFORMTYPE_INT, + SG_UNIFORMTYPE_INT2, + SG_UNIFORMTYPE_INT3, + SG_UNIFORMTYPE_INT4, + SG_UNIFORMTYPE_MAT4, + _SG_UNIFORMTYPE_NUM, + _SG_UNIFORMTYPE_FORCE_U32 = 0x7FFFFFFF + } sg_uniform_type; + + /* + sg_uniform_layout + + A hint for the interior memory layout of uniform blocks. This is + only really relevant for the GL backend where the internal layout + of uniform blocks must be known to sokol-gfx. For all other backends the + internal memory layout of uniform blocks doesn't matter, sokol-gfx + will just pass uniform data as a single memory blob to the + 3D backend. + + SG_UNIFORMLAYOUT_NATIVE (default) + Native layout means that a 'backend-native' memory layout + is used. For the GL backend this means that uniforms + are packed tightly in memory (e.g. there are no padding + bytes). + + SG_UNIFORMLAYOUT_STD140 + The memory layout is a subset of std140. Arrays are only + allowed for the FLOAT4, INT4 and MAT4. Alignment is as + is as follows: + + FLOAT, INT: 4 byte alignment + FLOAT2, INT2: 8 byte alignment + FLOAT3, INT3: 16 byte alignment(!) + FLOAT4, INT4: 16 byte alignment + MAT4: 16 byte alignment + FLOAT4[], INT4[]: 16 byte alignment + + The overall size of the uniform block must be a multiple + of 16. + + For more information search for 'UNIFORM DATA LAYOUT' in the documentation block + at the start of the header. + */ + typedef enum sg_uniform_layout { + _SG_UNIFORMLAYOUT_DEFAULT, /* value 0 reserved for default-init */ + SG_UNIFORMLAYOUT_NATIVE, /* default: layout depends on currently active backend */ + SG_UNIFORMLAYOUT_STD140, /* std140: memory layout according to std140 */ + _SG_UNIFORMLAYOUT_NUM, + _SG_UNIFORMLAYOUT_FORCE_U32 = 0x7FFFFFFF + } sg_uniform_layout; + + /* + sg_cull_mode + + The face-culling mode, this is used in the + sg_pipeline_desc.cull_mode member when creating a + pipeline object. + + The default cull mode is SG_CULLMODE_NONE + */ + typedef enum sg_cull_mode { + _SG_CULLMODE_DEFAULT, /* value 0 reserved for default-init */ + SG_CULLMODE_NONE, + SG_CULLMODE_FRONT, + SG_CULLMODE_BACK, + _SG_CULLMODE_NUM, + _SG_CULLMODE_FORCE_U32 = 0x7FFFFFFF + } sg_cull_mode; + + /* + sg_face_winding + + The vertex-winding rule that determines a front-facing primitive. This + is used in the member sg_pipeline_desc.face_winding + when creating a pipeline object. + + The default winding is SG_FACEWINDING_CW (clockwise) + */ + typedef enum sg_face_winding { + _SG_FACEWINDING_DEFAULT, /* value 0 reserved for default-init */ + SG_FACEWINDING_CCW, + SG_FACEWINDING_CW, + _SG_FACEWINDING_NUM, + _SG_FACEWINDING_FORCE_U32 = 0x7FFFFFFF + } sg_face_winding; + + /* + sg_compare_func + + The compare-function for depth- and stencil-ref tests. + This is used when creating pipeline objects in the members: + + sg_pipeline_desc + .depth + .compare + .stencil + .front.compare + .back.compar + + The default compare func for depth- and stencil-tests is + SG_COMPAREFUNC_ALWAYS. + */ + typedef enum sg_compare_func { + _SG_COMPAREFUNC_DEFAULT, /* value 0 reserved for default-init */ + SG_COMPAREFUNC_NEVER, + SG_COMPAREFUNC_LESS, + SG_COMPAREFUNC_EQUAL, + SG_COMPAREFUNC_LESS_EQUAL, + SG_COMPAREFUNC_GREATER, + SG_COMPAREFUNC_NOT_EQUAL, + SG_COMPAREFUNC_GREATER_EQUAL, + SG_COMPAREFUNC_ALWAYS, + _SG_COMPAREFUNC_NUM, + _SG_COMPAREFUNC_FORCE_U32 = 0x7FFFFFFF + } sg_compare_func; + + /* + sg_stencil_op + + The operation performed on a currently stored stencil-value when a + comparison test passes or fails. This is used when creating a pipeline + object in the members: + + sg_pipeline_desc + .stencil + .front + .fail_op + .depth_fail_op + .pass_op + .back + .fail_op + .depth_fail_op + .pass_op + + The default value is SG_STENCILOP_KEEP. + */ + typedef enum sg_stencil_op { + _SG_STENCILOP_DEFAULT, /* value 0 reserved for default-init */ + SG_STENCILOP_KEEP, + SG_STENCILOP_ZERO, + SG_STENCILOP_REPLACE, + SG_STENCILOP_INCR_CLAMP, + SG_STENCILOP_DECR_CLAMP, + SG_STENCILOP_INVERT, + SG_STENCILOP_INCR_WRAP, + SG_STENCILOP_DECR_WRAP, + _SG_STENCILOP_NUM, + _SG_STENCILOP_FORCE_U32 = 0x7FFFFFFF + } sg_stencil_op; + + /* + sg_blend_factor + + The source and destination factors in blending operations. + This is used in the following members when creating a pipeline object: + + sg_pipeline_desc + .colors[i] + .blend + .src_factor_rgb + .dst_factor_rgb + .src_factor_alpha + .dst_factor_alpha + + The default value is SG_BLENDFACTOR_ONE for source + factors, and SG_BLENDFACTOR_ZERO for destination factors. + */ + typedef enum sg_blend_factor { + _SG_BLENDFACTOR_DEFAULT, /* value 0 reserved for default-init */ + SG_BLENDFACTOR_ZERO, + SG_BLENDFACTOR_ONE, + SG_BLENDFACTOR_SRC_COLOR, + SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR, + SG_BLENDFACTOR_SRC_ALPHA, + SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, + SG_BLENDFACTOR_DST_COLOR, + SG_BLENDFACTOR_ONE_MINUS_DST_COLOR, + SG_BLENDFACTOR_DST_ALPHA, + SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA, + SG_BLENDFACTOR_SRC_ALPHA_SATURATED, + SG_BLENDFACTOR_BLEND_COLOR, + SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR, + SG_BLENDFACTOR_BLEND_ALPHA, + SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA, + _SG_BLENDFACTOR_NUM, + _SG_BLENDFACTOR_FORCE_U32 = 0x7FFFFFFF + } sg_blend_factor; + + /* + sg_blend_op + + Describes how the source and destination values are combined in the + fragment blending operation. It is used in the following members when + creating a pipeline object: + + sg_pipeline_desc + .colors[i] + .blend + .op_rgb + .op_alpha + + The default value is SG_BLENDOP_ADD. + */ + typedef enum sg_blend_op { + _SG_BLENDOP_DEFAULT, /* value 0 reserved for default-init */ + SG_BLENDOP_ADD, + SG_BLENDOP_SUBTRACT, + SG_BLENDOP_REVERSE_SUBTRACT, + _SG_BLENDOP_NUM, + _SG_BLENDOP_FORCE_U32 = 0x7FFFFFFF + } sg_blend_op; + + /* + sg_color_mask + + Selects the active color channels when writing a fragment color to the + framebuffer. This is used in the members + sg_pipeline_desc.colors[i].write_mask when creating a pipeline object. + + The default colormask is SG_COLORMASK_RGBA (write all colors channels) + + NOTE: since the color mask value 0 is reserved for the default value + (SG_COLORMASK_RGBA), use SG_COLORMASK_NONE if all color channels + should be disabled. + */ + typedef enum sg_color_mask { + _SG_COLORMASK_DEFAULT = 0, /* value 0 reserved for default-init */ + SG_COLORMASK_NONE = 0x10, /* special value for 'all channels disabled */ + SG_COLORMASK_R = 0x1, + SG_COLORMASK_G = 0x2, + SG_COLORMASK_RG = 0x3, + SG_COLORMASK_B = 0x4, + SG_COLORMASK_RB = 0x5, + SG_COLORMASK_GB = 0x6, + SG_COLORMASK_RGB = 0x7, + SG_COLORMASK_A = 0x8, + SG_COLORMASK_RA = 0x9, + SG_COLORMASK_GA = 0xA, + SG_COLORMASK_RGA = 0xB, + SG_COLORMASK_BA = 0xC, + SG_COLORMASK_RBA = 0xD, + SG_COLORMASK_GBA = 0xE, + SG_COLORMASK_RGBA = 0xF, + _SG_COLORMASK_FORCE_U32 = 0x7FFFFFFF + } sg_color_mask; + + /* + sg_action + + Defines what action should be performed at the start of a render pass: + + SG_ACTION_CLEAR: clear the render target image + SG_ACTION_LOAD: load the previous content of the render target image + SG_ACTION_DONTCARE: leave the render target image content undefined + + This is used in the sg_pass_action structure. + + The default action for all pass attachments is SG_ACTION_CLEAR, with the + clear color rgba = {0.5f, 0.5f, 0.5f, 1.0f], depth=1.0 and stencil=0. + + If you want to override the default behaviour, it is important to not + only set the clear color, but the 'action' field as well (as long as this + is in its _SG_ACTION_DEFAULT, the value fields will be ignored). + */ + typedef enum sg_action { + _SG_ACTION_DEFAULT, + SG_ACTION_CLEAR, + SG_ACTION_LOAD, + SG_ACTION_DONTCARE, + _SG_ACTION_NUM, + _SG_ACTION_FORCE_U32 = 0x7FFFFFFF + } sg_action; + + /* + sg_pass_action + + The sg_pass_action struct defines the actions to be performed + at the start of a rendering pass in the functions sg_begin_pass() + and sg_begin_default_pass(). + + A separate action and clear values can be defined for each + color attachment, and for the depth-stencil attachment. + + The default clear values are defined by the macros: + + - SG_DEFAULT_CLEAR_RED: 0.5f + - SG_DEFAULT_CLEAR_GREEN: 0.5f + - SG_DEFAULT_CLEAR_BLUE: 0.5f + - SG_DEFAULT_CLEAR_ALPHA: 1.0f + - SG_DEFAULT_CLEAR_DEPTH: 1.0f + - SG_DEFAULT_CLEAR_STENCIL: 0 + */ + typedef struct sg_color_attachment_action { + sg_action action; + sg_color value; + } sg_color_attachment_action; + + typedef struct sg_depth_attachment_action { + sg_action action; + float value; + } sg_depth_attachment_action; + + typedef struct sg_stencil_attachment_action { + sg_action action; + uint8_t value; + } sg_stencil_attachment_action; + + typedef struct sg_pass_action { + uint32_t _start_canary; + sg_color_attachment_action colors[SG_MAX_COLOR_ATTACHMENTS]; + sg_depth_attachment_action depth; + sg_stencil_attachment_action stencil; + uint32_t _end_canary; + } sg_pass_action; + + /* + sg_bindings + + The sg_bindings structure defines the resource binding slots + of the sokol_gfx render pipeline, used as argument to the + sg_apply_bindings() function. + + A resource binding struct contains: + + - 1..N vertex buffers + - 0..N vertex buffer offsets + - 0..1 index buffers + - 0..1 index buffer offsets + - 0..N vertex shader stage images + - 0..N fragment shader stage images + + The max number of vertex buffer and shader stage images + are defined by the SG_MAX_SHADERSTAGE_BUFFERS and + SG_MAX_SHADERSTAGE_IMAGES configuration constants. + + The optional buffer offsets can be used to put different unrelated + chunks of vertex- and/or index-data into the same buffer objects. + */ + typedef struct sg_bindings { + uint32_t _start_canary; + sg_buffer vertex_buffers[SG_MAX_SHADERSTAGE_BUFFERS]; + int vertex_buffer_offsets[SG_MAX_SHADERSTAGE_BUFFERS]; + sg_buffer index_buffer; + int index_buffer_offset; + sg_image vs_images[SG_MAX_SHADERSTAGE_IMAGES]; + sg_image fs_images[SG_MAX_SHADERSTAGE_IMAGES]; + uint32_t _end_canary; + } sg_bindings; + + /* + sg_buffer_desc + + Creation parameters for sg_buffer objects, used in the + sg_make_buffer() call. + + The default configuration is: + + .size: 0 (*must* be >0 for buffers without data) + .type: SG_BUFFERTYPE_VERTEXBUFFER + .usage: SG_USAGE_IMMUTABLE + .data.ptr 0 (*must* be valid for immutable buffers) + .data.size 0 (*must* be > 0 for immutable buffers) + .label 0 (optional string label for trace hooks) + + The label will be ignored by sokol_gfx.h, it is only useful + when hooking into sg_make_buffer() or sg_init_buffer() via + the sg_install_trace_hooks() function. + + For immutable buffers which are initialized with initial data, + keep the .size item zero-initialized, and set the size together with the + pointer to the initial data in the .data item. + + For mutable buffers without initial data, keep the .data item + zero-initialized, and set the buffer size in the .size item instead. + + You can also set both size values, but currently both size values must + be identical (this may change in the future when the dynamic resource + management may become more flexible). + + ADVANCED TOPIC: Injecting native 3D-API buffers: + + The following struct members allow to inject your own GL, Metal + or D3D11 buffers into sokol_gfx: + + .gl_buffers[SG_NUM_INFLIGHT_FRAMES] + .mtl_buffers[SG_NUM_INFLIGHT_FRAMES] + .d3d11_buffer + + You must still provide all other struct items except the .data item, and + these must match the creation parameters of the native buffers you + provide. For SG_USAGE_IMMUTABLE, only provide a single native 3D-API + buffer, otherwise you need to provide SG_NUM_INFLIGHT_FRAMES buffers + (only for GL and Metal, not D3D11). Providing multiple buffers for GL and + Metal is necessary because sokol_gfx will rotate through them when + calling sg_update_buffer() to prevent lock-stalls. + + Note that it is expected that immutable injected buffer have already been + initialized with content, and the .content member must be 0! + + Also you need to call sg_reset_state_cache() after calling native 3D-API + functions, and before calling any sokol_gfx function. + */ + typedef struct sg_buffer_desc { + uint32_t _start_canary; + size_t size; + sg_buffer_type type; + sg_usage usage; + sg_range data; + const char* label; + /* GL specific */ + uint32_t gl_buffers[SG_NUM_INFLIGHT_FRAMES]; + /* Metal specific */ + const void* mtl_buffers[SG_NUM_INFLIGHT_FRAMES]; + /* D3D11 specific */ + const void* d3d11_buffer; + /* WebGPU specific */ + const void* wgpu_buffer; + uint32_t _end_canary; + } sg_buffer_desc; + + /* + sg_image_data + + Defines the content of an image through a 2D array of sg_range structs. + The first array dimension is the cubemap face, and the second array + dimension the mipmap level. + */ + typedef struct sg_image_data { + sg_range subimage[SG_CUBEFACE_NUM][SG_MAX_MIPMAPS]; + } sg_image_data; + + /* + sg_image_desc + + Creation parameters for sg_image objects, used in the sg_make_image() + call. + + The default configuration is: + + .type: SG_IMAGETYPE_2D + .render_target: false + .width 0 (must be set to >0) + .height 0 (must be set to >0) + .num_slices 1 (3D textures: depth; array textures: number of layers) + .num_mipmaps: 1 + .usage: SG_USAGE_IMMUTABLE + .pixel_format: SG_PIXELFORMAT_RGBA8 for textures, or sg_desc.context.color_format for render targets + .sample_count: 1 for textures, or sg_desc.context.sample_count for render targets + .min_filter: SG_FILTER_NEAREST + .mag_filter: SG_FILTER_NEAREST + .wrap_u: SG_WRAP_REPEAT + .wrap_v: SG_WRAP_REPEAT + .wrap_w: SG_WRAP_REPEAT (only SG_IMAGETYPE_3D) + .border_color SG_BORDERCOLOR_OPAQUE_BLACK + .max_anisotropy 1 (must be 1..16) + .min_lod 0.0f + .max_lod FLT_MAX + .data an sg_image_data struct to define the initial content + .label 0 (optional string label for trace hooks) + + Q: Why is the default sample_count for render targets identical with the + "default sample count" from sg_desc.context.sample_count? + + A: So that it matches the default sample count in pipeline objects. Even + though it is a bit strange/confusing that offscreen render targets by default + get the same sample count as the default framebuffer, but it's better that + an offscreen render target created with default parameters matches + a pipeline object created with default parameters. + + NOTE: + + SG_IMAGETYPE_ARRAY and SG_IMAGETYPE_3D are not supported on WebGL/GLES2, + use sg_query_features().imagetype_array and + sg_query_features().imagetype_3d at runtime to check if array- and + 3D-textures are supported. + + Images with usage SG_USAGE_IMMUTABLE must be fully initialized by + providing a valid .data member which points to initialization data. + + ADVANCED TOPIC: Injecting native 3D-API textures: + + The following struct members allow to inject your own GL, Metal or D3D11 + textures into sokol_gfx: + + .gl_textures[SG_NUM_INFLIGHT_FRAMES] + .mtl_textures[SG_NUM_INFLIGHT_FRAMES] + .d3d11_texture + .d3d11_shader_resource_view + + For GL, you can also specify the texture target or leave it empty to use + the default texture target for the image type (GL_TEXTURE_2D for + SG_IMAGETYPE_2D etc) + + For D3D11, you can provide either a D3D11 texture, or a + shader-resource-view, or both. If only a texture is provided, a matching + shader-resource-view will be created. If only a shader-resource-view is + provided, the texture will be looked up from the shader-resource-view. + + The same rules apply as for injecting native buffers (see sg_buffer_desc + documentation for more details). + */ + typedef struct sg_image_desc { + uint32_t _start_canary; + sg_image_type type; + bool render_target; + int width; + int height; + int num_slices; + int num_mipmaps; + sg_usage usage; + sg_pixel_format pixel_format; + int sample_count; + sg_filter min_filter; + sg_filter mag_filter; + sg_wrap wrap_u; + sg_wrap wrap_v; + sg_wrap wrap_w; + sg_border_color border_color; + uint32_t max_anisotropy; + float min_lod; + float max_lod; + sg_image_data data; + const char* label; + /* GL specific */ + uint32_t gl_textures[SG_NUM_INFLIGHT_FRAMES]; + uint32_t gl_texture_target; + /* Metal specific */ + const void* mtl_textures[SG_NUM_INFLIGHT_FRAMES]; + /* D3D11 specific */ + const void* d3d11_texture; + const void* d3d11_shader_resource_view; + /* WebGPU specific */ + const void* wgpu_texture; + uint32_t _end_canary; + } sg_image_desc; + + /* + sg_shader_desc + + The structure sg_shader_desc defines all creation parameters for shader + programs, used as input to the sg_make_shader() function: + + - reflection information for vertex attributes (vertex shader inputs): + - vertex attribute name (required for GLES2, optional for GLES3 and GL) + - a semantic name and index (required for D3D11) + - for each shader-stage (vertex and fragment): + - the shader source or bytecode + - an optional entry function name + - an optional compile target (only for D3D11 when source is provided, + defaults are "vs_4_0" and "ps_4_0") + - reflection info for each uniform block used by the shader stage: + - the size of the uniform block in bytes + - a memory layout hint (native vs std140, only required for GL backends) + - reflection info for each uniform block member (only required for GL backends): + - member name + - member type (SG_UNIFORMTYPE_xxx) + - if the member is an array, the number of array items + - reflection info for the texture images used by the shader stage: + - the image type (SG_IMAGETYPE_xxx) + - the sampler type (SG_SAMPLERTYPE_xxx, default is SG_SAMPLERTYPE_FLOAT) + - the name of the texture sampler (required for GLES2, optional everywhere else) + + For all GL backends, shader source-code must be provided. For D3D11 and Metal, + either shader source-code or byte-code can be provided. + + For D3D11, if source code is provided, the d3dcompiler_47.dll will be loaded + on demand. If this fails, shader creation will fail. When compiling HLSL + source code, you can provide an optional target string via + sg_shader_stage_desc.d3d11_target, the default target is "vs_4_0" for the + vertex shader stage and "ps_4_0" for the pixel shader stage. + */ + typedef struct sg_shader_attr_desc { + const char* name; // GLSL vertex attribute name (only strictly required for GLES2) + const char* sem_name; // HLSL semantic name + int sem_index; // HLSL semantic index + } sg_shader_attr_desc; + + typedef struct sg_shader_uniform_desc { + const char* name; + sg_uniform_type type; + int array_count; + } sg_shader_uniform_desc; + + typedef struct sg_shader_uniform_block_desc { + size_t size; + sg_uniform_layout layout; + sg_shader_uniform_desc uniforms[SG_MAX_UB_MEMBERS]; + } sg_shader_uniform_block_desc; + + typedef struct sg_shader_image_desc { + const char* name; + sg_image_type image_type; + sg_sampler_type sampler_type; + } sg_shader_image_desc; + + typedef struct sg_shader_stage_desc { + const char* source; + sg_range bytecode; + const char* entry; + const char* d3d11_target; + sg_shader_uniform_block_desc uniform_blocks[SG_MAX_SHADERSTAGE_UBS]; + sg_shader_image_desc images[SG_MAX_SHADERSTAGE_IMAGES]; + } sg_shader_stage_desc; + + typedef struct sg_shader_desc { + uint32_t _start_canary; + sg_shader_attr_desc attrs[SG_MAX_VERTEX_ATTRIBUTES]; + sg_shader_stage_desc vs; + sg_shader_stage_desc fs; + const char* label; + uint32_t _end_canary; + } sg_shader_desc; + + /* + sg_pipeline_desc + + The sg_pipeline_desc struct defines all creation parameters for an + sg_pipeline object, used as argument to the sg_make_pipeline() function: + + - the vertex layout for all input vertex buffers + - a shader object + - the 3D primitive type (points, lines, triangles, ...) + - the index type (none, 16- or 32-bit) + - all the fixed-function-pipeline state (depth-, stencil-, blend-state, etc...) + + If the vertex data has no gaps between vertex components, you can omit + the .layout.buffers[].stride and layout.attrs[].offset items (leave them + default-initialized to 0), sokol-gfx will then compute the offsets and + strides from the vertex component formats (.layout.attrs[].format). + Please note that ALL vertex attribute offsets must be 0 in order for the + automatic offset computation to kick in. + + The default configuration is as follows: + + .shader: 0 (must be initialized with a valid sg_shader id!) + .layout: + .buffers[]: vertex buffer layouts + .stride: 0 (if no stride is given it will be computed) + .step_func SG_VERTEXSTEP_PER_VERTEX + .step_rate 1 + .attrs[]: vertex attribute declarations + .buffer_index 0 the vertex buffer bind slot + .offset 0 (offsets can be omitted if the vertex layout has no gaps) + .format SG_VERTEXFORMAT_INVALID (must be initialized!) + .depth: + .pixel_format: sg_desc.context.depth_format + .compare: SG_COMPAREFUNC_ALWAYS + .write_enabled: false + .bias: 0.0f + .bias_slope_scale: 0.0f + .bias_clamp: 0.0f + .stencil: + .enabled: false + .front/back: + .compare: SG_COMPAREFUNC_ALWAYS + .depth_fail_op: SG_STENCILOP_KEEP + .pass_op: SG_STENCILOP_KEEP + .compare: SG_COMPAREFUNC_ALWAYS + .read_mask: 0 + .write_mask: 0 + .ref: 0 + .color_count 1 + .colors[0..color_count] + .pixel_format sg_desc.context.color_format + .write_mask: SG_COLORMASK_RGBA + .blend: + .enabled: false + .src_factor_rgb: SG_BLENDFACTOR_ONE + .dst_factor_rgb: SG_BLENDFACTOR_ZERO + .op_rgb: SG_BLENDOP_ADD + .src_factor_alpha: SG_BLENDFACTOR_ONE + .dst_factor_alpha: SG_BLENDFACTOR_ZERO + .op_alpha: SG_BLENDOP_ADD + .primitive_type: SG_PRIMITIVETYPE_TRIANGLES + .index_type: SG_INDEXTYPE_NONE + .cull_mode: SG_CULLMODE_NONE + .face_winding: SG_FACEWINDING_CW + .sample_count: sg_desc.context.sample_count + .blend_color: (sg_color) { 0.0f, 0.0f, 0.0f, 0.0f } + .alpha_to_coverage_enabled: false + .label 0 (optional string label for trace hooks) + */ + typedef struct sg_buffer_layout_desc { + int stride; + sg_vertex_step step_func; + int step_rate; +#if defined(SOKOL_ZIG_BINDINGS) + uint32_t __pad[2]; +#endif + } sg_buffer_layout_desc; + + typedef struct sg_vertex_attr_desc { + int buffer_index; + int offset; + sg_vertex_format format; +#if defined(SOKOL_ZIG_BINDINGS) + uint32_t __pad[2]; +#endif + } sg_vertex_attr_desc; + + typedef struct sg_layout_desc { + sg_buffer_layout_desc buffers[SG_MAX_SHADERSTAGE_BUFFERS]; + sg_vertex_attr_desc attrs[SG_MAX_VERTEX_ATTRIBUTES]; + } sg_layout_desc; + + typedef struct sg_stencil_face_state { + sg_compare_func compare; + sg_stencil_op fail_op; + sg_stencil_op depth_fail_op; + sg_stencil_op pass_op; + } sg_stencil_face_state; + + typedef struct sg_stencil_state { + bool enabled; + sg_stencil_face_state front; + sg_stencil_face_state back; + uint8_t read_mask; + uint8_t write_mask; + uint8_t ref; + } sg_stencil_state; + + typedef struct sg_depth_state { + sg_pixel_format pixel_format; + sg_compare_func compare; + bool write_enabled; + float bias; + float bias_slope_scale; + float bias_clamp; + } sg_depth_state; + + typedef struct sg_blend_state { + bool enabled; + sg_blend_factor src_factor_rgb; + sg_blend_factor dst_factor_rgb; + sg_blend_op op_rgb; + sg_blend_factor src_factor_alpha; + sg_blend_factor dst_factor_alpha; + sg_blend_op op_alpha; + } sg_blend_state; + + typedef struct sg_color_state { + sg_pixel_format pixel_format; + sg_color_mask write_mask; + sg_blend_state blend; + } sg_color_state; + + typedef struct sg_pipeline_desc { + uint32_t _start_canary; + sg_shader shader; + sg_layout_desc layout; + sg_depth_state depth; + sg_stencil_state stencil; + int color_count; + sg_color_state colors[SG_MAX_COLOR_ATTACHMENTS]; + sg_primitive_type primitive_type; + sg_index_type index_type; + sg_cull_mode cull_mode; + sg_face_winding face_winding; + int sample_count; + sg_color blend_color; + bool alpha_to_coverage_enabled; + const char* label; + uint32_t _end_canary; + } sg_pipeline_desc; + + /* + sg_pass_desc + + Creation parameters for an sg_pass object, used as argument + to the sg_make_pass() function. + + A pass object contains 1..4 color-attachments and none, or one, + depth-stencil-attachment. Each attachment consists of + an image, and two additional indices describing + which subimage the pass will render to: one mipmap index, and + if the image is a cubemap, array-texture or 3D-texture, the + face-index, array-layer or depth-slice. + + Pass images must fulfill the following requirements: + + All images must have: + - been created as render target (sg_image_desc.render_target = true) + - the same size + - the same sample count + + In addition, all color-attachment images must have the same pixel format. + */ + typedef struct sg_pass_attachment_desc { + sg_image image; + int mip_level; + int slice; /* cube texture: face; array texture: layer; 3D texture: slice */ + } sg_pass_attachment_desc; + + typedef struct sg_pass_desc { + uint32_t _start_canary; + sg_pass_attachment_desc color_attachments[SG_MAX_COLOR_ATTACHMENTS]; + sg_pass_attachment_desc depth_stencil_attachment; + const char* label; + uint32_t _end_canary; + } sg_pass_desc; + + /* + sg_trace_hooks + + Installable callback functions to keep track of the sokol-gfx calls, + this is useful for debugging, or keeping track of resource creation + and destruction. + + Trace hooks are installed with sg_install_trace_hooks(), this returns + another sg_trace_hooks struct with the previous set of + trace hook function pointers. These should be invoked by the + new trace hooks to form a proper call chain. + */ + typedef struct sg_trace_hooks { + void* user_data; + void (*reset_state_cache)(void* user_data); + void (*make_buffer)(const sg_buffer_desc* desc, sg_buffer result, void* user_data); + void (*make_image)(const sg_image_desc* desc, sg_image result, void* user_data); + void (*make_shader)(const sg_shader_desc* desc, sg_shader result, void* user_data); + void (*make_pipeline)(const sg_pipeline_desc* desc, sg_pipeline result, void* user_data); + void (*make_pass)(const sg_pass_desc* desc, sg_pass result, void* user_data); + void (*destroy_buffer)(sg_buffer buf, void* user_data); + void (*destroy_image)(sg_image img, void* user_data); + void (*destroy_shader)(sg_shader shd, void* user_data); + void (*destroy_pipeline)(sg_pipeline pip, void* user_data); + void (*destroy_pass)(sg_pass pass, void* user_data); + void (*update_buffer)(sg_buffer buf, const sg_range* data, void* user_data); + void (*update_image)(sg_image img, const sg_image_data* data, void* user_data); + void (*append_buffer)(sg_buffer buf, const sg_range* data, int result, void* user_data); + void (*begin_default_pass)(const sg_pass_action* pass_action, int width, int height, void* user_data); + void (*begin_pass)(sg_pass pass, const sg_pass_action* pass_action, void* user_data); + void (*apply_viewport)(int x, int y, int width, int height, bool origin_top_left, void* user_data); + void (*apply_scissor_rect)(int x, int y, int width, int height, bool origin_top_left, void* user_data); + void (*apply_pipeline)(sg_pipeline pip, void* user_data); + void (*apply_bindings)(const sg_bindings* bindings, void* user_data); + void (*apply_uniforms)(sg_shader_stage stage, int ub_index, const sg_range* data, void* user_data); + void (*draw)(int base_element, int num_elements, int num_instances, void* user_data); + void (*end_pass)(void* user_data); + void (*commit)(void* user_data); + void (*alloc_buffer)(sg_buffer result, void* user_data); + void (*alloc_image)(sg_image result, void* user_data); + void (*alloc_shader)(sg_shader result, void* user_data); + void (*alloc_pipeline)(sg_pipeline result, void* user_data); + void (*alloc_pass)(sg_pass result, void* user_data); + void (*dealloc_buffer)(sg_buffer buf_id, void* user_data); + void (*dealloc_image)(sg_image img_id, void* user_data); + void (*dealloc_shader)(sg_shader shd_id, void* user_data); + void (*dealloc_pipeline)(sg_pipeline pip_id, void* user_data); + void (*dealloc_pass)(sg_pass pass_id, void* user_data); + void (*init_buffer)(sg_buffer buf_id, const sg_buffer_desc* desc, void* user_data); + void (*init_image)(sg_image img_id, const sg_image_desc* desc, void* user_data); + void (*init_shader)(sg_shader shd_id, const sg_shader_desc* desc, void* user_data); + void (*init_pipeline)(sg_pipeline pip_id, const sg_pipeline_desc* desc, void* user_data); + void (*init_pass)(sg_pass pass_id, const sg_pass_desc* desc, void* user_data); + void (*uninit_buffer)(sg_buffer buf_id, void* user_data); + void (*uninit_image)(sg_image img_id, void* user_data); + void (*uninit_shader)(sg_shader shd_id, void* user_data); + void (*uninit_pipeline)(sg_pipeline pip_id, void* user_data); + void (*uninit_pass)(sg_pass pass_id, void* user_data); + void (*fail_buffer)(sg_buffer buf_id, void* user_data); + void (*fail_image)(sg_image img_id, void* user_data); + void (*fail_shader)(sg_shader shd_id, void* user_data); + void (*fail_pipeline)(sg_pipeline pip_id, void* user_data); + void (*fail_pass)(sg_pass pass_id, void* user_data); + void (*push_debug_group)(const char* name, void* user_data); + void (*pop_debug_group)(void* user_data); + void (*err_buffer_pool_exhausted)(void* user_data); + void (*err_image_pool_exhausted)(void* user_data); + void (*err_shader_pool_exhausted)(void* user_data); + void (*err_pipeline_pool_exhausted)(void* user_data); + void (*err_pass_pool_exhausted)(void* user_data); + void (*err_context_mismatch)(void* user_data); + void (*err_pass_invalid)(void* user_data); + void (*err_draw_invalid)(void* user_data); + void (*err_bindings_invalid)(void* user_data); + } sg_trace_hooks; + + /* + sg_buffer_info + sg_image_info + sg_shader_info + sg_pipeline_info + sg_pass_info + + These structs contain various internal resource attributes which + might be useful for debug-inspection. Please don't rely on the + actual content of those structs too much, as they are quite closely + tied to sokol_gfx.h internals and may change more frequently than + the other public API elements. + + The *_info structs are used as the return values of the following functions: + + sg_query_buffer_info() + sg_query_image_info() + sg_query_shader_info() + sg_query_pipeline_info() + sg_query_pass_info() + */ + typedef struct sg_slot_info { + sg_resource_state state; /* the current state of this resource slot */ + uint32_t res_id; /* type-neutral resource if (e.g. sg_buffer.id) */ + uint32_t ctx_id; /* the context this resource belongs to */ + } sg_slot_info; + + typedef struct sg_buffer_info { + sg_slot_info slot; /* resource pool slot info */ + uint32_t update_frame_index; /* frame index of last sg_update_buffer() */ + uint32_t append_frame_index; /* frame index of last sg_append_buffer() */ + int append_pos; /* current position in buffer for sg_append_buffer() */ + bool append_overflow; /* is buffer in overflow state (due to sg_append_buffer) */ + int num_slots; /* number of renaming-slots for dynamically updated buffers */ + int active_slot; /* currently active write-slot for dynamically updated buffers */ + } sg_buffer_info; + + typedef struct sg_image_info { + sg_slot_info slot; /* resource pool slot info */ + uint32_t upd_frame_index; /* frame index of last sg_update_image() */ + int num_slots; /* number of renaming-slots for dynamically updated images */ + int active_slot; /* currently active write-slot for dynamically updated images */ + int width; /* image width */ + int height; /* image height */ + } sg_image_info; + + typedef struct sg_shader_info { + sg_slot_info slot; /* resoure pool slot info */ + } sg_shader_info; + + typedef struct sg_pipeline_info { + sg_slot_info slot; /* resource pool slot info */ + } sg_pipeline_info; + + typedef struct sg_pass_info { + sg_slot_info slot; /* resource pool slot info */ + } sg_pass_info; + + /* + sg_desc + + The sg_desc struct contains configuration values for sokol_gfx, + it is used as parameter to the sg_setup() call. + + NOTE that all callback function pointers come in two versions, one without + a userdata pointer, and one with a userdata pointer. You would + either initialize one or the other depending on whether you pass data + to your callbacks. + + FIXME: explain the various configuration options + + The default configuration is: + + .buffer_pool_size 128 + .image_pool_size 128 + .shader_pool_size 32 + .pipeline_pool_size 64 + .pass_pool_size 16 + .context_pool_size 16 + .sampler_cache_size 64 + .uniform_buffer_size 4 MB (4*1024*1024) + .staging_buffer_size 8 MB (8*1024*1024) + + .context.color_format: default value depends on selected backend: + all GL backends: SG_PIXELFORMAT_RGBA8 + Metal and D3D11: SG_PIXELFORMAT_BGRA8 + WGPU: *no default* (must be queried from WGPU swapchain) + .context.depth_format SG_PIXELFORMAT_DEPTH_STENCIL + .context.sample_count 1 + + GL specific: + .context.gl.force_gles2 + if this is true the GL backend will act in "GLES2 fallback mode" even + when compiled with SOKOL_GLES3, this is useful to fall back + to traditional WebGL if a browser doesn't support a WebGL2 context + + Metal specific: + (NOTE: All Objective-C object references are transferred through + a bridged (const void*) to sokol_gfx, which will use a unretained + bridged cast (__bridged id<xxx>) to retrieve the Objective-C + references back. Since the bridge cast is unretained, the caller + must hold a strong reference to the Objective-C object for the + duration of the sokol_gfx call! + + .context.metal.device + a pointer to the MTLDevice object + .context.metal.renderpass_descriptor_cb + .context.metal_renderpass_descriptor_userdata_cb + A C callback function to obtain the MTLRenderPassDescriptor for the + current frame when rendering to the default framebuffer, will be called + in sg_begin_default_pass(). + .context.metal.drawable_cb + .context.metal.drawable_userdata_cb + a C callback function to obtain a MTLDrawable for the current + frame when rendering to the default framebuffer, will be called in + sg_end_pass() of the default pass + .context.metal.user_data + optional user data pointer passed to the userdata versions of + callback functions + + D3D11 specific: + .context.d3d11.device + a pointer to the ID3D11Device object, this must have been created + before sg_setup() is called + .context.d3d11.device_context + a pointer to the ID3D11DeviceContext object + .context.d3d11.render_target_view_cb + .context.d3d11.render_target_view_userdata_cb + a C callback function to obtain a pointer to the current + ID3D11RenderTargetView object of the default framebuffer, + this function will be called in sg_begin_pass() when rendering + to the default framebuffer + .context.d3d11.depth_stencil_view_cb + .context.d3d11.depth_stencil_view_userdata_cb + a C callback function to obtain a pointer to the current + ID3D11DepthStencilView object of the default framebuffer, + this function will be called in sg_begin_pass() when rendering + to the default framebuffer + .context.metal.user_data + optional user data pointer passed to the userdata versions of + callback functions + + WebGPU specific: + .context.wgpu.device + a WGPUDevice handle + .context.wgpu.render_format + WGPUTextureFormat of the swap chain surface + .context.wgpu.render_view_cb + .context.wgpu.render_view_userdata_cb + callback to get the current WGPUTextureView of the swapchain's + rendering attachment (may be an MSAA surface) + .context.wgpu.resolve_view_cb + .context.wgpu.resolve_view_userdata_cb + callback to get the current WGPUTextureView of the swapchain's + MSAA-resolve-target surface, must return 0 if not MSAA rendering + .context.wgpu.depth_stencil_view_cb + .context.wgpu.depth_stencil_view_userdata_cb + callback to get current default-pass depth-stencil-surface WGPUTextureView + the pixel format of the default WGPUTextureView must be WGPUTextureFormat_Depth24Plus8 + .context.metal.user_data + optional user data pointer passed to the userdata versions of + callback functions + + When using sokol_gfx.h and sokol_app.h together, consider using the + helper function sapp_sgcontext() in the sokol_glue.h header to + initialize the sg_desc.context nested struct. sapp_sgcontext() returns + a completely initialized sg_context_desc struct with information + provided by sokol_app.h. + */ + typedef struct sg_gl_context_desc { + bool force_gles2; + } sg_gl_context_desc; + + typedef struct sg_metal_context_desc { + const void* device; + const void* (*renderpass_descriptor_cb)(void); + const void* (*renderpass_descriptor_userdata_cb)(void*); + const void* (*drawable_cb)(void); + const void* (*drawable_userdata_cb)(void*); + void* user_data; + } sg_metal_context_desc; + + typedef struct sg_d3d11_context_desc { + const void* device; + const void* device_context; + const void* (*render_target_view_cb)(void); + const void* (*render_target_view_userdata_cb)(void*); + const void* (*depth_stencil_view_cb)(void); + const void* (*depth_stencil_view_userdata_cb)(void*); + void* user_data; + } sg_d3d11_context_desc; + + typedef struct sg_wgpu_context_desc { + const void* device; /* WGPUDevice */ + const void* (*render_view_cb)(void); /* returns WGPUTextureView */ + const void* (*render_view_userdata_cb)(void*); + const void* (*resolve_view_cb)(void); /* returns WGPUTextureView */ + const void* (*resolve_view_userdata_cb)(void*); + const void* (*depth_stencil_view_cb)(void); /* returns WGPUTextureView, must be WGPUTextureFormat_Depth24Plus8 */ + const void* (*depth_stencil_view_userdata_cb)(void*); + void* user_data; + } sg_wgpu_context_desc; + + typedef struct sg_context_desc { + sg_pixel_format color_format; + sg_pixel_format depth_format; + int sample_count; + sg_gl_context_desc gl; + sg_metal_context_desc metal; + sg_d3d11_context_desc d3d11; + sg_wgpu_context_desc wgpu; + } sg_context_desc; + + typedef struct sg_desc { + uint32_t _start_canary; + int buffer_pool_size; + int image_pool_size; + int shader_pool_size; + int pipeline_pool_size; + int pass_pool_size; + int context_pool_size; + int uniform_buffer_size; + int staging_buffer_size; + int sampler_cache_size; + sg_context_desc context; + uint32_t _end_canary; + } sg_desc; + + /* setup and misc functions */ + SOKOL_GFX_API_DECL void sg_setup(const sg_desc* desc); + SOKOL_GFX_API_DECL void sg_shutdown(void); + SOKOL_GFX_API_DECL bool sg_isvalid(void); + SOKOL_GFX_API_DECL void sg_reset_state_cache(void); + SOKOL_GFX_API_DECL sg_trace_hooks sg_install_trace_hooks(const sg_trace_hooks* trace_hooks); + SOKOL_GFX_API_DECL void sg_push_debug_group(const char* name); + SOKOL_GFX_API_DECL void sg_pop_debug_group(void); + + /* resource creation, destruction and updating */ + SOKOL_GFX_API_DECL sg_buffer sg_make_buffer(const sg_buffer_desc* desc); + SOKOL_GFX_API_DECL sg_image sg_make_image(const sg_image_desc* desc); + SOKOL_GFX_API_DECL sg_shader sg_make_shader(const sg_shader_desc* desc); + SOKOL_GFX_API_DECL sg_pipeline sg_make_pipeline(const sg_pipeline_desc* desc); + SOKOL_GFX_API_DECL sg_pass sg_make_pass(const sg_pass_desc* desc); + SOKOL_GFX_API_DECL void sg_destroy_buffer(sg_buffer buf); + SOKOL_GFX_API_DECL void sg_destroy_image(sg_image img); + SOKOL_GFX_API_DECL void sg_destroy_shader(sg_shader shd); + SOKOL_GFX_API_DECL void sg_destroy_pipeline(sg_pipeline pip); + SOKOL_GFX_API_DECL void sg_destroy_pass(sg_pass pass); + SOKOL_GFX_API_DECL void sg_update_buffer(sg_buffer buf, const sg_range* data); + SOKOL_GFX_API_DECL void sg_update_image(sg_image img, const sg_image_data* data); + SOKOL_GFX_API_DECL int sg_append_buffer(sg_buffer buf, const sg_range* data); + SOKOL_GFX_API_DECL bool sg_query_buffer_overflow(sg_buffer buf); + + /* rendering functions */ + SOKOL_GFX_API_DECL void sg_begin_default_pass(const sg_pass_action* pass_action, int width, int height); + SOKOL_GFX_API_DECL void sg_begin_default_passf(const sg_pass_action* pass_action, float width, float height); + SOKOL_GFX_API_DECL void sg_begin_pass(sg_pass pass, const sg_pass_action* pass_action); + SOKOL_GFX_API_DECL void sg_apply_viewport(int x, int y, int width, int height, bool origin_top_left); + SOKOL_GFX_API_DECL void sg_apply_viewportf(float x, float y, float width, float height, bool origin_top_left); + SOKOL_GFX_API_DECL void sg_apply_scissor_rect(int x, int y, int width, int height, bool origin_top_left); + SOKOL_GFX_API_DECL void sg_apply_scissor_rectf(float x, float y, float width, float height, bool origin_top_left); + SOKOL_GFX_API_DECL void sg_apply_pipeline(sg_pipeline pip); + SOKOL_GFX_API_DECL void sg_apply_bindings(const sg_bindings* bindings); + SOKOL_GFX_API_DECL void sg_apply_uniforms(sg_shader_stage stage, int ub_index, const sg_range* data); + SOKOL_GFX_API_DECL void sg_draw(int base_element, int num_elements, int num_instances); + SOKOL_GFX_API_DECL void sg_end_pass(void); + SOKOL_GFX_API_DECL void sg_commit(void); + + /* getting information */ + SOKOL_GFX_API_DECL sg_desc sg_query_desc(void); + SOKOL_GFX_API_DECL sg_backend sg_query_backend(void); + SOKOL_GFX_API_DECL sg_features sg_query_features(void); + SOKOL_GFX_API_DECL sg_limits sg_query_limits(void); + SOKOL_GFX_API_DECL sg_pixelformat_info sg_query_pixelformat(sg_pixel_format fmt); + /* get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID) */ + SOKOL_GFX_API_DECL sg_resource_state sg_query_buffer_state(sg_buffer buf); + SOKOL_GFX_API_DECL sg_resource_state sg_query_image_state(sg_image img); + SOKOL_GFX_API_DECL sg_resource_state sg_query_shader_state(sg_shader shd); + SOKOL_GFX_API_DECL sg_resource_state sg_query_pipeline_state(sg_pipeline pip); + SOKOL_GFX_API_DECL sg_resource_state sg_query_pass_state(sg_pass pass); + /* get runtime information about a resource */ + SOKOL_GFX_API_DECL sg_buffer_info sg_query_buffer_info(sg_buffer buf); + SOKOL_GFX_API_DECL sg_image_info sg_query_image_info(sg_image img); + SOKOL_GFX_API_DECL sg_shader_info sg_query_shader_info(sg_shader shd); + SOKOL_GFX_API_DECL sg_pipeline_info sg_query_pipeline_info(sg_pipeline pip); + SOKOL_GFX_API_DECL sg_pass_info sg_query_pass_info(sg_pass pass); + /* get resource creation desc struct with their default values replaced */ + SOKOL_GFX_API_DECL sg_buffer_desc sg_query_buffer_defaults(const sg_buffer_desc* desc); + SOKOL_GFX_API_DECL sg_image_desc sg_query_image_defaults(const sg_image_desc* desc); + SOKOL_GFX_API_DECL sg_shader_desc sg_query_shader_defaults(const sg_shader_desc* desc); + SOKOL_GFX_API_DECL sg_pipeline_desc sg_query_pipeline_defaults(const sg_pipeline_desc* desc); + SOKOL_GFX_API_DECL sg_pass_desc sg_query_pass_defaults(const sg_pass_desc* desc); + + /* separate resource allocation and initialization (for async setup) */ + SOKOL_GFX_API_DECL sg_buffer sg_alloc_buffer(void); + SOKOL_GFX_API_DECL sg_image sg_alloc_image(void); + SOKOL_GFX_API_DECL sg_shader sg_alloc_shader(void); + SOKOL_GFX_API_DECL sg_pipeline sg_alloc_pipeline(void); + SOKOL_GFX_API_DECL sg_pass sg_alloc_pass(void); + SOKOL_GFX_API_DECL void sg_dealloc_buffer(sg_buffer buf_id); + SOKOL_GFX_API_DECL void sg_dealloc_image(sg_image img_id); + SOKOL_GFX_API_DECL void sg_dealloc_shader(sg_shader shd_id); + SOKOL_GFX_API_DECL void sg_dealloc_pipeline(sg_pipeline pip_id); + SOKOL_GFX_API_DECL void sg_dealloc_pass(sg_pass pass_id); + SOKOL_GFX_API_DECL void sg_init_buffer(sg_buffer buf_id, const sg_buffer_desc* desc); + SOKOL_GFX_API_DECL void sg_init_image(sg_image img_id, const sg_image_desc* desc); + SOKOL_GFX_API_DECL void sg_init_shader(sg_shader shd_id, const sg_shader_desc* desc); + SOKOL_GFX_API_DECL void sg_init_pipeline(sg_pipeline pip_id, const sg_pipeline_desc* desc); + SOKOL_GFX_API_DECL void sg_init_pass(sg_pass pass_id, const sg_pass_desc* desc); + SOKOL_GFX_API_DECL bool sg_uninit_buffer(sg_buffer buf_id); + SOKOL_GFX_API_DECL bool sg_uninit_image(sg_image img_id); + SOKOL_GFX_API_DECL bool sg_uninit_shader(sg_shader shd_id); + SOKOL_GFX_API_DECL bool sg_uninit_pipeline(sg_pipeline pip_id); + SOKOL_GFX_API_DECL bool sg_uninit_pass(sg_pass pass_id); + SOKOL_GFX_API_DECL void sg_fail_buffer(sg_buffer buf_id); + SOKOL_GFX_API_DECL void sg_fail_image(sg_image img_id); + SOKOL_GFX_API_DECL void sg_fail_shader(sg_shader shd_id); + SOKOL_GFX_API_DECL void sg_fail_pipeline(sg_pipeline pip_id); + SOKOL_GFX_API_DECL void sg_fail_pass(sg_pass pass_id); + + /* rendering contexts (optional) */ + SOKOL_GFX_API_DECL sg_context sg_setup_context(void); + SOKOL_GFX_API_DECL void sg_activate_context(sg_context ctx_id); + SOKOL_GFX_API_DECL void sg_discard_context(sg_context ctx_id); + + /* Backend-specific helper functions, these may come in handy for mixing + sokol-gfx rendering with 'native backend' rendering functions. + + This group of functions will be expanded as needed. + */ + + /* D3D11: return ID3D11Device */ + SOKOL_GFX_API_DECL const void* sg_d3d11_device(void); + + /* Metal: return __bridge-casted MTLDevice */ + SOKOL_GFX_API_DECL const void* sg_mtl_device(void); + + /* Metal: return __bridge-casted MTLRenderCommandEncoder in current pass (or zero if outside pass) */ + SOKOL_GFX_API_DECL const void* sg_mtl_render_command_encoder(void); + +#ifdef __cplusplus +} /* extern "C" */ + +/* reference-based equivalents for c++ */ +inline void sg_setup(const sg_desc& desc) { return sg_setup(&desc); } + +inline sg_buffer sg_make_buffer(const sg_buffer_desc& desc) { return sg_make_buffer(&desc); } +inline sg_image sg_make_image(const sg_image_desc& desc) { return sg_make_image(&desc); } +inline sg_shader sg_make_shader(const sg_shader_desc& desc) { return sg_make_shader(&desc); } +inline sg_pipeline sg_make_pipeline(const sg_pipeline_desc& desc) { return sg_make_pipeline(&desc); } +inline sg_pass sg_make_pass(const sg_pass_desc& desc) { return sg_make_pass(&desc); } +inline void sg_update_image(sg_image img, const sg_image_data& data) { return sg_update_image(img, &data); } + +inline void sg_begin_default_pass(const sg_pass_action& pass_action, int width, int height) { return sg_begin_default_pass(&pass_action, width, height); } +inline void sg_begin_default_passf(const sg_pass_action& pass_action, float width, float height) { return sg_begin_default_passf(&pass_action, width, height); } +inline void sg_begin_pass(sg_pass pass, const sg_pass_action& pass_action) { return sg_begin_pass(pass, &pass_action); } +inline void sg_apply_bindings(const sg_bindings& bindings) { return sg_apply_bindings(&bindings); } +inline void sg_apply_uniforms(sg_shader_stage stage, int ub_index, const sg_range& data) { return sg_apply_uniforms(stage, ub_index, &data); } + +inline sg_buffer_desc sg_query_buffer_defaults(const sg_buffer_desc& desc) { return sg_query_buffer_defaults(&desc); } +inline sg_image_desc sg_query_image_defaults(const sg_image_desc& desc) { return sg_query_image_defaults(&desc); } +inline sg_shader_desc sg_query_shader_defaults(const sg_shader_desc& desc) { return sg_query_shader_defaults(&desc); } +inline sg_pipeline_desc sg_query_pipeline_defaults(const sg_pipeline_desc& desc) { return sg_query_pipeline_defaults(&desc); } +inline sg_pass_desc sg_query_pass_defaults(const sg_pass_desc& desc) { return sg_query_pass_defaults(&desc); } + +inline void sg_init_buffer(sg_buffer buf_id, const sg_buffer_desc& desc) { return sg_init_buffer(buf_id, &desc); } +inline void sg_init_image(sg_image img_id, const sg_image_desc& desc) { return sg_init_image(img_id, &desc); } +inline void sg_init_shader(sg_shader shd_id, const sg_shader_desc& desc) { return sg_init_shader(shd_id, &desc); } +inline void sg_init_pipeline(sg_pipeline pip_id, const sg_pipeline_desc& desc) { return sg_init_pipeline(pip_id, &desc); } +inline void sg_init_pass(sg_pass pass_id, const sg_pass_desc& desc) { return sg_init_pass(pass_id, &desc); } + +inline void sg_update_buffer(sg_buffer buf_id, const sg_range& data) { return sg_update_buffer(buf_id, &data); } +inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_append_buffer(buf_id, &data); } +#endif +#endif // SOKOL_GFX_INCLUDED + +/*--- IMPLEMENTATION ---------------------------------------------------------*/ +#ifdef SOKOL_GFX_IMPL +#define SOKOL_GFX_IMPL_INCLUDED (1) + +#if !(defined(SOKOL_GLCORE33)||defined(SOKOL_GLES2)||defined(SOKOL_GLES3)||defined(SOKOL_D3D11)||defined(SOKOL_METAL)||defined(SOKOL_WGPU)||defined(SOKOL_DUMMY_BACKEND)) +#error "Please select a backend with SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND" +#endif +#include <string.h> /* memset */ +#include <float.h> /* FLT_MAX */ + +#ifndef SOKOL_API_IMPL +#define SOKOL_API_IMPL +#endif +#ifndef SOKOL_DEBUG +#ifndef NDEBUG +#define SOKOL_DEBUG (1) +#endif +#endif +#ifndef SOKOL_ASSERT +#include <assert.h> +#define SOKOL_ASSERT(c) assert(c) +#endif +#ifndef SOKOL_VALIDATE_BEGIN +#define SOKOL_VALIDATE_BEGIN() _sg_validate_begin() +#endif +#ifndef SOKOL_VALIDATE +#define SOKOL_VALIDATE(cond, err) _sg_validate((cond), err) +#endif +#ifndef SOKOL_VALIDATE_END +#define SOKOL_VALIDATE_END() _sg_validate_end() +#endif +#ifndef SOKOL_UNREACHABLE +#define SOKOL_UNREACHABLE SOKOL_ASSERT(false) +#endif +#ifndef SOKOL_MALLOC +#include <stdlib.h> +#define SOKOL_MALLOC(s) malloc(s) +#define SOKOL_FREE(p) free(p) +#endif +#ifndef SOKOL_LOG +#ifdef SOKOL_DEBUG +#include <stdio.h> +#define SOKOL_LOG(s) { SOKOL_ASSERT(s); puts(s); } +#else +#define SOKOL_LOG(s) +#endif +#endif + +#ifndef _SOKOL_PRIVATE +#if defined(__GNUC__) || defined(__clang__) +#define _SOKOL_PRIVATE __attribute__((unused)) static +#else +#define _SOKOL_PRIVATE static +#endif +#endif + +#ifndef _SOKOL_UNUSED +#define _SOKOL_UNUSED(x) (void)(x) +#endif + +#if defined(SOKOL_TRACE_HOOKS) +#define _SG_TRACE_ARGS(fn, ...) if (_sg.hooks.fn) { _sg.hooks.fn(__VA_ARGS__, _sg.hooks.user_data); } +#define _SG_TRACE_NOARGS(fn) if (_sg.hooks.fn) { _sg.hooks.fn(_sg.hooks.user_data); } +#else +#define _SG_TRACE_ARGS(fn, ...) +#define _SG_TRACE_NOARGS(fn) +#endif + +/* default clear values */ +#ifndef SG_DEFAULT_CLEAR_RED +#define SG_DEFAULT_CLEAR_RED (0.5f) +#endif +#ifndef SG_DEFAULT_CLEAR_GREEN +#define SG_DEFAULT_CLEAR_GREEN (0.5f) +#endif +#ifndef SG_DEFAULT_CLEAR_BLUE +#define SG_DEFAULT_CLEAR_BLUE (0.5f) +#endif +#ifndef SG_DEFAULT_CLEAR_ALPHA +#define SG_DEFAULT_CLEAR_ALPHA (1.0f) +#endif +#ifndef SG_DEFAULT_CLEAR_DEPTH +#define SG_DEFAULT_CLEAR_DEPTH (1.0f) +#endif +#ifndef SG_DEFAULT_CLEAR_STENCIL +#define SG_DEFAULT_CLEAR_STENCIL (0) +#endif + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4115) /* named type definition in parentheses */ +#pragma warning(disable:4505) /* unreferenced local function has been removed */ +#pragma warning(disable:4201) /* nonstandard extension used: nameless struct/union (needed by d3d11.h) */ +#pragma warning(disable:4054) /* 'type cast': from function pointer */ +#pragma warning(disable:4055) /* 'type cast': from data pointer */ +#endif + +#if defined(SOKOL_D3D11) +#ifndef D3D11_NO_HELPERS +#define D3D11_NO_HELPERS +#endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include <d3d11.h> +#include <d3dcompiler.h> +#ifdef _MSC_VER +#if (defined(WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) +#pragma comment (lib, "WindowsApp") +#else +#pragma comment (lib, "kernel32") +#pragma comment (lib, "user32") +#pragma comment (lib, "dxgi") +#pragma comment (lib, "d3d11") +#endif +#endif +#elif defined(SOKOL_METAL) +// see https://clang.llvm.org/docs/LanguageExtensions.html#automatic-reference-counting +#if !defined(__cplusplus) +#if __has_feature(objc_arc) && !__has_feature(objc_arc_fields) +#error "sokol_gfx.h requires __has_feature(objc_arc_field) if ARC is enabled (use a more recent compiler version)" +#endif +#endif +#include <TargetConditionals.h> +#if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE +#define _SG_TARGET_MACOS (1) +#else +#define _SG_TARGET_IOS (1) +#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR +#define _SG_TARGET_IOS_SIMULATOR (1) +#endif +#endif +#import <Metal/Metal.h> +#elif defined(SOKOL_WGPU) +#if defined(__EMSCRIPTEN__) +#include <webgpu/webgpu.h> +#else +#include <dawn/webgpu.h> +#endif +#elif defined(SOKOL_GLCORE33) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3) +#define _SOKOL_ANY_GL (1) + +// include platform specific GL headers (or on Win32: use an embedded GL loader) +#if !defined(SOKOL_EXTERNAL_GL_LOADER) +#if defined(_WIN32) +#if defined(SOKOL_GLCORE33) && !defined(SOKOL_EXTERNAL_GL_LOADER) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include <windows.h> +#define _SOKOL_USE_WIN32_GL_LOADER (1) +#pragma comment (lib, "kernel32") // GetProcAddress() +#endif +#elif defined(__APPLE__) +#include <TargetConditionals.h> +#ifndef GL_SILENCE_DEPRECATION +#define GL_SILENCE_DEPRECATION +#endif +#if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE +#include <OpenGL/gl3.h> +#else +#include <OpenGLES/ES3/gl.h> +#include <OpenGLES/ES3/glext.h> +#endif +#elif defined(__EMSCRIPTEN__) || defined(__ANDROID__) +#if defined(SOKOL_GLES3) +#include <GLES3/gl3.h> +#elif defined(SOKOL_GLES2) +#ifndef GL_EXT_PROTOTYPES +#define GL_GLEXT_PROTOTYPES +#endif +#include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> +#endif +#elif defined(__linux__) || defined(__unix__) +#define GL_GLEXT_PROTOTYPES +#include <GL/gl.h> +#endif +#endif + +// optional GL loader definitions (only on Win32) +#if defined(_SOKOL_USE_WIN32_GL_LOADER) +#define __gl_h_ 1 +#define __gl32_h_ 1 +#define __gl31_h_ 1 +#define __GL_H__ 1 +#define __glext_h_ 1 +#define __GLEXT_H_ 1 +#define __gltypes_h_ 1 +#define __glcorearb_h_ 1 +#define __gl_glcorearb_h_ 1 +#define GL_APIENTRY APIENTRY + +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef int GLsizei; +typedef char GLchar; +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +typedef double GLclampd; +typedef unsigned short GLushort; +typedef unsigned char GLubyte; +typedef unsigned char GLboolean; +typedef uint64_t GLuint64; +typedef double GLdouble; +typedef unsigned short GLhalf; +typedef float GLclampf; +typedef unsigned int GLbitfield; +typedef signed char GLbyte; +typedef short GLshort; +typedef void GLvoid; +typedef int64_t GLint64; +typedef float GLfloat; +typedef struct __GLsync * GLsync; +typedef int GLint; +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_R32F 0x822E +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_R16F 0x822D +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_NUM_EXTENSIONS 0x821D +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_INCR 0x1E02 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_STATIC_DRAW 0x88E4 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONSTANT_COLOR 0x8001 +#define GL_DECR_WRAP 0x8508 +#define GL_R8 0x8229 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_SHORT 0x1402 +#define GL_DEPTH_TEST 0x0B71 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_LINK_STATUS 0x8B82 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_RGBA16F 0x881A +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_STREAM_DRAW 0x88E0 +#define GL_ONE 1 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA8 0x8058 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_RGBA4 0x8056 +#define GL_RGB8 0x8051 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_STENCIL 0x1802 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_DEPTH 0x1801 +#define GL_FRONT 0x0404 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_REPEAT 0x2901 +#define GL_RGBA 0x1908 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_DECR 0x1E03 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_FLOAT 0x1406 +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_COLOR 0x1800 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TRIANGLES 0x0004 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_NONE 0 +#define GL_SRC_COLOR 0x0300 +#define GL_BYTE 0x1400 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_LINE_STRIP 0x0003 +#define GL_TEXTURE_3D 0x806F +#define GL_CW 0x0900 +#define GL_LINEAR 0x2601 +#define GL_RENDERBUFFER 0x8D41 +#define GL_GEQUAL 0x0206 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_RGBA32F 0x8814 +#define GL_BLEND 0x0BE2 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_EXTENSIONS 0x1F03 +#define GL_NO_ERROR 0 +#define GL_REPLACE 0x1E01 +#define GL_KEEP 0x1E00 +#define GL_CCW 0x0901 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_RGB 0x1907 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_FALSE 0 +#define GL_ZERO 0 +#define GL_CULL_FACE 0x0B44 +#define GL_INVERT 0x150A +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_NEAREST 0x2600 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_LEQUAL 0x0203 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DITHER 0x0BD0 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_EQUAL 0x0202 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RGB5 0x8050 +#define GL_LINES 0x0001 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_SRC_ALPHA 0x0302 +#define GL_INCR_WRAP 0x8507 +#define GL_LESS 0x0201 +#define GL_MULTISAMPLE 0x809D +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_BACK 0x0405 +#define GL_ALWAYS 0x0207 +#define GL_FUNC_ADD 0x8006 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_NOTEQUAL 0x0205 +#define GL_DST_COLOR 0x0306 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_RED 0x1903 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_DST_ALPHA 0x0304 +#define GL_RGB5_A1 0x8057 +#define GL_GREATER 0x0204 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_TRUE 1 +#define GL_NEVER 0x0200 +#define GL_POINTS 0x0000 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_RGBA_INTEGER 0x8D99 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_RGBA16 0x805B +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#endif + +#ifndef GL_UNSIGNED_INT_2_10_10_10_REV +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#endif +#ifndef GL_UNSIGNED_INT_24_8 +#define GL_UNSIGNED_INT_24_8 0x84FA +#endif +#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#endif +#ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif +#ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#endif +#ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#endif +#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif +#ifndef GL_COMPRESSED_RED_RGTC1 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#endif +#ifndef GL_COMPRESSED_SIGNED_RED_RGTC1 +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#endif +#ifndef GL_COMPRESSED_RED_GREEN_RGTC2 +#define GL_COMPRESSED_RED_GREEN_RGTC2 0x8DBD +#endif +#ifndef GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2 +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2 0x8DBE +#endif +#ifndef GL_COMPRESSED_RGBA_BPTC_UNORM_ARB +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#endif +#ifndef GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#endif +#ifndef GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#endif +#ifndef GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif +#ifndef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#endif +#ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#endif +#ifndef GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif +#ifndef GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#endif +#ifndef GL_COMPRESSED_RGB8_ETC2 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#endif +#ifndef GL_COMPRESSED_RGBA8_ETC2_EAC +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#endif +#ifndef GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#endif +#ifndef GL_COMPRESSED_RG11_EAC +#define GL_COMPRESSED_RG11_EAC 0x9272 +#endif +#ifndef GL_COMPRESSED_SIGNED_RG11_EAC +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#endif +#ifndef GL_DEPTH24_STENCIL8 +#define GL_DEPTH24_STENCIL8 0x88F0 +#endif +#ifndef GL_HALF_FLOAT +#define GL_HALF_FLOAT 0x140B +#endif +#ifndef GL_DEPTH_STENCIL +#define GL_DEPTH_STENCIL 0x84F9 +#endif +#ifndef GL_LUMINANCE +#define GL_LUMINANCE 0x1909 +#endif + +#ifdef SOKOL_GLES2 +#ifdef GL_ANGLE_instanced_arrays +#define _SOKOL_GL_INSTANCING_ENABLED +#define glDrawArraysInstanced(mode, first, count, instancecount) glDrawArraysInstancedANGLE(mode, first, count, instancecount) +#define glDrawElementsInstanced(mode, count, type, indices, instancecount) glDrawElementsInstancedANGLE(mode, count, type, indices, instancecount) +#define glVertexAttribDivisor(index, divisor) glVertexAttribDivisorANGLE(index, divisor) +#elif defined(GL_EXT_draw_instanced) && defined(GL_EXT_instanced_arrays) +#define _SOKOL_GL_INSTANCING_ENABLED +#define glDrawArraysInstanced(mode, first, count, instancecount) glDrawArraysInstancedEXT(mode, first, count, instancecount) +#define glDrawElementsInstanced(mode, count, type, indices, instancecount) glDrawElementsInstancedEXT(mode, count, type, indices, instancecount) +#define glVertexAttribDivisor(index, divisor) glVertexAttribDivisorEXT(index, divisor) +#else +#define _SOKOL_GLES2_INSTANCING_ERROR "Select GL_ANGLE_instanced_arrays or (GL_EXT_draw_instanced & GL_EXT_instanced_arrays) to enable instancing in GLES2" +#define glDrawArraysInstanced(mode, first, count, instancecount) SOKOL_ASSERT(0 && _SOKOL_GLES2_INSTANCING_ERROR) +#define glDrawElementsInstanced(mode, count, type, indices, instancecount) SOKOL_ASSERT(0 && _SOKOL_GLES2_INSTANCING_ERROR) +#define glVertexAttribDivisor(index, divisor) SOKOL_ASSERT(0 && _SOKOL_GLES2_INSTANCING_ERROR) +#endif +#else +#define _SOKOL_GL_INSTANCING_ENABLED +#endif +#define _SG_GL_CHECK_ERROR() { SOKOL_ASSERT(glGetError() == GL_NO_ERROR); } +#endif + +/*=== COMMON BACKEND STUFF ===================================================*/ + +/* resource pool slots */ +typedef struct { + uint32_t id; + uint32_t ctx_id; + sg_resource_state state; +} _sg_slot_t; + +/* constants */ +enum { + _SG_STRING_SIZE = 16, + _SG_SLOT_SHIFT = 16, + _SG_SLOT_MASK = (1<<_SG_SLOT_SHIFT)-1, + _SG_MAX_POOL_SIZE = (1<<_SG_SLOT_SHIFT), + _SG_DEFAULT_BUFFER_POOL_SIZE = 128, + _SG_DEFAULT_IMAGE_POOL_SIZE = 128, + _SG_DEFAULT_SHADER_POOL_SIZE = 32, + _SG_DEFAULT_PIPELINE_POOL_SIZE = 64, + _SG_DEFAULT_PASS_POOL_SIZE = 16, + _SG_DEFAULT_CONTEXT_POOL_SIZE = 16, + _SG_DEFAULT_SAMPLER_CACHE_CAPACITY = 64, + _SG_DEFAULT_UB_SIZE = 4 * 1024 * 1024, + _SG_DEFAULT_STAGING_SIZE = 8 * 1024 * 1024, +}; + +/* fixed-size string */ +typedef struct { + char buf[_SG_STRING_SIZE]; +} _sg_str_t; + +/* helper macros */ +#define _sg_def(val, def) (((val) == 0) ? (def) : (val)) +#define _sg_def_flt(val, def) (((val) == 0.0f) ? (def) : (val)) +#define _sg_min(a,b) (((a)<(b))?(a):(b)) +#define _sg_max(a,b) (((a)>(b))?(a):(b)) +#define _sg_clamp(v,v0,v1) (((v)<(v0))?(v0):(((v)>(v1))?(v1):(v))) +#define _sg_fequal(val,cmp,delta) ((((val)-(cmp))> -(delta))&&(((val)-(cmp))<(delta))) + +typedef struct { + int size; + int append_pos; + bool append_overflow; + sg_buffer_type type; + sg_usage usage; + uint32_t update_frame_index; + uint32_t append_frame_index; + int num_slots; + int active_slot; +} _sg_buffer_common_t; + +_SOKOL_PRIVATE void _sg_buffer_common_init(_sg_buffer_common_t* cmn, const sg_buffer_desc* desc) { + cmn->size = (int)desc->size; + cmn->append_pos = 0; + cmn->append_overflow = false; + cmn->type = desc->type; + cmn->usage = desc->usage; + cmn->update_frame_index = 0; + cmn->append_frame_index = 0; + cmn->num_slots = (cmn->usage == SG_USAGE_IMMUTABLE) ? 1 : SG_NUM_INFLIGHT_FRAMES; + cmn->active_slot = 0; +} + +typedef struct { + sg_image_type type; + bool render_target; + int width; + int height; + int num_slices; + int num_mipmaps; + sg_usage usage; + sg_pixel_format pixel_format; + int sample_count; + sg_filter min_filter; + sg_filter mag_filter; + sg_wrap wrap_u; + sg_wrap wrap_v; + sg_wrap wrap_w; + sg_border_color border_color; + uint32_t max_anisotropy; + uint32_t upd_frame_index; + int num_slots; + int active_slot; +} _sg_image_common_t; + +_SOKOL_PRIVATE void _sg_image_common_init(_sg_image_common_t* cmn, const sg_image_desc* desc) { + cmn->type = desc->type; + cmn->render_target = desc->render_target; + cmn->width = desc->width; + cmn->height = desc->height; + cmn->num_slices = desc->num_slices; + cmn->num_mipmaps = desc->num_mipmaps; + cmn->usage = desc->usage; + cmn->pixel_format = desc->pixel_format; + cmn->sample_count = desc->sample_count; + cmn->min_filter = desc->min_filter; + cmn->mag_filter = desc->mag_filter; + cmn->wrap_u = desc->wrap_u; + cmn->wrap_v = desc->wrap_v; + cmn->wrap_w = desc->wrap_w; + cmn->border_color = desc->border_color; + cmn->max_anisotropy = desc->max_anisotropy; + cmn->upd_frame_index = 0; + cmn->num_slots = (cmn->usage == SG_USAGE_IMMUTABLE) ? 1 : SG_NUM_INFLIGHT_FRAMES; + cmn->active_slot = 0; +} + +typedef struct { + size_t size; +} _sg_uniform_block_t; + +typedef struct { + sg_image_type image_type; + sg_sampler_type sampler_type; +} _sg_shader_image_t; + +typedef struct { + int num_uniform_blocks; + int num_images; + _sg_uniform_block_t uniform_blocks[SG_MAX_SHADERSTAGE_UBS]; + _sg_shader_image_t images[SG_MAX_SHADERSTAGE_IMAGES]; +} _sg_shader_stage_t; + +typedef struct { + _sg_shader_stage_t stage[SG_NUM_SHADER_STAGES]; +} _sg_shader_common_t; + +_SOKOL_PRIVATE void _sg_shader_common_init(_sg_shader_common_t* cmn, const sg_shader_desc* desc) { + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + const sg_shader_stage_desc* stage_desc = (stage_index == SG_SHADERSTAGE_VS) ? &desc->vs : &desc->fs; + _sg_shader_stage_t* stage = &cmn->stage[stage_index]; + SOKOL_ASSERT(stage->num_uniform_blocks == 0); + for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBS; ub_index++) { + const sg_shader_uniform_block_desc* ub_desc = &stage_desc->uniform_blocks[ub_index]; + if (0 == ub_desc->size) { + break; + } + stage->uniform_blocks[ub_index].size = ub_desc->size; + stage->num_uniform_blocks++; + } + SOKOL_ASSERT(stage->num_images == 0); + for (int img_index = 0; img_index < SG_MAX_SHADERSTAGE_IMAGES; img_index++) { + const sg_shader_image_desc* img_desc = &stage_desc->images[img_index]; + if (img_desc->image_type == _SG_IMAGETYPE_DEFAULT) { + break; + } + stage->images[img_index].image_type = img_desc->image_type; + stage->images[img_index].sampler_type = img_desc->sampler_type; + stage->num_images++; + } + } +} + +typedef struct { + sg_shader shader_id; + sg_index_type index_type; + bool use_instanced_draw; + bool vertex_layout_valid[SG_MAX_SHADERSTAGE_BUFFERS]; + int color_attachment_count; + sg_pixel_format color_formats[SG_MAX_COLOR_ATTACHMENTS]; + sg_pixel_format depth_format; + int sample_count; + float depth_bias; + float depth_bias_slope_scale; + float depth_bias_clamp; + sg_color blend_color; +} _sg_pipeline_common_t; + +_SOKOL_PRIVATE void _sg_pipeline_common_init(_sg_pipeline_common_t* cmn, const sg_pipeline_desc* desc) { + SOKOL_ASSERT((desc->color_count >= 1) && (desc->color_count <= SG_MAX_COLOR_ATTACHMENTS)); + cmn->shader_id = desc->shader; + cmn->index_type = desc->index_type; + cmn->use_instanced_draw = false; + for (int i = 0; i < SG_MAX_SHADERSTAGE_BUFFERS; i++) { + cmn->vertex_layout_valid[i] = false; + } + cmn->color_attachment_count = desc->color_count; + for (int i = 0; i < cmn->color_attachment_count; i++) { + cmn->color_formats[i] = desc->colors[i].pixel_format; + } + cmn->depth_format = desc->depth.pixel_format; + cmn->sample_count = desc->sample_count; + cmn->depth_bias = desc->depth.bias; + cmn->depth_bias_slope_scale = desc->depth.bias_slope_scale; + cmn->depth_bias_clamp = desc->depth.bias_clamp; + cmn->blend_color = desc->blend_color; +} + +typedef struct { + sg_image image_id; + int mip_level; + int slice; +} _sg_pass_attachment_common_t; + +typedef struct { + int num_color_atts; + _sg_pass_attachment_common_t color_atts[SG_MAX_COLOR_ATTACHMENTS]; + _sg_pass_attachment_common_t ds_att; +} _sg_pass_common_t; + +_SOKOL_PRIVATE void _sg_pass_common_init(_sg_pass_common_t* cmn, const sg_pass_desc* desc) { + const sg_pass_attachment_desc* att_desc; + _sg_pass_attachment_common_t* att; + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + att_desc = &desc->color_attachments[i]; + if (att_desc->image.id != SG_INVALID_ID) { + cmn->num_color_atts++; + att = &cmn->color_atts[i]; + att->image_id = att_desc->image; + att->mip_level = att_desc->mip_level; + att->slice = att_desc->slice; + } + } + att_desc = &desc->depth_stencil_attachment; + if (att_desc->image.id != SG_INVALID_ID) { + att = &cmn->ds_att; + att->image_id = att_desc->image; + att->mip_level = att_desc->mip_level; + att->slice = att_desc->slice; + } +} + +/*=== GENERIC SAMPLER CACHE ==================================================*/ + +/* + this is used by the Metal and WGPU backends to reduce the + number of sampler state objects created through the backend API +*/ +typedef struct { + sg_filter min_filter; + sg_filter mag_filter; + sg_wrap wrap_u; + sg_wrap wrap_v; + sg_wrap wrap_w; + sg_border_color border_color; + uint32_t max_anisotropy; + int min_lod; /* orig min/max_lod is float, this is int(min/max_lod*1000.0) */ + int max_lod; + uintptr_t sampler_handle; +} _sg_sampler_cache_item_t; + +typedef struct { + int capacity; + int num_items; + _sg_sampler_cache_item_t* items; +} _sg_sampler_cache_t; + +_SOKOL_PRIVATE void _sg_smpcache_init(_sg_sampler_cache_t* cache, int capacity) { + SOKOL_ASSERT(cache && (capacity > 0)); + memset(cache, 0, sizeof(_sg_sampler_cache_t)); + cache->capacity = capacity; + const size_t size = (size_t)cache->capacity * sizeof(_sg_sampler_cache_item_t); + cache->items = (_sg_sampler_cache_item_t*) SOKOL_MALLOC(size); + SOKOL_ASSERT(cache->items); + memset(cache->items, 0, size); +} + +_SOKOL_PRIVATE void _sg_smpcache_discard(_sg_sampler_cache_t* cache) { + SOKOL_ASSERT(cache && cache->items); + SOKOL_FREE(cache->items); + cache->items = 0; + cache->num_items = 0; + cache->capacity = 0; +} + +_SOKOL_PRIVATE int _sg_smpcache_minlod_int(float min_lod) { + return (int) (min_lod * 1000.0f); +} + +_SOKOL_PRIVATE int _sg_smpcache_maxlod_int(float max_lod) { + return (int) (_sg_clamp(max_lod, 0.0f, 1000.0f) * 1000.0f); +} + +_SOKOL_PRIVATE int _sg_smpcache_find_item(const _sg_sampler_cache_t* cache, const sg_image_desc* img_desc) { + /* return matching sampler cache item index or -1 */ + SOKOL_ASSERT(cache && cache->items); + SOKOL_ASSERT(img_desc); + const int min_lod = _sg_smpcache_minlod_int(img_desc->min_lod); + const int max_lod = _sg_smpcache_maxlod_int(img_desc->max_lod); + for (int i = 0; i < cache->num_items; i++) { + const _sg_sampler_cache_item_t* item = &cache->items[i]; + if ((img_desc->min_filter == item->min_filter) && + (img_desc->mag_filter == item->mag_filter) && + (img_desc->wrap_u == item->wrap_u) && + (img_desc->wrap_v == item->wrap_v) && + (img_desc->wrap_w == item->wrap_w) && + (img_desc->max_anisotropy == item->max_anisotropy) && + (img_desc->border_color == item->border_color) && + (min_lod == item->min_lod) && + (max_lod == item->max_lod)) + { + return i; + } + } + /* fallthrough: no matching cache item found */ + return -1; +} + +_SOKOL_PRIVATE void _sg_smpcache_add_item(_sg_sampler_cache_t* cache, const sg_image_desc* img_desc, uintptr_t sampler_handle) { + SOKOL_ASSERT(cache && cache->items); + SOKOL_ASSERT(img_desc); + SOKOL_ASSERT(cache->num_items < cache->capacity); + const int item_index = cache->num_items++; + _sg_sampler_cache_item_t* item = &cache->items[item_index]; + item->min_filter = img_desc->min_filter; + item->mag_filter = img_desc->mag_filter; + item->wrap_u = img_desc->wrap_u; + item->wrap_v = img_desc->wrap_v; + item->wrap_w = img_desc->wrap_w; + item->border_color = img_desc->border_color; + item->max_anisotropy = img_desc->max_anisotropy; + item->min_lod = _sg_smpcache_minlod_int(img_desc->min_lod); + item->max_lod = _sg_smpcache_maxlod_int(img_desc->max_lod); + item->sampler_handle = sampler_handle; +} + +_SOKOL_PRIVATE uintptr_t _sg_smpcache_sampler(_sg_sampler_cache_t* cache, int item_index) { + SOKOL_ASSERT(cache && cache->items); + SOKOL_ASSERT(item_index < cache->num_items); + return cache->items[item_index].sampler_handle; +} + +/*=== DUMMY BACKEND DECLARATIONS =============================================*/ +#if defined(SOKOL_DUMMY_BACKEND) +typedef struct { + _sg_slot_t slot; + _sg_buffer_common_t cmn; +} _sg_dummy_buffer_t; +typedef _sg_dummy_buffer_t _sg_buffer_t; + +typedef struct { + _sg_slot_t slot; + _sg_image_common_t cmn; +} _sg_dummy_image_t; +typedef _sg_dummy_image_t _sg_image_t; + +typedef struct { + _sg_slot_t slot; + _sg_shader_common_t cmn; +} _sg_dummy_shader_t; +typedef _sg_dummy_shader_t _sg_shader_t; + +typedef struct { + _sg_slot_t slot; + _sg_shader_t* shader; + _sg_pipeline_common_t cmn; +} _sg_dummy_pipeline_t; +typedef _sg_dummy_pipeline_t _sg_pipeline_t; + +typedef struct { + _sg_image_t* image; +} _sg_dummy_attachment_t; + +typedef struct { + _sg_slot_t slot; + _sg_pass_common_t cmn; + struct { + _sg_dummy_attachment_t color_atts[SG_MAX_COLOR_ATTACHMENTS]; + _sg_dummy_attachment_t ds_att; + } dmy; +} _sg_dummy_pass_t; +typedef _sg_dummy_pass_t _sg_pass_t; +typedef _sg_pass_attachment_common_t _sg_pass_attachment_t; + +typedef struct { + _sg_slot_t slot; +} _sg_dummy_context_t; +typedef _sg_dummy_context_t _sg_context_t; + +/*== GL BACKEND DECLARATIONS =================================================*/ +#elif defined(_SOKOL_ANY_GL) +typedef struct { + _sg_slot_t slot; + _sg_buffer_common_t cmn; + struct { + GLuint buf[SG_NUM_INFLIGHT_FRAMES]; + bool ext_buffers; /* if true, external buffers were injected with sg_buffer_desc.gl_buffers */ + } gl; +} _sg_gl_buffer_t; +typedef _sg_gl_buffer_t _sg_buffer_t; + +typedef struct { + _sg_slot_t slot; + _sg_image_common_t cmn; + struct { + GLenum target; + GLuint depth_render_buffer; + GLuint msaa_render_buffer; + GLuint tex[SG_NUM_INFLIGHT_FRAMES]; + bool ext_textures; /* if true, external textures were injected with sg_image_desc.gl_textures */ + } gl; +} _sg_gl_image_t; +typedef _sg_gl_image_t _sg_image_t; + +typedef struct { + GLint gl_loc; + sg_uniform_type type; + uint16_t count; + uint16_t offset; +} _sg_gl_uniform_t; + +typedef struct { + int num_uniforms; + _sg_gl_uniform_t uniforms[SG_MAX_UB_MEMBERS]; +} _sg_gl_uniform_block_t; + +typedef struct { + int gl_tex_slot; +} _sg_gl_shader_image_t; + +typedef struct { + _sg_str_t name; +} _sg_gl_shader_attr_t; + +typedef struct { + _sg_gl_uniform_block_t uniform_blocks[SG_MAX_SHADERSTAGE_UBS]; + _sg_gl_shader_image_t images[SG_MAX_SHADERSTAGE_IMAGES]; +} _sg_gl_shader_stage_t; + +typedef struct { + _sg_slot_t slot; + _sg_shader_common_t cmn; + struct { + GLuint prog; + _sg_gl_shader_attr_t attrs[SG_MAX_VERTEX_ATTRIBUTES]; + _sg_gl_shader_stage_t stage[SG_NUM_SHADER_STAGES]; + } gl; +} _sg_gl_shader_t; +typedef _sg_gl_shader_t _sg_shader_t; + +typedef struct { + int8_t vb_index; /* -1 if attr is not enabled */ + int8_t divisor; /* -1 if not initialized */ + uint8_t stride; + uint8_t size; + uint8_t normalized; + int offset; + GLenum type; +} _sg_gl_attr_t; + +typedef struct { + _sg_slot_t slot; + _sg_pipeline_common_t cmn; + _sg_shader_t* shader; + struct { + _sg_gl_attr_t attrs[SG_MAX_VERTEX_ATTRIBUTES]; + sg_depth_state depth; + sg_stencil_state stencil; + sg_primitive_type primitive_type; + sg_blend_state blend; + sg_color_mask color_write_mask[SG_MAX_COLOR_ATTACHMENTS]; + sg_cull_mode cull_mode; + sg_face_winding face_winding; + int sample_count; + bool alpha_to_coverage_enabled; + } gl; +} _sg_gl_pipeline_t; +typedef _sg_gl_pipeline_t _sg_pipeline_t; + +typedef struct { + _sg_image_t* image; + GLuint gl_msaa_resolve_buffer; +} _sg_gl_attachment_t; + +typedef struct { + _sg_slot_t slot; + _sg_pass_common_t cmn; + struct { + GLuint fb; + _sg_gl_attachment_t color_atts[SG_MAX_COLOR_ATTACHMENTS]; + _sg_gl_attachment_t ds_att; + } gl; +} _sg_gl_pass_t; +typedef _sg_gl_pass_t _sg_pass_t; +typedef _sg_pass_attachment_common_t _sg_pass_attachment_t; + +typedef struct { + _sg_slot_t slot; +#if !defined(SOKOL_GLES2) + GLuint vao; +#endif + GLuint default_framebuffer; +} _sg_gl_context_t; +typedef _sg_gl_context_t _sg_context_t; + +typedef struct { + _sg_gl_attr_t gl_attr; + GLuint gl_vbuf; +} _sg_gl_cache_attr_t; + +typedef struct { + GLenum target; + GLuint texture; +} _sg_gl_texture_bind_slot; + +typedef struct { + sg_depth_state depth; + sg_stencil_state stencil; + sg_blend_state blend; + sg_color_mask color_write_mask[SG_MAX_COLOR_ATTACHMENTS]; + sg_cull_mode cull_mode; + sg_face_winding face_winding; + bool polygon_offset_enabled; + int sample_count; + sg_color blend_color; + bool alpha_to_coverage_enabled; + _sg_gl_cache_attr_t attrs[SG_MAX_VERTEX_ATTRIBUTES]; + GLuint vertex_buffer; + GLuint index_buffer; + GLuint stored_vertex_buffer; + GLuint stored_index_buffer; + GLuint prog; + _sg_gl_texture_bind_slot textures[SG_MAX_SHADERSTAGE_IMAGES]; + _sg_gl_texture_bind_slot stored_texture; + int cur_ib_offset; + GLenum cur_primitive_type; + GLenum cur_index_type; + GLenum cur_active_texture; + _sg_pipeline_t* cur_pipeline; + sg_pipeline cur_pipeline_id; +} _sg_gl_state_cache_t; + +typedef struct { + bool valid; + bool gles2; + bool in_pass; + int cur_pass_width; + int cur_pass_height; + _sg_context_t* cur_context; + _sg_pass_t* cur_pass; + sg_pass cur_pass_id; + _sg_gl_state_cache_t cache; + bool ext_anisotropic; + GLint max_anisotropy; + GLint max_combined_texture_image_units; +#if _SOKOL_USE_WIN32_GL_LOADER + HINSTANCE opengl32_dll; +#endif +} _sg_gl_backend_t; + +/*== D3D11 BACKEND DECLARATIONS ==============================================*/ +#elif defined(SOKOL_D3D11) + +typedef struct { + _sg_slot_t slot; + _sg_buffer_common_t cmn; + struct { + ID3D11Buffer* buf; + } d3d11; +} _sg_d3d11_buffer_t; +typedef _sg_d3d11_buffer_t _sg_buffer_t; + +typedef struct { + _sg_slot_t slot; + _sg_image_common_t cmn; + struct { + DXGI_FORMAT format; + ID3D11Texture2D* tex2d; + ID3D11Texture3D* tex3d; + ID3D11Texture2D* texds; + ID3D11Texture2D* texmsaa; + ID3D11ShaderResourceView* srv; + ID3D11SamplerState* smp; + } d3d11; +} _sg_d3d11_image_t; +typedef _sg_d3d11_image_t _sg_image_t; + +typedef struct { + _sg_str_t sem_name; + int sem_index; +} _sg_d3d11_shader_attr_t; + +typedef struct { + ID3D11Buffer* cbufs[SG_MAX_SHADERSTAGE_UBS]; +} _sg_d3d11_shader_stage_t; + +typedef struct { + _sg_slot_t slot; + _sg_shader_common_t cmn; + struct { + _sg_d3d11_shader_attr_t attrs[SG_MAX_VERTEX_ATTRIBUTES]; + _sg_d3d11_shader_stage_t stage[SG_NUM_SHADER_STAGES]; + ID3D11VertexShader* vs; + ID3D11PixelShader* fs; + void* vs_blob; + size_t vs_blob_length; + } d3d11; +} _sg_d3d11_shader_t; +typedef _sg_d3d11_shader_t _sg_shader_t; + +typedef struct { + _sg_slot_t slot; + _sg_pipeline_common_t cmn; + _sg_shader_t* shader; + struct { + UINT stencil_ref; + UINT vb_strides[SG_MAX_SHADERSTAGE_BUFFERS]; + D3D_PRIMITIVE_TOPOLOGY topology; + DXGI_FORMAT index_format; + ID3D11InputLayout* il; + ID3D11RasterizerState* rs; + ID3D11DepthStencilState* dss; + ID3D11BlendState* bs; + } d3d11; +} _sg_d3d11_pipeline_t; +typedef _sg_d3d11_pipeline_t _sg_pipeline_t; + +typedef struct { + _sg_image_t* image; + ID3D11RenderTargetView* rtv; +} _sg_d3d11_color_attachment_t; + +typedef struct { + _sg_image_t* image; + ID3D11DepthStencilView* dsv; +} _sg_d3d11_ds_attachment_t; + +typedef struct { + _sg_slot_t slot; + _sg_pass_common_t cmn; + struct { + _sg_d3d11_color_attachment_t color_atts[SG_MAX_COLOR_ATTACHMENTS]; + _sg_d3d11_ds_attachment_t ds_att; + } d3d11; +} _sg_d3d11_pass_t; +typedef _sg_d3d11_pass_t _sg_pass_t; +typedef _sg_pass_attachment_common_t _sg_pass_attachment_t; + +typedef struct { + _sg_slot_t slot; +} _sg_d3d11_context_t; +typedef _sg_d3d11_context_t _sg_context_t; + +typedef struct { + bool valid; + ID3D11Device* dev; + ID3D11DeviceContext* ctx; + const void* (*rtv_cb)(void); + const void* (*rtv_userdata_cb)(void*); + const void* (*dsv_cb)(void); + const void* (*dsv_userdata_cb)(void*); + void* user_data; + bool in_pass; + bool use_indexed_draw; + bool use_instanced_draw; + int cur_width; + int cur_height; + int num_rtvs; + _sg_pass_t* cur_pass; + sg_pass cur_pass_id; + _sg_pipeline_t* cur_pipeline; + sg_pipeline cur_pipeline_id; + ID3D11RenderTargetView* cur_rtvs[SG_MAX_COLOR_ATTACHMENTS]; + ID3D11DepthStencilView* cur_dsv; + /* on-demand loaded d3dcompiler_47.dll handles */ + HINSTANCE d3dcompiler_dll; + bool d3dcompiler_dll_load_failed; + pD3DCompile D3DCompile_func; + /* global subresourcedata array for texture updates */ + D3D11_SUBRESOURCE_DATA subres_data[SG_MAX_MIPMAPS * SG_MAX_TEXTUREARRAY_LAYERS]; +} _sg_d3d11_backend_t; + +/*=== METAL BACKEND DECLARATIONS =============================================*/ +#elif defined(SOKOL_METAL) + +#if defined(_SG_TARGET_MACOS) || defined(_SG_TARGET_IOS_SIMULATOR) +#define _SG_MTL_UB_ALIGN (256) +#else +#define _SG_MTL_UB_ALIGN (16) +#endif +#define _SG_MTL_INVALID_SLOT_INDEX (0) + +typedef struct { + uint32_t frame_index; /* frame index at which it is safe to release this resource */ + int slot_index; +} _sg_mtl_release_item_t; + +typedef struct { + NSMutableArray* pool; + int num_slots; + int free_queue_top; + int* free_queue; + int release_queue_front; + int release_queue_back; + _sg_mtl_release_item_t* release_queue; +} _sg_mtl_idpool_t; + +typedef struct { + _sg_slot_t slot; + _sg_buffer_common_t cmn; + struct { + int buf[SG_NUM_INFLIGHT_FRAMES]; /* index into _sg_mtl_pool */ + } mtl; +} _sg_mtl_buffer_t; +typedef _sg_mtl_buffer_t _sg_buffer_t; + +typedef struct { + _sg_slot_t slot; + _sg_image_common_t cmn; + struct { + int tex[SG_NUM_INFLIGHT_FRAMES]; + int depth_tex; + int msaa_tex; + int sampler_state; + } mtl; +} _sg_mtl_image_t; +typedef _sg_mtl_image_t _sg_image_t; + +typedef struct { + int mtl_lib; + int mtl_func; +} _sg_mtl_shader_stage_t; + +typedef struct { + _sg_slot_t slot; + _sg_shader_common_t cmn; + struct { + _sg_mtl_shader_stage_t stage[SG_NUM_SHADER_STAGES]; + } mtl; +} _sg_mtl_shader_t; +typedef _sg_mtl_shader_t _sg_shader_t; + +typedef struct { + _sg_slot_t slot; + _sg_pipeline_common_t cmn; + _sg_shader_t* shader; + struct { + MTLPrimitiveType prim_type; + int index_size; + MTLIndexType index_type; + MTLCullMode cull_mode; + MTLWinding winding; + uint32_t stencil_ref; + int rps; + int dss; + } mtl; +} _sg_mtl_pipeline_t; +typedef _sg_mtl_pipeline_t _sg_pipeline_t; + +typedef struct { + _sg_image_t* image; +} _sg_mtl_attachment_t; + +typedef struct { + _sg_slot_t slot; + _sg_pass_common_t cmn; + struct { + _sg_mtl_attachment_t color_atts[SG_MAX_COLOR_ATTACHMENTS]; + _sg_mtl_attachment_t ds_att; + } mtl; +} _sg_mtl_pass_t; +typedef _sg_mtl_pass_t _sg_pass_t; +typedef _sg_pass_attachment_common_t _sg_pass_attachment_t; + +typedef struct { + _sg_slot_t slot; +} _sg_mtl_context_t; +typedef _sg_mtl_context_t _sg_context_t; + +/* resouce binding state cache */ +typedef struct { + const _sg_pipeline_t* cur_pipeline; + sg_pipeline cur_pipeline_id; + const _sg_buffer_t* cur_indexbuffer; + int cur_indexbuffer_offset; + sg_buffer cur_indexbuffer_id; + const _sg_buffer_t* cur_vertexbuffers[SG_MAX_SHADERSTAGE_BUFFERS]; + int cur_vertexbuffer_offsets[SG_MAX_SHADERSTAGE_BUFFERS]; + sg_buffer cur_vertexbuffer_ids[SG_MAX_SHADERSTAGE_BUFFERS]; + const _sg_image_t* cur_vs_images[SG_MAX_SHADERSTAGE_IMAGES]; + sg_image cur_vs_image_ids[SG_MAX_SHADERSTAGE_IMAGES]; + const _sg_image_t* cur_fs_images[SG_MAX_SHADERSTAGE_IMAGES]; + sg_image cur_fs_image_ids[SG_MAX_SHADERSTAGE_IMAGES]; +} _sg_mtl_state_cache_t; + +typedef struct { + bool valid; + const void*(*renderpass_descriptor_cb)(void); + const void*(*renderpass_descriptor_userdata_cb)(void*); + const void*(*drawable_cb)(void); + const void*(*drawable_userdata_cb)(void*); + void* user_data; + uint32_t frame_index; + uint32_t cur_frame_rotate_index; + int ub_size; + int cur_ub_offset; + uint8_t* cur_ub_base_ptr; + bool in_pass; + bool pass_valid; + int cur_width; + int cur_height; + _sg_mtl_state_cache_t state_cache; + _sg_sampler_cache_t sampler_cache; + _sg_mtl_idpool_t idpool; + dispatch_semaphore_t sem; + id<MTLDevice> device; + id<MTLCommandQueue> cmd_queue; + id<MTLCommandBuffer> cmd_buffer; + id<MTLRenderCommandEncoder> cmd_encoder; + id<MTLBuffer> uniform_buffers[SG_NUM_INFLIGHT_FRAMES]; +} _sg_mtl_backend_t; + +/*=== WGPU BACKEND DECLARATIONS ==============================================*/ +#elif defined(SOKOL_WGPU) + +#define _SG_WGPU_STAGING_ALIGN (256) +#define _SG_WGPU_STAGING_PIPELINE_SIZE (8) +#define _SG_WGPU_ROWPITCH_ALIGN (256) +#define _SG_WGPU_MAX_SHADERSTAGE_IMAGES (8) +#define _SG_WGPU_MAX_UNIFORM_UPDATE_SIZE (1<<16) + +typedef struct { + _sg_slot_t slot; + _sg_buffer_common_t cmn; + struct { + WGPUBuffer buf; + } wgpu; +} _sg_wgpu_buffer_t; +typedef _sg_wgpu_buffer_t _sg_buffer_t; + +typedef struct { + _sg_slot_t slot; + _sg_image_common_t cmn; + struct { + WGPUTexture tex; + WGPUTextureView tex_view; + WGPUTexture msaa_tex; + WGPUSampler sampler; + } wgpu; +} _sg_wgpu_image_t; +typedef _sg_wgpu_image_t _sg_image_t; + +typedef struct { + WGPUShaderModule module; + WGPUBindGroupLayout bind_group_layout; + _sg_str_t entry; +} _sg_wgpu_shader_stage_t; + +typedef struct { + _sg_slot_t slot; + _sg_shader_common_t cmn; + struct { + _sg_wgpu_shader_stage_t stage[SG_NUM_SHADER_STAGES]; + } wgpu; +} _sg_wgpu_shader_t; +typedef _sg_wgpu_shader_t _sg_shader_t; + +typedef struct { + _sg_slot_t slot; + _sg_pipeline_common_t cmn; + _sg_shader_t* shader; + struct { + WGPURenderPipeline pip; + uint32_t stencil_ref; + } wgpu; +} _sg_wgpu_pipeline_t; +typedef _sg_wgpu_pipeline_t _sg_pipeline_t; + +typedef struct { + _sg_image_t* image; + WGPUTextureView render_tex_view; + WGPUTextureView resolve_tex_view; +} _sg_wgpu_attachment_t; + +typedef struct { + _sg_slot_t slot; + _sg_pass_common_t cmn; + struct { + _sg_wgpu_attachment_t color_atts[SG_MAX_COLOR_ATTACHMENTS]; + _sg_wgpu_attachment_t ds_att; + } wgpu; +} _sg_wgpu_pass_t; +typedef _sg_wgpu_pass_t _sg_pass_t; +typedef _sg_pass_attachment_common_t _sg_pass_attachment_t; + +typedef struct { + _sg_slot_t slot; +} _sg_wgpu_context_t; +typedef _sg_wgpu_context_t _sg_context_t; + +/* a pool of per-frame uniform buffers */ +typedef struct { + WGPUBindGroupLayout bindgroup_layout; + uint32_t num_bytes; + uint32_t offset; /* current offset into current frame's mapped uniform buffer */ + uint32_t bind_offsets[SG_NUM_SHADER_STAGES][SG_MAX_SHADERSTAGE_UBS]; + WGPUBuffer buf; /* the GPU-side uniform buffer */ + WGPUBindGroup bindgroup; + struct { + int num; + int cur; + WGPUBuffer buf[_SG_WGPU_STAGING_PIPELINE_SIZE]; /* CPU-side staging buffers */ + uint8_t* ptr[_SG_WGPU_STAGING_PIPELINE_SIZE]; /* if != 0, staging buffer currently mapped */ + } stage; +} _sg_wgpu_ubpool_t; + +/* ...a similar pool (like uniform buffer pool) of dynamic-resource staging buffers */ +typedef struct { + uint32_t num_bytes; + uint32_t offset; /* current offset into current frame's staging buffer */ + int num; /* number of staging buffers */ + int cur; /* this frame's staging buffer */ + WGPUBuffer buf[_SG_WGPU_STAGING_PIPELINE_SIZE]; /* CPU-side staging buffers */ + uint8_t* ptr[_SG_WGPU_STAGING_PIPELINE_SIZE]; /* if != 0, staging buffer currently mapped */ +} _sg_wgpu_stagingpool_t; + +/* the WGPU backend state */ +typedef struct { + bool valid; + bool in_pass; + bool draw_indexed; + int cur_width; + int cur_height; + WGPUDevice dev; + WGPUTextureView (*render_view_cb)(void); + WGPUTextureView (*render_view_userdata_cb)(void*); + WGPUTextureView (*resolve_view_cb)(void); + WGPUTextureView (*resolve_view_userdata_cb)(void*); + WGPUTextureView (*depth_stencil_view_cb)(void); + WGPUTextureView (*depth_stencil_view_userdata_cb)(void*); + void* user_data; + WGPUQueue queue; + WGPUCommandEncoder render_cmd_enc; + WGPUCommandEncoder staging_cmd_enc; + WGPURenderPassEncoder pass_enc; + WGPUBindGroup empty_bind_group; + const _sg_pipeline_t* cur_pipeline; + sg_pipeline cur_pipeline_id; + _sg_sampler_cache_t sampler_cache; + _sg_wgpu_ubpool_t ub; + _sg_wgpu_stagingpool_t staging; +} _sg_wgpu_backend_t; +#endif + +/*=== RESOURCE POOL DECLARATIONS =============================================*/ + +/* this *MUST* remain 0 */ +#define _SG_INVALID_SLOT_INDEX (0) + +typedef struct { + int size; + int queue_top; + uint32_t* gen_ctrs; + int* free_queue; +} _sg_pool_t; + +typedef struct { + _sg_pool_t buffer_pool; + _sg_pool_t image_pool; + _sg_pool_t shader_pool; + _sg_pool_t pipeline_pool; + _sg_pool_t pass_pool; + _sg_pool_t context_pool; + _sg_buffer_t* buffers; + _sg_image_t* images; + _sg_shader_t* shaders; + _sg_pipeline_t* pipelines; + _sg_pass_t* passes; + _sg_context_t* contexts; +} _sg_pools_t; + +/*=== VALIDATION LAYER DECLARATIONS ==========================================*/ +typedef enum { + /* special case 'validation was successful' */ + _SG_VALIDATE_SUCCESS, + + /* buffer creation */ + _SG_VALIDATE_BUFFERDESC_CANARY, + _SG_VALIDATE_BUFFERDESC_SIZE, + _SG_VALIDATE_BUFFERDESC_DATA, + _SG_VALIDATE_BUFFERDESC_DATA_SIZE, + _SG_VALIDATE_BUFFERDESC_NO_DATA, + + /* image data (for image creation and updating) */ + _SG_VALIDATE_IMAGEDATA_NODATA, + _SG_VALIDATE_IMAGEDATA_DATA_SIZE, + + /* image creation */ + _SG_VALIDATE_IMAGEDESC_CANARY, + _SG_VALIDATE_IMAGEDESC_WIDTH, + _SG_VALIDATE_IMAGEDESC_HEIGHT, + _SG_VALIDATE_IMAGEDESC_RT_PIXELFORMAT, + _SG_VALIDATE_IMAGEDESC_NONRT_PIXELFORMAT, + _SG_VALIDATE_IMAGEDESC_MSAA_BUT_NO_RT, + _SG_VALIDATE_IMAGEDESC_NO_MSAA_RT_SUPPORT, + _SG_VALIDATE_IMAGEDESC_RT_IMMUTABLE, + _SG_VALIDATE_IMAGEDESC_RT_NO_DATA, + _SG_VALIDATE_IMAGEDESC_INJECTED_NO_DATA, + _SG_VALIDATE_IMAGEDESC_DYNAMIC_NO_DATA, + _SG_VALIDATE_IMAGEDESC_COMPRESSED_IMMUTABLE, + + /* shader creation */ + _SG_VALIDATE_SHADERDESC_CANARY, + _SG_VALIDATE_SHADERDESC_SOURCE, + _SG_VALIDATE_SHADERDESC_BYTECODE, + _SG_VALIDATE_SHADERDESC_SOURCE_OR_BYTECODE, + _SG_VALIDATE_SHADERDESC_NO_BYTECODE_SIZE, + _SG_VALIDATE_SHADERDESC_NO_CONT_UBS, + _SG_VALIDATE_SHADERDESC_NO_CONT_IMGS, + _SG_VALIDATE_SHADERDESC_NO_CONT_UB_MEMBERS, + _SG_VALIDATE_SHADERDESC_NO_UB_MEMBERS, + _SG_VALIDATE_SHADERDESC_UB_MEMBER_NAME, + _SG_VALIDATE_SHADERDESC_UB_SIZE_MISMATCH, + _SG_VALIDATE_SHADERDESC_UB_ARRAY_COUNT, + _SG_VALIDATE_SHADERDESC_UB_STD140_ARRAY_TYPE, + _SG_VALIDATE_SHADERDESC_IMG_NAME, + _SG_VALIDATE_SHADERDESC_ATTR_NAMES, + _SG_VALIDATE_SHADERDESC_ATTR_SEMANTICS, + _SG_VALIDATE_SHADERDESC_ATTR_STRING_TOO_LONG, + + /* pipeline creation */ + _SG_VALIDATE_PIPELINEDESC_CANARY, + _SG_VALIDATE_PIPELINEDESC_SHADER, + _SG_VALIDATE_PIPELINEDESC_NO_ATTRS, + _SG_VALIDATE_PIPELINEDESC_LAYOUT_STRIDE4, + _SG_VALIDATE_PIPELINEDESC_ATTR_NAME, + _SG_VALIDATE_PIPELINEDESC_ATTR_SEMANTICS, + + /* pass creation */ + _SG_VALIDATE_PASSDESC_CANARY, + _SG_VALIDATE_PASSDESC_NO_COLOR_ATTS, + _SG_VALIDATE_PASSDESC_NO_CONT_COLOR_ATTS, + _SG_VALIDATE_PASSDESC_IMAGE, + _SG_VALIDATE_PASSDESC_MIPLEVEL, + _SG_VALIDATE_PASSDESC_FACE, + _SG_VALIDATE_PASSDESC_LAYER, + _SG_VALIDATE_PASSDESC_SLICE, + _SG_VALIDATE_PASSDESC_IMAGE_NO_RT, + _SG_VALIDATE_PASSDESC_COLOR_INV_PIXELFORMAT, + _SG_VALIDATE_PASSDESC_DEPTH_INV_PIXELFORMAT, + _SG_VALIDATE_PASSDESC_IMAGE_SIZES, + _SG_VALIDATE_PASSDESC_IMAGE_SAMPLE_COUNTS, + + /* sg_begin_pass validation */ + _SG_VALIDATE_BEGINPASS_PASS, + _SG_VALIDATE_BEGINPASS_IMAGE, + + /* sg_apply_pipeline validation */ + _SG_VALIDATE_APIP_PIPELINE_VALID_ID, + _SG_VALIDATE_APIP_PIPELINE_EXISTS, + _SG_VALIDATE_APIP_PIPELINE_VALID, + _SG_VALIDATE_APIP_SHADER_EXISTS, + _SG_VALIDATE_APIP_SHADER_VALID, + _SG_VALIDATE_APIP_ATT_COUNT, + _SG_VALIDATE_APIP_COLOR_FORMAT, + _SG_VALIDATE_APIP_DEPTH_FORMAT, + _SG_VALIDATE_APIP_SAMPLE_COUNT, + + /* sg_apply_bindings validation */ + _SG_VALIDATE_ABND_PIPELINE, + _SG_VALIDATE_ABND_PIPELINE_EXISTS, + _SG_VALIDATE_ABND_PIPELINE_VALID, + _SG_VALIDATE_ABND_VBS, + _SG_VALIDATE_ABND_VB_EXISTS, + _SG_VALIDATE_ABND_VB_TYPE, + _SG_VALIDATE_ABND_VB_OVERFLOW, + _SG_VALIDATE_ABND_NO_IB, + _SG_VALIDATE_ABND_IB, + _SG_VALIDATE_ABND_IB_EXISTS, + _SG_VALIDATE_ABND_IB_TYPE, + _SG_VALIDATE_ABND_IB_OVERFLOW, + _SG_VALIDATE_ABND_VS_IMGS, + _SG_VALIDATE_ABND_VS_IMG_EXISTS, + _SG_VALIDATE_ABND_VS_IMG_TYPES, + _SG_VALIDATE_ABND_FS_IMGS, + _SG_VALIDATE_ABND_FS_IMG_EXISTS, + _SG_VALIDATE_ABND_FS_IMG_TYPES, + + /* sg_apply_uniforms validation */ + _SG_VALIDATE_AUB_NO_PIPELINE, + _SG_VALIDATE_AUB_NO_UB_AT_SLOT, + _SG_VALIDATE_AUB_SIZE, + + /* sg_update_buffer validation */ + _SG_VALIDATE_UPDATEBUF_USAGE, + _SG_VALIDATE_UPDATEBUF_SIZE, + _SG_VALIDATE_UPDATEBUF_ONCE, + _SG_VALIDATE_UPDATEBUF_APPEND, + + /* sg_append_buffer validation */ + _SG_VALIDATE_APPENDBUF_USAGE, + _SG_VALIDATE_APPENDBUF_SIZE, + _SG_VALIDATE_APPENDBUF_UPDATE, + + /* sg_update_image validation */ + _SG_VALIDATE_UPDIMG_USAGE, + _SG_VALIDATE_UPDIMG_NOTENOUGHDATA, + _SG_VALIDATE_UPDIMG_ONCE +} _sg_validate_error_t; + +/*=== GENERIC BACKEND STATE ==================================================*/ + +typedef struct { + bool valid; + sg_desc desc; /* original desc with default values patched in */ + uint32_t frame_index; + sg_context active_context; + sg_pass cur_pass; + sg_pipeline cur_pipeline; + bool pass_valid; + bool bindings_valid; + bool next_draw_valid; +#if defined(SOKOL_DEBUG) + _sg_validate_error_t validate_error; +#endif + _sg_pools_t pools; + sg_backend backend; + sg_features features; + sg_limits limits; + sg_pixelformat_info formats[_SG_PIXELFORMAT_NUM]; +#if defined(_SOKOL_ANY_GL) + _sg_gl_backend_t gl; +#elif defined(SOKOL_METAL) + _sg_mtl_backend_t mtl; +#elif defined(SOKOL_D3D11) + _sg_d3d11_backend_t d3d11; +#elif defined(SOKOL_WGPU) + _sg_wgpu_backend_t wgpu; +#endif +#if defined(SOKOL_TRACE_HOOKS) + sg_trace_hooks hooks; +#endif +} _sg_state_t; +static _sg_state_t _sg; + +/*-- helper functions --------------------------------------------------------*/ + +_SOKOL_PRIVATE bool _sg_strempty(const _sg_str_t* str) { + return 0 == str->buf[0]; +} + +_SOKOL_PRIVATE const char* _sg_strptr(const _sg_str_t* str) { + return &str->buf[0]; +} + +_SOKOL_PRIVATE void _sg_strcpy(_sg_str_t* dst, const char* src) { + SOKOL_ASSERT(dst); + if (src) { +#if defined(_MSC_VER) + strncpy_s(dst->buf, _SG_STRING_SIZE, src, (_SG_STRING_SIZE-1)); +#else + strncpy(dst->buf, src, _SG_STRING_SIZE); +#endif + dst->buf[_SG_STRING_SIZE-1] = 0; + } + else { + memset(dst->buf, 0, _SG_STRING_SIZE); + } +} + +_SOKOL_PRIVATE uint32_t _sg_align_u32(uint32_t val, uint32_t align) { + SOKOL_ASSERT((align > 0) && ((align & (align - 1)) == 0)); + return (val + (align - 1)) & ~(align - 1); +} + +/* return byte size of a vertex format */ +_SOKOL_PRIVATE int _sg_vertexformat_bytesize(sg_vertex_format fmt) { + switch (fmt) { + case SG_VERTEXFORMAT_FLOAT: return 4; + case SG_VERTEXFORMAT_FLOAT2: return 8; + case SG_VERTEXFORMAT_FLOAT3: return 12; + case SG_VERTEXFORMAT_FLOAT4: return 16; + case SG_VERTEXFORMAT_BYTE4: return 4; + case SG_VERTEXFORMAT_BYTE4N: return 4; + case SG_VERTEXFORMAT_UBYTE4: return 4; + case SG_VERTEXFORMAT_UBYTE4N: return 4; + case SG_VERTEXFORMAT_SHORT2: return 4; + case SG_VERTEXFORMAT_SHORT2N: return 4; + case SG_VERTEXFORMAT_USHORT2N: return 4; + case SG_VERTEXFORMAT_SHORT4: return 8; + case SG_VERTEXFORMAT_SHORT4N: return 8; + case SG_VERTEXFORMAT_USHORT4N: return 8; + case SG_VERTEXFORMAT_UINT10_N2: return 4; + case SG_VERTEXFORMAT_INVALID: return 0; + default: + SOKOL_UNREACHABLE; + return -1; + } +} + +_SOKOL_PRIVATE uint32_t _sg_uniform_alignment(sg_uniform_type type, int array_count, sg_uniform_layout ub_layout) { + if (ub_layout == SG_UNIFORMLAYOUT_NATIVE) { + return 1; + } + else { + SOKOL_ASSERT(array_count > 0); + if (array_count == 1) { + switch (type) { + case SG_UNIFORMTYPE_FLOAT: + case SG_UNIFORMTYPE_INT: + return 4; + case SG_UNIFORMTYPE_FLOAT2: + case SG_UNIFORMTYPE_INT2: + return 8; + case SG_UNIFORMTYPE_FLOAT3: + case SG_UNIFORMTYPE_FLOAT4: + case SG_UNIFORMTYPE_INT3: + case SG_UNIFORMTYPE_INT4: + return 16; + case SG_UNIFORMTYPE_MAT4: + return 16; + default: + SOKOL_UNREACHABLE; + return 1; + } + } + else { + return 16; + } + } +} + +_SOKOL_PRIVATE uint32_t _sg_uniform_size(sg_uniform_type type, int array_count, sg_uniform_layout ub_layout) { + SOKOL_ASSERT(array_count > 0); + if (array_count == 1) { + switch (type) { + case SG_UNIFORMTYPE_FLOAT: + case SG_UNIFORMTYPE_INT: + return 4; + case SG_UNIFORMTYPE_FLOAT2: + case SG_UNIFORMTYPE_INT2: + return 8; + case SG_UNIFORMTYPE_FLOAT3: + case SG_UNIFORMTYPE_INT3: + return 12; + case SG_UNIFORMTYPE_FLOAT4: + case SG_UNIFORMTYPE_INT4: + return 16; + case SG_UNIFORMTYPE_MAT4: + return 64; + default: + SOKOL_UNREACHABLE; + return 0; + } + } + else { + if (ub_layout == SG_UNIFORMLAYOUT_NATIVE) { + switch (type) { + case SG_UNIFORMTYPE_FLOAT: + case SG_UNIFORMTYPE_INT: + return 4 * (uint32_t)array_count; + case SG_UNIFORMTYPE_FLOAT2: + case SG_UNIFORMTYPE_INT2: + return 8 * (uint32_t)array_count; + case SG_UNIFORMTYPE_FLOAT3: + case SG_UNIFORMTYPE_INT3: + return 12 * (uint32_t)array_count; + case SG_UNIFORMTYPE_FLOAT4: + case SG_UNIFORMTYPE_INT4: + return 16 * (uint32_t)array_count; + case SG_UNIFORMTYPE_MAT4: + return 64 * (uint32_t)array_count; + default: + SOKOL_UNREACHABLE; + return 0; + } + } + else { + switch (type) { + case SG_UNIFORMTYPE_FLOAT: + case SG_UNIFORMTYPE_FLOAT2: + case SG_UNIFORMTYPE_FLOAT3: + case SG_UNIFORMTYPE_FLOAT4: + case SG_UNIFORMTYPE_INT: + case SG_UNIFORMTYPE_INT2: + case SG_UNIFORMTYPE_INT3: + case SG_UNIFORMTYPE_INT4: + return 16 * (uint32_t)array_count; + case SG_UNIFORMTYPE_MAT4: + return 64 * (uint32_t)array_count; + default: + SOKOL_UNREACHABLE; + return 0; + } + } + } +} + +/* return true if pixel format is a compressed format */ +_SOKOL_PRIVATE bool _sg_is_compressed_pixel_format(sg_pixel_format fmt) { + switch (fmt) { + case SG_PIXELFORMAT_BC1_RGBA: + case SG_PIXELFORMAT_BC2_RGBA: + case SG_PIXELFORMAT_BC3_RGBA: + case SG_PIXELFORMAT_BC4_R: + case SG_PIXELFORMAT_BC4_RSN: + case SG_PIXELFORMAT_BC5_RG: + case SG_PIXELFORMAT_BC5_RGSN: + case SG_PIXELFORMAT_BC6H_RGBF: + case SG_PIXELFORMAT_BC6H_RGBUF: + case SG_PIXELFORMAT_BC7_RGBA: + case SG_PIXELFORMAT_PVRTC_RGB_2BPP: + case SG_PIXELFORMAT_PVRTC_RGB_4BPP: + case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: + case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: + case SG_PIXELFORMAT_ETC2_RGB8: + case SG_PIXELFORMAT_ETC2_RGB8A1: + case SG_PIXELFORMAT_ETC2_RGBA8: + case SG_PIXELFORMAT_ETC2_RG11: + case SG_PIXELFORMAT_ETC2_RG11SN: + return true; + default: + return false; + } +} + +/* return true if pixel format is a valid render target format */ +_SOKOL_PRIVATE bool _sg_is_valid_rendertarget_color_format(sg_pixel_format fmt) { + const int fmt_index = (int) fmt; + SOKOL_ASSERT((fmt_index >= 0) && (fmt_index < _SG_PIXELFORMAT_NUM)); + return _sg.formats[fmt_index].render && !_sg.formats[fmt_index].depth; +} + +/* return true if pixel format is a valid depth format */ +_SOKOL_PRIVATE bool _sg_is_valid_rendertarget_depth_format(sg_pixel_format fmt) { + const int fmt_index = (int) fmt; + SOKOL_ASSERT((fmt_index >= 0) && (fmt_index < _SG_PIXELFORMAT_NUM)); + return _sg.formats[fmt_index].render && _sg.formats[fmt_index].depth; +} + +/* return true if pixel format is a depth-stencil format */ +_SOKOL_PRIVATE bool _sg_is_depth_stencil_format(sg_pixel_format fmt) { + return (SG_PIXELFORMAT_DEPTH_STENCIL == fmt); +} + +/* return the bytes-per-pixel for a pixel format */ +_SOKOL_PRIVATE int _sg_pixelformat_bytesize(sg_pixel_format fmt) { + switch (fmt) { + case SG_PIXELFORMAT_R8: + case SG_PIXELFORMAT_R8SN: + case SG_PIXELFORMAT_R8UI: + case SG_PIXELFORMAT_R8SI: + return 1; + + case SG_PIXELFORMAT_R16: + case SG_PIXELFORMAT_R16SN: + case SG_PIXELFORMAT_R16UI: + case SG_PIXELFORMAT_R16SI: + case SG_PIXELFORMAT_R16F: + case SG_PIXELFORMAT_RG8: + case SG_PIXELFORMAT_RG8SN: + case SG_PIXELFORMAT_RG8UI: + case SG_PIXELFORMAT_RG8SI: + return 2; + + case SG_PIXELFORMAT_R32UI: + case SG_PIXELFORMAT_R32SI: + case SG_PIXELFORMAT_R32F: + case SG_PIXELFORMAT_RG16: + case SG_PIXELFORMAT_RG16SN: + case SG_PIXELFORMAT_RG16UI: + case SG_PIXELFORMAT_RG16SI: + case SG_PIXELFORMAT_RG16F: + case SG_PIXELFORMAT_RGBA8: + case SG_PIXELFORMAT_RGBA8SN: + case SG_PIXELFORMAT_RGBA8UI: + case SG_PIXELFORMAT_RGBA8SI: + case SG_PIXELFORMAT_BGRA8: + case SG_PIXELFORMAT_RGB10A2: + case SG_PIXELFORMAT_RG11B10F: + return 4; + + case SG_PIXELFORMAT_RG32UI: + case SG_PIXELFORMAT_RG32SI: + case SG_PIXELFORMAT_RG32F: + case SG_PIXELFORMAT_RGBA16: + case SG_PIXELFORMAT_RGBA16SN: + case SG_PIXELFORMAT_RGBA16UI: + case SG_PIXELFORMAT_RGBA16SI: + case SG_PIXELFORMAT_RGBA16F: + return 8; + + case SG_PIXELFORMAT_RGBA32UI: + case SG_PIXELFORMAT_RGBA32SI: + case SG_PIXELFORMAT_RGBA32F: + return 16; + + default: + SOKOL_UNREACHABLE; + return 0; + } +} + +_SOKOL_PRIVATE int _sg_roundup(int val, int round_to) { + return (val+(round_to-1)) & ~(round_to-1); +} + +/* return row pitch for an image + + see ComputePitch in https://github.com/microsoft/DirectXTex/blob/master/DirectXTex/DirectXTexUtil.cpp + + For the special PVRTC pitch computation, see: + GL extension requirement (https://www.khronos.org/registry/OpenGL/extensions/IMG/IMG_texture_compression_pvrtc.txt) + + Quote: + + 6) How is the imageSize argument calculated for the CompressedTexImage2D + and CompressedTexSubImage2D functions. + + Resolution: For PVRTC 4BPP formats the imageSize is calculated as: + ( max(width, 8) * max(height, 8) * 4 + 7) / 8 + For PVRTC 2BPP formats the imageSize is calculated as: + ( max(width, 16) * max(height, 8) * 2 + 7) / 8 +*/ +_SOKOL_PRIVATE int _sg_row_pitch(sg_pixel_format fmt, int width, int row_align) { + int pitch; + switch (fmt) { + case SG_PIXELFORMAT_BC1_RGBA: + case SG_PIXELFORMAT_BC4_R: + case SG_PIXELFORMAT_BC4_RSN: + case SG_PIXELFORMAT_ETC2_RGB8: + case SG_PIXELFORMAT_ETC2_RGB8A1: + pitch = ((width + 3) / 4) * 8; + pitch = pitch < 8 ? 8 : pitch; + break; + case SG_PIXELFORMAT_BC2_RGBA: + case SG_PIXELFORMAT_BC3_RGBA: + case SG_PIXELFORMAT_BC5_RG: + case SG_PIXELFORMAT_BC5_RGSN: + case SG_PIXELFORMAT_BC6H_RGBF: + case SG_PIXELFORMAT_BC6H_RGBUF: + case SG_PIXELFORMAT_BC7_RGBA: + case SG_PIXELFORMAT_ETC2_RGBA8: + case SG_PIXELFORMAT_ETC2_RG11: + case SG_PIXELFORMAT_ETC2_RG11SN: + pitch = ((width + 3) / 4) * 16; + pitch = pitch < 16 ? 16 : pitch; + break; + case SG_PIXELFORMAT_PVRTC_RGB_4BPP: + case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: + pitch = (_sg_max(width, 8) * 4 + 7) / 8; + break; + case SG_PIXELFORMAT_PVRTC_RGB_2BPP: + case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: + pitch = (_sg_max(width, 16) * 2 + 7) / 8; + break; + default: + pitch = width * _sg_pixelformat_bytesize(fmt); + break; + } + pitch = _sg_roundup(pitch, row_align); + return pitch; +} + +/* compute the number of rows in a surface depending on pixel format */ +_SOKOL_PRIVATE int _sg_num_rows(sg_pixel_format fmt, int height) { + int num_rows; + switch (fmt) { + case SG_PIXELFORMAT_BC1_RGBA: + case SG_PIXELFORMAT_BC4_R: + case SG_PIXELFORMAT_BC4_RSN: + case SG_PIXELFORMAT_ETC2_RGB8: + case SG_PIXELFORMAT_ETC2_RGB8A1: + case SG_PIXELFORMAT_ETC2_RGBA8: + case SG_PIXELFORMAT_ETC2_RG11: + case SG_PIXELFORMAT_ETC2_RG11SN: + case SG_PIXELFORMAT_BC2_RGBA: + case SG_PIXELFORMAT_BC3_RGBA: + case SG_PIXELFORMAT_BC5_RG: + case SG_PIXELFORMAT_BC5_RGSN: + case SG_PIXELFORMAT_BC6H_RGBF: + case SG_PIXELFORMAT_BC6H_RGBUF: + case SG_PIXELFORMAT_BC7_RGBA: + num_rows = ((height + 3) / 4); + break; + case SG_PIXELFORMAT_PVRTC_RGB_4BPP: + case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: + case SG_PIXELFORMAT_PVRTC_RGB_2BPP: + case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: + /* NOTE: this is most likely not correct because it ignores any + PVCRTC block size, but multiplied with _sg_row_pitch() + it gives the correct surface pitch. + + See: https://www.khronos.org/registry/OpenGL/extensions/IMG/IMG_texture_compression_pvrtc.txt + */ + num_rows = ((_sg_max(height, 8) + 7) / 8) * 8; + break; + default: + num_rows = height; + break; + } + if (num_rows < 1) { + num_rows = 1; + } + return num_rows; +} + +/* return pitch of a 2D subimage / texture slice + see ComputePitch in https://github.com/microsoft/DirectXTex/blob/master/DirectXTex/DirectXTexUtil.cpp +*/ +_SOKOL_PRIVATE int _sg_surface_pitch(sg_pixel_format fmt, int width, int height, int row_align) { + int num_rows = _sg_num_rows(fmt, height); + return num_rows * _sg_row_pitch(fmt, width, row_align); +} + +/* capability table pixel format helper functions */ +_SOKOL_PRIVATE void _sg_pixelformat_all(sg_pixelformat_info* pfi) { + pfi->sample = true; + pfi->filter = true; + pfi->blend = true; + pfi->render = true; + pfi->msaa = true; +} + +_SOKOL_PRIVATE void _sg_pixelformat_s(sg_pixelformat_info* pfi) { + pfi->sample = true; +} + +_SOKOL_PRIVATE void _sg_pixelformat_sf(sg_pixelformat_info* pfi) { + pfi->sample = true; + pfi->filter = true; +} + +_SOKOL_PRIVATE void _sg_pixelformat_sr(sg_pixelformat_info* pfi) { + pfi->sample = true; + pfi->render = true; +} + +_SOKOL_PRIVATE void _sg_pixelformat_srmd(sg_pixelformat_info* pfi) { + pfi->sample = true; + pfi->render = true; + pfi->msaa = true; + pfi->depth = true; +} + +_SOKOL_PRIVATE void _sg_pixelformat_srm(sg_pixelformat_info* pfi) { + pfi->sample = true; + pfi->render = true; + pfi->msaa = true; +} + +_SOKOL_PRIVATE void _sg_pixelformat_sfrm(sg_pixelformat_info* pfi) { + pfi->sample = true; + pfi->filter = true; + pfi->render = true; + pfi->msaa = true; +} +_SOKOL_PRIVATE void _sg_pixelformat_sbrm(sg_pixelformat_info* pfi) { + pfi->sample = true; + pfi->blend = true; + pfi->render = true; + pfi->msaa = true; +} + +_SOKOL_PRIVATE void _sg_pixelformat_sbr(sg_pixelformat_info* pfi) { + pfi->sample = true; + pfi->blend = true; + pfi->render = true; +} + +_SOKOL_PRIVATE void _sg_pixelformat_sfbr(sg_pixelformat_info* pfi) { + pfi->sample = true; + pfi->filter = true; + pfi->blend = true; + pfi->render = true; +} + +/* resolve pass action defaults into a new pass action struct */ +_SOKOL_PRIVATE void _sg_resolve_default_pass_action(const sg_pass_action* from, sg_pass_action* to) { + SOKOL_ASSERT(from && to); + *to = *from; + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + if (to->colors[i].action == _SG_ACTION_DEFAULT) { + to->colors[i].action = SG_ACTION_CLEAR; + to->colors[i].value.r = SG_DEFAULT_CLEAR_RED; + to->colors[i].value.g = SG_DEFAULT_CLEAR_GREEN; + to->colors[i].value.b = SG_DEFAULT_CLEAR_BLUE; + to->colors[i].value.a = SG_DEFAULT_CLEAR_ALPHA; + } + } + if (to->depth.action == _SG_ACTION_DEFAULT) { + to->depth.action = SG_ACTION_CLEAR; + to->depth.value = SG_DEFAULT_CLEAR_DEPTH; + } + if (to->stencil.action == _SG_ACTION_DEFAULT) { + to->stencil.action = SG_ACTION_CLEAR; + to->stencil.value = SG_DEFAULT_CLEAR_STENCIL; + } +} + +/*== DUMMY BACKEND IMPL ======================================================*/ +#if defined(SOKOL_DUMMY_BACKEND) + +_SOKOL_PRIVATE void _sg_dummy_setup_backend(const sg_desc* desc) { + SOKOL_ASSERT(desc); + _SOKOL_UNUSED(desc); + _sg.backend = SG_BACKEND_DUMMY; + for (int i = SG_PIXELFORMAT_R8; i < SG_PIXELFORMAT_BC1_RGBA; i++) { + _sg.formats[i].sample = true; + _sg.formats[i].filter = true; + _sg.formats[i].render = true; + _sg.formats[i].blend = true; + _sg.formats[i].msaa = true; + } + _sg.formats[SG_PIXELFORMAT_DEPTH].depth = true; + _sg.formats[SG_PIXELFORMAT_DEPTH_STENCIL].depth = true; +} + +_SOKOL_PRIVATE void _sg_dummy_discard_backend(void) { + /* empty */ +} + +_SOKOL_PRIVATE void _sg_dummy_reset_state_cache(void) { + /* empty*/ +} + +_SOKOL_PRIVATE sg_resource_state _sg_dummy_create_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + _SOKOL_UNUSED(ctx); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_dummy_destroy_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + _SOKOL_UNUSED(ctx); +} + +_SOKOL_PRIVATE void _sg_dummy_activate_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + _SOKOL_UNUSED(ctx); +} + +_SOKOL_PRIVATE sg_resource_state _sg_dummy_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) { + SOKOL_ASSERT(buf && desc); + _sg_buffer_common_init(&buf->cmn, desc); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_dummy_destroy_buffer(_sg_buffer_t* buf) { + SOKOL_ASSERT(buf); + _SOKOL_UNUSED(buf); +} + +_SOKOL_PRIVATE sg_resource_state _sg_dummy_create_image(_sg_image_t* img, const sg_image_desc* desc) { + SOKOL_ASSERT(img && desc); + _sg_image_common_init(&img->cmn, desc); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_dummy_destroy_image(_sg_image_t* img) { + SOKOL_ASSERT(img); + _SOKOL_UNUSED(img); +} + +_SOKOL_PRIVATE sg_resource_state _sg_dummy_create_shader(_sg_shader_t* shd, const sg_shader_desc* desc) { + SOKOL_ASSERT(shd && desc); + _sg_shader_common_init(&shd->cmn, desc); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_dummy_destroy_shader(_sg_shader_t* shd) { + SOKOL_ASSERT(shd); + _SOKOL_UNUSED(shd); +} + +_SOKOL_PRIVATE sg_resource_state _sg_dummy_create_pipeline(_sg_pipeline_t* pip, _sg_shader_t* shd, const sg_pipeline_desc* desc) { + SOKOL_ASSERT(pip && desc); + pip->shader = shd; + _sg_pipeline_common_init(&pip->cmn, desc); + for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) { + const sg_vertex_attr_desc* a_desc = &desc->layout.attrs[attr_index]; + if (a_desc->format == SG_VERTEXFORMAT_INVALID) { + break; + } + SOKOL_ASSERT(a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS); + pip->cmn.vertex_layout_valid[a_desc->buffer_index] = true; + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_dummy_destroy_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + _SOKOL_UNUSED(pip); +} + +_SOKOL_PRIVATE sg_resource_state _sg_dummy_create_pass(_sg_pass_t* pass, _sg_image_t** att_images, const sg_pass_desc* desc) { + SOKOL_ASSERT(pass && desc); + SOKOL_ASSERT(att_images && att_images[0]); + + _sg_pass_common_init(&pass->cmn, desc); + + const sg_pass_attachment_desc* att_desc; + for (int i = 0; i < pass->cmn.num_color_atts; i++) { + att_desc = &desc->color_attachments[i]; + SOKOL_ASSERT(att_desc->image.id != SG_INVALID_ID); + SOKOL_ASSERT(0 == pass->dmy.color_atts[i].image); + SOKOL_ASSERT(att_images[i] && (att_images[i]->slot.id == att_desc->image.id)); + SOKOL_ASSERT(_sg_is_valid_rendertarget_color_format(att_images[i]->cmn.pixel_format)); + pass->dmy.color_atts[i].image = att_images[i]; + } + + SOKOL_ASSERT(0 == pass->dmy.ds_att.image); + att_desc = &desc->depth_stencil_attachment; + if (att_desc->image.id != SG_INVALID_ID) { + const int ds_img_index = SG_MAX_COLOR_ATTACHMENTS; + SOKOL_ASSERT(att_images[ds_img_index] && (att_images[ds_img_index]->slot.id == att_desc->image.id)); + SOKOL_ASSERT(_sg_is_valid_rendertarget_depth_format(att_images[ds_img_index]->cmn.pixel_format)); + pass->dmy.ds_att.image = att_images[ds_img_index]; + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_dummy_destroy_pass(_sg_pass_t* pass) { + SOKOL_ASSERT(pass); + _SOKOL_UNUSED(pass); +} + +_SOKOL_PRIVATE _sg_image_t* _sg_dummy_pass_color_image(const _sg_pass_t* pass, int index) { + SOKOL_ASSERT(pass && (index >= 0) && (index < SG_MAX_COLOR_ATTACHMENTS)); + /* NOTE: may return null */ + return pass->dmy.color_atts[index].image; +} + +_SOKOL_PRIVATE _sg_image_t* _sg_dummy_pass_ds_image(const _sg_pass_t* pass) { + /* NOTE: may return null */ + SOKOL_ASSERT(pass); + return pass->dmy.ds_att.image; +} + +_SOKOL_PRIVATE void _sg_dummy_begin_pass(_sg_pass_t* pass, const sg_pass_action* action, int w, int h) { + SOKOL_ASSERT(action); + _SOKOL_UNUSED(pass); + _SOKOL_UNUSED(action); + _SOKOL_UNUSED(w); + _SOKOL_UNUSED(h); +} + +_SOKOL_PRIVATE void _sg_dummy_end_pass(void) { + /* empty */ +} + +_SOKOL_PRIVATE void _sg_dummy_commit(void) { + /* empty */ +} + +_SOKOL_PRIVATE void _sg_dummy_apply_viewport(int x, int y, int w, int h, bool origin_top_left) { + _SOKOL_UNUSED(x); + _SOKOL_UNUSED(y); + _SOKOL_UNUSED(w); + _SOKOL_UNUSED(h); + _SOKOL_UNUSED(origin_top_left); +} + +_SOKOL_PRIVATE void _sg_dummy_apply_scissor_rect(int x, int y, int w, int h, bool origin_top_left) { + _SOKOL_UNUSED(x); + _SOKOL_UNUSED(y); + _SOKOL_UNUSED(w); + _SOKOL_UNUSED(h); + _SOKOL_UNUSED(origin_top_left); +} + +_SOKOL_PRIVATE void _sg_dummy_apply_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + _SOKOL_UNUSED(pip); +} + +_SOKOL_PRIVATE void _sg_dummy_apply_bindings( + _sg_pipeline_t* pip, + _sg_buffer_t** vbs, const int* vb_offsets, int num_vbs, + _sg_buffer_t* ib, int ib_offset, + _sg_image_t** vs_imgs, int num_vs_imgs, + _sg_image_t** fs_imgs, int num_fs_imgs) +{ + SOKOL_ASSERT(pip); + SOKOL_ASSERT(vbs && vb_offsets); + SOKOL_ASSERT(vs_imgs); + SOKOL_ASSERT(fs_imgs); + _SOKOL_UNUSED(pip); + _SOKOL_UNUSED(vbs); _SOKOL_UNUSED(vb_offsets); _SOKOL_UNUSED(num_vbs); + _SOKOL_UNUSED(ib); _SOKOL_UNUSED(ib_offset); + _SOKOL_UNUSED(vs_imgs); _SOKOL_UNUSED(num_vs_imgs); + _SOKOL_UNUSED(fs_imgs); _SOKOL_UNUSED(num_fs_imgs); +} + +_SOKOL_PRIVATE void _sg_dummy_apply_uniforms(sg_shader_stage stage_index, int ub_index, const sg_range* data) { + _SOKOL_UNUSED(stage_index); + _SOKOL_UNUSED(ub_index); + _SOKOL_UNUSED(data); +} + +_SOKOL_PRIVATE void _sg_dummy_draw(int base_element, int num_elements, int num_instances) { + _SOKOL_UNUSED(base_element); + _SOKOL_UNUSED(num_elements); + _SOKOL_UNUSED(num_instances); +} + +_SOKOL_PRIVATE void _sg_dummy_update_buffer(_sg_buffer_t* buf, const sg_range* data) { + SOKOL_ASSERT(buf && data && data->ptr && (data->size > 0)); + _SOKOL_UNUSED(data); + if (++buf->cmn.active_slot >= buf->cmn.num_slots) { + buf->cmn.active_slot = 0; + } +} + +_SOKOL_PRIVATE int _sg_dummy_append_buffer(_sg_buffer_t* buf, const sg_range* data, bool new_frame) { + SOKOL_ASSERT(buf && data && data->ptr && (data->size > 0)); + _SOKOL_UNUSED(data); + if (new_frame) { + if (++buf->cmn.active_slot >= buf->cmn.num_slots) { + buf->cmn.active_slot = 0; + } + } + /* NOTE: this is a requirement from WebGPU, but we want identical behaviour across all backend */ + return _sg_roundup((int)data->size, 4); +} + +_SOKOL_PRIVATE void _sg_dummy_update_image(_sg_image_t* img, const sg_image_data* data) { + SOKOL_ASSERT(img && data); + _SOKOL_UNUSED(data); + if (++img->cmn.active_slot >= img->cmn.num_slots) { + img->cmn.active_slot = 0; + } +} + +/*== GL BACKEND ==============================================================*/ +#elif defined(_SOKOL_ANY_GL) + +/*=== OPTIONAL GL LOADER FOR WIN32 ===========================================*/ +#if defined(_SOKOL_USE_WIN32_GL_LOADER) + +// X Macro list of GL function names and signatures +#define _SG_GL_FUNCS \ +_SG_XMACRO(glBindVertexArray, void, (GLuint array)) \ +_SG_XMACRO(glFramebufferTextureLayer, void, (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)) \ +_SG_XMACRO(glGenFramebuffers, void, (GLsizei n, GLuint * framebuffers)) \ +_SG_XMACRO(glBindFramebuffer, void, (GLenum target, GLuint framebuffer)) \ +_SG_XMACRO(glBindRenderbuffer, void, (GLenum target, GLuint renderbuffer)) \ +_SG_XMACRO(glGetStringi, const GLubyte *, (GLenum name, GLuint index)) \ +_SG_XMACRO(glClearBufferfi, void, (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)) \ +_SG_XMACRO(glClearBufferfv, void, (GLenum buffer, GLint drawbuffer, const GLfloat * value)) \ +_SG_XMACRO(glClearBufferuiv, void, (GLenum buffer, GLint drawbuffer, const GLuint * value)) \ +_SG_XMACRO(glClearBufferiv, void, (GLenum buffer, GLint drawbuffer, const GLint * value)) \ +_SG_XMACRO(glDeleteRenderbuffers, void, (GLsizei n, const GLuint * renderbuffers)) \ +_SG_XMACRO(glUniform1fv, void, (GLint location, GLsizei count, const GLfloat * value)) \ +_SG_XMACRO(glUniform2fv, void, (GLint location, GLsizei count, const GLfloat * value)) \ +_SG_XMACRO(glUniform3fv, void, (GLint location, GLsizei count, const GLfloat * value)) \ +_SG_XMACRO(glUniform4fv, void, (GLint location, GLsizei count, const GLfloat * value)) \ +_SG_XMACRO(glUniform1iv, void, (GLint location, GLsizei count, const GLint * value)) \ +_SG_XMACRO(glUniform2iv, void, (GLint location, GLsizei count, const GLint * value)) \ +_SG_XMACRO(glUniform3iv, void, (GLint location, GLsizei count, const GLint * value)) \ +_SG_XMACRO(glUniform4iv, void, (GLint location, GLsizei count, const GLint * value)) \ +_SG_XMACRO(glUniformMatrix4fv, void, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)) \ +_SG_XMACRO(glUseProgram, void, (GLuint program)) \ +_SG_XMACRO(glShaderSource, void, (GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length)) \ +_SG_XMACRO(glLinkProgram, void, (GLuint program)) \ +_SG_XMACRO(glGetUniformLocation, GLint, (GLuint program, const GLchar * name)) \ +_SG_XMACRO(glGetShaderiv, void, (GLuint shader, GLenum pname, GLint * params)) \ +_SG_XMACRO(glGetProgramInfoLog, void, (GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog)) \ +_SG_XMACRO(glGetAttribLocation, GLint, (GLuint program, const GLchar * name)) \ +_SG_XMACRO(glDisableVertexAttribArray, void, (GLuint index)) \ +_SG_XMACRO(glDeleteShader, void, (GLuint shader)) \ +_SG_XMACRO(glDeleteProgram, void, (GLuint program)) \ +_SG_XMACRO(glCompileShader, void, (GLuint shader)) \ +_SG_XMACRO(glStencilFuncSeparate, void, (GLenum face, GLenum func, GLint ref, GLuint mask)) \ +_SG_XMACRO(glStencilOpSeparate, void, (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)) \ +_SG_XMACRO(glRenderbufferStorageMultisample, void, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)) \ +_SG_XMACRO(glDrawBuffers, void, (GLsizei n, const GLenum * bufs)) \ +_SG_XMACRO(glVertexAttribDivisor, void, (GLuint index, GLuint divisor)) \ +_SG_XMACRO(glBufferSubData, void, (GLenum target, GLintptr offset, GLsizeiptr size, const void * data)) \ +_SG_XMACRO(glGenBuffers, void, (GLsizei n, GLuint * buffers)) \ +_SG_XMACRO(glCheckFramebufferStatus, GLenum, (GLenum target)) \ +_SG_XMACRO(glFramebufferRenderbuffer, void, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)) \ +_SG_XMACRO(glCompressedTexImage2D, void, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data)) \ +_SG_XMACRO(glCompressedTexImage3D, void, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data)) \ +_SG_XMACRO(glActiveTexture, void, (GLenum texture)) \ +_SG_XMACRO(glTexSubImage3D, void, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels)) \ +_SG_XMACRO(glRenderbufferStorage, void, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height)) \ +_SG_XMACRO(glGenTextures, void, (GLsizei n, GLuint * textures)) \ +_SG_XMACRO(glPolygonOffset, void, (GLfloat factor, GLfloat units)) \ +_SG_XMACRO(glDrawElements, void, (GLenum mode, GLsizei count, GLenum type, const void * indices)) \ +_SG_XMACRO(glDeleteFramebuffers, void, (GLsizei n, const GLuint * framebuffers)) \ +_SG_XMACRO(glBlendEquationSeparate, void, (GLenum modeRGB, GLenum modeAlpha)) \ +_SG_XMACRO(glDeleteTextures, void, (GLsizei n, const GLuint * textures)) \ +_SG_XMACRO(glGetProgramiv, void, (GLuint program, GLenum pname, GLint * params)) \ +_SG_XMACRO(glBindTexture, void, (GLenum target, GLuint texture)) \ +_SG_XMACRO(glTexImage3D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels)) \ +_SG_XMACRO(glCreateShader, GLuint, (GLenum type)) \ +_SG_XMACRO(glTexSubImage2D, void, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels)) \ +_SG_XMACRO(glClearDepth, void, (GLdouble depth)) \ +_SG_XMACRO(glFramebufferTexture2D, void, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)) \ +_SG_XMACRO(glCreateProgram, GLuint, (void)) \ +_SG_XMACRO(glViewport, void, (GLint x, GLint y, GLsizei width, GLsizei height)) \ +_SG_XMACRO(glDeleteBuffers, void, (GLsizei n, const GLuint * buffers)) \ +_SG_XMACRO(glDrawArrays, void, (GLenum mode, GLint first, GLsizei count)) \ +_SG_XMACRO(glDrawElementsInstanced, void, (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount)) \ +_SG_XMACRO(glVertexAttribPointer, void, (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer)) \ +_SG_XMACRO(glUniform1i, void, (GLint location, GLint v0)) \ +_SG_XMACRO(glDisable, void, (GLenum cap)) \ +_SG_XMACRO(glColorMask, void, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)) \ +_SG_XMACRO(glColorMaski, void, (GLuint buf, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)) \ +_SG_XMACRO(glBindBuffer, void, (GLenum target, GLuint buffer)) \ +_SG_XMACRO(glDeleteVertexArrays, void, (GLsizei n, const GLuint * arrays)) \ +_SG_XMACRO(glDepthMask, void, (GLboolean flag)) \ +_SG_XMACRO(glDrawArraysInstanced, void, (GLenum mode, GLint first, GLsizei count, GLsizei instancecount)) \ +_SG_XMACRO(glClearStencil, void, (GLint s)) \ +_SG_XMACRO(glScissor, void, (GLint x, GLint y, GLsizei width, GLsizei height)) \ +_SG_XMACRO(glGenRenderbuffers, void, (GLsizei n, GLuint * renderbuffers)) \ +_SG_XMACRO(glBufferData, void, (GLenum target, GLsizeiptr size, const void * data, GLenum usage)) \ +_SG_XMACRO(glBlendFuncSeparate, void, (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)) \ +_SG_XMACRO(glTexParameteri, void, (GLenum target, GLenum pname, GLint param)) \ +_SG_XMACRO(glGetIntegerv, void, (GLenum pname, GLint * data)) \ +_SG_XMACRO(glEnable, void, (GLenum cap)) \ +_SG_XMACRO(glBlitFramebuffer, void, (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)) \ +_SG_XMACRO(glStencilMask, void, (GLuint mask)) \ +_SG_XMACRO(glAttachShader, void, (GLuint program, GLuint shader)) \ +_SG_XMACRO(glGetError, GLenum, (void)) \ +_SG_XMACRO(glClearColor, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)) \ +_SG_XMACRO(glBlendColor, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)) \ +_SG_XMACRO(glTexParameterf, void, (GLenum target, GLenum pname, GLfloat param)) \ +_SG_XMACRO(glTexParameterfv, void, (GLenum target, GLenum pname, GLfloat* params)) \ +_SG_XMACRO(glGetShaderInfoLog, void, (GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog)) \ +_SG_XMACRO(glDepthFunc, void, (GLenum func)) \ +_SG_XMACRO(glStencilOp , void, (GLenum fail, GLenum zfail, GLenum zpass)) \ +_SG_XMACRO(glStencilFunc, void, (GLenum func, GLint ref, GLuint mask)) \ +_SG_XMACRO(glEnableVertexAttribArray, void, (GLuint index)) \ +_SG_XMACRO(glBlendFunc, void, (GLenum sfactor, GLenum dfactor)) \ +_SG_XMACRO(glReadBuffer, void, (GLenum src)) \ +_SG_XMACRO(glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * data)) \ +_SG_XMACRO(glClear, void, (GLbitfield mask)) \ +_SG_XMACRO(glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels)) \ +_SG_XMACRO(glGenVertexArrays, void, (GLsizei n, GLuint * arrays)) \ +_SG_XMACRO(glFrontFace, void, (GLenum mode)) \ +_SG_XMACRO(glCullFace, void, (GLenum mode)) + +// generate GL function pointer typedefs +#define _SG_XMACRO(name, ret, args) typedef ret (GL_APIENTRY* PFN_ ## name) args; +_SG_GL_FUNCS +#undef _SG_XMACRO + +// generate GL function pointers +#define _SG_XMACRO(name, ret, args) static PFN_ ## name name; +_SG_GL_FUNCS +#undef _SG_XMACRO + +// helper function to lookup GL functions in GL DLL +typedef PROC (WINAPI * _sg_wglGetProcAddress)(LPCSTR); +_SOKOL_PRIVATE void* _sg_gl_getprocaddr(const char* name, _sg_wglGetProcAddress wgl_getprocaddress) { + void* proc_addr = (void*) wgl_getprocaddress(name); + if (0 == proc_addr) { + proc_addr = (void*) GetProcAddress(_sg.gl.opengl32_dll, name); + } + SOKOL_ASSERT(proc_addr); + return proc_addr; +} + +// populate GL function pointers +_SOKOL_PRIVATE void _sg_gl_load_opengl(void) { + SOKOL_ASSERT(0 == _sg.gl.opengl32_dll); + _sg.gl.opengl32_dll = LoadLibraryA("opengl32.dll"); + SOKOL_ASSERT(_sg.gl.opengl32_dll); + _sg_wglGetProcAddress wgl_getprocaddress = (_sg_wglGetProcAddress) GetProcAddress(_sg.gl.opengl32_dll, "wglGetProcAddress"); + SOKOL_ASSERT(wgl_getprocaddress); +#define _SG_XMACRO(name, ret, args) name = (PFN_ ## name) _sg_gl_getprocaddr(#name, wgl_getprocaddress); + _SG_GL_FUNCS +#undef _SG_XMACRO +} + +_SOKOL_PRIVATE void _sg_gl_unload_opengl(void) { + SOKOL_ASSERT(_sg.gl.opengl32_dll); + FreeLibrary(_sg.gl.opengl32_dll); + _sg.gl.opengl32_dll = 0; +} +#endif // _SOKOL_USE_WIN32_GL_LOADER + +/*-- type translation --------------------------------------------------------*/ +_SOKOL_PRIVATE GLenum _sg_gl_buffer_target(sg_buffer_type t) { + switch (t) { + case SG_BUFFERTYPE_VERTEXBUFFER: return GL_ARRAY_BUFFER; + case SG_BUFFERTYPE_INDEXBUFFER: return GL_ELEMENT_ARRAY_BUFFER; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_texture_target(sg_image_type t) { + switch (t) { + case SG_IMAGETYPE_2D: return GL_TEXTURE_2D; + case SG_IMAGETYPE_CUBE: return GL_TEXTURE_CUBE_MAP; +#if !defined(SOKOL_GLES2) + case SG_IMAGETYPE_3D: return GL_TEXTURE_3D; + case SG_IMAGETYPE_ARRAY: return GL_TEXTURE_2D_ARRAY; +#endif + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_usage(sg_usage u) { + switch (u) { + case SG_USAGE_IMMUTABLE: return GL_STATIC_DRAW; + case SG_USAGE_DYNAMIC: return GL_DYNAMIC_DRAW; + case SG_USAGE_STREAM: return GL_STREAM_DRAW; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_shader_stage(sg_shader_stage stage) { + switch (stage) { + case SG_SHADERSTAGE_VS: return GL_VERTEX_SHADER; + case SG_SHADERSTAGE_FS: return GL_FRAGMENT_SHADER; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLint _sg_gl_vertexformat_size(sg_vertex_format fmt) { + switch (fmt) { + case SG_VERTEXFORMAT_FLOAT: return 1; + case SG_VERTEXFORMAT_FLOAT2: return 2; + case SG_VERTEXFORMAT_FLOAT3: return 3; + case SG_VERTEXFORMAT_FLOAT4: return 4; + case SG_VERTEXFORMAT_BYTE4: return 4; + case SG_VERTEXFORMAT_BYTE4N: return 4; + case SG_VERTEXFORMAT_UBYTE4: return 4; + case SG_VERTEXFORMAT_UBYTE4N: return 4; + case SG_VERTEXFORMAT_SHORT2: return 2; + case SG_VERTEXFORMAT_SHORT2N: return 2; + case SG_VERTEXFORMAT_USHORT2N: return 2; + case SG_VERTEXFORMAT_SHORT4: return 4; + case SG_VERTEXFORMAT_SHORT4N: return 4; + case SG_VERTEXFORMAT_USHORT4N: return 4; + case SG_VERTEXFORMAT_UINT10_N2: return 4; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_vertexformat_type(sg_vertex_format fmt) { + switch (fmt) { + case SG_VERTEXFORMAT_FLOAT: + case SG_VERTEXFORMAT_FLOAT2: + case SG_VERTEXFORMAT_FLOAT3: + case SG_VERTEXFORMAT_FLOAT4: + return GL_FLOAT; + case SG_VERTEXFORMAT_BYTE4: + case SG_VERTEXFORMAT_BYTE4N: + return GL_BYTE; + case SG_VERTEXFORMAT_UBYTE4: + case SG_VERTEXFORMAT_UBYTE4N: + return GL_UNSIGNED_BYTE; + case SG_VERTEXFORMAT_SHORT2: + case SG_VERTEXFORMAT_SHORT2N: + case SG_VERTEXFORMAT_SHORT4: + case SG_VERTEXFORMAT_SHORT4N: + return GL_SHORT; + case SG_VERTEXFORMAT_USHORT2N: + case SG_VERTEXFORMAT_USHORT4N: + return GL_UNSIGNED_SHORT; + case SG_VERTEXFORMAT_UINT10_N2: + return GL_UNSIGNED_INT_2_10_10_10_REV; + default: + SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLboolean _sg_gl_vertexformat_normalized(sg_vertex_format fmt) { + switch (fmt) { + case SG_VERTEXFORMAT_BYTE4N: + case SG_VERTEXFORMAT_UBYTE4N: + case SG_VERTEXFORMAT_SHORT2N: + case SG_VERTEXFORMAT_USHORT2N: + case SG_VERTEXFORMAT_SHORT4N: + case SG_VERTEXFORMAT_USHORT4N: + case SG_VERTEXFORMAT_UINT10_N2: + return GL_TRUE; + default: + return GL_FALSE; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_primitive_type(sg_primitive_type t) { + switch (t) { + case SG_PRIMITIVETYPE_POINTS: return GL_POINTS; + case SG_PRIMITIVETYPE_LINES: return GL_LINES; + case SG_PRIMITIVETYPE_LINE_STRIP: return GL_LINE_STRIP; + case SG_PRIMITIVETYPE_TRIANGLES: return GL_TRIANGLES; + case SG_PRIMITIVETYPE_TRIANGLE_STRIP: return GL_TRIANGLE_STRIP; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_index_type(sg_index_type t) { + switch (t) { + case SG_INDEXTYPE_NONE: return 0; + case SG_INDEXTYPE_UINT16: return GL_UNSIGNED_SHORT; + case SG_INDEXTYPE_UINT32: return GL_UNSIGNED_INT; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_compare_func(sg_compare_func cmp) { + switch (cmp) { + case SG_COMPAREFUNC_NEVER: return GL_NEVER; + case SG_COMPAREFUNC_LESS: return GL_LESS; + case SG_COMPAREFUNC_EQUAL: return GL_EQUAL; + case SG_COMPAREFUNC_LESS_EQUAL: return GL_LEQUAL; + case SG_COMPAREFUNC_GREATER: return GL_GREATER; + case SG_COMPAREFUNC_NOT_EQUAL: return GL_NOTEQUAL; + case SG_COMPAREFUNC_GREATER_EQUAL: return GL_GEQUAL; + case SG_COMPAREFUNC_ALWAYS: return GL_ALWAYS; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_stencil_op(sg_stencil_op op) { + switch (op) { + case SG_STENCILOP_KEEP: return GL_KEEP; + case SG_STENCILOP_ZERO: return GL_ZERO; + case SG_STENCILOP_REPLACE: return GL_REPLACE; + case SG_STENCILOP_INCR_CLAMP: return GL_INCR; + case SG_STENCILOP_DECR_CLAMP: return GL_DECR; + case SG_STENCILOP_INVERT: return GL_INVERT; + case SG_STENCILOP_INCR_WRAP: return GL_INCR_WRAP; + case SG_STENCILOP_DECR_WRAP: return GL_DECR_WRAP; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_blend_factor(sg_blend_factor f) { + switch (f) { + case SG_BLENDFACTOR_ZERO: return GL_ZERO; + case SG_BLENDFACTOR_ONE: return GL_ONE; + case SG_BLENDFACTOR_SRC_COLOR: return GL_SRC_COLOR; + case SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR: return GL_ONE_MINUS_SRC_COLOR; + case SG_BLENDFACTOR_SRC_ALPHA: return GL_SRC_ALPHA; + case SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: return GL_ONE_MINUS_SRC_ALPHA; + case SG_BLENDFACTOR_DST_COLOR: return GL_DST_COLOR; + case SG_BLENDFACTOR_ONE_MINUS_DST_COLOR: return GL_ONE_MINUS_DST_COLOR; + case SG_BLENDFACTOR_DST_ALPHA: return GL_DST_ALPHA; + case SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA: return GL_ONE_MINUS_DST_ALPHA; + case SG_BLENDFACTOR_SRC_ALPHA_SATURATED: return GL_SRC_ALPHA_SATURATE; + case SG_BLENDFACTOR_BLEND_COLOR: return GL_CONSTANT_COLOR; + case SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR: return GL_ONE_MINUS_CONSTANT_COLOR; + case SG_BLENDFACTOR_BLEND_ALPHA: return GL_CONSTANT_ALPHA; + case SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA: return GL_ONE_MINUS_CONSTANT_ALPHA; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_blend_op(sg_blend_op op) { + switch (op) { + case SG_BLENDOP_ADD: return GL_FUNC_ADD; + case SG_BLENDOP_SUBTRACT: return GL_FUNC_SUBTRACT; + case SG_BLENDOP_REVERSE_SUBTRACT: return GL_FUNC_REVERSE_SUBTRACT; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_filter(sg_filter f) { + switch (f) { + case SG_FILTER_NEAREST: return GL_NEAREST; + case SG_FILTER_LINEAR: return GL_LINEAR; + case SG_FILTER_NEAREST_MIPMAP_NEAREST: return GL_NEAREST_MIPMAP_NEAREST; + case SG_FILTER_NEAREST_MIPMAP_LINEAR: return GL_NEAREST_MIPMAP_LINEAR; + case SG_FILTER_LINEAR_MIPMAP_NEAREST: return GL_LINEAR_MIPMAP_NEAREST; + case SG_FILTER_LINEAR_MIPMAP_LINEAR: return GL_LINEAR_MIPMAP_LINEAR; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_wrap(sg_wrap w) { + switch (w) { + case SG_WRAP_CLAMP_TO_EDGE: return GL_CLAMP_TO_EDGE; +#if defined(SOKOL_GLCORE33) + case SG_WRAP_CLAMP_TO_BORDER: return GL_CLAMP_TO_BORDER; +#else + case SG_WRAP_CLAMP_TO_BORDER: return GL_CLAMP_TO_EDGE; +#endif + case SG_WRAP_REPEAT: return GL_REPEAT; + case SG_WRAP_MIRRORED_REPEAT: return GL_MIRRORED_REPEAT; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_teximage_type(sg_pixel_format fmt) { + switch (fmt) { + case SG_PIXELFORMAT_R8: + case SG_PIXELFORMAT_R8UI: + case SG_PIXELFORMAT_RG8: + case SG_PIXELFORMAT_RG8UI: + case SG_PIXELFORMAT_RGBA8: + case SG_PIXELFORMAT_RGBA8UI: + case SG_PIXELFORMAT_BGRA8: + return GL_UNSIGNED_BYTE; + case SG_PIXELFORMAT_R8SN: + case SG_PIXELFORMAT_R8SI: + case SG_PIXELFORMAT_RG8SN: + case SG_PIXELFORMAT_RG8SI: + case SG_PIXELFORMAT_RGBA8SN: + case SG_PIXELFORMAT_RGBA8SI: + return GL_BYTE; + case SG_PIXELFORMAT_R16: + case SG_PIXELFORMAT_R16UI: + case SG_PIXELFORMAT_RG16: + case SG_PIXELFORMAT_RG16UI: + case SG_PIXELFORMAT_RGBA16: + case SG_PIXELFORMAT_RGBA16UI: + return GL_UNSIGNED_SHORT; + case SG_PIXELFORMAT_R16SN: + case SG_PIXELFORMAT_R16SI: + case SG_PIXELFORMAT_RG16SN: + case SG_PIXELFORMAT_RG16SI: + case SG_PIXELFORMAT_RGBA16SN: + case SG_PIXELFORMAT_RGBA16SI: + return GL_SHORT; + case SG_PIXELFORMAT_R16F: + case SG_PIXELFORMAT_RG16F: + case SG_PIXELFORMAT_RGBA16F: + return GL_HALF_FLOAT; + case SG_PIXELFORMAT_R32UI: + case SG_PIXELFORMAT_RG32UI: + case SG_PIXELFORMAT_RGBA32UI: + return GL_UNSIGNED_INT; + case SG_PIXELFORMAT_R32SI: + case SG_PIXELFORMAT_RG32SI: + case SG_PIXELFORMAT_RGBA32SI: + return GL_INT; + case SG_PIXELFORMAT_R32F: + case SG_PIXELFORMAT_RG32F: + case SG_PIXELFORMAT_RGBA32F: + return GL_FLOAT; +#if !defined(SOKOL_GLES2) + case SG_PIXELFORMAT_RGB10A2: + return GL_UNSIGNED_INT_2_10_10_10_REV; + case SG_PIXELFORMAT_RG11B10F: + return GL_UNSIGNED_INT_10F_11F_11F_REV; +#endif + case SG_PIXELFORMAT_DEPTH: + return GL_UNSIGNED_SHORT; + case SG_PIXELFORMAT_DEPTH_STENCIL: + return GL_UNSIGNED_INT_24_8; + default: + SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_teximage_format(sg_pixel_format fmt) { + switch (fmt) { + case SG_PIXELFORMAT_R8: + case SG_PIXELFORMAT_R8SN: + case SG_PIXELFORMAT_R16: + case SG_PIXELFORMAT_R16SN: + case SG_PIXELFORMAT_R16F: + case SG_PIXELFORMAT_R32F: +#if defined(SOKOL_GLES2) + return GL_LUMINANCE; +#else + if (_sg.gl.gles2) { + return GL_LUMINANCE; + } + else { + return GL_RED; + } +#endif +#if !defined(SOKOL_GLES2) + case SG_PIXELFORMAT_R8UI: + case SG_PIXELFORMAT_R8SI: + case SG_PIXELFORMAT_R16UI: + case SG_PIXELFORMAT_R16SI: + case SG_PIXELFORMAT_R32UI: + case SG_PIXELFORMAT_R32SI: + return GL_RED_INTEGER; + case SG_PIXELFORMAT_RG8: + case SG_PIXELFORMAT_RG8SN: + case SG_PIXELFORMAT_RG16: + case SG_PIXELFORMAT_RG16SN: + case SG_PIXELFORMAT_RG16F: + case SG_PIXELFORMAT_RG32F: + return GL_RG; + case SG_PIXELFORMAT_RG8UI: + case SG_PIXELFORMAT_RG8SI: + case SG_PIXELFORMAT_RG16UI: + case SG_PIXELFORMAT_RG16SI: + case SG_PIXELFORMAT_RG32UI: + case SG_PIXELFORMAT_RG32SI: + return GL_RG_INTEGER; +#endif + case SG_PIXELFORMAT_RGBA8: + case SG_PIXELFORMAT_RGBA8SN: + case SG_PIXELFORMAT_RGBA16: + case SG_PIXELFORMAT_RGBA16SN: + case SG_PIXELFORMAT_RGBA16F: + case SG_PIXELFORMAT_RGBA32F: + case SG_PIXELFORMAT_RGB10A2: + return GL_RGBA; +#if !defined(SOKOL_GLES2) + case SG_PIXELFORMAT_RGBA8UI: + case SG_PIXELFORMAT_RGBA8SI: + case SG_PIXELFORMAT_RGBA16UI: + case SG_PIXELFORMAT_RGBA16SI: + case SG_PIXELFORMAT_RGBA32UI: + case SG_PIXELFORMAT_RGBA32SI: + return GL_RGBA_INTEGER; +#endif + case SG_PIXELFORMAT_RG11B10F: + return GL_RGB; + case SG_PIXELFORMAT_DEPTH: + return GL_DEPTH_COMPONENT; + case SG_PIXELFORMAT_DEPTH_STENCIL: + return GL_DEPTH_STENCIL; + case SG_PIXELFORMAT_BC1_RGBA: + return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + case SG_PIXELFORMAT_BC2_RGBA: + return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + case SG_PIXELFORMAT_BC3_RGBA: + return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + case SG_PIXELFORMAT_BC4_R: + return GL_COMPRESSED_RED_RGTC1; + case SG_PIXELFORMAT_BC4_RSN: + return GL_COMPRESSED_SIGNED_RED_RGTC1; + case SG_PIXELFORMAT_BC5_RG: + return GL_COMPRESSED_RED_GREEN_RGTC2; + case SG_PIXELFORMAT_BC5_RGSN: + return GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2; + case SG_PIXELFORMAT_BC6H_RGBF: + return GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB; + case SG_PIXELFORMAT_BC6H_RGBUF: + return GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB; + case SG_PIXELFORMAT_BC7_RGBA: + return GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; + case SG_PIXELFORMAT_PVRTC_RGB_2BPP: + return GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + case SG_PIXELFORMAT_PVRTC_RGB_4BPP: + return GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: + return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: + return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + case SG_PIXELFORMAT_ETC2_RGB8: + return GL_COMPRESSED_RGB8_ETC2; + case SG_PIXELFORMAT_ETC2_RGB8A1: + return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + case SG_PIXELFORMAT_ETC2_RGBA8: + return GL_COMPRESSED_RGBA8_ETC2_EAC; + case SG_PIXELFORMAT_ETC2_RG11: + return GL_COMPRESSED_RG11_EAC; + case SG_PIXELFORMAT_ETC2_RG11SN: + return GL_COMPRESSED_SIGNED_RG11_EAC; + default: + SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_teximage_internal_format(sg_pixel_format fmt) { +#if defined(SOKOL_GLES2) + return _sg_gl_teximage_format(fmt); +#else + if (_sg.gl.gles2) { + return _sg_gl_teximage_format(fmt); + } + else { + switch (fmt) { + case SG_PIXELFORMAT_R8: return GL_R8; + case SG_PIXELFORMAT_R8SN: return GL_R8_SNORM; + case SG_PIXELFORMAT_R8UI: return GL_R8UI; + case SG_PIXELFORMAT_R8SI: return GL_R8I; +#if !defined(SOKOL_GLES3) + case SG_PIXELFORMAT_R16: return GL_R16; + case SG_PIXELFORMAT_R16SN: return GL_R16_SNORM; +#endif + case SG_PIXELFORMAT_R16UI: return GL_R16UI; + case SG_PIXELFORMAT_R16SI: return GL_R16I; + case SG_PIXELFORMAT_R16F: return GL_R16F; + case SG_PIXELFORMAT_RG8: return GL_RG8; + case SG_PIXELFORMAT_RG8SN: return GL_RG8_SNORM; + case SG_PIXELFORMAT_RG8UI: return GL_RG8UI; + case SG_PIXELFORMAT_RG8SI: return GL_RG8I; + case SG_PIXELFORMAT_R32UI: return GL_R32UI; + case SG_PIXELFORMAT_R32SI: return GL_R32I; + case SG_PIXELFORMAT_R32F: return GL_R32F; +#if !defined(SOKOL_GLES3) + case SG_PIXELFORMAT_RG16: return GL_RG16; + case SG_PIXELFORMAT_RG16SN: return GL_RG16_SNORM; +#endif + case SG_PIXELFORMAT_RG16UI: return GL_RG16UI; + case SG_PIXELFORMAT_RG16SI: return GL_RG16I; + case SG_PIXELFORMAT_RG16F: return GL_RG16F; + case SG_PIXELFORMAT_RGBA8: return GL_RGBA8; + case SG_PIXELFORMAT_RGBA8SN: return GL_RGBA8_SNORM; + case SG_PIXELFORMAT_RGBA8UI: return GL_RGBA8UI; + case SG_PIXELFORMAT_RGBA8SI: return GL_RGBA8I; + case SG_PIXELFORMAT_RGB10A2: return GL_RGB10_A2; + case SG_PIXELFORMAT_RG11B10F: return GL_R11F_G11F_B10F; + case SG_PIXELFORMAT_RG32UI: return GL_RG32UI; + case SG_PIXELFORMAT_RG32SI: return GL_RG32I; + case SG_PIXELFORMAT_RG32F: return GL_RG32F; +#if !defined(SOKOL_GLES3) + case SG_PIXELFORMAT_RGBA16: return GL_RGBA16; + case SG_PIXELFORMAT_RGBA16SN: return GL_RGBA16_SNORM; +#endif + case SG_PIXELFORMAT_RGBA16UI: return GL_RGBA16UI; + case SG_PIXELFORMAT_RGBA16SI: return GL_RGBA16I; + case SG_PIXELFORMAT_RGBA16F: return GL_RGBA16F; + case SG_PIXELFORMAT_RGBA32UI: return GL_RGBA32UI; + case SG_PIXELFORMAT_RGBA32SI: return GL_RGBA32I; + case SG_PIXELFORMAT_RGBA32F: return GL_RGBA32F; + case SG_PIXELFORMAT_DEPTH: return GL_DEPTH_COMPONENT16; + case SG_PIXELFORMAT_DEPTH_STENCIL: return GL_DEPTH24_STENCIL8; + case SG_PIXELFORMAT_BC1_RGBA: return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + case SG_PIXELFORMAT_BC2_RGBA: return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + case SG_PIXELFORMAT_BC3_RGBA: return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + case SG_PIXELFORMAT_BC4_R: return GL_COMPRESSED_RED_RGTC1; + case SG_PIXELFORMAT_BC4_RSN: return GL_COMPRESSED_SIGNED_RED_RGTC1; + case SG_PIXELFORMAT_BC5_RG: return GL_COMPRESSED_RED_GREEN_RGTC2; + case SG_PIXELFORMAT_BC5_RGSN: return GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2; + case SG_PIXELFORMAT_BC6H_RGBF: return GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB; + case SG_PIXELFORMAT_BC6H_RGBUF: return GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB; + case SG_PIXELFORMAT_BC7_RGBA: return GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; + case SG_PIXELFORMAT_PVRTC_RGB_2BPP: return GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + case SG_PIXELFORMAT_PVRTC_RGB_4BPP: return GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + case SG_PIXELFORMAT_ETC2_RGB8: return GL_COMPRESSED_RGB8_ETC2; + case SG_PIXELFORMAT_ETC2_RGB8A1: return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + case SG_PIXELFORMAT_ETC2_RGBA8: return GL_COMPRESSED_RGBA8_ETC2_EAC; + case SG_PIXELFORMAT_ETC2_RG11: return GL_COMPRESSED_RG11_EAC; + case SG_PIXELFORMAT_ETC2_RG11SN: return GL_COMPRESSED_SIGNED_RG11_EAC; + default: SOKOL_UNREACHABLE; return 0; + } + } +#endif +} + +_SOKOL_PRIVATE GLenum _sg_gl_cubeface_target(int face_index) { + switch (face_index) { + case 0: return GL_TEXTURE_CUBE_MAP_POSITIVE_X; + case 1: return GL_TEXTURE_CUBE_MAP_NEGATIVE_X; + case 2: return GL_TEXTURE_CUBE_MAP_POSITIVE_Y; + case 3: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y; + case 4: return GL_TEXTURE_CUBE_MAP_POSITIVE_Z; + case 5: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_depth_attachment_format(sg_pixel_format fmt) { + switch (fmt) { + case SG_PIXELFORMAT_DEPTH: return GL_DEPTH_COMPONENT16; + case SG_PIXELFORMAT_DEPTH_STENCIL: return GL_DEPTH24_STENCIL8; + default: SOKOL_UNREACHABLE; return 0; + } +} + +/* see: https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml */ +_SOKOL_PRIVATE void _sg_gl_init_pixelformats(bool has_bgra) { +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R8]); + } + else { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R8]); + } +#else + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R8]); +#endif +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R8SI]); +#if !defined(SOKOL_GLES3) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16SN]); +#endif + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R16SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG8]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG8SI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32UI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32SI]); +#if !defined(SOKOL_GLES3) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16SN]); +#endif + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16SI]); + } +#endif + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA8]); +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA8SI]); + } +#endif + if (has_bgra) { + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_BGRA8]); + } +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGB10A2]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG11B10F]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG32UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG32SI]); +#if !defined(SOKOL_GLES3) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16SN]); +#endif + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA16SI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA32UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA32SI]); + } +#endif + // FIXME: WEBGL_depth_texture extension? + _sg_pixelformat_srmd(&_sg.formats[SG_PIXELFORMAT_DEPTH]); + _sg_pixelformat_srmd(&_sg.formats[SG_PIXELFORMAT_DEPTH_STENCIL]); +} + +/* FIXME: OES_half_float_blend */ +_SOKOL_PRIVATE void _sg_gl_init_pixelformats_half_float(bool has_colorbuffer_half_float, bool has_texture_half_float_linear) { +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + if (has_texture_half_float_linear) { + if (has_colorbuffer_half_float) { + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); + } + else { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R16F]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG16F]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); + } + } + else { + if (has_colorbuffer_half_float) { + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_R16F]); + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RG16F]); + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); + } + else { + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_R16F]); + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RG16F]); + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); + } + } + } + else { +#endif + /* GLES2 can only render to RGBA, and there's no RG format */ + if (has_texture_half_float_linear) { + if (has_colorbuffer_half_float) { + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); + } + else { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); + } + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R16F]); + } + else { + if (has_colorbuffer_half_float) { + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); + } + else { + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); + } + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_R16F]); + } +#if !defined(SOKOL_GLES2) + } +#endif +} + +_SOKOL_PRIVATE void _sg_gl_init_pixelformats_float(bool has_colorbuffer_float, bool has_texture_float_linear, bool has_float_blend) { +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + if (has_texture_float_linear) { + if (has_colorbuffer_float) { + if (has_float_blend) { + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R32F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + else { + _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_R32F]); + _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + } + else { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R32F]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + } + else { + if (has_colorbuffer_float) { + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_R32F]); + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + else { + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_R32F]); + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + } + } + else { +#endif + /* GLES2 can only render to RGBA, and there's no RG format */ + if (has_texture_float_linear) { + if (has_colorbuffer_float) { + if (has_float_blend) { + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + else { + _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + } + else { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R32F]); + } + else { + if (has_colorbuffer_float) { + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + else { + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_R32F]); + } +#if !defined(SOKOL_GLES2) + } +#endif +} + +_SOKOL_PRIVATE void _sg_gl_init_pixelformats_s3tc(void) { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC1_RGBA]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC2_RGBA]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC3_RGBA]); +} + +_SOKOL_PRIVATE void _sg_gl_init_pixelformats_rgtc(void) { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC4_R]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC4_RSN]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC5_RG]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC5_RGSN]); +} + +_SOKOL_PRIVATE void _sg_gl_init_pixelformats_bptc(void) { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC6H_RGBF]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC6H_RGBUF]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC7_RGBA]); +} + +_SOKOL_PRIVATE void _sg_gl_init_pixelformats_pvrtc(void) { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_PVRTC_RGB_2BPP]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_PVRTC_RGB_4BPP]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_PVRTC_RGBA_2BPP]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_PVRTC_RGBA_4BPP]); +} + +_SOKOL_PRIVATE void _sg_gl_init_pixelformats_etc2(void) { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_ETC2_RGB8]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_ETC2_RGB8A1]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_ETC2_RGBA8]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_ETC2_RG11]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_ETC2_RG11SN]); +} + +_SOKOL_PRIVATE void _sg_gl_init_limits(void) { + _SG_GL_CHECK_ERROR(); + GLint gl_int; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_int); + _SG_GL_CHECK_ERROR(); + _sg.limits.max_image_size_2d = gl_int; + _sg.limits.max_image_size_array = gl_int; + glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &gl_int); + _SG_GL_CHECK_ERROR(); + _sg.limits.max_image_size_cube = gl_int; + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &gl_int); + _SG_GL_CHECK_ERROR(); + if (gl_int > SG_MAX_VERTEX_ATTRIBUTES) { + gl_int = SG_MAX_VERTEX_ATTRIBUTES; + } + _sg.limits.max_vertex_attrs = gl_int; + glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &gl_int); + _SG_GL_CHECK_ERROR(); + _sg.limits.gl_max_vertex_uniform_vectors = gl_int; +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &gl_int); + _SG_GL_CHECK_ERROR(); + _sg.limits.max_image_size_3d = gl_int; + glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &gl_int); + _SG_GL_CHECK_ERROR(); + _sg.limits.max_image_array_layers = gl_int; + } +#endif + if (_sg.gl.ext_anisotropic) { + glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_int); + _SG_GL_CHECK_ERROR(); + _sg.gl.max_anisotropy = gl_int; + } + else { + _sg.gl.max_anisotropy = 1; + } + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &gl_int); + _SG_GL_CHECK_ERROR(); + _sg.gl.max_combined_texture_image_units = gl_int; +} + +#if defined(SOKOL_GLCORE33) +_SOKOL_PRIVATE void _sg_gl_init_caps_glcore33(void) { + _sg.backend = SG_BACKEND_GLCORE33; + + _sg.features.origin_top_left = false; + _sg.features.instancing = true; + _sg.features.multiple_render_targets = true; + _sg.features.msaa_render_targets = true; + _sg.features.imagetype_3d = true; + _sg.features.imagetype_array = true; + _sg.features.image_clamp_to_border = true; + _sg.features.mrt_independent_blend_state = false; + _sg.features.mrt_independent_write_mask = true; + + /* scan extensions */ + bool has_s3tc = false; /* BC1..BC3 */ + bool has_rgtc = false; /* BC4 and BC5 */ + bool has_bptc = false; /* BC6H and BC7 */ + bool has_pvrtc = false; + bool has_etc2 = false; + GLint num_ext = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &num_ext); + for (int i = 0; i < num_ext; i++) { + const char* ext = (const char*) glGetStringi(GL_EXTENSIONS, (GLuint)i); + if (ext) { + if (strstr(ext, "_texture_compression_s3tc")) { + has_s3tc = true; + } + else if (strstr(ext, "_texture_compression_rgtc")) { + has_rgtc = true; + } + else if (strstr(ext, "_texture_compression_bptc")) { + has_bptc = true; + } + else if (strstr(ext, "_texture_compression_pvrtc")) { + has_pvrtc = true; + } + else if (strstr(ext, "_ES3_compatibility")) { + has_etc2 = true; + } + else if (strstr(ext, "_texture_filter_anisotropic")) { + _sg.gl.ext_anisotropic = true; + } + } + } + + /* limits */ + _sg_gl_init_limits(); + + /* pixel formats */ + const bool has_bgra = false; /* not a bug */ + const bool has_colorbuffer_float = true; + const bool has_colorbuffer_half_float = true; + const bool has_texture_float_linear = true; /* FIXME??? */ + const bool has_texture_half_float_linear = true; + const bool has_float_blend = true; + _sg_gl_init_pixelformats(has_bgra); + _sg_gl_init_pixelformats_float(has_colorbuffer_float, has_texture_float_linear, has_float_blend); + _sg_gl_init_pixelformats_half_float(has_colorbuffer_half_float, has_texture_half_float_linear); + if (has_s3tc) { + _sg_gl_init_pixelformats_s3tc(); + } + if (has_rgtc) { + _sg_gl_init_pixelformats_rgtc(); + } + if (has_bptc) { + _sg_gl_init_pixelformats_bptc(); + } + if (has_pvrtc) { + _sg_gl_init_pixelformats_pvrtc(); + } + if (has_etc2) { + _sg_gl_init_pixelformats_etc2(); + } +} +#endif + +#if defined(SOKOL_GLES3) +_SOKOL_PRIVATE void _sg_gl_init_caps_gles3(void) { + _sg.backend = SG_BACKEND_GLES3; + + _sg.features.origin_top_left = false; + _sg.features.instancing = true; + _sg.features.multiple_render_targets = true; + _sg.features.msaa_render_targets = true; + _sg.features.imagetype_3d = true; + _sg.features.imagetype_array = true; + _sg.features.image_clamp_to_border = false; + _sg.features.mrt_independent_blend_state = false; + _sg.features.mrt_independent_write_mask = false; + + bool has_s3tc = false; /* BC1..BC3 */ + bool has_rgtc = false; /* BC4 and BC5 */ + bool has_bptc = false; /* BC6H and BC7 */ + bool has_pvrtc = false; +#if defined(__EMSCRIPTEN__) + bool has_etc2 = false; +#else + bool has_etc2 = true; +#endif + bool has_colorbuffer_float = false; + bool has_colorbuffer_half_float = false; + bool has_texture_float_linear = false; + bool has_float_blend = false; + GLint num_ext = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &num_ext); + for (int i = 0; i < num_ext; i++) { + const char* ext = (const char*) glGetStringi(GL_EXTENSIONS, (GLuint)i); + if (ext) { + if (strstr(ext, "_texture_compression_s3tc")) { + has_s3tc = true; + } + else if (strstr(ext, "_compressed_texture_s3tc")) { + has_s3tc = true; + } + else if (strstr(ext, "_texture_compression_rgtc")) { + has_rgtc = true; + } + else if (strstr(ext, "_texture_compression_bptc")) { + has_bptc = true; + } + else if (strstr(ext, "_texture_compression_pvrtc")) { + has_pvrtc = true; + } + else if (strstr(ext, "_compressed_texture_pvrtc")) { + has_pvrtc = true; + } + else if (strstr(ext, "_compressed_texture_etc")) { + has_etc2 = true; + } + else if (strstr(ext, "_color_buffer_float")) { + has_colorbuffer_float = true; + } + else if (strstr(ext, "_color_buffer_half_float")) { + has_colorbuffer_half_float = true; + } + else if (strstr(ext, "_texture_float_linear")) { + has_texture_float_linear = true; + } + else if (strstr(ext, "_float_blend")) { + has_float_blend = true; + } + else if (strstr(ext, "_texture_filter_anisotropic")) { + _sg.gl.ext_anisotropic = true; + } + } + } + + /* on WebGL2, color_buffer_float also includes 16-bit formats + see: https://developer.mozilla.org/en-US/docs/Web/API/EXT_color_buffer_float + */ +#if defined(__EMSCRIPTEN__) + has_colorbuffer_half_float = has_colorbuffer_float; +#endif + + /* limits */ + _sg_gl_init_limits(); + + /* pixel formats */ + const bool has_texture_half_float_linear = true; + const bool has_bgra = false; /* not a bug */ + _sg_gl_init_pixelformats(has_bgra); + _sg_gl_init_pixelformats_float(has_colorbuffer_float, has_texture_float_linear, has_float_blend); + _sg_gl_init_pixelformats_half_float(has_colorbuffer_half_float, has_texture_half_float_linear); + if (has_s3tc) { + _sg_gl_init_pixelformats_s3tc(); + } + if (has_rgtc) { + _sg_gl_init_pixelformats_rgtc(); + } + if (has_bptc) { + _sg_gl_init_pixelformats_bptc(); + } + if (has_pvrtc) { + _sg_gl_init_pixelformats_pvrtc(); + } + if (has_etc2) { + _sg_gl_init_pixelformats_etc2(); + } +} +#endif + +#if defined(SOKOL_GLES3) || defined(SOKOL_GLES2) +_SOKOL_PRIVATE void _sg_gl_init_caps_gles2(void) { + _sg.backend = SG_BACKEND_GLES2; + + bool has_s3tc = false; /* BC1..BC3 */ + bool has_rgtc = false; /* BC4 and BC5 */ + bool has_bptc = false; /* BC6H and BC7 */ + bool has_pvrtc = false; + bool has_etc2 = false; + bool has_texture_float = false; + bool has_texture_float_linear = false; + bool has_colorbuffer_float = false; + bool has_float_blend = false; + bool has_instancing = false; + const char* ext = (const char*) glGetString(GL_EXTENSIONS); + if (ext) { + has_s3tc = strstr(ext, "_texture_compression_s3tc") || strstr(ext, "_compressed_texture_s3tc"); + has_rgtc = strstr(ext, "_texture_compression_rgtc"); + has_bptc = strstr(ext, "_texture_compression_bptc"); + has_pvrtc = strstr(ext, "_texture_compression_pvrtc") || strstr(ext, "_compressed_texture_pvrtc"); + has_etc2 = strstr(ext, "_compressed_texture_etc"); + has_texture_float = strstr(ext, "_texture_float"); + has_texture_float_linear = strstr(ext, "_texture_float_linear"); + has_colorbuffer_float = strstr(ext, "_color_buffer_float"); + has_float_blend = strstr(ext, "_float_blend"); + /* don't bother with half_float support on WebGL1 + has_texture_half_float = strstr(ext, "_texture_half_float"); + has_texture_half_float_linear = strstr(ext, "_texture_half_float_linear"); + has_colorbuffer_half_float = strstr(ext, "_color_buffer_half_float"); + */ + has_instancing = strstr(ext, "_instanced_arrays"); + _sg.gl.ext_anisotropic = strstr(ext, "ext_anisotropic"); + } + + _sg.features.origin_top_left = false; +#if defined(_SOKOL_GL_INSTANCING_ENABLED) + _sg.features.instancing = has_instancing; +#endif + _sg.features.multiple_render_targets = false; + _sg.features.msaa_render_targets = false; + _sg.features.imagetype_3d = false; + _sg.features.imagetype_array = false; + _sg.features.image_clamp_to_border = false; + _sg.features.mrt_independent_blend_state = false; + _sg.features.mrt_independent_write_mask = false; + + /* limits */ + _sg_gl_init_limits(); + + /* pixel formats */ + const bool has_bgra = false; /* not a bug */ + const bool has_texture_half_float = false; + const bool has_texture_half_float_linear = false; + const bool has_colorbuffer_half_float = false; + _sg_gl_init_pixelformats(has_bgra); + if (has_texture_float) { + _sg_gl_init_pixelformats_float(has_colorbuffer_float, has_texture_float_linear, has_float_blend); + } + if (has_texture_half_float) { + _sg_gl_init_pixelformats_half_float(has_colorbuffer_half_float, has_texture_half_float_linear); + } + if (has_s3tc) { + _sg_gl_init_pixelformats_s3tc(); + } + if (has_rgtc) { + _sg_gl_init_pixelformats_rgtc(); + } + if (has_bptc) { + _sg_gl_init_pixelformats_bptc(); + } + if (has_pvrtc) { + _sg_gl_init_pixelformats_pvrtc(); + } + if (has_etc2) { + _sg_gl_init_pixelformats_etc2(); + } + /* GLES2 doesn't allow multi-sampled render targets at all */ + for (int i = 0; i < _SG_PIXELFORMAT_NUM; i++) { + _sg.formats[i].msaa = false; + } +} +#endif + +/*-- state cache implementation ----------------------------------------------*/ +_SOKOL_PRIVATE void _sg_gl_cache_clear_buffer_bindings(bool force) { + if (force || (_sg.gl.cache.vertex_buffer != 0)) { + glBindBuffer(GL_ARRAY_BUFFER, 0); + _sg.gl.cache.vertex_buffer = 0; + } + if (force || (_sg.gl.cache.index_buffer != 0)) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + _sg.gl.cache.index_buffer = 0; + } +} + +_SOKOL_PRIVATE void _sg_gl_cache_bind_buffer(GLenum target, GLuint buffer) { + SOKOL_ASSERT((GL_ARRAY_BUFFER == target) || (GL_ELEMENT_ARRAY_BUFFER == target)); + if (target == GL_ARRAY_BUFFER) { + if (_sg.gl.cache.vertex_buffer != buffer) { + _sg.gl.cache.vertex_buffer = buffer; + glBindBuffer(target, buffer); + } + } + else { + if (_sg.gl.cache.index_buffer != buffer) { + _sg.gl.cache.index_buffer = buffer; + glBindBuffer(target, buffer); + } + } +} + +_SOKOL_PRIVATE void _sg_gl_cache_store_buffer_binding(GLenum target) { + if (target == GL_ARRAY_BUFFER) { + _sg.gl.cache.stored_vertex_buffer = _sg.gl.cache.vertex_buffer; + } + else { + _sg.gl.cache.stored_index_buffer = _sg.gl.cache.index_buffer; + } +} + +_SOKOL_PRIVATE void _sg_gl_cache_restore_buffer_binding(GLenum target) { + if (target == GL_ARRAY_BUFFER) { + if (_sg.gl.cache.stored_vertex_buffer != 0) { + /* we only care restoring valid ids */ + _sg_gl_cache_bind_buffer(target, _sg.gl.cache.stored_vertex_buffer); + _sg.gl.cache.stored_vertex_buffer = 0; + } + } + else { + if (_sg.gl.cache.stored_index_buffer != 0) { + /* we only care restoring valid ids */ + _sg_gl_cache_bind_buffer(target, _sg.gl.cache.stored_index_buffer); + _sg.gl.cache.stored_index_buffer = 0; + } + } +} + +/* called when from _sg_gl_destroy_buffer() */ +_SOKOL_PRIVATE void _sg_gl_cache_invalidate_buffer(GLuint buf) { + if (buf == _sg.gl.cache.vertex_buffer) { + _sg.gl.cache.vertex_buffer = 0; + glBindBuffer(GL_ARRAY_BUFFER, 0); + } + if (buf == _sg.gl.cache.index_buffer) { + _sg.gl.cache.index_buffer = 0; + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + } + if (buf == _sg.gl.cache.stored_vertex_buffer) { + _sg.gl.cache.stored_vertex_buffer = 0; + } + if (buf == _sg.gl.cache.stored_index_buffer) { + _sg.gl.cache.stored_index_buffer = 0; + } + for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTES; i++) { + if (buf == _sg.gl.cache.attrs[i].gl_vbuf) { + _sg.gl.cache.attrs[i].gl_vbuf = 0; + } + } +} + +_SOKOL_PRIVATE void _sg_gl_cache_active_texture(GLenum texture) { + if (_sg.gl.cache.cur_active_texture != texture) { + _sg.gl.cache.cur_active_texture = texture; + glActiveTexture(texture); + } +} + +_SOKOL_PRIVATE void _sg_gl_cache_clear_texture_bindings(bool force) { + for (int i = 0; (i < SG_MAX_SHADERSTAGE_IMAGES) && (i < _sg.gl.max_combined_texture_image_units); i++) { + if (force || (_sg.gl.cache.textures[i].texture != 0)) { + GLenum gl_texture_slot = (GLenum) (GL_TEXTURE0 + i); + glActiveTexture(gl_texture_slot); + glBindTexture(GL_TEXTURE_2D, 0); + glBindTexture(GL_TEXTURE_CUBE_MAP, 0); +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + glBindTexture(GL_TEXTURE_3D, 0); + glBindTexture(GL_TEXTURE_2D_ARRAY, 0); + } +#endif + _sg.gl.cache.textures[i].target = 0; + _sg.gl.cache.textures[i].texture = 0; + _sg.gl.cache.cur_active_texture = gl_texture_slot; + } + } +} + +_SOKOL_PRIVATE void _sg_gl_cache_bind_texture(int slot_index, GLenum target, GLuint texture) { + /* it's valid to call this function with target=0 and/or texture=0 + target=0 will unbind the previous binding, texture=0 will clear + the new binding + */ + SOKOL_ASSERT(slot_index < SG_MAX_SHADERSTAGE_IMAGES); + if (slot_index >= _sg.gl.max_combined_texture_image_units) { + return; + } + _sg_gl_texture_bind_slot* slot = &_sg.gl.cache.textures[slot_index]; + if ((slot->target != target) || (slot->texture != texture)) { + _sg_gl_cache_active_texture((GLenum)(GL_TEXTURE0 + slot_index)); + /* if the target has changed, clear the previous binding on that target */ + if ((target != slot->target) && (slot->target != 0)) { + glBindTexture(slot->target, 0); + } + /* apply new binding (texture can be 0 to unbind) */ + if (target != 0) { + glBindTexture(target, texture); + } + slot->target = target; + slot->texture = texture; + } +} + +_SOKOL_PRIVATE void _sg_gl_cache_store_texture_binding(int slot_index) { + SOKOL_ASSERT(slot_index < SG_MAX_SHADERSTAGE_IMAGES); + _sg.gl.cache.stored_texture = _sg.gl.cache.textures[slot_index]; +} + +_SOKOL_PRIVATE void _sg_gl_cache_restore_texture_binding(int slot_index) { + SOKOL_ASSERT(slot_index < SG_MAX_SHADERSTAGE_IMAGES); + _sg_gl_texture_bind_slot* slot = &_sg.gl.cache.stored_texture; + if (slot->texture != 0) { + /* we only care restoring valid ids */ + SOKOL_ASSERT(slot->target != 0); + _sg_gl_cache_bind_texture(slot_index, slot->target, slot->texture); + slot->target = 0; + slot->texture = 0; + } +} + +/* called from _sg_gl_destroy_texture() */ +_SOKOL_PRIVATE void _sg_gl_cache_invalidate_texture(GLuint tex) { + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + _sg_gl_texture_bind_slot* slot = &_sg.gl.cache.textures[i]; + if (tex == slot->texture) { + _sg_gl_cache_active_texture((GLenum)(GL_TEXTURE0 + i)); + glBindTexture(slot->target, 0); + slot->target = 0; + slot->texture = 0; + } + } + if (tex == _sg.gl.cache.stored_texture.texture) { + _sg.gl.cache.stored_texture.target = 0; + _sg.gl.cache.stored_texture.texture = 0; + } +} + +/* called from _sg_gl_destroy_shader() */ +_SOKOL_PRIVATE void _sg_gl_cache_invalidate_program(GLuint prog) { + if (prog == _sg.gl.cache.prog) { + _sg.gl.cache.prog = 0; + glUseProgram(0); + } +} + +/* called from _sg_gl_destroy_pipeline() */ +_SOKOL_PRIVATE void _sg_gl_cache_invalidate_pipeline(_sg_pipeline_t* pip) { + if (pip == _sg.gl.cache.cur_pipeline) { + _sg.gl.cache.cur_pipeline = 0; + _sg.gl.cache.cur_pipeline_id.id = SG_INVALID_ID; + } +} + +_SOKOL_PRIVATE void _sg_gl_reset_state_cache(void) { + if (_sg.gl.cur_context) { + _SG_GL_CHECK_ERROR(); +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + glBindVertexArray(_sg.gl.cur_context->vao); + _SG_GL_CHECK_ERROR(); + } +#endif + memset(&_sg.gl.cache, 0, sizeof(_sg.gl.cache)); + _sg_gl_cache_clear_buffer_bindings(true); + _SG_GL_CHECK_ERROR(); + _sg_gl_cache_clear_texture_bindings(true); + _SG_GL_CHECK_ERROR(); + for (int i = 0; i < _sg.limits.max_vertex_attrs; i++) { + _sg_gl_attr_t* attr = &_sg.gl.cache.attrs[i].gl_attr; + attr->vb_index = -1; + attr->divisor = -1; + glDisableVertexAttribArray((GLuint)i); + _SG_GL_CHECK_ERROR(); + } + _sg.gl.cache.cur_primitive_type = GL_TRIANGLES; + + /* shader program */ + glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&_sg.gl.cache.prog); + _SG_GL_CHECK_ERROR(); + + /* depth and stencil state */ + _sg.gl.cache.depth.compare = SG_COMPAREFUNC_ALWAYS; + _sg.gl.cache.stencil.front.compare = SG_COMPAREFUNC_ALWAYS; + _sg.gl.cache.stencil.front.fail_op = SG_STENCILOP_KEEP; + _sg.gl.cache.stencil.front.depth_fail_op = SG_STENCILOP_KEEP; + _sg.gl.cache.stencil.front.pass_op = SG_STENCILOP_KEEP; + _sg.gl.cache.stencil.back.compare = SG_COMPAREFUNC_ALWAYS; + _sg.gl.cache.stencil.back.fail_op = SG_STENCILOP_KEEP; + _sg.gl.cache.stencil.back.depth_fail_op = SG_STENCILOP_KEEP; + _sg.gl.cache.stencil.back.pass_op = SG_STENCILOP_KEEP; + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_ALWAYS); + glDepthMask(GL_FALSE); + glDisable(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS, 0, 0); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glStencilMask(0); + + /* blend state */ + _sg.gl.cache.blend.src_factor_rgb = SG_BLENDFACTOR_ONE; + _sg.gl.cache.blend.dst_factor_rgb = SG_BLENDFACTOR_ZERO; + _sg.gl.cache.blend.op_rgb = SG_BLENDOP_ADD; + _sg.gl.cache.blend.src_factor_alpha = SG_BLENDFACTOR_ONE; + _sg.gl.cache.blend.dst_factor_alpha = SG_BLENDFACTOR_ZERO; + _sg.gl.cache.blend.op_alpha = SG_BLENDOP_ADD; + glDisable(GL_BLEND); + glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO); + glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD); + glBlendColor(0.0f, 0.0f, 0.0f, 0.0f); + + /* standalone state */ + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + _sg.gl.cache.color_write_mask[i] = SG_COLORMASK_RGBA; + } + _sg.gl.cache.cull_mode = SG_CULLMODE_NONE; + _sg.gl.cache.face_winding = SG_FACEWINDING_CW; + _sg.gl.cache.sample_count = 1; + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); + glDisable(GL_CULL_FACE); + glFrontFace(GL_CW); + glCullFace(GL_BACK); + glEnable(GL_SCISSOR_TEST); + glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); + glEnable(GL_DITHER); + glDisable(GL_POLYGON_OFFSET_FILL); +#if defined(SOKOL_GLCORE33) + glEnable(GL_MULTISAMPLE); + glEnable(GL_PROGRAM_POINT_SIZE); +#endif + } +} + +_SOKOL_PRIVATE void _sg_gl_setup_backend(const sg_desc* desc) { + /* assumes that _sg.gl is already zero-initialized */ + _sg.gl.valid = true; +#if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + _sg.gl.gles2 = desc->context.gl.force_gles2; +#else + _SOKOL_UNUSED(desc); + _sg.gl.gles2 = false; +#endif + +#if defined(_SOKOL_USE_WIN32_GL_LOADER) + _sg_gl_load_opengl(); +#endif + + /* clear initial GL error state */ +#if defined(SOKOL_DEBUG) + while (glGetError() != GL_NO_ERROR); +#endif +#if defined(SOKOL_GLCORE33) + _sg_gl_init_caps_glcore33(); +#elif defined(SOKOL_GLES3) + if (_sg.gl.gles2) { + _sg_gl_init_caps_gles2(); + } + else { + _sg_gl_init_caps_gles3(); + } +#else + _sg_gl_init_caps_gles2(); +#endif +} + +_SOKOL_PRIVATE void _sg_gl_discard_backend(void) { + SOKOL_ASSERT(_sg.gl.valid); + _sg.gl.valid = false; +#if defined(_SOKOL_USE_WIN32_GL_LOADER) + _sg_gl_unload_opengl(); +#endif +} + +_SOKOL_PRIVATE void _sg_gl_activate_context(_sg_context_t* ctx) { + SOKOL_ASSERT(_sg.gl.valid); + /* NOTE: ctx can be 0 to unset the current context */ + _sg.gl.cur_context = ctx; + _sg_gl_reset_state_cache(); +} + +/*-- GL backend resource creation and destruction ----------------------------*/ +_SOKOL_PRIVATE sg_resource_state _sg_gl_create_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + SOKOL_ASSERT(0 == ctx->default_framebuffer); + _SG_GL_CHECK_ERROR(); + glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&ctx->default_framebuffer); + _SG_GL_CHECK_ERROR(); +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + SOKOL_ASSERT(0 == ctx->vao); + glGenVertexArrays(1, &ctx->vao); + glBindVertexArray(ctx->vao); + _SG_GL_CHECK_ERROR(); + } +#endif + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_gl_destroy_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + if (ctx->vao) { + glDeleteVertexArrays(1, &ctx->vao); + } + _SG_GL_CHECK_ERROR(); + } +#else + _SOKOL_UNUSED(ctx); +#endif +} + +_SOKOL_PRIVATE sg_resource_state _sg_gl_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) { + SOKOL_ASSERT(buf && desc); + _SG_GL_CHECK_ERROR(); + _sg_buffer_common_init(&buf->cmn, desc); + buf->gl.ext_buffers = (0 != desc->gl_buffers[0]); + GLenum gl_target = _sg_gl_buffer_target(buf->cmn.type); + GLenum gl_usage = _sg_gl_usage(buf->cmn.usage); + for (int slot = 0; slot < buf->cmn.num_slots; slot++) { + GLuint gl_buf = 0; + if (buf->gl.ext_buffers) { + SOKOL_ASSERT(desc->gl_buffers[slot]); + gl_buf = desc->gl_buffers[slot]; + } + else { + glGenBuffers(1, &gl_buf); + SOKOL_ASSERT(gl_buf); + _sg_gl_cache_store_buffer_binding(gl_target); + _sg_gl_cache_bind_buffer(gl_target, gl_buf); + glBufferData(gl_target, buf->cmn.size, 0, gl_usage); + if (buf->cmn.usage == SG_USAGE_IMMUTABLE) { + SOKOL_ASSERT(desc->data.ptr); + glBufferSubData(gl_target, 0, buf->cmn.size, desc->data.ptr); + } + _sg_gl_cache_restore_buffer_binding(gl_target); + } + buf->gl.buf[slot] = gl_buf; + } + _SG_GL_CHECK_ERROR(); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_gl_destroy_buffer(_sg_buffer_t* buf) { + SOKOL_ASSERT(buf); + _SG_GL_CHECK_ERROR(); + for (int slot = 0; slot < buf->cmn.num_slots; slot++) { + if (buf->gl.buf[slot]) { + _sg_gl_cache_invalidate_buffer(buf->gl.buf[slot]); + if (!buf->gl.ext_buffers) { + glDeleteBuffers(1, &buf->gl.buf[slot]); + } + } + } + _SG_GL_CHECK_ERROR(); +} + +_SOKOL_PRIVATE bool _sg_gl_supported_texture_format(sg_pixel_format fmt) { + const int fmt_index = (int) fmt; + SOKOL_ASSERT((fmt_index > SG_PIXELFORMAT_NONE) && (fmt_index < _SG_PIXELFORMAT_NUM)); + return _sg.formats[fmt_index].sample; +} + +_SOKOL_PRIVATE sg_resource_state _sg_gl_create_image(_sg_image_t* img, const sg_image_desc* desc) { + SOKOL_ASSERT(img && desc); + _SG_GL_CHECK_ERROR(); + _sg_image_common_init(&img->cmn, desc); + img->gl.ext_textures = (0 != desc->gl_textures[0]); + + /* check if texture format is support */ + if (!_sg_gl_supported_texture_format(img->cmn.pixel_format)) { + SOKOL_LOG("texture format not supported by GL context\n"); + return SG_RESOURCESTATE_FAILED; + } + /* check for optional texture types */ + if ((img->cmn.type == SG_IMAGETYPE_3D) && !_sg.features.imagetype_3d) { + SOKOL_LOG("3D textures not supported by GL context\n"); + return SG_RESOURCESTATE_FAILED; + } + if ((img->cmn.type == SG_IMAGETYPE_ARRAY) && !_sg.features.imagetype_array) { + SOKOL_LOG("array textures not supported by GL context\n"); + return SG_RESOURCESTATE_FAILED; + } + +#if !defined(SOKOL_GLES2) + bool msaa = false; + if (!_sg.gl.gles2) { + msaa = (img->cmn.sample_count > 1) && (_sg.features.msaa_render_targets); + } +#endif + + if (_sg_is_valid_rendertarget_depth_format(img->cmn.pixel_format)) { + /* special case depth-stencil-buffer? */ + SOKOL_ASSERT((img->cmn.usage == SG_USAGE_IMMUTABLE) && (img->cmn.num_slots == 1)); + SOKOL_ASSERT(!img->gl.ext_textures); /* cannot provide external texture for depth images */ + glGenRenderbuffers(1, &img->gl.depth_render_buffer); + glBindRenderbuffer(GL_RENDERBUFFER, img->gl.depth_render_buffer); + GLenum gl_depth_format = _sg_gl_depth_attachment_format(img->cmn.pixel_format); +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2 && msaa) { + glRenderbufferStorageMultisample(GL_RENDERBUFFER, img->cmn.sample_count, gl_depth_format, img->cmn.width, img->cmn.height); + } + else +#endif + { + glRenderbufferStorage(GL_RENDERBUFFER, gl_depth_format, img->cmn.width, img->cmn.height); + } + } + else { + /* regular color texture */ + img->gl.target = _sg_gl_texture_target(img->cmn.type); + const GLenum gl_internal_format = _sg_gl_teximage_internal_format(img->cmn.pixel_format); + + /* if this is a MSAA render target, need to create a separate render buffer */ +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2 && img->cmn.render_target && msaa) { + glGenRenderbuffers(1, &img->gl.msaa_render_buffer); + glBindRenderbuffer(GL_RENDERBUFFER, img->gl.msaa_render_buffer); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, img->cmn.sample_count, gl_internal_format, img->cmn.width, img->cmn.height); + } +#endif + + if (img->gl.ext_textures) { + /* inject externally GL textures */ + for (int slot = 0; slot < img->cmn.num_slots; slot++) { + SOKOL_ASSERT(desc->gl_textures[slot]); + img->gl.tex[slot] = desc->gl_textures[slot]; + } + if (desc->gl_texture_target) { + img->gl.target = (GLenum)desc->gl_texture_target; + } + } + else { + /* create our own GL texture(s) */ + const GLenum gl_format = _sg_gl_teximage_format(img->cmn.pixel_format); + const bool is_compressed = _sg_is_compressed_pixel_format(img->cmn.pixel_format); + for (int slot = 0; slot < img->cmn.num_slots; slot++) { + glGenTextures(1, &img->gl.tex[slot]); + SOKOL_ASSERT(img->gl.tex[slot]); + _sg_gl_cache_store_texture_binding(0); + _sg_gl_cache_bind_texture(0, img->gl.target, img->gl.tex[slot]); + GLenum gl_min_filter = _sg_gl_filter(img->cmn.min_filter); + GLenum gl_mag_filter = _sg_gl_filter(img->cmn.mag_filter); + glTexParameteri(img->gl.target, GL_TEXTURE_MIN_FILTER, (GLint)gl_min_filter); + glTexParameteri(img->gl.target, GL_TEXTURE_MAG_FILTER, (GLint)gl_mag_filter); + if (_sg.gl.ext_anisotropic && (img->cmn.max_anisotropy > 1)) { + GLint max_aniso = (GLint) img->cmn.max_anisotropy; + if (max_aniso > _sg.gl.max_anisotropy) { + max_aniso = _sg.gl.max_anisotropy; + } + glTexParameteri(img->gl.target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_aniso); + } + if (img->cmn.type == SG_IMAGETYPE_CUBE) { + glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + else { + glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_S, (GLint)_sg_gl_wrap(img->cmn.wrap_u)); + glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_T, (GLint)_sg_gl_wrap(img->cmn.wrap_v)); +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2 && (img->cmn.type == SG_IMAGETYPE_3D)) { + glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_R, (GLint)_sg_gl_wrap(img->cmn.wrap_w)); + } +#endif +#if defined(SOKOL_GLCORE33) + float border[4]; + switch (img->cmn.border_color) { + case SG_BORDERCOLOR_TRANSPARENT_BLACK: + border[0] = 0.0f; border[1] = 0.0f; border[2] = 0.0f; border[3] = 0.0f; + break; + case SG_BORDERCOLOR_OPAQUE_WHITE: + border[0] = 1.0f; border[1] = 1.0f; border[2] = 1.0f; border[3] = 1.0f; + break; + default: + border[0] = 0.0f; border[1] = 0.0f; border[2] = 0.0f; border[3] = 1.0f; + break; + } + glTexParameterfv(img->gl.target, GL_TEXTURE_BORDER_COLOR, border); +#endif + } +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + /* GL spec has strange defaults for mipmap min/max lod: -1000 to +1000 */ + const float min_lod = _sg_clamp(desc->min_lod, 0.0f, 1000.0f); + const float max_lod = _sg_clamp(desc->max_lod, 0.0f, 1000.0f); + glTexParameterf(img->gl.target, GL_TEXTURE_MIN_LOD, min_lod); + glTexParameterf(img->gl.target, GL_TEXTURE_MAX_LOD, max_lod); + } +#endif + const int num_faces = img->cmn.type == SG_IMAGETYPE_CUBE ? 6 : 1; + int data_index = 0; + for (int face_index = 0; face_index < num_faces; face_index++) { + for (int mip_index = 0; mip_index < img->cmn.num_mipmaps; mip_index++, data_index++) { + GLenum gl_img_target = img->gl.target; + if (SG_IMAGETYPE_CUBE == img->cmn.type) { + gl_img_target = _sg_gl_cubeface_target(face_index); + } + const GLvoid* data_ptr = desc->data.subimage[face_index][mip_index].ptr; + int mip_width = img->cmn.width >> mip_index; + if (mip_width == 0) { + mip_width = 1; + } + int mip_height = img->cmn.height >> mip_index; + if (mip_height == 0) { + mip_height = 1; + } + if ((SG_IMAGETYPE_2D == img->cmn.type) || (SG_IMAGETYPE_CUBE == img->cmn.type)) { + if (is_compressed) { + const GLsizei data_size = (GLsizei) desc->data.subimage[face_index][mip_index].size; + glCompressedTexImage2D(gl_img_target, mip_index, gl_internal_format, + mip_width, mip_height, 0, data_size, data_ptr); + } + else { + const GLenum gl_type = _sg_gl_teximage_type(img->cmn.pixel_format); + glTexImage2D(gl_img_target, mip_index, (GLint)gl_internal_format, + mip_width, mip_height, 0, gl_format, gl_type, data_ptr); + } + } +#if !defined(SOKOL_GLES2) + else if (!_sg.gl.gles2 && ((SG_IMAGETYPE_3D == img->cmn.type) || (SG_IMAGETYPE_ARRAY == img->cmn.type))) { + int mip_depth = img->cmn.num_slices; + if (SG_IMAGETYPE_3D == img->cmn.type) { + mip_depth >>= mip_index; + } + if (mip_depth == 0) { + mip_depth = 1; + } + if (is_compressed) { + const GLsizei data_size = (GLsizei) desc->data.subimage[face_index][mip_index].size; + glCompressedTexImage3D(gl_img_target, mip_index, gl_internal_format, + mip_width, mip_height, mip_depth, 0, data_size, data_ptr); + } + else { + const GLenum gl_type = _sg_gl_teximage_type(img->cmn.pixel_format); + glTexImage3D(gl_img_target, mip_index, (GLint)gl_internal_format, + mip_width, mip_height, mip_depth, 0, gl_format, gl_type, data_ptr); + } + } +#endif + } + } + _sg_gl_cache_restore_texture_binding(0); + } + } + } + _SG_GL_CHECK_ERROR(); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_gl_destroy_image(_sg_image_t* img) { + SOKOL_ASSERT(img); + _SG_GL_CHECK_ERROR(); + for (int slot = 0; slot < img->cmn.num_slots; slot++) { + if (img->gl.tex[slot]) { + _sg_gl_cache_invalidate_texture(img->gl.tex[slot]); + if (!img->gl.ext_textures) { + glDeleteTextures(1, &img->gl.tex[slot]); + } + } + } + if (img->gl.depth_render_buffer) { + glDeleteRenderbuffers(1, &img->gl.depth_render_buffer); + } + if (img->gl.msaa_render_buffer) { + glDeleteRenderbuffers(1, &img->gl.msaa_render_buffer); + } + _SG_GL_CHECK_ERROR(); +} + +_SOKOL_PRIVATE GLuint _sg_gl_compile_shader(sg_shader_stage stage, const char* src) { + SOKOL_ASSERT(src); + _SG_GL_CHECK_ERROR(); + GLuint gl_shd = glCreateShader(_sg_gl_shader_stage(stage)); + glShaderSource(gl_shd, 1, &src, 0); + glCompileShader(gl_shd); + GLint compile_status = 0; + glGetShaderiv(gl_shd, GL_COMPILE_STATUS, &compile_status); + if (!compile_status) { + /* compilation failed, log error and delete shader */ + GLint log_len = 0; + glGetShaderiv(gl_shd, GL_INFO_LOG_LENGTH, &log_len); + if (log_len > 0) { + GLchar* log_buf = (GLchar*) SOKOL_MALLOC((size_t)log_len); + glGetShaderInfoLog(gl_shd, log_len, &log_len, log_buf); + SOKOL_LOG(log_buf); + SOKOL_FREE(log_buf); + } + glDeleteShader(gl_shd); + gl_shd = 0; + } + _SG_GL_CHECK_ERROR(); + return gl_shd; +} + +_SOKOL_PRIVATE sg_resource_state _sg_gl_create_shader(_sg_shader_t* shd, const sg_shader_desc* desc) { + SOKOL_ASSERT(shd && desc); + SOKOL_ASSERT(!shd->gl.prog); + _SG_GL_CHECK_ERROR(); + + _sg_shader_common_init(&shd->cmn, desc); + + /* copy vertex attribute names over, these are required for GLES2, and optional for GLES3 and GL3.x */ + for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTES; i++) { + _sg_strcpy(&shd->gl.attrs[i].name, desc->attrs[i].name); + } + + GLuint gl_vs = _sg_gl_compile_shader(SG_SHADERSTAGE_VS, desc->vs.source); + GLuint gl_fs = _sg_gl_compile_shader(SG_SHADERSTAGE_FS, desc->fs.source); + if (!(gl_vs && gl_fs)) { + return SG_RESOURCESTATE_FAILED; + } + GLuint gl_prog = glCreateProgram(); + glAttachShader(gl_prog, gl_vs); + glAttachShader(gl_prog, gl_fs); + glLinkProgram(gl_prog); + glDeleteShader(gl_vs); + glDeleteShader(gl_fs); + _SG_GL_CHECK_ERROR(); + + GLint link_status; + glGetProgramiv(gl_prog, GL_LINK_STATUS, &link_status); + if (!link_status) { + GLint log_len = 0; + glGetProgramiv(gl_prog, GL_INFO_LOG_LENGTH, &log_len); + if (log_len > 0) { + GLchar* log_buf = (GLchar*) SOKOL_MALLOC((size_t)log_len); + glGetProgramInfoLog(gl_prog, log_len, &log_len, log_buf); + SOKOL_LOG(log_buf); + SOKOL_FREE(log_buf); + } + glDeleteProgram(gl_prog); + return SG_RESOURCESTATE_FAILED; + } + shd->gl.prog = gl_prog; + + /* resolve uniforms */ + _SG_GL_CHECK_ERROR(); + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + const sg_shader_stage_desc* stage_desc = (stage_index == SG_SHADERSTAGE_VS)? &desc->vs : &desc->fs; + _sg_gl_shader_stage_t* gl_stage = &shd->gl.stage[stage_index]; + for (int ub_index = 0; ub_index < shd->cmn.stage[stage_index].num_uniform_blocks; ub_index++) { + const sg_shader_uniform_block_desc* ub_desc = &stage_desc->uniform_blocks[ub_index]; + SOKOL_ASSERT(ub_desc->size > 0); + _sg_gl_uniform_block_t* ub = &gl_stage->uniform_blocks[ub_index]; + SOKOL_ASSERT(ub->num_uniforms == 0); + uint32_t cur_uniform_offset = 0; + for (int u_index = 0; u_index < SG_MAX_UB_MEMBERS; u_index++) { + const sg_shader_uniform_desc* u_desc = &ub_desc->uniforms[u_index]; + if (u_desc->type == SG_UNIFORMTYPE_INVALID) { + break; + } + const uint32_t u_align = _sg_uniform_alignment(u_desc->type, u_desc->array_count, ub_desc->layout); + const uint32_t u_size = _sg_uniform_size(u_desc->type, u_desc->array_count, ub_desc->layout); + cur_uniform_offset = _sg_align_u32(cur_uniform_offset, u_align); + _sg_gl_uniform_t* u = &ub->uniforms[u_index]; + u->type = u_desc->type; + u->count = (uint16_t) u_desc->array_count; + u->offset = (uint16_t) cur_uniform_offset; + cur_uniform_offset += u_size; + if (u_desc->name) { + u->gl_loc = glGetUniformLocation(gl_prog, u_desc->name); + } + else { + u->gl_loc = u_index; + } + ub->num_uniforms++; + } + if (ub_desc->layout == SG_UNIFORMLAYOUT_STD140) { + cur_uniform_offset = _sg_align_u32(cur_uniform_offset, 16); + } + SOKOL_ASSERT(ub_desc->size == (size_t)cur_uniform_offset); + _SOKOL_UNUSED(cur_uniform_offset); + } + } + + /* resolve image locations */ + _SG_GL_CHECK_ERROR(); + GLuint cur_prog = 0; + glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&cur_prog); + glUseProgram(gl_prog); + int gl_tex_slot = 0; + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + const sg_shader_stage_desc* stage_desc = (stage_index == SG_SHADERSTAGE_VS)? &desc->vs : &desc->fs; + _sg_gl_shader_stage_t* gl_stage = &shd->gl.stage[stage_index]; + for (int img_index = 0; img_index < shd->cmn.stage[stage_index].num_images; img_index++) { + const sg_shader_image_desc* img_desc = &stage_desc->images[img_index]; + SOKOL_ASSERT(img_desc->image_type != _SG_IMAGETYPE_DEFAULT); + _sg_gl_shader_image_t* gl_img = &gl_stage->images[img_index]; + GLint gl_loc = img_index; + if (img_desc->name) { + gl_loc = glGetUniformLocation(gl_prog, img_desc->name); + } + if (gl_loc != -1) { + gl_img->gl_tex_slot = gl_tex_slot++; + glUniform1i(gl_loc, gl_img->gl_tex_slot); + } + else { + gl_img->gl_tex_slot = -1; + } + } + } + /* it's legal to call glUseProgram with 0 */ + glUseProgram(cur_prog); + _SG_GL_CHECK_ERROR(); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_gl_destroy_shader(_sg_shader_t* shd) { + SOKOL_ASSERT(shd); + _SG_GL_CHECK_ERROR(); + if (shd->gl.prog) { + _sg_gl_cache_invalidate_program(shd->gl.prog); + glDeleteProgram(shd->gl.prog); + } + _SG_GL_CHECK_ERROR(); +} + +_SOKOL_PRIVATE sg_resource_state _sg_gl_create_pipeline(_sg_pipeline_t* pip, _sg_shader_t* shd, const sg_pipeline_desc* desc) { + SOKOL_ASSERT(pip && shd && desc); + SOKOL_ASSERT(!pip->shader && pip->cmn.shader_id.id == SG_INVALID_ID); + SOKOL_ASSERT(desc->shader.id == shd->slot.id); + SOKOL_ASSERT(shd->gl.prog); + pip->shader = shd; + _sg_pipeline_common_init(&pip->cmn, desc); + pip->gl.primitive_type = desc->primitive_type; + pip->gl.depth = desc->depth; + pip->gl.stencil = desc->stencil; + // FIXME: blend color and write mask per draw-buffer-attachment (requires GL4) + pip->gl.blend = desc->colors[0].blend; + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + pip->gl.color_write_mask[i] = desc->colors[i].write_mask; + } + pip->gl.cull_mode = desc->cull_mode; + pip->gl.face_winding = desc->face_winding; + pip->gl.sample_count = desc->sample_count; + pip->gl.alpha_to_coverage_enabled = desc->alpha_to_coverage_enabled; + + /* resolve vertex attributes */ + for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) { + pip->gl.attrs[attr_index].vb_index = -1; + } + for (int attr_index = 0; attr_index < _sg.limits.max_vertex_attrs; attr_index++) { + const sg_vertex_attr_desc* a_desc = &desc->layout.attrs[attr_index]; + if (a_desc->format == SG_VERTEXFORMAT_INVALID) { + break; + } + SOKOL_ASSERT(a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS); + const sg_buffer_layout_desc* l_desc = &desc->layout.buffers[a_desc->buffer_index]; + const sg_vertex_step step_func = l_desc->step_func; + const int step_rate = l_desc->step_rate; + GLint attr_loc = attr_index; + if (!_sg_strempty(&shd->gl.attrs[attr_index].name)) { + attr_loc = glGetAttribLocation(pip->shader->gl.prog, _sg_strptr(&shd->gl.attrs[attr_index].name)); + } + SOKOL_ASSERT(attr_loc < (GLint)_sg.limits.max_vertex_attrs); + if (attr_loc != -1) { + _sg_gl_attr_t* gl_attr = &pip->gl.attrs[attr_loc]; + SOKOL_ASSERT(gl_attr->vb_index == -1); + gl_attr->vb_index = (int8_t) a_desc->buffer_index; + if (step_func == SG_VERTEXSTEP_PER_VERTEX) { + gl_attr->divisor = 0; + } + else { + gl_attr->divisor = (int8_t) step_rate; + pip->cmn.use_instanced_draw = true; + } + SOKOL_ASSERT(l_desc->stride > 0); + gl_attr->stride = (uint8_t) l_desc->stride; + gl_attr->offset = a_desc->offset; + gl_attr->size = (uint8_t) _sg_gl_vertexformat_size(a_desc->format); + gl_attr->type = _sg_gl_vertexformat_type(a_desc->format); + gl_attr->normalized = _sg_gl_vertexformat_normalized(a_desc->format); + pip->cmn.vertex_layout_valid[a_desc->buffer_index] = true; + } + else { + SOKOL_LOG("Vertex attribute not found in shader: "); + SOKOL_LOG(_sg_strptr(&shd->gl.attrs[attr_index].name)); + } + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_gl_destroy_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + _sg_gl_cache_invalidate_pipeline(pip); +} + +/* + _sg_create_pass + + att_imgs must point to a _sg_image* att_imgs[SG_MAX_COLOR_ATTACHMENTS+1] array, + first entries are the color attachment images (or nullptr), last entry + is the depth-stencil image (or nullptr). +*/ +_SOKOL_PRIVATE sg_resource_state _sg_gl_create_pass(_sg_pass_t* pass, _sg_image_t** att_images, const sg_pass_desc* desc) { + SOKOL_ASSERT(pass && att_images && desc); + SOKOL_ASSERT(att_images && att_images[0]); + _SG_GL_CHECK_ERROR(); + + _sg_pass_common_init(&pass->cmn, desc); + + /* copy image pointers */ + const sg_pass_attachment_desc* att_desc; + for (int i = 0; i < pass->cmn.num_color_atts; i++) { + att_desc = &desc->color_attachments[i]; + SOKOL_ASSERT(att_desc->image.id != SG_INVALID_ID); + SOKOL_ASSERT(0 == pass->gl.color_atts[i].image); + SOKOL_ASSERT(att_images[i] && (att_images[i]->slot.id == att_desc->image.id)); + SOKOL_ASSERT(_sg_is_valid_rendertarget_color_format(att_images[i]->cmn.pixel_format)); + pass->gl.color_atts[i].image = att_images[i]; + } + SOKOL_ASSERT(0 == pass->gl.ds_att.image); + att_desc = &desc->depth_stencil_attachment; + if (att_desc->image.id != SG_INVALID_ID) { + const int ds_img_index = SG_MAX_COLOR_ATTACHMENTS; + SOKOL_ASSERT(att_images[ds_img_index] && (att_images[ds_img_index]->slot.id == att_desc->image.id)); + SOKOL_ASSERT(_sg_is_valid_rendertarget_depth_format(att_images[ds_img_index]->cmn.pixel_format)); + pass->gl.ds_att.image = att_images[ds_img_index]; + } + + /* store current framebuffer binding (restored at end of function) */ + GLuint gl_orig_fb; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&gl_orig_fb); + + /* create a framebuffer object */ + glGenFramebuffers(1, &pass->gl.fb); + glBindFramebuffer(GL_FRAMEBUFFER, pass->gl.fb); + + /* attach msaa render buffer or textures */ + const bool is_msaa = (0 != att_images[0]->gl.msaa_render_buffer); + if (is_msaa) { + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + const _sg_image_t* att_img = pass->gl.color_atts[i].image; + if (att_img) { + const GLuint gl_render_buffer = att_img->gl.msaa_render_buffer; + SOKOL_ASSERT(gl_render_buffer); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, (GLenum)(GL_COLOR_ATTACHMENT0+i), GL_RENDERBUFFER, gl_render_buffer); + } + } + } + else { + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + const _sg_image_t* att_img = pass->gl.color_atts[i].image; + const int mip_level = pass->cmn.color_atts[i].mip_level; + const int slice = pass->cmn.color_atts[i].slice; + if (att_img) { + const GLuint gl_tex = att_img->gl.tex[0]; + SOKOL_ASSERT(gl_tex); + const GLenum gl_att = (GLenum)(GL_COLOR_ATTACHMENT0 + i); + switch (att_img->cmn.type) { + case SG_IMAGETYPE_2D: + glFramebufferTexture2D(GL_FRAMEBUFFER, gl_att, GL_TEXTURE_2D, gl_tex, mip_level); + break; + case SG_IMAGETYPE_CUBE: + glFramebufferTexture2D(GL_FRAMEBUFFER, gl_att, _sg_gl_cubeface_target(slice), gl_tex, mip_level); + break; + default: + /* 3D- or array-texture */ +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + glFramebufferTextureLayer(GL_FRAMEBUFFER, gl_att, gl_tex, mip_level, slice); + } +#endif + break; + } + } + } + } + + /* attach depth-stencil buffer to framebuffer */ + if (pass->gl.ds_att.image) { + const GLuint gl_render_buffer = pass->gl.ds_att.image->gl.depth_render_buffer; + SOKOL_ASSERT(gl_render_buffer); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, gl_render_buffer); + if (_sg_is_depth_stencil_format(pass->gl.ds_att.image->cmn.pixel_format)) { + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, gl_render_buffer); + } + } + + /* check if framebuffer is complete */ + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + SOKOL_LOG("Framebuffer completeness check failed!\n"); + return SG_RESOURCESTATE_FAILED; + } + + /* setup color attachments for the framebuffer */ +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + GLenum att[SG_MAX_COLOR_ATTACHMENTS] = { + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3 + }; + glDrawBuffers(pass->cmn.num_color_atts, att); + } +#endif + + /* create MSAA resolve framebuffers if necessary */ + if (is_msaa) { + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + _sg_gl_attachment_t* gl_att = &pass->gl.color_atts[i]; + _sg_pass_attachment_t* cmn_att = &pass->cmn.color_atts[i]; + if (gl_att->image) { + SOKOL_ASSERT(0 == gl_att->gl_msaa_resolve_buffer); + glGenFramebuffers(1, &gl_att->gl_msaa_resolve_buffer); + glBindFramebuffer(GL_FRAMEBUFFER, gl_att->gl_msaa_resolve_buffer); + const GLuint gl_tex = gl_att->image->gl.tex[0]; + SOKOL_ASSERT(gl_tex); + switch (gl_att->image->cmn.type) { + case SG_IMAGETYPE_2D: + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, gl_tex, cmn_att->mip_level); + break; + case SG_IMAGETYPE_CUBE: + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + _sg_gl_cubeface_target(cmn_att->slice), gl_tex, cmn_att->mip_level); + break; + default: +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, gl_tex, cmn_att->mip_level, cmn_att->slice); + } +#endif + break; + } + /* check if framebuffer is complete */ + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + SOKOL_LOG("Framebuffer completeness check failed (msaa resolve buffer)!\n"); + return SG_RESOURCESTATE_FAILED; + } + /* setup color attachments for the framebuffer */ +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2) { + const GLenum gl_draw_bufs = GL_COLOR_ATTACHMENT0; + glDrawBuffers(1, &gl_draw_bufs); + } +#endif + } + } + } + + /* restore original framebuffer binding */ + glBindFramebuffer(GL_FRAMEBUFFER, gl_orig_fb); + _SG_GL_CHECK_ERROR(); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_gl_destroy_pass(_sg_pass_t* pass) { + SOKOL_ASSERT(pass); + SOKOL_ASSERT(pass != _sg.gl.cur_pass); + _SG_GL_CHECK_ERROR(); + if (0 != pass->gl.fb) { + glDeleteFramebuffers(1, &pass->gl.fb); + } + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + if (pass->gl.color_atts[i].gl_msaa_resolve_buffer) { + glDeleteFramebuffers(1, &pass->gl.color_atts[i].gl_msaa_resolve_buffer); + } + } + if (pass->gl.ds_att.gl_msaa_resolve_buffer) { + glDeleteFramebuffers(1, &pass->gl.ds_att.gl_msaa_resolve_buffer); + } + _SG_GL_CHECK_ERROR(); +} + +_SOKOL_PRIVATE _sg_image_t* _sg_gl_pass_color_image(const _sg_pass_t* pass, int index) { + SOKOL_ASSERT(pass && (index >= 0) && (index < SG_MAX_COLOR_ATTACHMENTS)); + /* NOTE: may return null */ + return pass->gl.color_atts[index].image; +} + +_SOKOL_PRIVATE _sg_image_t* _sg_gl_pass_ds_image(const _sg_pass_t* pass) { + /* NOTE: may return null */ + SOKOL_ASSERT(pass); + return pass->gl.ds_att.image; +} + +_SOKOL_PRIVATE void _sg_gl_begin_pass(_sg_pass_t* pass, const sg_pass_action* action, int w, int h) { + /* FIXME: what if a texture used as render target is still bound, should we + unbind all currently bound textures in begin pass? */ + SOKOL_ASSERT(action); + SOKOL_ASSERT(!_sg.gl.in_pass); + _SG_GL_CHECK_ERROR(); + _sg.gl.in_pass = true; + _sg.gl.cur_pass = pass; /* can be 0 */ + if (pass) { + _sg.gl.cur_pass_id.id = pass->slot.id; + } + else { + _sg.gl.cur_pass_id.id = SG_INVALID_ID; + } + _sg.gl.cur_pass_width = w; + _sg.gl.cur_pass_height = h; + + /* number of color attachments */ + const int num_color_atts = pass ? pass->cmn.num_color_atts : 1; + + /* bind the render pass framebuffer */ + if (pass) { + /* offscreen pass */ + SOKOL_ASSERT(pass->gl.fb); + glBindFramebuffer(GL_FRAMEBUFFER, pass->gl.fb); + } + else { + /* default pass */ + SOKOL_ASSERT(_sg.gl.cur_context); + glBindFramebuffer(GL_FRAMEBUFFER, _sg.gl.cur_context->default_framebuffer); + } + glViewport(0, 0, w, h); + glScissor(0, 0, w, h); + + /* clear color and depth-stencil attachments if needed */ + bool clear_color = false; + for (int i = 0; i < num_color_atts; i++) { + if (SG_ACTION_CLEAR == action->colors[i].action) { + clear_color = true; + break; + } + } + const bool clear_depth = (action->depth.action == SG_ACTION_CLEAR); + const bool clear_stencil = (action->stencil.action == SG_ACTION_CLEAR); + + bool need_pip_cache_flush = false; + if (clear_color) { + bool need_color_mask_flush = false; + // NOTE: not a bug to iterate over all possible color attachments + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + if (SG_COLORMASK_RGBA != _sg.gl.cache.color_write_mask[i]) { + need_pip_cache_flush = true; + need_color_mask_flush = true; + _sg.gl.cache.color_write_mask[i] = SG_COLORMASK_RGBA; + } + } + if (need_color_mask_flush) { + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + } + } + if (clear_depth) { + if (!_sg.gl.cache.depth.write_enabled) { + need_pip_cache_flush = true; + _sg.gl.cache.depth.write_enabled = true; + glDepthMask(GL_TRUE); + } + if (_sg.gl.cache.depth.compare != SG_COMPAREFUNC_ALWAYS) { + need_pip_cache_flush = true; + _sg.gl.cache.depth.compare = SG_COMPAREFUNC_ALWAYS; + glDepthFunc(GL_ALWAYS); + } + } + if (clear_stencil) { + if (_sg.gl.cache.stencil.write_mask != 0xFF) { + need_pip_cache_flush = true; + _sg.gl.cache.stencil.write_mask = 0xFF; + glStencilMask(0xFF); + } + } + if (need_pip_cache_flush) { + /* we messed with the state cache directly, need to clear cached + pipeline to force re-evaluation in next sg_apply_pipeline() */ + _sg.gl.cache.cur_pipeline = 0; + _sg.gl.cache.cur_pipeline_id.id = SG_INVALID_ID; + } + bool use_mrt_clear = (0 != pass); +#if defined(SOKOL_GLES2) + use_mrt_clear = false; +#else + if (_sg.gl.gles2) { + use_mrt_clear = false; + } +#endif + if (!use_mrt_clear) { + GLbitfield clear_mask = 0; + if (clear_color) { + clear_mask |= GL_COLOR_BUFFER_BIT; + const sg_color c = action->colors[0].value; + glClearColor(c.r, c.g, c.b, c.a); + } + if (clear_depth) { + clear_mask |= GL_DEPTH_BUFFER_BIT; +#ifdef SOKOL_GLCORE33 + glClearDepth(action->depth.value); +#else + glClearDepthf(action->depth.value); +#endif + } + if (clear_stencil) { + clear_mask |= GL_STENCIL_BUFFER_BIT; + glClearStencil(action->stencil.value); + } + if (0 != clear_mask) { + glClear(clear_mask); + } + } +#if !defined SOKOL_GLES2 + else { + SOKOL_ASSERT(pass); + for (int i = 0; i < num_color_atts; i++) { + if (action->colors[i].action == SG_ACTION_CLEAR) { + glClearBufferfv(GL_COLOR, i, &action->colors[i].value.r); + } + } + if (pass->gl.ds_att.image) { + if (clear_depth && clear_stencil) { + glClearBufferfi(GL_DEPTH_STENCIL, 0, action->depth.value, action->stencil.value); + } + else if (clear_depth) { + glClearBufferfv(GL_DEPTH, 0, &action->depth.value); + } + else if (clear_stencil) { + GLint val = (GLint) action->stencil.value; + glClearBufferiv(GL_STENCIL, 0, &val); + } + } + } +#endif + _SG_GL_CHECK_ERROR(); +} + +_SOKOL_PRIVATE void _sg_gl_end_pass(void) { + SOKOL_ASSERT(_sg.gl.in_pass); + _SG_GL_CHECK_ERROR(); + + /* if this was an offscreen pass, and MSAA rendering was used, need + to resolve into the pass images */ +#if !defined(SOKOL_GLES2) + if (!_sg.gl.gles2 && _sg.gl.cur_pass) { + /* check if the pass object is still valid */ + const _sg_pass_t* pass = _sg.gl.cur_pass; + SOKOL_ASSERT(pass->slot.id == _sg.gl.cur_pass_id.id); + bool is_msaa = (0 != _sg.gl.cur_pass->gl.color_atts[0].gl_msaa_resolve_buffer); + if (is_msaa) { + SOKOL_ASSERT(pass->gl.fb); + glBindFramebuffer(GL_READ_FRAMEBUFFER, pass->gl.fb); + SOKOL_ASSERT(pass->gl.color_atts[0].image); + const int w = pass->gl.color_atts[0].image->cmn.width; + const int h = pass->gl.color_atts[0].image->cmn.height; + for (int att_index = 0; att_index < SG_MAX_COLOR_ATTACHMENTS; att_index++) { + const _sg_gl_attachment_t* gl_att = &pass->gl.color_atts[att_index]; + if (gl_att->image) { + SOKOL_ASSERT(gl_att->gl_msaa_resolve_buffer); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gl_att->gl_msaa_resolve_buffer); + glReadBuffer((GLenum)(GL_COLOR_ATTACHMENT0 + att_index)); + glBlitFramebuffer(0, 0, w, h, 0, 0, w, h, GL_COLOR_BUFFER_BIT, GL_NEAREST); + } + else { + break; + } + } + } + } +#endif + _sg.gl.cur_pass = 0; + _sg.gl.cur_pass_id.id = SG_INVALID_ID; + _sg.gl.cur_pass_width = 0; + _sg.gl.cur_pass_height = 0; + + SOKOL_ASSERT(_sg.gl.cur_context); + glBindFramebuffer(GL_FRAMEBUFFER, _sg.gl.cur_context->default_framebuffer); + _sg.gl.in_pass = false; + _SG_GL_CHECK_ERROR(); +} + +_SOKOL_PRIVATE void _sg_gl_apply_viewport(int x, int y, int w, int h, bool origin_top_left) { + SOKOL_ASSERT(_sg.gl.in_pass); + y = origin_top_left ? (_sg.gl.cur_pass_height - (y+h)) : y; + glViewport(x, y, w, h); +} + +_SOKOL_PRIVATE void _sg_gl_apply_scissor_rect(int x, int y, int w, int h, bool origin_top_left) { + SOKOL_ASSERT(_sg.gl.in_pass); + y = origin_top_left ? (_sg.gl.cur_pass_height - (y+h)) : y; + glScissor(x, y, w, h); +} + +_SOKOL_PRIVATE void _sg_gl_apply_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + SOKOL_ASSERT(pip->shader && (pip->cmn.shader_id.id == pip->shader->slot.id)); + _SG_GL_CHECK_ERROR(); + if ((_sg.gl.cache.cur_pipeline != pip) || (_sg.gl.cache.cur_pipeline_id.id != pip->slot.id)) { + _sg.gl.cache.cur_pipeline = pip; + _sg.gl.cache.cur_pipeline_id.id = pip->slot.id; + _sg.gl.cache.cur_primitive_type = _sg_gl_primitive_type(pip->gl.primitive_type); + _sg.gl.cache.cur_index_type = _sg_gl_index_type(pip->cmn.index_type); + + /* update depth state */ + { + const sg_depth_state* state_ds = &pip->gl.depth; + sg_depth_state* cache_ds = &_sg.gl.cache.depth; + if (state_ds->compare != cache_ds->compare) { + cache_ds->compare = state_ds->compare; + glDepthFunc(_sg_gl_compare_func(state_ds->compare)); + } + if (state_ds->write_enabled != cache_ds->write_enabled) { + cache_ds->write_enabled = state_ds->write_enabled; + glDepthMask(state_ds->write_enabled); + } + if (!_sg_fequal(state_ds->bias, cache_ds->bias, 0.000001f) || + !_sg_fequal(state_ds->bias_slope_scale, cache_ds->bias_slope_scale, 0.000001f)) + { + /* according to ANGLE's D3D11 backend: + D3D11 SlopeScaledDepthBias ==> GL polygonOffsetFactor + D3D11 DepthBias ==> GL polygonOffsetUnits + DepthBiasClamp has no meaning on GL + */ + cache_ds->bias = state_ds->bias; + cache_ds->bias_slope_scale = state_ds->bias_slope_scale; + glPolygonOffset(state_ds->bias_slope_scale, state_ds->bias); + bool po_enabled = true; + if (_sg_fequal(state_ds->bias, 0.0f, 0.000001f) && + _sg_fequal(state_ds->bias_slope_scale, 0.0f, 0.000001f)) + { + po_enabled = false; + } + if (po_enabled != _sg.gl.cache.polygon_offset_enabled) { + _sg.gl.cache.polygon_offset_enabled = po_enabled; + if (po_enabled) { + glEnable(GL_POLYGON_OFFSET_FILL); + } + else { + glDisable(GL_POLYGON_OFFSET_FILL); + } + } + } + } + + /* update stencil state */ + { + const sg_stencil_state* state_ss = &pip->gl.stencil; + sg_stencil_state* cache_ss = &_sg.gl.cache.stencil; + if (state_ss->enabled != cache_ss->enabled) { + cache_ss->enabled = state_ss->enabled; + if (state_ss->enabled) { + glEnable(GL_STENCIL_TEST); + } + else { + glDisable(GL_STENCIL_TEST); + } + } + if (state_ss->write_mask != cache_ss->write_mask) { + cache_ss->write_mask = state_ss->write_mask; + glStencilMask(state_ss->write_mask); + } + for (int i = 0; i < 2; i++) { + const sg_stencil_face_state* state_sfs = (i==0)? &state_ss->front : &state_ss->back; + sg_stencil_face_state* cache_sfs = (i==0)? &cache_ss->front : &cache_ss->back; + GLenum gl_face = (i==0)? GL_FRONT : GL_BACK; + if ((state_sfs->compare != cache_sfs->compare) || + (state_ss->read_mask != cache_ss->read_mask) || + (state_ss->ref != cache_ss->ref)) + { + cache_sfs->compare = state_sfs->compare; + glStencilFuncSeparate(gl_face, + _sg_gl_compare_func(state_sfs->compare), + state_ss->ref, + state_ss->read_mask); + } + if ((state_sfs->fail_op != cache_sfs->fail_op) || + (state_sfs->depth_fail_op != cache_sfs->depth_fail_op) || + (state_sfs->pass_op != cache_sfs->pass_op)) + { + cache_sfs->fail_op = state_sfs->fail_op; + cache_sfs->depth_fail_op = state_sfs->depth_fail_op; + cache_sfs->pass_op = state_sfs->pass_op; + glStencilOpSeparate(gl_face, + _sg_gl_stencil_op(state_sfs->fail_op), + _sg_gl_stencil_op(state_sfs->depth_fail_op), + _sg_gl_stencil_op(state_sfs->pass_op)); + } + } + cache_ss->read_mask = state_ss->read_mask; + cache_ss->ref = state_ss->ref; + } + + /* update blend state + FIXME: separate blend state per color attachment not support, needs GL4 + */ + { + const sg_blend_state* state_bs = &pip->gl.blend; + sg_blend_state* cache_bs = &_sg.gl.cache.blend; + if (state_bs->enabled != cache_bs->enabled) { + cache_bs->enabled = state_bs->enabled; + if (state_bs->enabled) { + glEnable(GL_BLEND); + } + else { + glDisable(GL_BLEND); + } + } + if ((state_bs->src_factor_rgb != cache_bs->src_factor_rgb) || + (state_bs->dst_factor_rgb != cache_bs->dst_factor_rgb) || + (state_bs->src_factor_alpha != cache_bs->src_factor_alpha) || + (state_bs->dst_factor_alpha != cache_bs->dst_factor_alpha)) + { + cache_bs->src_factor_rgb = state_bs->src_factor_rgb; + cache_bs->dst_factor_rgb = state_bs->dst_factor_rgb; + cache_bs->src_factor_alpha = state_bs->src_factor_alpha; + cache_bs->dst_factor_alpha = state_bs->dst_factor_alpha; + glBlendFuncSeparate(_sg_gl_blend_factor(state_bs->src_factor_rgb), + _sg_gl_blend_factor(state_bs->dst_factor_rgb), + _sg_gl_blend_factor(state_bs->src_factor_alpha), + _sg_gl_blend_factor(state_bs->dst_factor_alpha)); + } + if ((state_bs->op_rgb != cache_bs->op_rgb) || (state_bs->op_alpha != cache_bs->op_alpha)) { + cache_bs->op_rgb = state_bs->op_rgb; + cache_bs->op_alpha = state_bs->op_alpha; + glBlendEquationSeparate(_sg_gl_blend_op(state_bs->op_rgb), _sg_gl_blend_op(state_bs->op_alpha)); + } + } + + /* standalone state */ + for (GLuint i = 0; i < (GLuint)pip->cmn.color_attachment_count; i++) { + if (pip->gl.color_write_mask[i] != _sg.gl.cache.color_write_mask[i]) { + const sg_color_mask cm = pip->gl.color_write_mask[i]; + _sg.gl.cache.color_write_mask[i] = cm; +#ifdef SOKOL_GLCORE33 + glColorMaski(i, + (cm & SG_COLORMASK_R) != 0, + (cm & SG_COLORMASK_G) != 0, + (cm & SG_COLORMASK_B) != 0, + (cm & SG_COLORMASK_A) != 0); +#else + if (0 == i) { + glColorMask((cm & SG_COLORMASK_R) != 0, + (cm & SG_COLORMASK_G) != 0, + (cm & SG_COLORMASK_B) != 0, + (cm & SG_COLORMASK_A) != 0); + } +#endif + } + } + + if (!_sg_fequal(pip->cmn.blend_color.r, _sg.gl.cache.blend_color.r, 0.0001f) || + !_sg_fequal(pip->cmn.blend_color.g, _sg.gl.cache.blend_color.g, 0.0001f) || + !_sg_fequal(pip->cmn.blend_color.b, _sg.gl.cache.blend_color.b, 0.0001f) || + !_sg_fequal(pip->cmn.blend_color.a, _sg.gl.cache.blend_color.a, 0.0001f)) + { + sg_color c = pip->cmn.blend_color; + _sg.gl.cache.blend_color = c; + glBlendColor(c.r, c.g, c.b, c.a); + } + if (pip->gl.cull_mode != _sg.gl.cache.cull_mode) { + _sg.gl.cache.cull_mode = pip->gl.cull_mode; + if (SG_CULLMODE_NONE == pip->gl.cull_mode) { + glDisable(GL_CULL_FACE); + } + else { + glEnable(GL_CULL_FACE); + GLenum gl_mode = (SG_CULLMODE_FRONT == pip->gl.cull_mode) ? GL_FRONT : GL_BACK; + glCullFace(gl_mode); + } + } + if (pip->gl.face_winding != _sg.gl.cache.face_winding) { + _sg.gl.cache.face_winding = pip->gl.face_winding; + GLenum gl_winding = (SG_FACEWINDING_CW == pip->gl.face_winding) ? GL_CW : GL_CCW; + glFrontFace(gl_winding); + } + if (pip->gl.alpha_to_coverage_enabled != _sg.gl.cache.alpha_to_coverage_enabled) { + _sg.gl.cache.alpha_to_coverage_enabled = pip->gl.alpha_to_coverage_enabled; + if (pip->gl.alpha_to_coverage_enabled) { + glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); + } + else { + glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); + } + } +#ifdef SOKOL_GLCORE33 + if (pip->gl.sample_count != _sg.gl.cache.sample_count) { + _sg.gl.cache.sample_count = pip->gl.sample_count; + if (pip->gl.sample_count > 1) { + glEnable(GL_MULTISAMPLE); + } + else { + glDisable(GL_MULTISAMPLE); + } + } +#endif + + /* bind shader program */ + if (pip->shader->gl.prog != _sg.gl.cache.prog) { + _sg.gl.cache.prog = pip->shader->gl.prog; + glUseProgram(pip->shader->gl.prog); + } + } + _SG_GL_CHECK_ERROR(); +} + +_SOKOL_PRIVATE void _sg_gl_apply_bindings( + _sg_pipeline_t* pip, + _sg_buffer_t** vbs, const int* vb_offsets, int num_vbs, + _sg_buffer_t* ib, int ib_offset, + _sg_image_t** vs_imgs, int num_vs_imgs, + _sg_image_t** fs_imgs, int num_fs_imgs) +{ + SOKOL_ASSERT(pip); + _SOKOL_UNUSED(num_fs_imgs); + _SOKOL_UNUSED(num_vs_imgs); + _SOKOL_UNUSED(num_vbs); + _SG_GL_CHECK_ERROR(); + + /* bind textures */ + _SG_GL_CHECK_ERROR(); + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + const _sg_shader_stage_t* stage = &pip->shader->cmn.stage[stage_index]; + const _sg_gl_shader_stage_t* gl_stage = &pip->shader->gl.stage[stage_index]; + _sg_image_t** imgs = (stage_index == SG_SHADERSTAGE_VS)? vs_imgs : fs_imgs; + SOKOL_ASSERT(((stage_index == SG_SHADERSTAGE_VS)? num_vs_imgs : num_fs_imgs) == stage->num_images); + for (int img_index = 0; img_index < stage->num_images; img_index++) { + const _sg_gl_shader_image_t* gl_shd_img = &gl_stage->images[img_index]; + if (gl_shd_img->gl_tex_slot != -1) { + _sg_image_t* img = imgs[img_index]; + const GLuint gl_tex = img->gl.tex[img->cmn.active_slot]; + SOKOL_ASSERT(img && img->gl.target); + SOKOL_ASSERT((gl_shd_img->gl_tex_slot != -1) && gl_tex); + _sg_gl_cache_bind_texture(gl_shd_img->gl_tex_slot, img->gl.target, gl_tex); + } + } + } + _SG_GL_CHECK_ERROR(); + + /* index buffer (can be 0) */ + const GLuint gl_ib = ib ? ib->gl.buf[ib->cmn.active_slot] : 0; + _sg_gl_cache_bind_buffer(GL_ELEMENT_ARRAY_BUFFER, gl_ib); + _sg.gl.cache.cur_ib_offset = ib_offset; + + /* vertex attributes */ + for (GLuint attr_index = 0; attr_index < (GLuint)_sg.limits.max_vertex_attrs; attr_index++) { + _sg_gl_attr_t* attr = &pip->gl.attrs[attr_index]; + _sg_gl_cache_attr_t* cache_attr = &_sg.gl.cache.attrs[attr_index]; + bool cache_attr_dirty = false; + int vb_offset = 0; + GLuint gl_vb = 0; + if (attr->vb_index >= 0) { + /* attribute is enabled */ + SOKOL_ASSERT(attr->vb_index < num_vbs); + _sg_buffer_t* vb = vbs[attr->vb_index]; + SOKOL_ASSERT(vb); + gl_vb = vb->gl.buf[vb->cmn.active_slot]; + vb_offset = vb_offsets[attr->vb_index] + attr->offset; + if ((gl_vb != cache_attr->gl_vbuf) || + (attr->size != cache_attr->gl_attr.size) || + (attr->type != cache_attr->gl_attr.type) || + (attr->normalized != cache_attr->gl_attr.normalized) || + (attr->stride != cache_attr->gl_attr.stride) || + (vb_offset != cache_attr->gl_attr.offset) || + (cache_attr->gl_attr.divisor != attr->divisor)) + { + _sg_gl_cache_bind_buffer(GL_ARRAY_BUFFER, gl_vb); + glVertexAttribPointer(attr_index, attr->size, attr->type, + attr->normalized, attr->stride, + (const GLvoid*)(GLintptr)vb_offset); +#if defined(_SOKOL_GL_INSTANCING_ENABLED) + if (_sg.features.instancing) { + glVertexAttribDivisor(attr_index, (GLuint)attr->divisor); + } +#endif + cache_attr_dirty = true; + } + if (cache_attr->gl_attr.vb_index == -1) { + glEnableVertexAttribArray(attr_index); + cache_attr_dirty = true; + } + } + else { + /* attribute is disabled */ + if (cache_attr->gl_attr.vb_index != -1) { + glDisableVertexAttribArray(attr_index); + cache_attr_dirty = true; + } + } + if (cache_attr_dirty) { + cache_attr->gl_attr = *attr; + cache_attr->gl_attr.offset = vb_offset; + cache_attr->gl_vbuf = gl_vb; + } + } + _SG_GL_CHECK_ERROR(); +} + +_SOKOL_PRIVATE void _sg_gl_apply_uniforms(sg_shader_stage stage_index, int ub_index, const sg_range* data) { + SOKOL_ASSERT(_sg.gl.cache.cur_pipeline); + SOKOL_ASSERT(_sg.gl.cache.cur_pipeline->slot.id == _sg.gl.cache.cur_pipeline_id.id); + SOKOL_ASSERT(_sg.gl.cache.cur_pipeline->shader->slot.id == _sg.gl.cache.cur_pipeline->cmn.shader_id.id); + SOKOL_ASSERT(_sg.gl.cache.cur_pipeline->shader->cmn.stage[stage_index].num_uniform_blocks > ub_index); + SOKOL_ASSERT(_sg.gl.cache.cur_pipeline->shader->cmn.stage[stage_index].uniform_blocks[ub_index].size == data->size); + const _sg_gl_shader_stage_t* gl_stage = &_sg.gl.cache.cur_pipeline->shader->gl.stage[stage_index]; + const _sg_gl_uniform_block_t* gl_ub = &gl_stage->uniform_blocks[ub_index]; + for (int u_index = 0; u_index < gl_ub->num_uniforms; u_index++) { + const _sg_gl_uniform_t* u = &gl_ub->uniforms[u_index]; + SOKOL_ASSERT(u->type != SG_UNIFORMTYPE_INVALID); + if (u->gl_loc == -1) { + continue; + } + GLfloat* fptr = (GLfloat*) (((uint8_t*)data->ptr) + u->offset); + GLint* iptr = (GLint*) (((uint8_t*)data->ptr) + u->offset); + switch (u->type) { + case SG_UNIFORMTYPE_INVALID: + break; + case SG_UNIFORMTYPE_FLOAT: + glUniform1fv(u->gl_loc, u->count, fptr); + break; + case SG_UNIFORMTYPE_FLOAT2: + glUniform2fv(u->gl_loc, u->count, fptr); + break; + case SG_UNIFORMTYPE_FLOAT3: + glUniform3fv(u->gl_loc, u->count, fptr); + break; + case SG_UNIFORMTYPE_FLOAT4: + glUniform4fv(u->gl_loc, u->count, fptr); + break; + case SG_UNIFORMTYPE_INT: + glUniform1iv(u->gl_loc, u->count, iptr); + break; + case SG_UNIFORMTYPE_INT2: + glUniform2iv(u->gl_loc, u->count, iptr); + break; + case SG_UNIFORMTYPE_INT3: + glUniform3iv(u->gl_loc, u->count, iptr); + break; + case SG_UNIFORMTYPE_INT4: + glUniform4iv(u->gl_loc, u->count, iptr); + break; + case SG_UNIFORMTYPE_MAT4: + glUniformMatrix4fv(u->gl_loc, u->count, GL_FALSE, fptr); + break; + default: + SOKOL_UNREACHABLE; + break; + } + } +} + +_SOKOL_PRIVATE void _sg_gl_draw(int base_element, int num_elements, int num_instances) { + SOKOL_ASSERT(_sg.gl.cache.cur_pipeline); + const GLenum i_type = _sg.gl.cache.cur_index_type; + const GLenum p_type = _sg.gl.cache.cur_primitive_type; + if (0 != i_type) { + /* indexed rendering */ + const int i_size = (i_type == GL_UNSIGNED_SHORT) ? 2 : 4; + const int ib_offset = _sg.gl.cache.cur_ib_offset; + const GLvoid* indices = (const GLvoid*)(GLintptr)(base_element*i_size+ib_offset); + if (_sg.gl.cache.cur_pipeline->cmn.use_instanced_draw) { + if (_sg.features.instancing) { + glDrawElementsInstanced(p_type, num_elements, i_type, indices, num_instances); + } + } + else { + glDrawElements(p_type, num_elements, i_type, indices); + } + } + else { + /* non-indexed rendering */ + if (_sg.gl.cache.cur_pipeline->cmn.use_instanced_draw) { + if (_sg.features.instancing) { + glDrawArraysInstanced(p_type, base_element, num_elements, num_instances); + } + } + else { + glDrawArrays(p_type, base_element, num_elements); + } + } +} + +_SOKOL_PRIVATE void _sg_gl_commit(void) { + SOKOL_ASSERT(!_sg.gl.in_pass); + /* "soft" clear bindings (only those that are actually bound) */ + _sg_gl_cache_clear_buffer_bindings(false); + _sg_gl_cache_clear_texture_bindings(false); +} + +_SOKOL_PRIVATE void _sg_gl_update_buffer(_sg_buffer_t* buf, const sg_range* data) { + SOKOL_ASSERT(buf && data && data->ptr && (data->size > 0)); + /* only one update per buffer per frame allowed */ + if (++buf->cmn.active_slot >= buf->cmn.num_slots) { + buf->cmn.active_slot = 0; + } + GLenum gl_tgt = _sg_gl_buffer_target(buf->cmn.type); + SOKOL_ASSERT(buf->cmn.active_slot < SG_NUM_INFLIGHT_FRAMES); + GLuint gl_buf = buf->gl.buf[buf->cmn.active_slot]; + SOKOL_ASSERT(gl_buf); + _SG_GL_CHECK_ERROR(); + _sg_gl_cache_store_buffer_binding(gl_tgt); + _sg_gl_cache_bind_buffer(gl_tgt, gl_buf); + glBufferSubData(gl_tgt, 0, (GLsizeiptr)data->size, data->ptr); + _sg_gl_cache_restore_buffer_binding(gl_tgt); + _SG_GL_CHECK_ERROR(); +} + +_SOKOL_PRIVATE int _sg_gl_append_buffer(_sg_buffer_t* buf, const sg_range* data, bool new_frame) { + SOKOL_ASSERT(buf && data && data->ptr && (data->size > 0)); + if (new_frame) { + if (++buf->cmn.active_slot >= buf->cmn.num_slots) { + buf->cmn.active_slot = 0; + } + } + GLenum gl_tgt = _sg_gl_buffer_target(buf->cmn.type); + SOKOL_ASSERT(buf->cmn.active_slot < SG_NUM_INFLIGHT_FRAMES); + GLuint gl_buf = buf->gl.buf[buf->cmn.active_slot]; + SOKOL_ASSERT(gl_buf); + _SG_GL_CHECK_ERROR(); + _sg_gl_cache_store_buffer_binding(gl_tgt); + _sg_gl_cache_bind_buffer(gl_tgt, gl_buf); + glBufferSubData(gl_tgt, buf->cmn.append_pos, (GLsizeiptr)data->size, data->ptr); + _sg_gl_cache_restore_buffer_binding(gl_tgt); + _SG_GL_CHECK_ERROR(); + /* NOTE: this is a requirement from WebGPU, but we want identical behaviour across all backend */ + return _sg_roundup((int)data->size, 4); +} + +_SOKOL_PRIVATE void _sg_gl_update_image(_sg_image_t* img, const sg_image_data* data) { + SOKOL_ASSERT(img && data); + /* only one update per image per frame allowed */ + if (++img->cmn.active_slot >= img->cmn.num_slots) { + img->cmn.active_slot = 0; + } + SOKOL_ASSERT(img->cmn.active_slot < SG_NUM_INFLIGHT_FRAMES); + SOKOL_ASSERT(0 != img->gl.tex[img->cmn.active_slot]); + _sg_gl_cache_store_texture_binding(0); + _sg_gl_cache_bind_texture(0, img->gl.target, img->gl.tex[img->cmn.active_slot]); + const GLenum gl_img_format = _sg_gl_teximage_format(img->cmn.pixel_format); + const GLenum gl_img_type = _sg_gl_teximage_type(img->cmn.pixel_format); + const int num_faces = img->cmn.type == SG_IMAGETYPE_CUBE ? 6 : 1; + const int num_mips = img->cmn.num_mipmaps; + for (int face_index = 0; face_index < num_faces; face_index++) { + for (int mip_index = 0; mip_index < num_mips; mip_index++) { + GLenum gl_img_target = img->gl.target; + if (SG_IMAGETYPE_CUBE == img->cmn.type) { + gl_img_target = _sg_gl_cubeface_target(face_index); + } + const GLvoid* data_ptr = data->subimage[face_index][mip_index].ptr; + int mip_width = img->cmn.width >> mip_index; + if (mip_width == 0) { + mip_width = 1; + } + int mip_height = img->cmn.height >> mip_index; + if (mip_height == 0) { + mip_height = 1; + } + if ((SG_IMAGETYPE_2D == img->cmn.type) || (SG_IMAGETYPE_CUBE == img->cmn.type)) { + glTexSubImage2D(gl_img_target, mip_index, + 0, 0, + mip_width, mip_height, + gl_img_format, gl_img_type, + data_ptr); + } +#if !defined(SOKOL_GLES2) + else if (!_sg.gl.gles2 && ((SG_IMAGETYPE_3D == img->cmn.type) || (SG_IMAGETYPE_ARRAY == img->cmn.type))) { + int mip_depth = img->cmn.num_slices >> mip_index; + if (mip_depth == 0) { + mip_depth = 1; + } + glTexSubImage3D(gl_img_target, mip_index, + 0, 0, 0, + mip_width, mip_height, mip_depth, + gl_img_format, gl_img_type, + data_ptr); + + } +#endif + } + } + _sg_gl_cache_restore_texture_binding(0); +} + +/*== D3D11 BACKEND IMPLEMENTATION ============================================*/ +#elif defined(SOKOL_D3D11) + +#if defined(__cplusplus) +#define _sg_d3d11_AddRef(self) (self)->AddRef() +#else +#define _sg_d3d11_AddRef(self) (self)->lpVtbl->AddRef(self) +#endif + +#if defined(__cplusplus) +#define _sg_d3d11_Release(self) (self)->Release() +#else +#define _sg_d3d11_Release(self) (self)->lpVtbl->Release(self) +#endif + +/*-- D3D11 C/C++ wrappers ----------------------------------------------------*/ +static inline HRESULT _sg_d3d11_CheckFormatSupport(ID3D11Device* self, DXGI_FORMAT Format, UINT* pFormatSupport) { +#if defined(__cplusplus) + return self->CheckFormatSupport(Format, pFormatSupport); +#else + return self->lpVtbl->CheckFormatSupport(self, Format, pFormatSupport); +#endif +} + +static inline void _sg_d3d11_OMSetRenderTargets(ID3D11DeviceContext* self, UINT NumViews, ID3D11RenderTargetView* const* ppRenderTargetViews, ID3D11DepthStencilView *pDepthStencilView) { +#if defined(__cplusplus) + self->OMSetRenderTargets(NumViews, ppRenderTargetViews, pDepthStencilView); +#else + self->lpVtbl->OMSetRenderTargets(self, NumViews, ppRenderTargetViews, pDepthStencilView); +#endif +} + +static inline void _sg_d3d11_RSSetState(ID3D11DeviceContext* self, ID3D11RasterizerState* pRasterizerState) { +#if defined(__cplusplus) + self->RSSetState(pRasterizerState); +#else + self->lpVtbl->RSSetState(self, pRasterizerState); +#endif +} + +static inline void _sg_d3d11_OMSetDepthStencilState(ID3D11DeviceContext* self, ID3D11DepthStencilState* pDepthStencilState, UINT StencilRef) { +#if defined(__cplusplus) + self->OMSetDepthStencilState(pDepthStencilState, StencilRef); +#else + self->lpVtbl->OMSetDepthStencilState(self, pDepthStencilState, StencilRef); +#endif +} + +static inline void _sg_d3d11_OMSetBlendState(ID3D11DeviceContext* self, ID3D11BlendState* pBlendState, const FLOAT BlendFactor[4], UINT SampleMask) { +#if defined(__cplusplus) + self->OMSetBlendState(pBlendState, BlendFactor, SampleMask); +#else + self->lpVtbl->OMSetBlendState(self, pBlendState, BlendFactor, SampleMask); +#endif +} + +static inline void _sg_d3d11_IASetVertexBuffers(ID3D11DeviceContext* self, UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppVertexBuffers, const UINT* pStrides, const UINT* pOffsets) { +#if defined(__cplusplus) + self->IASetVertexBuffers(StartSlot, NumBuffers, ppVertexBuffers, pStrides, pOffsets); +#else + self->lpVtbl->IASetVertexBuffers(self, StartSlot, NumBuffers, ppVertexBuffers, pStrides, pOffsets); +#endif +} + +static inline void _sg_d3d11_IASetIndexBuffer(ID3D11DeviceContext* self, ID3D11Buffer* pIndexBuffer, DXGI_FORMAT Format, UINT Offset) { +#if defined(__cplusplus) + self->IASetIndexBuffer(pIndexBuffer, Format, Offset); +#else + self->lpVtbl->IASetIndexBuffer(self, pIndexBuffer, Format, Offset); +#endif +} + +static inline void _sg_d3d11_IASetInputLayout(ID3D11DeviceContext* self, ID3D11InputLayout* pInputLayout) { +#if defined(__cplusplus) + self->IASetInputLayout(pInputLayout); +#else + self->lpVtbl->IASetInputLayout(self, pInputLayout); +#endif +} + +static inline void _sg_d3d11_VSSetShader(ID3D11DeviceContext* self, ID3D11VertexShader* pVertexShader, ID3D11ClassInstance* const* ppClassInstances, UINT NumClassInstances) { +#if defined(__cplusplus) + self->VSSetShader(pVertexShader, ppClassInstances, NumClassInstances); +#else + self->lpVtbl->VSSetShader(self, pVertexShader, ppClassInstances, NumClassInstances); +#endif +} + +static inline void _sg_d3d11_PSSetShader(ID3D11DeviceContext* self, ID3D11PixelShader* pPixelShader, ID3D11ClassInstance* const* ppClassInstances, UINT NumClassInstances) { +#if defined(__cplusplus) + self->PSSetShader(pPixelShader, ppClassInstances, NumClassInstances); +#else + self->lpVtbl->PSSetShader(self, pPixelShader, ppClassInstances, NumClassInstances); +#endif +} + +static inline void _sg_d3d11_VSSetConstantBuffers(ID3D11DeviceContext* self, UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) { +#if defined(__cplusplus) + self->VSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); +#else + self->lpVtbl->VSSetConstantBuffers(self, StartSlot, NumBuffers, ppConstantBuffers); +#endif +} + +static inline void _sg_d3d11_PSSetConstantBuffers(ID3D11DeviceContext* self, UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers) { +#if defined(__cplusplus) + self->PSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); +#else + self->lpVtbl->PSSetConstantBuffers(self, StartSlot, NumBuffers, ppConstantBuffers); +#endif +} + +static inline void _sg_d3d11_VSSetShaderResources(ID3D11DeviceContext* self, UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView* const* ppShaderResourceViews) { +#if defined(__cplusplus) + self->VSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); +#else + self->lpVtbl->VSSetShaderResources(self, StartSlot, NumViews, ppShaderResourceViews); +#endif +} + +static inline void _sg_d3d11_PSSetShaderResources(ID3D11DeviceContext* self, UINT StartSlot, UINT NumViews, ID3D11ShaderResourceView* const* ppShaderResourceViews) { +#if defined(__cplusplus) + self->PSSetShaderResources(StartSlot, NumViews, ppShaderResourceViews); +#else + self->lpVtbl->PSSetShaderResources(self, StartSlot, NumViews, ppShaderResourceViews); +#endif +} + +static inline void _sg_d3d11_VSSetSamplers(ID3D11DeviceContext* self, UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) { +#if defined(__cplusplus) + self->VSSetSamplers(StartSlot, NumSamplers, ppSamplers); +#else + self->lpVtbl->VSSetSamplers(self, StartSlot, NumSamplers, ppSamplers); +#endif +} + +static inline void _sg_d3d11_PSSetSamplers(ID3D11DeviceContext* self, UINT StartSlot, UINT NumSamplers, ID3D11SamplerState* const* ppSamplers) { +#if defined(__cplusplus) + self->PSSetSamplers(StartSlot, NumSamplers, ppSamplers); +#else + self->lpVtbl->PSSetSamplers(self, StartSlot, NumSamplers, ppSamplers); +#endif +} + +static inline HRESULT _sg_d3d11_CreateBuffer(ID3D11Device* self, const D3D11_BUFFER_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Buffer** ppBuffer) { +#if defined(__cplusplus) + return self->CreateBuffer(pDesc, pInitialData, ppBuffer); +#else + return self->lpVtbl->CreateBuffer(self, pDesc, pInitialData, ppBuffer); +#endif +} + +static inline HRESULT _sg_d3d11_CreateTexture2D(ID3D11Device* self, const D3D11_TEXTURE2D_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Texture2D** ppTexture2D) { +#if defined(__cplusplus) + return self->CreateTexture2D(pDesc, pInitialData, ppTexture2D); +#else + return self->lpVtbl->CreateTexture2D(self, pDesc, pInitialData, ppTexture2D); +#endif +} + +static inline HRESULT _sg_d3d11_CreateShaderResourceView(ID3D11Device* self, ID3D11Resource* pResource, const D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc, ID3D11ShaderResourceView** ppSRView) { +#if defined(__cplusplus) + return self->CreateShaderResourceView(pResource, pDesc, ppSRView); +#else + return self->lpVtbl->CreateShaderResourceView(self, pResource, pDesc, ppSRView); +#endif +} + +static inline void _sg_d3d11_GetResource(ID3D11View* self, ID3D11Resource** ppResource) { +#if defined(__cplusplus) + self->GetResource(ppResource); +#else + self->lpVtbl->GetResource(self, ppResource); +#endif +} + +static inline HRESULT _sg_d3d11_CreateTexture3D(ID3D11Device* self, const D3D11_TEXTURE3D_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData, ID3D11Texture3D** ppTexture3D) { +#if defined(__cplusplus) + return self->CreateTexture3D(pDesc, pInitialData, ppTexture3D); +#else + return self->lpVtbl->CreateTexture3D(self, pDesc, pInitialData, ppTexture3D); +#endif +} + +static inline HRESULT _sg_d3d11_CreateSamplerState(ID3D11Device* self, const D3D11_SAMPLER_DESC* pSamplerDesc, ID3D11SamplerState** ppSamplerState) { +#if defined(__cplusplus) + return self->CreateSamplerState(pSamplerDesc, ppSamplerState); +#else + return self->lpVtbl->CreateSamplerState(self, pSamplerDesc, ppSamplerState); +#endif +} + +static inline LPVOID _sg_d3d11_GetBufferPointer(ID3D10Blob* self) { +#if defined(__cplusplus) + return self->GetBufferPointer(); +#else + return self->lpVtbl->GetBufferPointer(self); +#endif +} + +static inline SIZE_T _sg_d3d11_GetBufferSize(ID3D10Blob* self) { +#if defined(__cplusplus) + return self->GetBufferSize(); +#else + return self->lpVtbl->GetBufferSize(self); +#endif +} + +static inline HRESULT _sg_d3d11_CreateVertexShader(ID3D11Device* self, const void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11VertexShader** ppVertexShader) { +#if defined(__cplusplus) + return self->CreateVertexShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppVertexShader); +#else + return self->lpVtbl->CreateVertexShader(self, pShaderBytecode, BytecodeLength, pClassLinkage, ppVertexShader); +#endif +} + +static inline HRESULT _sg_d3d11_CreatePixelShader(ID3D11Device* self, const void* pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage* pClassLinkage, ID3D11PixelShader** ppPixelShader) { +#if defined(__cplusplus) + return self->CreatePixelShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppPixelShader); +#else + return self->lpVtbl->CreatePixelShader(self, pShaderBytecode, BytecodeLength, pClassLinkage, ppPixelShader); +#endif +} + +static inline HRESULT _sg_d3d11_CreateInputLayout(ID3D11Device* self, const D3D11_INPUT_ELEMENT_DESC* pInputElementDescs, UINT NumElements, const void* pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, ID3D11InputLayout **ppInputLayout) { +#if defined(__cplusplus) + return self->CreateInputLayout(pInputElementDescs, NumElements, pShaderBytecodeWithInputSignature, BytecodeLength, ppInputLayout); +#else + return self->lpVtbl->CreateInputLayout(self, pInputElementDescs, NumElements, pShaderBytecodeWithInputSignature, BytecodeLength, ppInputLayout); +#endif +} + +static inline HRESULT _sg_d3d11_CreateRasterizerState(ID3D11Device* self, const D3D11_RASTERIZER_DESC* pRasterizerDesc, ID3D11RasterizerState** ppRasterizerState) { +#if defined(__cplusplus) + return self->CreateRasterizerState(pRasterizerDesc, ppRasterizerState); +#else + return self->lpVtbl->CreateRasterizerState(self, pRasterizerDesc, ppRasterizerState); +#endif +} + +static inline HRESULT _sg_d3d11_CreateDepthStencilState(ID3D11Device* self, const D3D11_DEPTH_STENCIL_DESC* pDepthStencilDesc, ID3D11DepthStencilState** ppDepthStencilState) { +#if defined(__cplusplus) + return self->CreateDepthStencilState(pDepthStencilDesc, ppDepthStencilState); +#else + return self->lpVtbl->CreateDepthStencilState(self, pDepthStencilDesc, ppDepthStencilState); +#endif +} + +static inline HRESULT _sg_d3d11_CreateBlendState(ID3D11Device* self, const D3D11_BLEND_DESC* pBlendStateDesc, ID3D11BlendState** ppBlendState) { +#if defined(__cplusplus) + return self->CreateBlendState(pBlendStateDesc, ppBlendState); +#else + return self->lpVtbl->CreateBlendState(self, pBlendStateDesc, ppBlendState); +#endif +} + +static inline HRESULT _sg_d3d11_CreateRenderTargetView(ID3D11Device* self, ID3D11Resource *pResource, const D3D11_RENDER_TARGET_VIEW_DESC* pDesc, ID3D11RenderTargetView** ppRTView) { +#if defined(__cplusplus) + return self->CreateRenderTargetView(pResource, pDesc, ppRTView); +#else + return self->lpVtbl->CreateRenderTargetView(self, pResource, pDesc, ppRTView); +#endif +} + +static inline HRESULT _sg_d3d11_CreateDepthStencilView(ID3D11Device* self, ID3D11Resource* pResource, const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc, ID3D11DepthStencilView** ppDepthStencilView) { +#if defined(__cplusplus) + return self->CreateDepthStencilView(pResource, pDesc, ppDepthStencilView); +#else + return self->lpVtbl->CreateDepthStencilView(self, pResource, pDesc, ppDepthStencilView); +#endif +} + +static inline void _sg_d3d11_RSSetViewports(ID3D11DeviceContext* self, UINT NumViewports, const D3D11_VIEWPORT* pViewports) { +#if defined(__cplusplus) + self->RSSetViewports(NumViewports, pViewports); +#else + self->lpVtbl->RSSetViewports(self, NumViewports, pViewports); +#endif +} + +static inline void _sg_d3d11_RSSetScissorRects(ID3D11DeviceContext* self, UINT NumRects, const D3D11_RECT* pRects) { +#if defined(__cplusplus) + self->RSSetScissorRects(NumRects, pRects); +#else + self->lpVtbl->RSSetScissorRects(self, NumRects, pRects); +#endif +} + +static inline void _sg_d3d11_ClearRenderTargetView(ID3D11DeviceContext* self, ID3D11RenderTargetView* pRenderTargetView, const FLOAT ColorRGBA[4]) { +#if defined(__cplusplus) + self->ClearRenderTargetView(pRenderTargetView, ColorRGBA); +#else + self->lpVtbl->ClearRenderTargetView(self, pRenderTargetView, ColorRGBA); +#endif +} + +static inline void _sg_d3d11_ClearDepthStencilView(ID3D11DeviceContext* self, ID3D11DepthStencilView* pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil) { +#if defined(__cplusplus) + self->ClearDepthStencilView(pDepthStencilView, ClearFlags, Depth, Stencil); +#else + self->lpVtbl->ClearDepthStencilView(self, pDepthStencilView, ClearFlags, Depth, Stencil); +#endif +} + +static inline void _sg_d3d11_ResolveSubresource(ID3D11DeviceContext* self, ID3D11Resource* pDstResource, UINT DstSubresource, ID3D11Resource* pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format) { +#if defined(__cplusplus) + self->ResolveSubresource(pDstResource, DstSubresource, pSrcResource, SrcSubresource, Format); +#else + self->lpVtbl->ResolveSubresource(self, pDstResource, DstSubresource, pSrcResource, SrcSubresource, Format); +#endif +} + +static inline void _sg_d3d11_IASetPrimitiveTopology(ID3D11DeviceContext* self, D3D11_PRIMITIVE_TOPOLOGY Topology) { +#if defined(__cplusplus) + self->IASetPrimitiveTopology(Topology); +#else + self->lpVtbl->IASetPrimitiveTopology(self, Topology); +#endif +} + +static inline void _sg_d3d11_UpdateSubresource(ID3D11DeviceContext* self, ID3D11Resource* pDstResource, UINT DstSubresource, const D3D11_BOX* pDstBox, const void* pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch) { +#if defined(__cplusplus) + self->UpdateSubresource(pDstResource, DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch); +#else + self->lpVtbl->UpdateSubresource(self, pDstResource, DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch); +#endif +} + +static inline void _sg_d3d11_DrawIndexed(ID3D11DeviceContext* self, UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation) { +#if defined(__cplusplus) + self->DrawIndexed(IndexCount, StartIndexLocation, BaseVertexLocation); +#else + self->lpVtbl->DrawIndexed(self, IndexCount, StartIndexLocation, BaseVertexLocation); +#endif +} + +static inline void _sg_d3d11_DrawIndexedInstanced(ID3D11DeviceContext* self, UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, INT BaseVertexLocation, UINT StartInstanceLocation) { +#if defined(__cplusplus) + self->DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation, BaseVertexLocation, StartInstanceLocation); +#else + self->lpVtbl->DrawIndexedInstanced(self, IndexCountPerInstance, InstanceCount, StartIndexLocation, BaseVertexLocation, StartInstanceLocation); +#endif +} + +static inline void _sg_d3d11_Draw(ID3D11DeviceContext* self, UINT VertexCount, UINT StartVertexLocation) { +#if defined(__cplusplus) + self->Draw(VertexCount, StartVertexLocation); +#else + self->lpVtbl->Draw(self, VertexCount, StartVertexLocation); +#endif +} + +static inline void _sg_d3d11_DrawInstanced(ID3D11DeviceContext* self, UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation) { +#if defined(__cplusplus) + self->DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation, StartInstanceLocation); +#else + self->lpVtbl->DrawInstanced(self, VertexCountPerInstance, InstanceCount, StartVertexLocation, StartInstanceLocation); +#endif +} + +static inline HRESULT _sg_d3d11_Map(ID3D11DeviceContext* self, ID3D11Resource* pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, D3D11_MAPPED_SUBRESOURCE* pMappedResource) { +#if defined(__cplusplus) + return self->Map(pResource, Subresource, MapType, MapFlags, pMappedResource); +#else + return self->lpVtbl->Map(self, pResource, Subresource, MapType, MapFlags, pMappedResource); +#endif +} + +static inline void _sg_d3d11_Unmap(ID3D11DeviceContext* self, ID3D11Resource* pResource, UINT Subresource) { +#if defined(__cplusplus) + self->Unmap(pResource, Subresource); +#else + self->lpVtbl->Unmap(self, pResource, Subresource); +#endif +} + +static inline void _sg_d3d11_ClearState(ID3D11DeviceContext* self) { +#if defined(__cplusplus) + self->ClearState(); +#else + self->lpVtbl->ClearState(self); +#endif +} + +/*-- enum translation functions ----------------------------------------------*/ +_SOKOL_PRIVATE D3D11_USAGE _sg_d3d11_usage(sg_usage usg) { + switch (usg) { + case SG_USAGE_IMMUTABLE: + return D3D11_USAGE_IMMUTABLE; + case SG_USAGE_DYNAMIC: + case SG_USAGE_STREAM: + return D3D11_USAGE_DYNAMIC; + default: + SOKOL_UNREACHABLE; + return (D3D11_USAGE) 0; + } +} + +_SOKOL_PRIVATE UINT _sg_d3d11_cpu_access_flags(sg_usage usg) { + switch (usg) { + case SG_USAGE_IMMUTABLE: + return 0; + case SG_USAGE_DYNAMIC: + case SG_USAGE_STREAM: + return D3D11_CPU_ACCESS_WRITE; + default: + SOKOL_UNREACHABLE; + return 0; + } +} + +_SOKOL_PRIVATE DXGI_FORMAT _sg_d3d11_pixel_format(sg_pixel_format fmt) { + switch (fmt) { + case SG_PIXELFORMAT_R8: return DXGI_FORMAT_R8_UNORM; + case SG_PIXELFORMAT_R8SN: return DXGI_FORMAT_R8_SNORM; + case SG_PIXELFORMAT_R8UI: return DXGI_FORMAT_R8_UINT; + case SG_PIXELFORMAT_R8SI: return DXGI_FORMAT_R8_SINT; + case SG_PIXELFORMAT_R16: return DXGI_FORMAT_R16_UNORM; + case SG_PIXELFORMAT_R16SN: return DXGI_FORMAT_R16_SNORM; + case SG_PIXELFORMAT_R16UI: return DXGI_FORMAT_R16_UINT; + case SG_PIXELFORMAT_R16SI: return DXGI_FORMAT_R16_SINT; + case SG_PIXELFORMAT_R16F: return DXGI_FORMAT_R16_FLOAT; + case SG_PIXELFORMAT_RG8: return DXGI_FORMAT_R8G8_UNORM; + case SG_PIXELFORMAT_RG8SN: return DXGI_FORMAT_R8G8_SNORM; + case SG_PIXELFORMAT_RG8UI: return DXGI_FORMAT_R8G8_UINT; + case SG_PIXELFORMAT_RG8SI: return DXGI_FORMAT_R8G8_SINT; + case SG_PIXELFORMAT_R32UI: return DXGI_FORMAT_R32_UINT; + case SG_PIXELFORMAT_R32SI: return DXGI_FORMAT_R32_SINT; + case SG_PIXELFORMAT_R32F: return DXGI_FORMAT_R32_FLOAT; + case SG_PIXELFORMAT_RG16: return DXGI_FORMAT_R16G16_UNORM; + case SG_PIXELFORMAT_RG16SN: return DXGI_FORMAT_R16G16_SNORM; + case SG_PIXELFORMAT_RG16UI: return DXGI_FORMAT_R16G16_UINT; + case SG_PIXELFORMAT_RG16SI: return DXGI_FORMAT_R16G16_SINT; + case SG_PIXELFORMAT_RG16F: return DXGI_FORMAT_R16G16_FLOAT; + case SG_PIXELFORMAT_RGBA8: return DXGI_FORMAT_R8G8B8A8_UNORM; + case SG_PIXELFORMAT_RGBA8SN: return DXGI_FORMAT_R8G8B8A8_SNORM; + case SG_PIXELFORMAT_RGBA8UI: return DXGI_FORMAT_R8G8B8A8_UINT; + case SG_PIXELFORMAT_RGBA8SI: return DXGI_FORMAT_R8G8B8A8_SINT; + case SG_PIXELFORMAT_BGRA8: return DXGI_FORMAT_B8G8R8A8_UNORM; + case SG_PIXELFORMAT_RGB10A2: return DXGI_FORMAT_R10G10B10A2_UNORM; + case SG_PIXELFORMAT_RG11B10F: return DXGI_FORMAT_R11G11B10_FLOAT; + case SG_PIXELFORMAT_RG32UI: return DXGI_FORMAT_R32G32_UINT; + case SG_PIXELFORMAT_RG32SI: return DXGI_FORMAT_R32G32_SINT; + case SG_PIXELFORMAT_RG32F: return DXGI_FORMAT_R32G32_FLOAT; + case SG_PIXELFORMAT_RGBA16: return DXGI_FORMAT_R16G16B16A16_UNORM; + case SG_PIXELFORMAT_RGBA16SN: return DXGI_FORMAT_R16G16B16A16_SNORM; + case SG_PIXELFORMAT_RGBA16UI: return DXGI_FORMAT_R16G16B16A16_UINT; + case SG_PIXELFORMAT_RGBA16SI: return DXGI_FORMAT_R16G16B16A16_SINT; + case SG_PIXELFORMAT_RGBA16F: return DXGI_FORMAT_R16G16B16A16_FLOAT; + case SG_PIXELFORMAT_RGBA32UI: return DXGI_FORMAT_R32G32B32A32_UINT; + case SG_PIXELFORMAT_RGBA32SI: return DXGI_FORMAT_R32G32B32A32_SINT; + case SG_PIXELFORMAT_RGBA32F: return DXGI_FORMAT_R32G32B32A32_FLOAT; + case SG_PIXELFORMAT_DEPTH: return DXGI_FORMAT_D32_FLOAT; + case SG_PIXELFORMAT_DEPTH_STENCIL: return DXGI_FORMAT_D24_UNORM_S8_UINT; + case SG_PIXELFORMAT_BC1_RGBA: return DXGI_FORMAT_BC1_UNORM; + case SG_PIXELFORMAT_BC2_RGBA: return DXGI_FORMAT_BC2_UNORM; + case SG_PIXELFORMAT_BC3_RGBA: return DXGI_FORMAT_BC3_UNORM; + case SG_PIXELFORMAT_BC4_R: return DXGI_FORMAT_BC4_UNORM; + case SG_PIXELFORMAT_BC4_RSN: return DXGI_FORMAT_BC4_SNORM; + case SG_PIXELFORMAT_BC5_RG: return DXGI_FORMAT_BC5_UNORM; + case SG_PIXELFORMAT_BC5_RGSN: return DXGI_FORMAT_BC5_SNORM; + case SG_PIXELFORMAT_BC6H_RGBF: return DXGI_FORMAT_BC6H_SF16; + case SG_PIXELFORMAT_BC6H_RGBUF: return DXGI_FORMAT_BC6H_UF16; + case SG_PIXELFORMAT_BC7_RGBA: return DXGI_FORMAT_BC7_UNORM; + default: return DXGI_FORMAT_UNKNOWN; + }; +} + +_SOKOL_PRIVATE D3D11_PRIMITIVE_TOPOLOGY _sg_d3d11_primitive_topology(sg_primitive_type prim_type) { + switch (prim_type) { + case SG_PRIMITIVETYPE_POINTS: return D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; + case SG_PRIMITIVETYPE_LINES: return D3D11_PRIMITIVE_TOPOLOGY_LINELIST; + case SG_PRIMITIVETYPE_LINE_STRIP: return D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP; + case SG_PRIMITIVETYPE_TRIANGLES: return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + case SG_PRIMITIVETYPE_TRIANGLE_STRIP: return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; + default: SOKOL_UNREACHABLE; return (D3D11_PRIMITIVE_TOPOLOGY) 0; + } +} + +_SOKOL_PRIVATE DXGI_FORMAT _sg_d3d11_index_format(sg_index_type index_type) { + switch (index_type) { + case SG_INDEXTYPE_NONE: return DXGI_FORMAT_UNKNOWN; + case SG_INDEXTYPE_UINT16: return DXGI_FORMAT_R16_UINT; + case SG_INDEXTYPE_UINT32: return DXGI_FORMAT_R32_UINT; + default: SOKOL_UNREACHABLE; return (DXGI_FORMAT) 0; + } +} + +_SOKOL_PRIVATE D3D11_FILTER _sg_d3d11_filter(sg_filter min_f, sg_filter mag_f, uint32_t max_anisotropy) { + if (max_anisotropy > 1) { + return D3D11_FILTER_ANISOTROPIC; + } + else if (mag_f == SG_FILTER_NEAREST) { + switch (min_f) { + case SG_FILTER_NEAREST: + case SG_FILTER_NEAREST_MIPMAP_NEAREST: + return D3D11_FILTER_MIN_MAG_MIP_POINT; + case SG_FILTER_LINEAR: + case SG_FILTER_LINEAR_MIPMAP_NEAREST: + return D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT; + case SG_FILTER_NEAREST_MIPMAP_LINEAR: + return D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR; + case SG_FILTER_LINEAR_MIPMAP_LINEAR: + return D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR; + default: + SOKOL_UNREACHABLE; break; + } + } + else if (mag_f == SG_FILTER_LINEAR) { + switch (min_f) { + case SG_FILTER_NEAREST: + case SG_FILTER_NEAREST_MIPMAP_NEAREST: + return D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT; + case SG_FILTER_LINEAR: + case SG_FILTER_LINEAR_MIPMAP_NEAREST: + return D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT; + case SG_FILTER_NEAREST_MIPMAP_LINEAR: + return D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR; + case SG_FILTER_LINEAR_MIPMAP_LINEAR: + return D3D11_FILTER_MIN_MAG_MIP_LINEAR; + default: + SOKOL_UNREACHABLE; break; + } + } + /* invalid value for mag filter */ + SOKOL_UNREACHABLE; + return D3D11_FILTER_MIN_MAG_MIP_POINT; +} + +_SOKOL_PRIVATE D3D11_TEXTURE_ADDRESS_MODE _sg_d3d11_address_mode(sg_wrap m) { + switch (m) { + case SG_WRAP_REPEAT: return D3D11_TEXTURE_ADDRESS_WRAP; + case SG_WRAP_CLAMP_TO_EDGE: return D3D11_TEXTURE_ADDRESS_CLAMP; + case SG_WRAP_CLAMP_TO_BORDER: return D3D11_TEXTURE_ADDRESS_BORDER; + case SG_WRAP_MIRRORED_REPEAT: return D3D11_TEXTURE_ADDRESS_MIRROR; + default: SOKOL_UNREACHABLE; return (D3D11_TEXTURE_ADDRESS_MODE) 0; + } +} + +_SOKOL_PRIVATE DXGI_FORMAT _sg_d3d11_vertex_format(sg_vertex_format fmt) { + switch (fmt) { + case SG_VERTEXFORMAT_FLOAT: return DXGI_FORMAT_R32_FLOAT; + case SG_VERTEXFORMAT_FLOAT2: return DXGI_FORMAT_R32G32_FLOAT; + case SG_VERTEXFORMAT_FLOAT3: return DXGI_FORMAT_R32G32B32_FLOAT; + case SG_VERTEXFORMAT_FLOAT4: return DXGI_FORMAT_R32G32B32A32_FLOAT; + case SG_VERTEXFORMAT_BYTE4: return DXGI_FORMAT_R8G8B8A8_SINT; + case SG_VERTEXFORMAT_BYTE4N: return DXGI_FORMAT_R8G8B8A8_SNORM; + case SG_VERTEXFORMAT_UBYTE4: return DXGI_FORMAT_R8G8B8A8_UINT; + case SG_VERTEXFORMAT_UBYTE4N: return DXGI_FORMAT_R8G8B8A8_UNORM; + case SG_VERTEXFORMAT_SHORT2: return DXGI_FORMAT_R16G16_SINT; + case SG_VERTEXFORMAT_SHORT2N: return DXGI_FORMAT_R16G16_SNORM; + case SG_VERTEXFORMAT_USHORT2N: return DXGI_FORMAT_R16G16_UNORM; + case SG_VERTEXFORMAT_SHORT4: return DXGI_FORMAT_R16G16B16A16_SINT; + case SG_VERTEXFORMAT_SHORT4N: return DXGI_FORMAT_R16G16B16A16_SNORM; + case SG_VERTEXFORMAT_USHORT4N: return DXGI_FORMAT_R16G16B16A16_UNORM; + case SG_VERTEXFORMAT_UINT10_N2: return DXGI_FORMAT_R10G10B10A2_UNORM; + default: SOKOL_UNREACHABLE; return (DXGI_FORMAT) 0; + } +} + +_SOKOL_PRIVATE D3D11_INPUT_CLASSIFICATION _sg_d3d11_input_classification(sg_vertex_step step) { + switch (step) { + case SG_VERTEXSTEP_PER_VERTEX: return D3D11_INPUT_PER_VERTEX_DATA; + case SG_VERTEXSTEP_PER_INSTANCE: return D3D11_INPUT_PER_INSTANCE_DATA; + default: SOKOL_UNREACHABLE; return (D3D11_INPUT_CLASSIFICATION) 0; + } +} + +_SOKOL_PRIVATE D3D11_CULL_MODE _sg_d3d11_cull_mode(sg_cull_mode m) { + switch (m) { + case SG_CULLMODE_NONE: return D3D11_CULL_NONE; + case SG_CULLMODE_FRONT: return D3D11_CULL_FRONT; + case SG_CULLMODE_BACK: return D3D11_CULL_BACK; + default: SOKOL_UNREACHABLE; return (D3D11_CULL_MODE) 0; + } +} + +_SOKOL_PRIVATE D3D11_COMPARISON_FUNC _sg_d3d11_compare_func(sg_compare_func f) { + switch (f) { + case SG_COMPAREFUNC_NEVER: return D3D11_COMPARISON_NEVER; + case SG_COMPAREFUNC_LESS: return D3D11_COMPARISON_LESS; + case SG_COMPAREFUNC_EQUAL: return D3D11_COMPARISON_EQUAL; + case SG_COMPAREFUNC_LESS_EQUAL: return D3D11_COMPARISON_LESS_EQUAL; + case SG_COMPAREFUNC_GREATER: return D3D11_COMPARISON_GREATER; + case SG_COMPAREFUNC_NOT_EQUAL: return D3D11_COMPARISON_NOT_EQUAL; + case SG_COMPAREFUNC_GREATER_EQUAL: return D3D11_COMPARISON_GREATER_EQUAL; + case SG_COMPAREFUNC_ALWAYS: return D3D11_COMPARISON_ALWAYS; + default: SOKOL_UNREACHABLE; return (D3D11_COMPARISON_FUNC) 0; + } +} + +_SOKOL_PRIVATE D3D11_STENCIL_OP _sg_d3d11_stencil_op(sg_stencil_op op) { + switch (op) { + case SG_STENCILOP_KEEP: return D3D11_STENCIL_OP_KEEP; + case SG_STENCILOP_ZERO: return D3D11_STENCIL_OP_ZERO; + case SG_STENCILOP_REPLACE: return D3D11_STENCIL_OP_REPLACE; + case SG_STENCILOP_INCR_CLAMP: return D3D11_STENCIL_OP_INCR_SAT; + case SG_STENCILOP_DECR_CLAMP: return D3D11_STENCIL_OP_DECR_SAT; + case SG_STENCILOP_INVERT: return D3D11_STENCIL_OP_INVERT; + case SG_STENCILOP_INCR_WRAP: return D3D11_STENCIL_OP_INCR; + case SG_STENCILOP_DECR_WRAP: return D3D11_STENCIL_OP_DECR; + default: SOKOL_UNREACHABLE; return (D3D11_STENCIL_OP) 0; + } +} + +_SOKOL_PRIVATE D3D11_BLEND _sg_d3d11_blend_factor(sg_blend_factor f) { + switch (f) { + case SG_BLENDFACTOR_ZERO: return D3D11_BLEND_ZERO; + case SG_BLENDFACTOR_ONE: return D3D11_BLEND_ONE; + case SG_BLENDFACTOR_SRC_COLOR: return D3D11_BLEND_SRC_COLOR; + case SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR: return D3D11_BLEND_INV_SRC_COLOR; + case SG_BLENDFACTOR_SRC_ALPHA: return D3D11_BLEND_SRC_ALPHA; + case SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: return D3D11_BLEND_INV_SRC_ALPHA; + case SG_BLENDFACTOR_DST_COLOR: return D3D11_BLEND_DEST_COLOR; + case SG_BLENDFACTOR_ONE_MINUS_DST_COLOR: return D3D11_BLEND_INV_DEST_COLOR; + case SG_BLENDFACTOR_DST_ALPHA: return D3D11_BLEND_DEST_ALPHA; + case SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA: return D3D11_BLEND_INV_DEST_ALPHA; + case SG_BLENDFACTOR_SRC_ALPHA_SATURATED: return D3D11_BLEND_SRC_ALPHA_SAT; + case SG_BLENDFACTOR_BLEND_COLOR: return D3D11_BLEND_BLEND_FACTOR; + case SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR: return D3D11_BLEND_INV_BLEND_FACTOR; + case SG_BLENDFACTOR_BLEND_ALPHA: return D3D11_BLEND_BLEND_FACTOR; + case SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA: return D3D11_BLEND_INV_BLEND_FACTOR; + default: SOKOL_UNREACHABLE; return (D3D11_BLEND) 0; + } +} + +_SOKOL_PRIVATE D3D11_BLEND_OP _sg_d3d11_blend_op(sg_blend_op op) { + switch (op) { + case SG_BLENDOP_ADD: return D3D11_BLEND_OP_ADD; + case SG_BLENDOP_SUBTRACT: return D3D11_BLEND_OP_SUBTRACT; + case SG_BLENDOP_REVERSE_SUBTRACT: return D3D11_BLEND_OP_REV_SUBTRACT; + default: SOKOL_UNREACHABLE; return (D3D11_BLEND_OP) 0; + } +} + +_SOKOL_PRIVATE UINT8 _sg_d3d11_color_write_mask(sg_color_mask m) { + UINT8 res = 0; + if (m & SG_COLORMASK_R) { + res |= D3D11_COLOR_WRITE_ENABLE_RED; + } + if (m & SG_COLORMASK_G) { + res |= D3D11_COLOR_WRITE_ENABLE_GREEN; + } + if (m & SG_COLORMASK_B) { + res |= D3D11_COLOR_WRITE_ENABLE_BLUE; + } + if (m & SG_COLORMASK_A) { + res |= D3D11_COLOR_WRITE_ENABLE_ALPHA; + } + return res; +} + +/* see: https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-resources-limits#resource-limits-for-feature-level-11-hardware */ +_SOKOL_PRIVATE void _sg_d3d11_init_caps(void) { + _sg.backend = SG_BACKEND_D3D11; + + _sg.features.instancing = true; + _sg.features.origin_top_left = true; + _sg.features.multiple_render_targets = true; + _sg.features.msaa_render_targets = true; + _sg.features.imagetype_3d = true; + _sg.features.imagetype_array = true; + _sg.features.image_clamp_to_border = true; + _sg.features.mrt_independent_blend_state = true; + _sg.features.mrt_independent_write_mask = true; + + _sg.limits.max_image_size_2d = 16 * 1024; + _sg.limits.max_image_size_cube = 16 * 1024; + _sg.limits.max_image_size_3d = 2 * 1024; + _sg.limits.max_image_size_array = 16 * 1024; + _sg.limits.max_image_array_layers = 2 * 1024; + _sg.limits.max_vertex_attrs = SG_MAX_VERTEX_ATTRIBUTES; + + /* see: https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ne-d3d11-d3d11_format_support */ + for (int fmt = (SG_PIXELFORMAT_NONE+1); fmt < _SG_PIXELFORMAT_NUM; fmt++) { + UINT dxgi_fmt_caps = 0; + const DXGI_FORMAT dxgi_fmt = _sg_d3d11_pixel_format((sg_pixel_format)fmt); + if (dxgi_fmt != DXGI_FORMAT_UNKNOWN) { + HRESULT hr = _sg_d3d11_CheckFormatSupport(_sg.d3d11.dev, dxgi_fmt, &dxgi_fmt_caps); + SOKOL_ASSERT(SUCCEEDED(hr) || (E_FAIL == hr)); + if (!SUCCEEDED(hr)) { + dxgi_fmt_caps = 0; + } + } + sg_pixelformat_info* info = &_sg.formats[fmt]; + info->sample = 0 != (dxgi_fmt_caps & D3D11_FORMAT_SUPPORT_TEXTURE2D); + info->filter = 0 != (dxgi_fmt_caps & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE); + info->render = 0 != (dxgi_fmt_caps & D3D11_FORMAT_SUPPORT_RENDER_TARGET); + info->blend = 0 != (dxgi_fmt_caps & D3D11_FORMAT_SUPPORT_BLENDABLE); + info->msaa = 0 != (dxgi_fmt_caps & D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET); + info->depth = 0 != (dxgi_fmt_caps & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL); + if (info->depth) { + info->render = true; + } + } +} + +_SOKOL_PRIVATE void _sg_d3d11_setup_backend(const sg_desc* desc) { + /* assume _sg.d3d11 already is zero-initialized */ + SOKOL_ASSERT(desc); + SOKOL_ASSERT(desc->context.d3d11.device); + SOKOL_ASSERT(desc->context.d3d11.device_context); + SOKOL_ASSERT(desc->context.d3d11.render_target_view_cb || desc->context.d3d11.render_target_view_userdata_cb); + SOKOL_ASSERT(desc->context.d3d11.depth_stencil_view_cb || desc->context.d3d11.depth_stencil_view_userdata_cb); + _sg.d3d11.valid = true; + _sg.d3d11.dev = (ID3D11Device*) desc->context.d3d11.device; + _sg.d3d11.ctx = (ID3D11DeviceContext*) desc->context.d3d11.device_context; + _sg.d3d11.rtv_cb = desc->context.d3d11.render_target_view_cb; + _sg.d3d11.rtv_userdata_cb = desc->context.d3d11.render_target_view_userdata_cb; + _sg.d3d11.dsv_cb = desc->context.d3d11.depth_stencil_view_cb; + _sg.d3d11.dsv_userdata_cb = desc->context.d3d11.depth_stencil_view_userdata_cb; + _sg.d3d11.user_data = desc->context.d3d11.user_data; + _sg_d3d11_init_caps(); +} + +_SOKOL_PRIVATE void _sg_d3d11_discard_backend(void) { + SOKOL_ASSERT(_sg.d3d11.valid); + _sg.d3d11.valid = false; +} + +_SOKOL_PRIVATE void _sg_d3d11_clear_state(void) { + /* clear all the device context state, so that resource refs don't keep stuck in the d3d device context */ + _sg_d3d11_ClearState(_sg.d3d11.ctx); +} + +_SOKOL_PRIVATE void _sg_d3d11_reset_state_cache(void) { + /* just clear the d3d11 device context state */ + _sg_d3d11_clear_state(); +} + +_SOKOL_PRIVATE void _sg_d3d11_activate_context(_sg_context_t* ctx) { + _SOKOL_UNUSED(ctx); + _sg_d3d11_clear_state(); +} + +_SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + _SOKOL_UNUSED(ctx); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_d3d11_destroy_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + _SOKOL_UNUSED(ctx); + /* empty */ +} + +_SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) { + SOKOL_ASSERT(buf && desc); + SOKOL_ASSERT(!buf->d3d11.buf); + _sg_buffer_common_init(&buf->cmn, desc); + const bool injected = (0 != desc->d3d11_buffer); + if (injected) { + buf->d3d11.buf = (ID3D11Buffer*) desc->d3d11_buffer; + _sg_d3d11_AddRef(buf->d3d11.buf); + } + else { + D3D11_BUFFER_DESC d3d11_desc; + memset(&d3d11_desc, 0, sizeof(d3d11_desc)); + d3d11_desc.ByteWidth = (UINT)buf->cmn.size; + d3d11_desc.Usage = _sg_d3d11_usage(buf->cmn.usage); + d3d11_desc.BindFlags = buf->cmn.type == SG_BUFFERTYPE_VERTEXBUFFER ? D3D11_BIND_VERTEX_BUFFER : D3D11_BIND_INDEX_BUFFER; + d3d11_desc.CPUAccessFlags = _sg_d3d11_cpu_access_flags(buf->cmn.usage); + D3D11_SUBRESOURCE_DATA* init_data_ptr = 0; + D3D11_SUBRESOURCE_DATA init_data; + memset(&init_data, 0, sizeof(init_data)); + if (buf->cmn.usage == SG_USAGE_IMMUTABLE) { + SOKOL_ASSERT(desc->data.ptr); + init_data.pSysMem = desc->data.ptr; + init_data_ptr = &init_data; + } + HRESULT hr = _sg_d3d11_CreateBuffer(_sg.d3d11.dev, &d3d11_desc, init_data_ptr, &buf->d3d11.buf); + if (!(SUCCEEDED(hr) && buf->d3d11.buf)) { + SOKOL_LOG("failed to create D3D11 buffer\n"); + return SG_RESOURCESTATE_FAILED; + } + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_d3d11_destroy_buffer(_sg_buffer_t* buf) { + SOKOL_ASSERT(buf); + if (buf->d3d11.buf) { + _sg_d3d11_Release(buf->d3d11.buf); + } +} + +_SOKOL_PRIVATE void _sg_d3d11_fill_subres_data(const _sg_image_t* img, const sg_image_data* data) { + const int num_faces = (img->cmn.type == SG_IMAGETYPE_CUBE) ? 6:1; + const int num_slices = (img->cmn.type == SG_IMAGETYPE_ARRAY) ? img->cmn.num_slices:1; + int subres_index = 0; + for (int face_index = 0; face_index < num_faces; face_index++) { + for (int slice_index = 0; slice_index < num_slices; slice_index++) { + for (int mip_index = 0; mip_index < img->cmn.num_mipmaps; mip_index++, subres_index++) { + SOKOL_ASSERT(subres_index < (SG_MAX_MIPMAPS * SG_MAX_TEXTUREARRAY_LAYERS)); + D3D11_SUBRESOURCE_DATA* subres_data = &_sg.d3d11.subres_data[subres_index]; + const int mip_width = ((img->cmn.width>>mip_index)>0) ? img->cmn.width>>mip_index : 1; + const int mip_height = ((img->cmn.height>>mip_index)>0) ? img->cmn.height>>mip_index : 1; + const sg_range* subimg_data = &(data->subimage[face_index][mip_index]); + const size_t slice_size = subimg_data->size / (size_t)num_slices; + const size_t slice_offset = slice_size * (size_t)slice_index; + const uint8_t* ptr = (const uint8_t*) subimg_data->ptr; + subres_data->pSysMem = ptr + slice_offset; + subres_data->SysMemPitch = (UINT)_sg_row_pitch(img->cmn.pixel_format, mip_width, 1); + if (img->cmn.type == SG_IMAGETYPE_3D) { + /* FIXME? const int mip_depth = ((img->depth>>mip_index)>0) ? img->depth>>mip_index : 1; */ + subres_data->SysMemSlicePitch = (UINT)_sg_surface_pitch(img->cmn.pixel_format, mip_width, mip_height, 1); + } + else { + subres_data->SysMemSlicePitch = 0; + } + } + } + } +} + +_SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const sg_image_desc* desc) { + SOKOL_ASSERT(img && desc); + SOKOL_ASSERT(!img->d3d11.tex2d && !img->d3d11.tex3d && !img->d3d11.texds && !img->d3d11.texmsaa); + SOKOL_ASSERT(!img->d3d11.srv && !img->d3d11.smp); + HRESULT hr; + + _sg_image_common_init(&img->cmn, desc); + const bool injected = (0 != desc->d3d11_texture) || (0 != desc->d3d11_shader_resource_view); + const bool msaa = (img->cmn.sample_count > 1); + img->d3d11.format = _sg_d3d11_pixel_format(img->cmn.pixel_format); + + /* special case depth-stencil buffer? */ + if (_sg_is_valid_rendertarget_depth_format(img->cmn.pixel_format)) { + /* create only a depth-texture */ + SOKOL_ASSERT(!injected); + if (img->d3d11.format == DXGI_FORMAT_UNKNOWN) { + SOKOL_LOG("trying to create a D3D11 depth-texture with unsupported pixel format\n"); + return SG_RESOURCESTATE_FAILED; + } + D3D11_TEXTURE2D_DESC d3d11_desc; + memset(&d3d11_desc, 0, sizeof(d3d11_desc)); + d3d11_desc.Width = (UINT)img->cmn.width; + d3d11_desc.Height = (UINT)img->cmn.height; + d3d11_desc.MipLevels = 1; + d3d11_desc.ArraySize = 1; + d3d11_desc.Format = img->d3d11.format; + d3d11_desc.Usage = D3D11_USAGE_DEFAULT; + d3d11_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL; + d3d11_desc.SampleDesc.Count = (UINT)img->cmn.sample_count; + d3d11_desc.SampleDesc.Quality = (UINT) (msaa ? D3D11_STANDARD_MULTISAMPLE_PATTERN : 0); + hr = _sg_d3d11_CreateTexture2D(_sg.d3d11.dev, &d3d11_desc, NULL, &img->d3d11.texds); + if (!(SUCCEEDED(hr) && img->d3d11.texds)) { + SOKOL_LOG("failed to create D3D11 texture 2D\n"); + return SG_RESOURCESTATE_FAILED; + } + } + else { + /* create (or inject) color texture and shader-resource-view */ + + /* prepare initial content pointers */ + D3D11_SUBRESOURCE_DATA* init_data = 0; + if (!injected && (img->cmn.usage == SG_USAGE_IMMUTABLE) && !img->cmn.render_target) { + _sg_d3d11_fill_subres_data(img, &desc->data); + init_data = _sg.d3d11.subres_data; + } + if (img->cmn.type != SG_IMAGETYPE_3D) { + /* 2D-, cube- or array-texture */ + /* if this is an MSAA render target, the following texture will be the 'resolve-texture' */ + + /* first check for injected texture and/or resource view */ + if (injected) { + img->d3d11.tex2d = (ID3D11Texture2D*) desc->d3d11_texture; + img->d3d11.srv = (ID3D11ShaderResourceView*) desc->d3d11_shader_resource_view; + if (img->d3d11.tex2d) { + _sg_d3d11_AddRef(img->d3d11.tex2d); + } + else { + /* if only a shader-resource-view was provided, but no texture, lookup + the texture from the shader-resource-view, this also bumps the refcount + */ + SOKOL_ASSERT(img->d3d11.srv); + _sg_d3d11_GetResource((ID3D11View*)img->d3d11.srv, (ID3D11Resource**)&img->d3d11.tex2d); + SOKOL_ASSERT(img->d3d11.tex2d); + } + if (img->d3d11.srv) { + _sg_d3d11_AddRef(img->d3d11.srv); + } + } + + /* if not injected, create texture */ + if (0 == img->d3d11.tex2d) { + D3D11_TEXTURE2D_DESC d3d11_tex_desc; + memset(&d3d11_tex_desc, 0, sizeof(d3d11_tex_desc)); + d3d11_tex_desc.Width = (UINT)img->cmn.width; + d3d11_tex_desc.Height = (UINT)img->cmn.height; + d3d11_tex_desc.MipLevels = (UINT)img->cmn.num_mipmaps; + switch (img->cmn.type) { + case SG_IMAGETYPE_ARRAY: d3d11_tex_desc.ArraySize = (UINT)img->cmn.num_slices; break; + case SG_IMAGETYPE_CUBE: d3d11_tex_desc.ArraySize = 6; break; + default: d3d11_tex_desc.ArraySize = 1; break; + } + d3d11_tex_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + d3d11_tex_desc.Format = img->d3d11.format; + if (img->cmn.render_target) { + d3d11_tex_desc.Usage = D3D11_USAGE_DEFAULT; + if (!msaa) { + d3d11_tex_desc.BindFlags |= D3D11_BIND_RENDER_TARGET; + } + d3d11_tex_desc.CPUAccessFlags = 0; + } + else { + d3d11_tex_desc.Usage = _sg_d3d11_usage(img->cmn.usage); + d3d11_tex_desc.CPUAccessFlags = _sg_d3d11_cpu_access_flags(img->cmn.usage); + } + if (img->d3d11.format == DXGI_FORMAT_UNKNOWN) { + /* trying to create a texture format that's not supported by D3D */ + SOKOL_LOG("trying to create a D3D11 texture with unsupported pixel format\n"); + return SG_RESOURCESTATE_FAILED; + } + d3d11_tex_desc.SampleDesc.Count = 1; + d3d11_tex_desc.SampleDesc.Quality = 0; + d3d11_tex_desc.MiscFlags = (img->cmn.type == SG_IMAGETYPE_CUBE) ? D3D11_RESOURCE_MISC_TEXTURECUBE : 0; + + hr = _sg_d3d11_CreateTexture2D(_sg.d3d11.dev, &d3d11_tex_desc, init_data, &img->d3d11.tex2d); + if (!(SUCCEEDED(hr) && img->d3d11.tex2d)) { + SOKOL_LOG("failed to create D3D11 texture 2D\n"); + return SG_RESOURCESTATE_FAILED; + } + } + + /* ...and similar, if not injected, create shader-resource-view */ + if (0 == img->d3d11.srv) { + D3D11_SHADER_RESOURCE_VIEW_DESC d3d11_srv_desc; + memset(&d3d11_srv_desc, 0, sizeof(d3d11_srv_desc)); + d3d11_srv_desc.Format = img->d3d11.format; + switch (img->cmn.type) { + case SG_IMAGETYPE_2D: + d3d11_srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + d3d11_srv_desc.Texture2D.MipLevels = (UINT)img->cmn.num_mipmaps; + break; + case SG_IMAGETYPE_CUBE: + d3d11_srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; + d3d11_srv_desc.TextureCube.MipLevels = (UINT)img->cmn.num_mipmaps; + break; + case SG_IMAGETYPE_ARRAY: + d3d11_srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; + d3d11_srv_desc.Texture2DArray.MipLevels = (UINT)img->cmn.num_mipmaps; + d3d11_srv_desc.Texture2DArray.ArraySize = (UINT)img->cmn.num_slices; + break; + default: + SOKOL_UNREACHABLE; break; + } + hr = _sg_d3d11_CreateShaderResourceView(_sg.d3d11.dev, (ID3D11Resource*)img->d3d11.tex2d, &d3d11_srv_desc, &img->d3d11.srv); + if (!(SUCCEEDED(hr) && img->d3d11.srv)) { + SOKOL_LOG("failed to create D3D11 resource view\n"); + return SG_RESOURCESTATE_FAILED; + } + } + } + else { + /* 3D texture - same procedure, first check if injected, than create non-injected */ + if (injected) { + img->d3d11.tex3d = (ID3D11Texture3D*) desc->d3d11_texture; + img->d3d11.srv = (ID3D11ShaderResourceView*) desc->d3d11_shader_resource_view; + if (img->d3d11.tex3d) { + _sg_d3d11_AddRef(img->d3d11.tex3d); + } + else { + SOKOL_ASSERT(img->d3d11.srv); + _sg_d3d11_GetResource((ID3D11View*)img->d3d11.srv, (ID3D11Resource**)&img->d3d11.tex3d); + SOKOL_ASSERT(img->d3d11.tex3d); + } + if (img->d3d11.srv) { + _sg_d3d11_AddRef(img->d3d11.srv); + } + } + + if (0 == img->d3d11.tex3d) { + D3D11_TEXTURE3D_DESC d3d11_tex_desc; + memset(&d3d11_tex_desc, 0, sizeof(d3d11_tex_desc)); + d3d11_tex_desc.Width = (UINT)img->cmn.width; + d3d11_tex_desc.Height = (UINT)img->cmn.height; + d3d11_tex_desc.Depth = (UINT)img->cmn.num_slices; + d3d11_tex_desc.MipLevels = (UINT)img->cmn.num_mipmaps; + d3d11_tex_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + d3d11_tex_desc.Format = img->d3d11.format; + if (img->cmn.render_target) { + d3d11_tex_desc.Usage = D3D11_USAGE_DEFAULT; + if (!msaa) { + d3d11_tex_desc.BindFlags |= D3D11_BIND_RENDER_TARGET; + } + d3d11_tex_desc.CPUAccessFlags = 0; + } + else { + d3d11_tex_desc.Usage = _sg_d3d11_usage(img->cmn.usage); + d3d11_tex_desc.CPUAccessFlags = _sg_d3d11_cpu_access_flags(img->cmn.usage); + } + if (img->d3d11.format == DXGI_FORMAT_UNKNOWN) { + /* trying to create a texture format that's not supported by D3D */ + SOKOL_LOG("trying to create a D3D11 texture with unsupported pixel format\n"); + return SG_RESOURCESTATE_FAILED; + } + hr = _sg_d3d11_CreateTexture3D(_sg.d3d11.dev, &d3d11_tex_desc, init_data, &img->d3d11.tex3d); + if (!(SUCCEEDED(hr) && img->d3d11.tex3d)) { + SOKOL_LOG("failed to create D3D11 texture 3D\n"); + return SG_RESOURCESTATE_FAILED; + } + } + + if (0 == img->d3d11.srv) { + D3D11_SHADER_RESOURCE_VIEW_DESC d3d11_srv_desc; + memset(&d3d11_srv_desc, 0, sizeof(d3d11_srv_desc)); + d3d11_srv_desc.Format = img->d3d11.format; + d3d11_srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; + d3d11_srv_desc.Texture3D.MipLevels = (UINT)img->cmn.num_mipmaps; + hr = _sg_d3d11_CreateShaderResourceView(_sg.d3d11.dev, (ID3D11Resource*)img->d3d11.tex3d, &d3d11_srv_desc, &img->d3d11.srv); + if (!(SUCCEEDED(hr) && img->d3d11.srv)) { + SOKOL_LOG("failed to create D3D11 resource view\n"); + return SG_RESOURCESTATE_FAILED; + } + } + } + + /* also need to create a separate MSAA render target texture? */ + if (msaa) { + D3D11_TEXTURE2D_DESC d3d11_tex_desc; + memset(&d3d11_tex_desc, 0, sizeof(d3d11_tex_desc)); + d3d11_tex_desc.Width = (UINT)img->cmn.width; + d3d11_tex_desc.Height = (UINT)img->cmn.height; + d3d11_tex_desc.MipLevels = 1; + d3d11_tex_desc.ArraySize = 1; + d3d11_tex_desc.Format = img->d3d11.format; + d3d11_tex_desc.Usage = D3D11_USAGE_DEFAULT; + d3d11_tex_desc.BindFlags = D3D11_BIND_RENDER_TARGET; + d3d11_tex_desc.CPUAccessFlags = 0; + d3d11_tex_desc.SampleDesc.Count = (UINT)img->cmn.sample_count; + d3d11_tex_desc.SampleDesc.Quality = (UINT)D3D11_STANDARD_MULTISAMPLE_PATTERN; + hr = _sg_d3d11_CreateTexture2D(_sg.d3d11.dev, &d3d11_tex_desc, NULL, &img->d3d11.texmsaa); + if (!(SUCCEEDED(hr) && img->d3d11.texmsaa)) { + SOKOL_LOG("failed to create D3D11 texture 2D\n"); + return SG_RESOURCESTATE_FAILED; + } + } + + /* sampler state object, note D3D11 implements an internal shared-pool for sampler objects */ + D3D11_SAMPLER_DESC d3d11_smp_desc; + memset(&d3d11_smp_desc, 0, sizeof(d3d11_smp_desc)); + d3d11_smp_desc.Filter = _sg_d3d11_filter(img->cmn.min_filter, img->cmn.mag_filter, img->cmn.max_anisotropy); + d3d11_smp_desc.AddressU = _sg_d3d11_address_mode(img->cmn.wrap_u); + d3d11_smp_desc.AddressV = _sg_d3d11_address_mode(img->cmn.wrap_v); + d3d11_smp_desc.AddressW = _sg_d3d11_address_mode(img->cmn.wrap_w); + switch (img->cmn.border_color) { + case SG_BORDERCOLOR_TRANSPARENT_BLACK: + /* all 0.0f */ + break; + case SG_BORDERCOLOR_OPAQUE_WHITE: + for (int i = 0; i < 4; i++) { + d3d11_smp_desc.BorderColor[i] = 1.0f; + } + break; + default: + /* opaque black */ + d3d11_smp_desc.BorderColor[3] = 1.0f; + break; + } + d3d11_smp_desc.MaxAnisotropy = img->cmn.max_anisotropy; + d3d11_smp_desc.ComparisonFunc = D3D11_COMPARISON_NEVER; + d3d11_smp_desc.MinLOD = desc->min_lod; + d3d11_smp_desc.MaxLOD = desc->max_lod; + hr = _sg_d3d11_CreateSamplerState(_sg.d3d11.dev, &d3d11_smp_desc, &img->d3d11.smp); + if (!(SUCCEEDED(hr) && img->d3d11.smp)) { + SOKOL_LOG("failed to create D3D11 sampler state\n"); + return SG_RESOURCESTATE_FAILED; + } + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_d3d11_destroy_image(_sg_image_t* img) { + SOKOL_ASSERT(img); + if (img->d3d11.tex2d) { + _sg_d3d11_Release(img->d3d11.tex2d); + } + if (img->d3d11.tex3d) { + _sg_d3d11_Release(img->d3d11.tex3d); + } + if (img->d3d11.texds) { + _sg_d3d11_Release(img->d3d11.texds); + } + if (img->d3d11.texmsaa) { + _sg_d3d11_Release(img->d3d11.texmsaa); + } + if (img->d3d11.srv) { + _sg_d3d11_Release(img->d3d11.srv); + } + if (img->d3d11.smp) { + _sg_d3d11_Release(img->d3d11.smp); + } +} + +_SOKOL_PRIVATE bool _sg_d3d11_load_d3dcompiler_dll(void) { + /* on UWP, don't do anything (not tested) */ +#if (defined(WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) + return true; +#else + /* load DLL on demand */ + if ((0 == _sg.d3d11.d3dcompiler_dll) && !_sg.d3d11.d3dcompiler_dll_load_failed) { + _sg.d3d11.d3dcompiler_dll = LoadLibraryA("d3dcompiler_47.dll"); + if (0 == _sg.d3d11.d3dcompiler_dll) { + /* don't attempt to load missing DLL in the future */ + SOKOL_LOG("failed to load d3dcompiler_47.dll!\n"); + _sg.d3d11.d3dcompiler_dll_load_failed = true; + return false; + } + /* look up function pointers */ + _sg.d3d11.D3DCompile_func = (pD3DCompile)(void*) GetProcAddress(_sg.d3d11.d3dcompiler_dll, "D3DCompile"); + SOKOL_ASSERT(_sg.d3d11.D3DCompile_func); + } + return 0 != _sg.d3d11.d3dcompiler_dll; +#endif +} + +#if (defined(WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) +#define _sg_d3d11_D3DCompile D3DCompile +#else +#define _sg_d3d11_D3DCompile _sg.d3d11.D3DCompile_func +#endif + +_SOKOL_PRIVATE ID3DBlob* _sg_d3d11_compile_shader(const sg_shader_stage_desc* stage_desc) { + if (!_sg_d3d11_load_d3dcompiler_dll()) { + return NULL; + } + SOKOL_ASSERT(stage_desc->d3d11_target); + ID3DBlob* output = NULL; + ID3DBlob* errors_or_warnings = NULL; + HRESULT hr = _sg_d3d11_D3DCompile( + stage_desc->source, /* pSrcData */ + strlen(stage_desc->source), /* SrcDataSize */ + NULL, /* pSourceName */ + NULL, /* pDefines */ + NULL, /* pInclude */ + stage_desc->entry ? stage_desc->entry : "main", /* pEntryPoint */ + stage_desc->d3d11_target, /* pTarget (vs_5_0 or ps_5_0) */ + D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR | D3DCOMPILE_OPTIMIZATION_LEVEL3, /* Flags1 */ + 0, /* Flags2 */ + &output, /* ppCode */ + &errors_or_warnings); /* ppErrorMsgs */ + if (errors_or_warnings) { + SOKOL_LOG((LPCSTR)_sg_d3d11_GetBufferPointer(errors_or_warnings)); + _sg_d3d11_Release(errors_or_warnings); errors_or_warnings = NULL; + } + if (FAILED(hr)) { + /* just in case, usually output is NULL here */ + if (output) { + _sg_d3d11_Release(output); + output = NULL; + } + } + return output; +} + +_SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_shader(_sg_shader_t* shd, const sg_shader_desc* desc) { + SOKOL_ASSERT(shd && desc); + SOKOL_ASSERT(!shd->d3d11.vs && !shd->d3d11.fs && !shd->d3d11.vs_blob); + HRESULT hr; + + _sg_shader_common_init(&shd->cmn, desc); + + /* copy vertex attribute semantic names and indices */ + for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTES; i++) { + _sg_strcpy(&shd->d3d11.attrs[i].sem_name, desc->attrs[i].sem_name); + shd->d3d11.attrs[i].sem_index = desc->attrs[i].sem_index; + } + + /* shader stage uniform blocks and image slots */ + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + _sg_shader_stage_t* cmn_stage = &shd->cmn.stage[stage_index]; + _sg_d3d11_shader_stage_t* d3d11_stage = &shd->d3d11.stage[stage_index]; + for (int ub_index = 0; ub_index < cmn_stage->num_uniform_blocks; ub_index++) { + const _sg_uniform_block_t* ub = &cmn_stage->uniform_blocks[ub_index]; + + /* create a D3D constant buffer for each uniform block */ + SOKOL_ASSERT(0 == d3d11_stage->cbufs[ub_index]); + D3D11_BUFFER_DESC cb_desc; + memset(&cb_desc, 0, sizeof(cb_desc)); + cb_desc.ByteWidth = (UINT)_sg_roundup((int)ub->size, 16); + cb_desc.Usage = D3D11_USAGE_DEFAULT; + cb_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + hr = _sg_d3d11_CreateBuffer(_sg.d3d11.dev, &cb_desc, NULL, &d3d11_stage->cbufs[ub_index]); + if (!(SUCCEEDED(hr) && d3d11_stage->cbufs[ub_index])) { + SOKOL_LOG("failed to create D3D11 buffer\n"); + return SG_RESOURCESTATE_FAILED; + } + } + } + + const void* vs_ptr = 0, *fs_ptr = 0; + SIZE_T vs_length = 0, fs_length = 0; + ID3DBlob* vs_blob = 0, *fs_blob = 0; + if (desc->vs.bytecode.ptr && desc->fs.bytecode.ptr) { + /* create from shader byte code */ + vs_ptr = desc->vs.bytecode.ptr; + fs_ptr = desc->fs.bytecode.ptr; + vs_length = desc->vs.bytecode.size; + fs_length = desc->fs.bytecode.size; + } + else { + /* compile from shader source code */ + vs_blob = _sg_d3d11_compile_shader(&desc->vs); + fs_blob = _sg_d3d11_compile_shader(&desc->fs); + if (vs_blob && fs_blob) { + vs_ptr = _sg_d3d11_GetBufferPointer(vs_blob); + vs_length = _sg_d3d11_GetBufferSize(vs_blob); + fs_ptr = _sg_d3d11_GetBufferPointer(fs_blob); + fs_length = _sg_d3d11_GetBufferSize(fs_blob); + } + } + sg_resource_state result = SG_RESOURCESTATE_FAILED; + if (vs_ptr && fs_ptr && (vs_length > 0) && (fs_length > 0)) { + /* create the D3D vertex- and pixel-shader objects */ + hr = _sg_d3d11_CreateVertexShader(_sg.d3d11.dev, vs_ptr, vs_length, NULL, &shd->d3d11.vs); + bool vs_succeeded = SUCCEEDED(hr) && shd->d3d11.vs; + hr = _sg_d3d11_CreatePixelShader(_sg.d3d11.dev, fs_ptr, fs_length, NULL, &shd->d3d11.fs); + bool fs_succeeded = SUCCEEDED(hr) && shd->d3d11.fs; + + /* need to store the vertex shader byte code, this is needed later in sg_create_pipeline */ + if (vs_succeeded && fs_succeeded) { + shd->d3d11.vs_blob_length = vs_length; + shd->d3d11.vs_blob = SOKOL_MALLOC((size_t)vs_length); + SOKOL_ASSERT(shd->d3d11.vs_blob); + memcpy(shd->d3d11.vs_blob, vs_ptr, vs_length); + result = SG_RESOURCESTATE_VALID; + } + } + if (vs_blob) { + _sg_d3d11_Release(vs_blob); vs_blob = 0; + } + if (fs_blob) { + _sg_d3d11_Release(fs_blob); fs_blob = 0; + } + return result; +} + +_SOKOL_PRIVATE void _sg_d3d11_destroy_shader(_sg_shader_t* shd) { + SOKOL_ASSERT(shd); + if (shd->d3d11.vs) { + _sg_d3d11_Release(shd->d3d11.vs); + } + if (shd->d3d11.fs) { + _sg_d3d11_Release(shd->d3d11.fs); + } + if (shd->d3d11.vs_blob) { + SOKOL_FREE(shd->d3d11.vs_blob); + } + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + _sg_shader_stage_t* cmn_stage = &shd->cmn.stage[stage_index]; + _sg_d3d11_shader_stage_t* d3d11_stage = &shd->d3d11.stage[stage_index]; + for (int ub_index = 0; ub_index < cmn_stage->num_uniform_blocks; ub_index++) { + if (d3d11_stage->cbufs[ub_index]) { + _sg_d3d11_Release(d3d11_stage->cbufs[ub_index]); + } + } + } +} + +_SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_pipeline(_sg_pipeline_t* pip, _sg_shader_t* shd, const sg_pipeline_desc* desc) { + SOKOL_ASSERT(pip && shd && desc); + SOKOL_ASSERT(desc->shader.id == shd->slot.id); + SOKOL_ASSERT(shd->slot.state == SG_RESOURCESTATE_VALID); + SOKOL_ASSERT(shd->d3d11.vs_blob && shd->d3d11.vs_blob_length > 0); + SOKOL_ASSERT(!pip->d3d11.il && !pip->d3d11.rs && !pip->d3d11.dss && !pip->d3d11.bs); + + pip->shader = shd; + _sg_pipeline_common_init(&pip->cmn, desc); + pip->d3d11.index_format = _sg_d3d11_index_format(pip->cmn.index_type); + pip->d3d11.topology = _sg_d3d11_primitive_topology(desc->primitive_type); + pip->d3d11.stencil_ref = desc->stencil.ref; + + /* create input layout object */ + HRESULT hr; + D3D11_INPUT_ELEMENT_DESC d3d11_comps[SG_MAX_VERTEX_ATTRIBUTES]; + memset(d3d11_comps, 0, sizeof(d3d11_comps)); + int attr_index = 0; + for (; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) { + const sg_vertex_attr_desc* a_desc = &desc->layout.attrs[attr_index]; + if (a_desc->format == SG_VERTEXFORMAT_INVALID) { + break; + } + SOKOL_ASSERT(a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS); + const sg_buffer_layout_desc* l_desc = &desc->layout.buffers[a_desc->buffer_index]; + const sg_vertex_step step_func = l_desc->step_func; + const int step_rate = l_desc->step_rate; + D3D11_INPUT_ELEMENT_DESC* d3d11_comp = &d3d11_comps[attr_index]; + d3d11_comp->SemanticName = _sg_strptr(&shd->d3d11.attrs[attr_index].sem_name); + d3d11_comp->SemanticIndex = (UINT)shd->d3d11.attrs[attr_index].sem_index; + d3d11_comp->Format = _sg_d3d11_vertex_format(a_desc->format); + d3d11_comp->InputSlot = (UINT)a_desc->buffer_index; + d3d11_comp->AlignedByteOffset = (UINT)a_desc->offset; + d3d11_comp->InputSlotClass = _sg_d3d11_input_classification(step_func); + if (SG_VERTEXSTEP_PER_INSTANCE == step_func) { + d3d11_comp->InstanceDataStepRate = (UINT)step_rate; + pip->cmn.use_instanced_draw = true; + } + pip->cmn.vertex_layout_valid[a_desc->buffer_index] = true; + } + for (int layout_index = 0; layout_index < SG_MAX_SHADERSTAGE_BUFFERS; layout_index++) { + if (pip->cmn.vertex_layout_valid[layout_index]) { + const sg_buffer_layout_desc* l_desc = &desc->layout.buffers[layout_index]; + SOKOL_ASSERT(l_desc->stride > 0); + pip->d3d11.vb_strides[layout_index] = (UINT)l_desc->stride; + } + else { + pip->d3d11.vb_strides[layout_index] = 0; + } + } + hr = _sg_d3d11_CreateInputLayout(_sg.d3d11.dev, + d3d11_comps, /* pInputElementDesc */ + (UINT)attr_index, /* NumElements */ + shd->d3d11.vs_blob, /* pShaderByteCodeWithInputSignature */ + shd->d3d11.vs_blob_length, /* BytecodeLength */ + &pip->d3d11.il); + if (!(SUCCEEDED(hr) && pip->d3d11.il)) { + SOKOL_LOG("failed to create D3D11 input layout\n"); + return SG_RESOURCESTATE_FAILED; + } + + /* create rasterizer state */ + D3D11_RASTERIZER_DESC rs_desc; + memset(&rs_desc, 0, sizeof(rs_desc)); + rs_desc.FillMode = D3D11_FILL_SOLID; + rs_desc.CullMode = _sg_d3d11_cull_mode(desc->cull_mode); + rs_desc.FrontCounterClockwise = desc->face_winding == SG_FACEWINDING_CCW; + rs_desc.DepthBias = (INT) pip->cmn.depth_bias; + rs_desc.DepthBiasClamp = pip->cmn.depth_bias_clamp; + rs_desc.SlopeScaledDepthBias = pip->cmn.depth_bias_slope_scale; + rs_desc.DepthClipEnable = TRUE; + rs_desc.ScissorEnable = TRUE; + rs_desc.MultisampleEnable = desc->sample_count > 1; + rs_desc.AntialiasedLineEnable = FALSE; + hr = _sg_d3d11_CreateRasterizerState(_sg.d3d11.dev, &rs_desc, &pip->d3d11.rs); + if (!(SUCCEEDED(hr) && pip->d3d11.rs)) { + SOKOL_LOG("failed to create D3D11 rasterizer state\n"); + return SG_RESOURCESTATE_FAILED; + } + + /* create depth-stencil state */ + D3D11_DEPTH_STENCIL_DESC dss_desc; + memset(&dss_desc, 0, sizeof(dss_desc)); + dss_desc.DepthEnable = TRUE; + dss_desc.DepthWriteMask = desc->depth.write_enabled ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; + dss_desc.DepthFunc = _sg_d3d11_compare_func(desc->depth.compare); + dss_desc.StencilEnable = desc->stencil.enabled; + dss_desc.StencilReadMask = desc->stencil.read_mask; + dss_desc.StencilWriteMask = desc->stencil.write_mask; + const sg_stencil_face_state* sf = &desc->stencil.front; + dss_desc.FrontFace.StencilFailOp = _sg_d3d11_stencil_op(sf->fail_op); + dss_desc.FrontFace.StencilDepthFailOp = _sg_d3d11_stencil_op(sf->depth_fail_op); + dss_desc.FrontFace.StencilPassOp = _sg_d3d11_stencil_op(sf->pass_op); + dss_desc.FrontFace.StencilFunc = _sg_d3d11_compare_func(sf->compare); + const sg_stencil_face_state* sb = &desc->stencil.back; + dss_desc.BackFace.StencilFailOp = _sg_d3d11_stencil_op(sb->fail_op); + dss_desc.BackFace.StencilDepthFailOp = _sg_d3d11_stencil_op(sb->depth_fail_op); + dss_desc.BackFace.StencilPassOp = _sg_d3d11_stencil_op(sb->pass_op); + dss_desc.BackFace.StencilFunc = _sg_d3d11_compare_func(sb->compare); + hr = _sg_d3d11_CreateDepthStencilState(_sg.d3d11.dev, &dss_desc, &pip->d3d11.dss); + if (!(SUCCEEDED(hr) && pip->d3d11.dss)) { + SOKOL_LOG("failed to create D3D11 depth stencil state\n"); + return SG_RESOURCESTATE_FAILED; + } + + /* create blend state */ + D3D11_BLEND_DESC bs_desc; + memset(&bs_desc, 0, sizeof(bs_desc)); + bs_desc.AlphaToCoverageEnable = desc->alpha_to_coverage_enabled; + bs_desc.IndependentBlendEnable = TRUE; + { + int i = 0; + for (i = 0; i < desc->color_count; i++) { + const sg_blend_state* src = &desc->colors[i].blend; + D3D11_RENDER_TARGET_BLEND_DESC* dst = &bs_desc.RenderTarget[i]; + dst->BlendEnable = src->enabled; + dst->SrcBlend = _sg_d3d11_blend_factor(src->src_factor_rgb); + dst->DestBlend = _sg_d3d11_blend_factor(src->dst_factor_rgb); + dst->BlendOp = _sg_d3d11_blend_op(src->op_rgb); + dst->SrcBlendAlpha = _sg_d3d11_blend_factor(src->src_factor_alpha); + dst->DestBlendAlpha = _sg_d3d11_blend_factor(src->dst_factor_alpha); + dst->BlendOpAlpha = _sg_d3d11_blend_op(src->op_alpha); + dst->RenderTargetWriteMask = _sg_d3d11_color_write_mask(desc->colors[i].write_mask); + } + for (; i < 8; i++) { + D3D11_RENDER_TARGET_BLEND_DESC* dst = &bs_desc.RenderTarget[i]; + dst->BlendEnable = FALSE; + dst->SrcBlend = dst->SrcBlendAlpha = D3D11_BLEND_ONE; + dst->DestBlend = dst->DestBlendAlpha = D3D11_BLEND_ZERO; + dst->BlendOp = dst->BlendOpAlpha = D3D11_BLEND_OP_ADD; + dst->RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + } + } + hr = _sg_d3d11_CreateBlendState(_sg.d3d11.dev, &bs_desc, &pip->d3d11.bs); + if (!(SUCCEEDED(hr) && pip->d3d11.bs)) { + SOKOL_LOG("failed to create D3D11 blend state\n"); + return SG_RESOURCESTATE_FAILED; + } + + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_d3d11_destroy_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + if (pip == _sg.d3d11.cur_pipeline) { + _sg.d3d11.cur_pipeline = 0; + _sg.d3d11.cur_pipeline_id.id = SG_INVALID_ID; + } + if (pip->d3d11.il) { + _sg_d3d11_Release(pip->d3d11.il); + } + if (pip->d3d11.rs) { + _sg_d3d11_Release(pip->d3d11.rs); + } + if (pip->d3d11.dss) { + _sg_d3d11_Release(pip->d3d11.dss); + } + if (pip->d3d11.bs) { + _sg_d3d11_Release(pip->d3d11.bs); + } +} + +_SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_pass(_sg_pass_t* pass, _sg_image_t** att_images, const sg_pass_desc* desc) { + SOKOL_ASSERT(pass && desc); + SOKOL_ASSERT(att_images && att_images[0]); + SOKOL_ASSERT(_sg.d3d11.dev); + + _sg_pass_common_init(&pass->cmn, desc); + + for (int i = 0; i < pass->cmn.num_color_atts; i++) { + const sg_pass_attachment_desc* att_desc = &desc->color_attachments[i]; + _SOKOL_UNUSED(att_desc); + SOKOL_ASSERT(att_desc->image.id != SG_INVALID_ID); + _sg_image_t* att_img = att_images[i]; + SOKOL_ASSERT(att_img && (att_img->slot.id == att_desc->image.id)); + SOKOL_ASSERT(_sg_is_valid_rendertarget_color_format(att_img->cmn.pixel_format)); + SOKOL_ASSERT(0 == pass->d3d11.color_atts[i].image); + pass->d3d11.color_atts[i].image = att_img; + + /* create D3D11 render-target-view */ + const _sg_pass_attachment_t* cmn_att = &pass->cmn.color_atts[i]; + SOKOL_ASSERT(0 == pass->d3d11.color_atts[i].rtv); + ID3D11Resource* d3d11_res = 0; + const bool is_msaa = att_img->cmn.sample_count > 1; + D3D11_RENDER_TARGET_VIEW_DESC d3d11_rtv_desc; + memset(&d3d11_rtv_desc, 0, sizeof(d3d11_rtv_desc)); + d3d11_rtv_desc.Format = att_img->d3d11.format; + if ((att_img->cmn.type == SG_IMAGETYPE_2D) || is_msaa) { + if (is_msaa) { + d3d11_res = (ID3D11Resource*) att_img->d3d11.texmsaa; + d3d11_rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS; + } + else { + d3d11_res = (ID3D11Resource*) att_img->d3d11.tex2d; + d3d11_rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; + d3d11_rtv_desc.Texture2D.MipSlice = (UINT)cmn_att->mip_level; + } + } + else if ((att_img->cmn.type == SG_IMAGETYPE_CUBE) || (att_img->cmn.type == SG_IMAGETYPE_ARRAY)) { + d3d11_res = (ID3D11Resource*) att_img->d3d11.tex2d; + d3d11_rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; + d3d11_rtv_desc.Texture2DArray.MipSlice = (UINT)cmn_att->mip_level; + d3d11_rtv_desc.Texture2DArray.FirstArraySlice = (UINT)cmn_att->slice; + d3d11_rtv_desc.Texture2DArray.ArraySize = 1; + } + else { + SOKOL_ASSERT(att_img->cmn.type == SG_IMAGETYPE_3D); + d3d11_res = (ID3D11Resource*) att_img->d3d11.tex3d; + d3d11_rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D; + d3d11_rtv_desc.Texture3D.MipSlice = (UINT)cmn_att->mip_level; + d3d11_rtv_desc.Texture3D.FirstWSlice = (UINT)cmn_att->slice; + d3d11_rtv_desc.Texture3D.WSize = 1; + } + SOKOL_ASSERT(d3d11_res); + HRESULT hr = _sg_d3d11_CreateRenderTargetView(_sg.d3d11.dev, d3d11_res, &d3d11_rtv_desc, &pass->d3d11.color_atts[i].rtv); + if (!(SUCCEEDED(hr) && pass->d3d11.color_atts[i].rtv)) { + SOKOL_LOG("failed to create D3D11 render target view\n"); + return SG_RESOURCESTATE_FAILED; + } + } + + /* optional depth-stencil image */ + SOKOL_ASSERT(0 == pass->d3d11.ds_att.image); + SOKOL_ASSERT(0 == pass->d3d11.ds_att.dsv); + if (desc->depth_stencil_attachment.image.id != SG_INVALID_ID) { + const int ds_img_index = SG_MAX_COLOR_ATTACHMENTS; + const sg_pass_attachment_desc* att_desc = &desc->depth_stencil_attachment; + _SOKOL_UNUSED(att_desc); + _sg_image_t* att_img = att_images[ds_img_index]; + SOKOL_ASSERT(att_img && (att_img->slot.id == att_desc->image.id)); + SOKOL_ASSERT(_sg_is_valid_rendertarget_depth_format(att_img->cmn.pixel_format)); + SOKOL_ASSERT(0 == pass->d3d11.ds_att.image); + pass->d3d11.ds_att.image = att_img; + + /* create D3D11 depth-stencil-view */ + D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_dsv_desc; + memset(&d3d11_dsv_desc, 0, sizeof(d3d11_dsv_desc)); + d3d11_dsv_desc.Format = att_img->d3d11.format; + const bool is_msaa = att_img->cmn.sample_count > 1; + if (is_msaa) { + d3d11_dsv_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS; + } + else { + d3d11_dsv_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; + } + ID3D11Resource* d3d11_res = (ID3D11Resource*) att_img->d3d11.texds; + SOKOL_ASSERT(d3d11_res); + HRESULT hr = _sg_d3d11_CreateDepthStencilView(_sg.d3d11.dev, d3d11_res, &d3d11_dsv_desc, &pass->d3d11.ds_att.dsv); + if (!(SUCCEEDED(hr) && pass->d3d11.ds_att.dsv)) { + SOKOL_LOG("failed to create D3D11 depth stencil view\n"); + return SG_RESOURCESTATE_FAILED; + } + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_d3d11_destroy_pass(_sg_pass_t* pass) { + SOKOL_ASSERT(pass); + SOKOL_ASSERT(pass != _sg.d3d11.cur_pass); + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + if (pass->d3d11.color_atts[i].rtv) { + _sg_d3d11_Release(pass->d3d11.color_atts[i].rtv); + } + } + if (pass->d3d11.ds_att.dsv) { + _sg_d3d11_Release(pass->d3d11.ds_att.dsv); + } +} + +_SOKOL_PRIVATE _sg_image_t* _sg_d3d11_pass_color_image(const _sg_pass_t* pass, int index) { + SOKOL_ASSERT(pass && (index >= 0) && (index < SG_MAX_COLOR_ATTACHMENTS)); + /* NOTE: may return null */ + return pass->d3d11.color_atts[index].image; +} + +_SOKOL_PRIVATE _sg_image_t* _sg_d3d11_pass_ds_image(const _sg_pass_t* pass) { + /* NOTE: may return null */ + SOKOL_ASSERT(pass); + return pass->d3d11.ds_att.image; +} + +_SOKOL_PRIVATE void _sg_d3d11_begin_pass(_sg_pass_t* pass, const sg_pass_action* action, int w, int h) { + SOKOL_ASSERT(action); + SOKOL_ASSERT(!_sg.d3d11.in_pass); + SOKOL_ASSERT(_sg.d3d11.rtv_cb || _sg.d3d11.rtv_userdata_cb); + SOKOL_ASSERT(_sg.d3d11.dsv_cb || _sg.d3d11.dsv_userdata_cb); + _sg.d3d11.in_pass = true; + _sg.d3d11.cur_width = w; + _sg.d3d11.cur_height = h; + if (pass) { + _sg.d3d11.cur_pass = pass; + _sg.d3d11.cur_pass_id.id = pass->slot.id; + _sg.d3d11.num_rtvs = 0; + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + _sg.d3d11.cur_rtvs[i] = pass->d3d11.color_atts[i].rtv; + if (_sg.d3d11.cur_rtvs[i]) { + _sg.d3d11.num_rtvs++; + } + } + _sg.d3d11.cur_dsv = pass->d3d11.ds_att.dsv; + } + else { + /* render to default frame buffer */ + _sg.d3d11.cur_pass = 0; + _sg.d3d11.cur_pass_id.id = SG_INVALID_ID; + _sg.d3d11.num_rtvs = 1; + if (_sg.d3d11.rtv_cb) { + _sg.d3d11.cur_rtvs[0] = (ID3D11RenderTargetView*) _sg.d3d11.rtv_cb(); + } + else { + _sg.d3d11.cur_rtvs[0] = (ID3D11RenderTargetView*) _sg.d3d11.rtv_userdata_cb(_sg.d3d11.user_data); + } + for (int i = 1; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + _sg.d3d11.cur_rtvs[i] = 0; + } + if (_sg.d3d11.dsv_cb) { + _sg.d3d11.cur_dsv = (ID3D11DepthStencilView*) _sg.d3d11.dsv_cb(); + } + else { + _sg.d3d11.cur_dsv = (ID3D11DepthStencilView*) _sg.d3d11.dsv_userdata_cb(_sg.d3d11.user_data); + } + SOKOL_ASSERT(_sg.d3d11.cur_rtvs[0] && _sg.d3d11.cur_dsv); + } + /* apply the render-target- and depth-stencil-views */ + _sg_d3d11_OMSetRenderTargets(_sg.d3d11.ctx, SG_MAX_COLOR_ATTACHMENTS, _sg.d3d11.cur_rtvs, _sg.d3d11.cur_dsv); + + /* set viewport and scissor rect to cover whole screen */ + D3D11_VIEWPORT vp; + memset(&vp, 0, sizeof(vp)); + vp.Width = (FLOAT) w; + vp.Height = (FLOAT) h; + vp.MaxDepth = 1.0f; + _sg_d3d11_RSSetViewports(_sg.d3d11.ctx, 1, &vp); + D3D11_RECT rect; + rect.left = 0; + rect.top = 0; + rect.right = w; + rect.bottom = h; + _sg_d3d11_RSSetScissorRects(_sg.d3d11.ctx, 1, &rect); + + /* perform clear action */ + for (int i = 0; i < _sg.d3d11.num_rtvs; i++) { + if (action->colors[i].action == SG_ACTION_CLEAR) { + _sg_d3d11_ClearRenderTargetView(_sg.d3d11.ctx, _sg.d3d11.cur_rtvs[i], &action->colors[i].value.r); + } + } + UINT ds_flags = 0; + if (action->depth.action == SG_ACTION_CLEAR) { + ds_flags |= D3D11_CLEAR_DEPTH; + } + if (action->stencil.action == SG_ACTION_CLEAR) { + ds_flags |= D3D11_CLEAR_STENCIL; + } + if ((0 != ds_flags) && _sg.d3d11.cur_dsv) { + _sg_d3d11_ClearDepthStencilView(_sg.d3d11.ctx, _sg.d3d11.cur_dsv, ds_flags, action->depth.value, action->stencil.value); + } +} + +/* D3D11CalcSubresource only exists for C++ */ +_SOKOL_PRIVATE UINT _sg_d3d11_calcsubresource(UINT mip_slice, UINT array_slice, UINT mip_levels) { + return mip_slice + array_slice * mip_levels; +} + +_SOKOL_PRIVATE void _sg_d3d11_end_pass(void) { + SOKOL_ASSERT(_sg.d3d11.in_pass && _sg.d3d11.ctx); + _sg.d3d11.in_pass = false; + + /* need to resolve MSAA render target into texture? */ + if (_sg.d3d11.cur_pass) { + SOKOL_ASSERT(_sg.d3d11.cur_pass->slot.id == _sg.d3d11.cur_pass_id.id); + for (int i = 0; i < _sg.d3d11.num_rtvs; i++) { + _sg_pass_attachment_t* cmn_att = &_sg.d3d11.cur_pass->cmn.color_atts[i]; + _sg_image_t* att_img = _sg.d3d11.cur_pass->d3d11.color_atts[i].image; + SOKOL_ASSERT(att_img && (att_img->slot.id == cmn_att->image_id.id)); + if (att_img->cmn.sample_count > 1) { + /* FIXME: support MSAA resolve into 3D texture */ + SOKOL_ASSERT(att_img->d3d11.tex2d && att_img->d3d11.texmsaa && !att_img->d3d11.tex3d); + SOKOL_ASSERT(DXGI_FORMAT_UNKNOWN != att_img->d3d11.format); + UINT dst_subres = _sg_d3d11_calcsubresource((UINT)cmn_att->mip_level, (UINT)cmn_att->slice, (UINT)att_img->cmn.num_mipmaps); + _sg_d3d11_ResolveSubresource(_sg.d3d11.ctx, + (ID3D11Resource*) att_img->d3d11.tex2d, /* pDstResource */ + dst_subres, /* DstSubresource */ + (ID3D11Resource*) att_img->d3d11.texmsaa, /* pSrcResource */ + 0, /* SrcSubresource */ + att_img->d3d11.format); + } + } + } + _sg.d3d11.cur_pass = 0; + _sg.d3d11.cur_pass_id.id = SG_INVALID_ID; + _sg.d3d11.cur_pipeline = 0; + _sg.d3d11.cur_pipeline_id.id = SG_INVALID_ID; + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + _sg.d3d11.cur_rtvs[i] = 0; + } + _sg.d3d11.cur_dsv = 0; + _sg_d3d11_clear_state(); +} + +_SOKOL_PRIVATE void _sg_d3d11_apply_viewport(int x, int y, int w, int h, bool origin_top_left) { + SOKOL_ASSERT(_sg.d3d11.ctx); + SOKOL_ASSERT(_sg.d3d11.in_pass); + D3D11_VIEWPORT vp; + vp.TopLeftX = (FLOAT) x; + vp.TopLeftY = (FLOAT) (origin_top_left ? y : (_sg.d3d11.cur_height - (y + h))); + vp.Width = (FLOAT) w; + vp.Height = (FLOAT) h; + vp.MinDepth = 0.0f; + vp.MaxDepth = 1.0f; + _sg_d3d11_RSSetViewports(_sg.d3d11.ctx, 1, &vp); +} + +_SOKOL_PRIVATE void _sg_d3d11_apply_scissor_rect(int x, int y, int w, int h, bool origin_top_left) { + SOKOL_ASSERT(_sg.d3d11.ctx); + SOKOL_ASSERT(_sg.d3d11.in_pass); + D3D11_RECT rect; + rect.left = x; + rect.top = (origin_top_left ? y : (_sg.d3d11.cur_height - (y + h))); + rect.right = x + w; + rect.bottom = origin_top_left ? (y + h) : (_sg.d3d11.cur_height - y); + _sg_d3d11_RSSetScissorRects(_sg.d3d11.ctx, 1, &rect); +} + +_SOKOL_PRIVATE void _sg_d3d11_apply_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + SOKOL_ASSERT(pip->shader && (pip->cmn.shader_id.id == pip->shader->slot.id)); + SOKOL_ASSERT(_sg.d3d11.ctx); + SOKOL_ASSERT(_sg.d3d11.in_pass); + SOKOL_ASSERT(pip->d3d11.rs && pip->d3d11.bs && pip->d3d11.dss && pip->d3d11.il); + + _sg.d3d11.cur_pipeline = pip; + _sg.d3d11.cur_pipeline_id.id = pip->slot.id; + _sg.d3d11.use_indexed_draw = (pip->d3d11.index_format != DXGI_FORMAT_UNKNOWN); + _sg.d3d11.use_instanced_draw = pip->cmn.use_instanced_draw; + + _sg_d3d11_RSSetState(_sg.d3d11.ctx, pip->d3d11.rs); + _sg_d3d11_OMSetDepthStencilState(_sg.d3d11.ctx, pip->d3d11.dss, pip->d3d11.stencil_ref); + _sg_d3d11_OMSetBlendState(_sg.d3d11.ctx, pip->d3d11.bs, &pip->cmn.blend_color.r, 0xFFFFFFFF); + _sg_d3d11_IASetPrimitiveTopology(_sg.d3d11.ctx, pip->d3d11.topology); + _sg_d3d11_IASetInputLayout(_sg.d3d11.ctx, pip->d3d11.il); + _sg_d3d11_VSSetShader(_sg.d3d11.ctx, pip->shader->d3d11.vs, NULL, 0); + _sg_d3d11_VSSetConstantBuffers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_UBS, pip->shader->d3d11.stage[SG_SHADERSTAGE_VS].cbufs); + _sg_d3d11_PSSetShader(_sg.d3d11.ctx, pip->shader->d3d11.fs, NULL, 0); + _sg_d3d11_PSSetConstantBuffers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_UBS, pip->shader->d3d11.stage[SG_SHADERSTAGE_FS].cbufs); +} + +_SOKOL_PRIVATE void _sg_d3d11_apply_bindings( + _sg_pipeline_t* pip, + _sg_buffer_t** vbs, const int* vb_offsets, int num_vbs, + _sg_buffer_t* ib, int ib_offset, + _sg_image_t** vs_imgs, int num_vs_imgs, + _sg_image_t** fs_imgs, int num_fs_imgs) +{ + SOKOL_ASSERT(pip); + SOKOL_ASSERT(_sg.d3d11.ctx); + SOKOL_ASSERT(_sg.d3d11.in_pass); + + /* gather all the D3D11 resources into arrays */ + ID3D11Buffer* d3d11_ib = ib ? ib->d3d11.buf : 0; + ID3D11Buffer* d3d11_vbs[SG_MAX_SHADERSTAGE_BUFFERS]; + UINT d3d11_vb_offsets[SG_MAX_SHADERSTAGE_BUFFERS]; + ID3D11ShaderResourceView* d3d11_vs_srvs[SG_MAX_SHADERSTAGE_IMAGES]; + ID3D11SamplerState* d3d11_vs_smps[SG_MAX_SHADERSTAGE_IMAGES]; + ID3D11ShaderResourceView* d3d11_fs_srvs[SG_MAX_SHADERSTAGE_IMAGES]; + ID3D11SamplerState* d3d11_fs_smps[SG_MAX_SHADERSTAGE_IMAGES]; + int i; + for (i = 0; i < num_vbs; i++) { + SOKOL_ASSERT(vbs[i]->d3d11.buf); + d3d11_vbs[i] = vbs[i]->d3d11.buf; + d3d11_vb_offsets[i] = (UINT)vb_offsets[i]; + } + for (; i < SG_MAX_SHADERSTAGE_BUFFERS; i++) { + d3d11_vbs[i] = 0; + d3d11_vb_offsets[i] = 0; + } + for (i = 0; i < num_vs_imgs; i++) { + SOKOL_ASSERT(vs_imgs[i]->d3d11.srv); + SOKOL_ASSERT(vs_imgs[i]->d3d11.smp); + d3d11_vs_srvs[i] = vs_imgs[i]->d3d11.srv; + d3d11_vs_smps[i] = vs_imgs[i]->d3d11.smp; + } + for (; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + d3d11_vs_srvs[i] = 0; + d3d11_vs_smps[i] = 0; + } + for (i = 0; i < num_fs_imgs; i++) { + SOKOL_ASSERT(fs_imgs[i]->d3d11.srv); + SOKOL_ASSERT(fs_imgs[i]->d3d11.smp); + d3d11_fs_srvs[i] = fs_imgs[i]->d3d11.srv; + d3d11_fs_smps[i] = fs_imgs[i]->d3d11.smp; + } + for (; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + d3d11_fs_srvs[i] = 0; + d3d11_fs_smps[i] = 0; + } + + _sg_d3d11_IASetVertexBuffers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_BUFFERS, d3d11_vbs, pip->d3d11.vb_strides, d3d11_vb_offsets); + _sg_d3d11_IASetIndexBuffer(_sg.d3d11.ctx, d3d11_ib, pip->d3d11.index_format, (UINT)ib_offset); + _sg_d3d11_VSSetShaderResources(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, d3d11_vs_srvs); + _sg_d3d11_VSSetSamplers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, d3d11_vs_smps); + _sg_d3d11_PSSetShaderResources(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, d3d11_fs_srvs); + _sg_d3d11_PSSetSamplers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, d3d11_fs_smps); +} + +_SOKOL_PRIVATE void _sg_d3d11_apply_uniforms(sg_shader_stage stage_index, int ub_index, const sg_range* data) { + SOKOL_ASSERT(_sg.d3d11.ctx && _sg.d3d11.in_pass); + SOKOL_ASSERT(_sg.d3d11.cur_pipeline && _sg.d3d11.cur_pipeline->slot.id == _sg.d3d11.cur_pipeline_id.id); + SOKOL_ASSERT(_sg.d3d11.cur_pipeline->shader && _sg.d3d11.cur_pipeline->shader->slot.id == _sg.d3d11.cur_pipeline->cmn.shader_id.id); + SOKOL_ASSERT(ub_index < _sg.d3d11.cur_pipeline->shader->cmn.stage[stage_index].num_uniform_blocks); + SOKOL_ASSERT(data->size == _sg.d3d11.cur_pipeline->shader->cmn.stage[stage_index].uniform_blocks[ub_index].size); + ID3D11Buffer* cb = _sg.d3d11.cur_pipeline->shader->d3d11.stage[stage_index].cbufs[ub_index]; + SOKOL_ASSERT(cb); + _sg_d3d11_UpdateSubresource(_sg.d3d11.ctx, (ID3D11Resource*)cb, 0, NULL, data->ptr, 0, 0); +} + +_SOKOL_PRIVATE void _sg_d3d11_draw(int base_element, int num_elements, int num_instances) { + SOKOL_ASSERT(_sg.d3d11.in_pass); + if (_sg.d3d11.use_indexed_draw) { + if (_sg.d3d11.use_instanced_draw) { + _sg_d3d11_DrawIndexedInstanced(_sg.d3d11.ctx, (UINT)num_elements, (UINT)num_instances, (UINT)base_element, 0, 0); + } + else { + _sg_d3d11_DrawIndexed(_sg.d3d11.ctx, (UINT)num_elements, (UINT)base_element, 0); + } + } + else { + if (_sg.d3d11.use_instanced_draw) { + _sg_d3d11_DrawInstanced(_sg.d3d11.ctx, (UINT)num_elements, (UINT)num_instances, (UINT)base_element, 0); + } + else { + _sg_d3d11_Draw(_sg.d3d11.ctx, (UINT)num_elements, (UINT)base_element); + } + } +} + +_SOKOL_PRIVATE void _sg_d3d11_commit(void) { + SOKOL_ASSERT(!_sg.d3d11.in_pass); +} + +_SOKOL_PRIVATE void _sg_d3d11_update_buffer(_sg_buffer_t* buf, const sg_range* data) { + SOKOL_ASSERT(buf && data && data->ptr && (data->size > 0)); + SOKOL_ASSERT(_sg.d3d11.ctx); + SOKOL_ASSERT(buf->d3d11.buf); + D3D11_MAPPED_SUBRESOURCE d3d11_msr; + HRESULT hr = _sg_d3d11_Map(_sg.d3d11.ctx, (ID3D11Resource*)buf->d3d11.buf, 0, D3D11_MAP_WRITE_DISCARD, 0, &d3d11_msr); + if (SUCCEEDED(hr)) { + memcpy(d3d11_msr.pData, data->ptr, data->size); + _sg_d3d11_Unmap(_sg.d3d11.ctx, (ID3D11Resource*)buf->d3d11.buf, 0); + } else { + SOKOL_LOG("failed to map buffer while updating!\n"); + } +} + +_SOKOL_PRIVATE int _sg_d3d11_append_buffer(_sg_buffer_t* buf, const sg_range* data, bool new_frame) { + SOKOL_ASSERT(buf && data && data->ptr && (data->size > 0)); + SOKOL_ASSERT(_sg.d3d11.ctx); + SOKOL_ASSERT(buf->d3d11.buf); + D3D11_MAP map_type = new_frame ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE; + D3D11_MAPPED_SUBRESOURCE d3d11_msr; + HRESULT hr = _sg_d3d11_Map(_sg.d3d11.ctx, (ID3D11Resource*)buf->d3d11.buf, 0, map_type, 0, &d3d11_msr); + if (SUCCEEDED(hr)) { + uint8_t* dst_ptr = (uint8_t*)d3d11_msr.pData + buf->cmn.append_pos; + memcpy(dst_ptr, data->ptr, data->size); + _sg_d3d11_Unmap(_sg.d3d11.ctx, (ID3D11Resource*)buf->d3d11.buf, 0); + } else { + SOKOL_LOG("failed to map buffer while appending!\n"); + } + /* NOTE: this alignment is a requirement from WebGPU, but we want identical behaviour across all backend */ + return _sg_roundup((int)data->size, 4); +} + +_SOKOL_PRIVATE void _sg_d3d11_update_image(_sg_image_t* img, const sg_image_data* data) { + SOKOL_ASSERT(img && data); + SOKOL_ASSERT(_sg.d3d11.ctx); + SOKOL_ASSERT(img->d3d11.tex2d || img->d3d11.tex3d); + ID3D11Resource* d3d11_res = 0; + if (img->d3d11.tex3d) { + d3d11_res = (ID3D11Resource*) img->d3d11.tex3d; + } + else { + d3d11_res = (ID3D11Resource*) img->d3d11.tex2d; + } + SOKOL_ASSERT(d3d11_res); + const int num_faces = (img->cmn.type == SG_IMAGETYPE_CUBE) ? 6:1; + const int num_slices = (img->cmn.type == SG_IMAGETYPE_ARRAY) ? img->cmn.num_slices:1; + UINT subres_index = 0; + HRESULT hr; + D3D11_MAPPED_SUBRESOURCE d3d11_msr; + for (int face_index = 0; face_index < num_faces; face_index++) { + for (int slice_index = 0; slice_index < num_slices; slice_index++) { + for (int mip_index = 0; mip_index < img->cmn.num_mipmaps; mip_index++, subres_index++) { + SOKOL_ASSERT(subres_index < (SG_MAX_MIPMAPS * SG_MAX_TEXTUREARRAY_LAYERS)); + const int mip_width = ((img->cmn.width>>mip_index)>0) ? img->cmn.width>>mip_index : 1; + const int mip_height = ((img->cmn.height>>mip_index)>0) ? img->cmn.height>>mip_index : 1; + const int src_pitch = _sg_row_pitch(img->cmn.pixel_format, mip_width, 1); + const sg_range* subimg_data = &(data->subimage[face_index][mip_index]); + const size_t slice_size = subimg_data->size / (size_t)num_slices; + const size_t slice_offset = slice_size * (size_t)slice_index; + const uint8_t* slice_ptr = ((const uint8_t*)subimg_data->ptr) + slice_offset; + hr = _sg_d3d11_Map(_sg.d3d11.ctx, d3d11_res, subres_index, D3D11_MAP_WRITE_DISCARD, 0, &d3d11_msr); + if (SUCCEEDED(hr)) { + /* FIXME: need to handle difference in depth-pitch for 3D textures as well! */ + if (src_pitch == (int)d3d11_msr.RowPitch) { + memcpy(d3d11_msr.pData, slice_ptr, slice_size); + } + else { + SOKOL_ASSERT(src_pitch < (int)d3d11_msr.RowPitch); + const uint8_t* src_ptr = slice_ptr; + uint8_t* dst_ptr = (uint8_t*) d3d11_msr.pData; + for (int row_index = 0; row_index < mip_height; row_index++) { + memcpy(dst_ptr, src_ptr, (size_t)src_pitch); + src_ptr += src_pitch; + dst_ptr += d3d11_msr.RowPitch; + } + } + _sg_d3d11_Unmap(_sg.d3d11.ctx, d3d11_res, subres_index); + } else { + SOKOL_LOG("failed to map texture!\n"); + } + } + } + } +} + +/*== METAL BACKEND IMPLEMENTATION ============================================*/ +#elif defined(SOKOL_METAL) + +#if __has_feature(objc_arc) +#define _SG_OBJC_RETAIN(obj) { } +#define _SG_OBJC_RELEASE(obj) { obj = nil; } +#define _SG_OBJC_RELEASE_WITH_NULL(obj) { obj = [NSNull null]; } +#else +#define _SG_OBJC_RETAIN(obj) { [obj retain]; } +#define _SG_OBJC_RELEASE(obj) { [obj release]; obj = nil; } +#define _SG_OBJC_RELEASE_WITH_NULL(obj) { [obj release]; obj = [NSNull null]; } +#endif + +/*-- enum translation functions ----------------------------------------------*/ +_SOKOL_PRIVATE MTLLoadAction _sg_mtl_load_action(sg_action a) { + switch (a) { + case SG_ACTION_CLEAR: return MTLLoadActionClear; + case SG_ACTION_LOAD: return MTLLoadActionLoad; + case SG_ACTION_DONTCARE: return MTLLoadActionDontCare; + default: SOKOL_UNREACHABLE; return (MTLLoadAction)0; + } +} + +_SOKOL_PRIVATE MTLResourceOptions _sg_mtl_buffer_resource_options(sg_usage usg) { + switch (usg) { + case SG_USAGE_IMMUTABLE: +#if defined(_SG_TARGET_MACOS) + return MTLResourceStorageModeManaged; +#else + return MTLResourceStorageModeShared; +#endif + case SG_USAGE_DYNAMIC: + case SG_USAGE_STREAM: +#if defined(_SG_TARGET_MACOS) + return MTLResourceCPUCacheModeWriteCombined|MTLResourceStorageModeManaged; +#else + return MTLResourceCPUCacheModeWriteCombined|MTLResourceStorageModeShared; +#endif + default: + SOKOL_UNREACHABLE; + return 0; + } +} + +_SOKOL_PRIVATE MTLVertexStepFunction _sg_mtl_step_function(sg_vertex_step step) { + switch (step) { + case SG_VERTEXSTEP_PER_VERTEX: return MTLVertexStepFunctionPerVertex; + case SG_VERTEXSTEP_PER_INSTANCE: return MTLVertexStepFunctionPerInstance; + default: SOKOL_UNREACHABLE; return (MTLVertexStepFunction)0; + } +} + +_SOKOL_PRIVATE MTLVertexFormat _sg_mtl_vertex_format(sg_vertex_format fmt) { + switch (fmt) { + case SG_VERTEXFORMAT_FLOAT: return MTLVertexFormatFloat; + case SG_VERTEXFORMAT_FLOAT2: return MTLVertexFormatFloat2; + case SG_VERTEXFORMAT_FLOAT3: return MTLVertexFormatFloat3; + case SG_VERTEXFORMAT_FLOAT4: return MTLVertexFormatFloat4; + case SG_VERTEXFORMAT_BYTE4: return MTLVertexFormatChar4; + case SG_VERTEXFORMAT_BYTE4N: return MTLVertexFormatChar4Normalized; + case SG_VERTEXFORMAT_UBYTE4: return MTLVertexFormatUChar4; + case SG_VERTEXFORMAT_UBYTE4N: return MTLVertexFormatUChar4Normalized; + case SG_VERTEXFORMAT_SHORT2: return MTLVertexFormatShort2; + case SG_VERTEXFORMAT_SHORT2N: return MTLVertexFormatShort2Normalized; + case SG_VERTEXFORMAT_USHORT2N: return MTLVertexFormatUShort2Normalized; + case SG_VERTEXFORMAT_SHORT4: return MTLVertexFormatShort4; + case SG_VERTEXFORMAT_SHORT4N: return MTLVertexFormatShort4Normalized; + case SG_VERTEXFORMAT_USHORT4N: return MTLVertexFormatUShort4Normalized; + case SG_VERTEXFORMAT_UINT10_N2: return MTLVertexFormatUInt1010102Normalized; + default: SOKOL_UNREACHABLE; return (MTLVertexFormat)0; + } +} + +_SOKOL_PRIVATE MTLPrimitiveType _sg_mtl_primitive_type(sg_primitive_type t) { + switch (t) { + case SG_PRIMITIVETYPE_POINTS: return MTLPrimitiveTypePoint; + case SG_PRIMITIVETYPE_LINES: return MTLPrimitiveTypeLine; + case SG_PRIMITIVETYPE_LINE_STRIP: return MTLPrimitiveTypeLineStrip; + case SG_PRIMITIVETYPE_TRIANGLES: return MTLPrimitiveTypeTriangle; + case SG_PRIMITIVETYPE_TRIANGLE_STRIP: return MTLPrimitiveTypeTriangleStrip; + default: SOKOL_UNREACHABLE; return (MTLPrimitiveType)0; + } +} + +_SOKOL_PRIVATE MTLPixelFormat _sg_mtl_pixel_format(sg_pixel_format fmt) { + switch (fmt) { + case SG_PIXELFORMAT_R8: return MTLPixelFormatR8Unorm; + case SG_PIXELFORMAT_R8SN: return MTLPixelFormatR8Snorm; + case SG_PIXELFORMAT_R8UI: return MTLPixelFormatR8Uint; + case SG_PIXELFORMAT_R8SI: return MTLPixelFormatR8Sint; + case SG_PIXELFORMAT_R16: return MTLPixelFormatR16Unorm; + case SG_PIXELFORMAT_R16SN: return MTLPixelFormatR16Snorm; + case SG_PIXELFORMAT_R16UI: return MTLPixelFormatR16Uint; + case SG_PIXELFORMAT_R16SI: return MTLPixelFormatR16Sint; + case SG_PIXELFORMAT_R16F: return MTLPixelFormatR16Float; + case SG_PIXELFORMAT_RG8: return MTLPixelFormatRG8Unorm; + case SG_PIXELFORMAT_RG8SN: return MTLPixelFormatRG8Snorm; + case SG_PIXELFORMAT_RG8UI: return MTLPixelFormatRG8Uint; + case SG_PIXELFORMAT_RG8SI: return MTLPixelFormatRG8Sint; + case SG_PIXELFORMAT_R32UI: return MTLPixelFormatR32Uint; + case SG_PIXELFORMAT_R32SI: return MTLPixelFormatR32Sint; + case SG_PIXELFORMAT_R32F: return MTLPixelFormatR32Float; + case SG_PIXELFORMAT_RG16: return MTLPixelFormatRG16Unorm; + case SG_PIXELFORMAT_RG16SN: return MTLPixelFormatRG16Snorm; + case SG_PIXELFORMAT_RG16UI: return MTLPixelFormatRG16Uint; + case SG_PIXELFORMAT_RG16SI: return MTLPixelFormatRG16Sint; + case SG_PIXELFORMAT_RG16F: return MTLPixelFormatRG16Float; + case SG_PIXELFORMAT_RGBA8: return MTLPixelFormatRGBA8Unorm; + case SG_PIXELFORMAT_RGBA8SN: return MTLPixelFormatRGBA8Snorm; + case SG_PIXELFORMAT_RGBA8UI: return MTLPixelFormatRGBA8Uint; + case SG_PIXELFORMAT_RGBA8SI: return MTLPixelFormatRGBA8Sint; + case SG_PIXELFORMAT_BGRA8: return MTLPixelFormatBGRA8Unorm; + case SG_PIXELFORMAT_RGB10A2: return MTLPixelFormatRGB10A2Unorm; + case SG_PIXELFORMAT_RG11B10F: return MTLPixelFormatRG11B10Float; + case SG_PIXELFORMAT_RG32UI: return MTLPixelFormatRG32Uint; + case SG_PIXELFORMAT_RG32SI: return MTLPixelFormatRG32Sint; + case SG_PIXELFORMAT_RG32F: return MTLPixelFormatRG32Float; + case SG_PIXELFORMAT_RGBA16: return MTLPixelFormatRGBA16Unorm; + case SG_PIXELFORMAT_RGBA16SN: return MTLPixelFormatRGBA16Snorm; + case SG_PIXELFORMAT_RGBA16UI: return MTLPixelFormatRGBA16Uint; + case SG_PIXELFORMAT_RGBA16SI: return MTLPixelFormatRGBA16Sint; + case SG_PIXELFORMAT_RGBA16F: return MTLPixelFormatRGBA16Float; + case SG_PIXELFORMAT_RGBA32UI: return MTLPixelFormatRGBA32Uint; + case SG_PIXELFORMAT_RGBA32SI: return MTLPixelFormatRGBA32Sint; + case SG_PIXELFORMAT_RGBA32F: return MTLPixelFormatRGBA32Float; + case SG_PIXELFORMAT_DEPTH: return MTLPixelFormatDepth32Float; + case SG_PIXELFORMAT_DEPTH_STENCIL: return MTLPixelFormatDepth32Float_Stencil8; +#if defined(_SG_TARGET_MACOS) + case SG_PIXELFORMAT_BC1_RGBA: return MTLPixelFormatBC1_RGBA; + case SG_PIXELFORMAT_BC2_RGBA: return MTLPixelFormatBC2_RGBA; + case SG_PIXELFORMAT_BC3_RGBA: return MTLPixelFormatBC3_RGBA; + case SG_PIXELFORMAT_BC4_R: return MTLPixelFormatBC4_RUnorm; + case SG_PIXELFORMAT_BC4_RSN: return MTLPixelFormatBC4_RSnorm; + case SG_PIXELFORMAT_BC5_RG: return MTLPixelFormatBC5_RGUnorm; + case SG_PIXELFORMAT_BC5_RGSN: return MTLPixelFormatBC5_RGSnorm; + case SG_PIXELFORMAT_BC6H_RGBF: return MTLPixelFormatBC6H_RGBFloat; + case SG_PIXELFORMAT_BC6H_RGBUF: return MTLPixelFormatBC6H_RGBUfloat; + case SG_PIXELFORMAT_BC7_RGBA: return MTLPixelFormatBC7_RGBAUnorm; +#else + case SG_PIXELFORMAT_PVRTC_RGB_2BPP: return MTLPixelFormatPVRTC_RGB_2BPP; + case SG_PIXELFORMAT_PVRTC_RGB_4BPP: return MTLPixelFormatPVRTC_RGB_4BPP; + case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: return MTLPixelFormatPVRTC_RGBA_2BPP; + case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: return MTLPixelFormatPVRTC_RGBA_4BPP; + case SG_PIXELFORMAT_ETC2_RGB8: return MTLPixelFormatETC2_RGB8; + case SG_PIXELFORMAT_ETC2_RGB8A1: return MTLPixelFormatETC2_RGB8A1; + case SG_PIXELFORMAT_ETC2_RGBA8: return MTLPixelFormatEAC_RGBA8; + case SG_PIXELFORMAT_ETC2_RG11: return MTLPixelFormatEAC_RG11Unorm; + case SG_PIXELFORMAT_ETC2_RG11SN: return MTLPixelFormatEAC_RG11Snorm; +#endif + default: return MTLPixelFormatInvalid; + } +} + +_SOKOL_PRIVATE MTLColorWriteMask _sg_mtl_color_write_mask(sg_color_mask m) { + MTLColorWriteMask mtl_mask = MTLColorWriteMaskNone; + if (m & SG_COLORMASK_R) { + mtl_mask |= MTLColorWriteMaskRed; + } + if (m & SG_COLORMASK_G) { + mtl_mask |= MTLColorWriteMaskGreen; + } + if (m & SG_COLORMASK_B) { + mtl_mask |= MTLColorWriteMaskBlue; + } + if (m & SG_COLORMASK_A) { + mtl_mask |= MTLColorWriteMaskAlpha; + } + return mtl_mask; +} + +_SOKOL_PRIVATE MTLBlendOperation _sg_mtl_blend_op(sg_blend_op op) { + switch (op) { + case SG_BLENDOP_ADD: return MTLBlendOperationAdd; + case SG_BLENDOP_SUBTRACT: return MTLBlendOperationSubtract; + case SG_BLENDOP_REVERSE_SUBTRACT: return MTLBlendOperationReverseSubtract; + default: SOKOL_UNREACHABLE; return (MTLBlendOperation)0; + } +} + +_SOKOL_PRIVATE MTLBlendFactor _sg_mtl_blend_factor(sg_blend_factor f) { + switch (f) { + case SG_BLENDFACTOR_ZERO: return MTLBlendFactorZero; + case SG_BLENDFACTOR_ONE: return MTLBlendFactorOne; + case SG_BLENDFACTOR_SRC_COLOR: return MTLBlendFactorSourceColor; + case SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR: return MTLBlendFactorOneMinusSourceColor; + case SG_BLENDFACTOR_SRC_ALPHA: return MTLBlendFactorSourceAlpha; + case SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: return MTLBlendFactorOneMinusSourceAlpha; + case SG_BLENDFACTOR_DST_COLOR: return MTLBlendFactorDestinationColor; + case SG_BLENDFACTOR_ONE_MINUS_DST_COLOR: return MTLBlendFactorOneMinusDestinationColor; + case SG_BLENDFACTOR_DST_ALPHA: return MTLBlendFactorDestinationAlpha; + case SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA: return MTLBlendFactorOneMinusDestinationAlpha; + case SG_BLENDFACTOR_SRC_ALPHA_SATURATED: return MTLBlendFactorSourceAlphaSaturated; + case SG_BLENDFACTOR_BLEND_COLOR: return MTLBlendFactorBlendColor; + case SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR: return MTLBlendFactorOneMinusBlendColor; + case SG_BLENDFACTOR_BLEND_ALPHA: return MTLBlendFactorBlendAlpha; + case SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA: return MTLBlendFactorOneMinusBlendAlpha; + default: SOKOL_UNREACHABLE; return (MTLBlendFactor)0; + } +} + +_SOKOL_PRIVATE MTLCompareFunction _sg_mtl_compare_func(sg_compare_func f) { + switch (f) { + case SG_COMPAREFUNC_NEVER: return MTLCompareFunctionNever; + case SG_COMPAREFUNC_LESS: return MTLCompareFunctionLess; + case SG_COMPAREFUNC_EQUAL: return MTLCompareFunctionEqual; + case SG_COMPAREFUNC_LESS_EQUAL: return MTLCompareFunctionLessEqual; + case SG_COMPAREFUNC_GREATER: return MTLCompareFunctionGreater; + case SG_COMPAREFUNC_NOT_EQUAL: return MTLCompareFunctionNotEqual; + case SG_COMPAREFUNC_GREATER_EQUAL: return MTLCompareFunctionGreaterEqual; + case SG_COMPAREFUNC_ALWAYS: return MTLCompareFunctionAlways; + default: SOKOL_UNREACHABLE; return (MTLCompareFunction)0; + } +} + +_SOKOL_PRIVATE MTLStencilOperation _sg_mtl_stencil_op(sg_stencil_op op) { + switch (op) { + case SG_STENCILOP_KEEP: return MTLStencilOperationKeep; + case SG_STENCILOP_ZERO: return MTLStencilOperationZero; + case SG_STENCILOP_REPLACE: return MTLStencilOperationReplace; + case SG_STENCILOP_INCR_CLAMP: return MTLStencilOperationIncrementClamp; + case SG_STENCILOP_DECR_CLAMP: return MTLStencilOperationDecrementClamp; + case SG_STENCILOP_INVERT: return MTLStencilOperationInvert; + case SG_STENCILOP_INCR_WRAP: return MTLStencilOperationIncrementWrap; + case SG_STENCILOP_DECR_WRAP: return MTLStencilOperationDecrementWrap; + default: SOKOL_UNREACHABLE; return (MTLStencilOperation)0; + } +} + +_SOKOL_PRIVATE MTLCullMode _sg_mtl_cull_mode(sg_cull_mode m) { + switch (m) { + case SG_CULLMODE_NONE: return MTLCullModeNone; + case SG_CULLMODE_FRONT: return MTLCullModeFront; + case SG_CULLMODE_BACK: return MTLCullModeBack; + default: SOKOL_UNREACHABLE; return (MTLCullMode)0; + } +} + +_SOKOL_PRIVATE MTLWinding _sg_mtl_winding(sg_face_winding w) { + switch (w) { + case SG_FACEWINDING_CW: return MTLWindingClockwise; + case SG_FACEWINDING_CCW: return MTLWindingCounterClockwise; + default: SOKOL_UNREACHABLE; return (MTLWinding)0; + } +} + +_SOKOL_PRIVATE MTLIndexType _sg_mtl_index_type(sg_index_type t) { + switch (t) { + case SG_INDEXTYPE_UINT16: return MTLIndexTypeUInt16; + case SG_INDEXTYPE_UINT32: return MTLIndexTypeUInt32; + default: SOKOL_UNREACHABLE; return (MTLIndexType)0; + } +} + +_SOKOL_PRIVATE int _sg_mtl_index_size(sg_index_type t) { + switch (t) { + case SG_INDEXTYPE_NONE: return 0; + case SG_INDEXTYPE_UINT16: return 2; + case SG_INDEXTYPE_UINT32: return 4; + default: SOKOL_UNREACHABLE; return 0; + } +} + +_SOKOL_PRIVATE MTLTextureType _sg_mtl_texture_type(sg_image_type t) { + switch (t) { + case SG_IMAGETYPE_2D: return MTLTextureType2D; + case SG_IMAGETYPE_CUBE: return MTLTextureTypeCube; + case SG_IMAGETYPE_3D: return MTLTextureType3D; + case SG_IMAGETYPE_ARRAY: return MTLTextureType2DArray; + default: SOKOL_UNREACHABLE; return (MTLTextureType)0; + } +} + +_SOKOL_PRIVATE bool _sg_mtl_is_pvrtc(sg_pixel_format fmt) { + switch (fmt) { + case SG_PIXELFORMAT_PVRTC_RGB_2BPP: + case SG_PIXELFORMAT_PVRTC_RGB_4BPP: + case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: + case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: + return true; + default: + return false; + } +} + +_SOKOL_PRIVATE MTLSamplerAddressMode _sg_mtl_address_mode(sg_wrap w) { + switch (w) { + case SG_WRAP_REPEAT: return MTLSamplerAddressModeRepeat; + case SG_WRAP_CLAMP_TO_EDGE: return MTLSamplerAddressModeClampToEdge; +#if defined(_SG_TARGET_MACOS) + case SG_WRAP_CLAMP_TO_BORDER: return MTLSamplerAddressModeClampToBorderColor; +#else + /* clamp-to-border not supported on iOS, fall back to clamp-to-edge */ + case SG_WRAP_CLAMP_TO_BORDER: return MTLSamplerAddressModeClampToEdge; +#endif + case SG_WRAP_MIRRORED_REPEAT: return MTLSamplerAddressModeMirrorRepeat; + default: SOKOL_UNREACHABLE; return (MTLSamplerAddressMode)0; + } +} + +#if defined(_SG_TARGET_MACOS) +_SOKOL_PRIVATE MTLSamplerBorderColor _sg_mtl_border_color(sg_border_color c) { + switch (c) { + case SG_BORDERCOLOR_TRANSPARENT_BLACK: return MTLSamplerBorderColorTransparentBlack; + case SG_BORDERCOLOR_OPAQUE_BLACK: return MTLSamplerBorderColorOpaqueBlack; + case SG_BORDERCOLOR_OPAQUE_WHITE: return MTLSamplerBorderColorOpaqueWhite; + default: SOKOL_UNREACHABLE; return (MTLSamplerBorderColor)0; + } +} +#endif + +_SOKOL_PRIVATE MTLSamplerMinMagFilter _sg_mtl_minmag_filter(sg_filter f) { + switch (f) { + case SG_FILTER_NEAREST: + case SG_FILTER_NEAREST_MIPMAP_NEAREST: + case SG_FILTER_NEAREST_MIPMAP_LINEAR: + return MTLSamplerMinMagFilterNearest; + case SG_FILTER_LINEAR: + case SG_FILTER_LINEAR_MIPMAP_NEAREST: + case SG_FILTER_LINEAR_MIPMAP_LINEAR: + return MTLSamplerMinMagFilterLinear; + default: + SOKOL_UNREACHABLE; return (MTLSamplerMinMagFilter)0; + } +} + +_SOKOL_PRIVATE MTLSamplerMipFilter _sg_mtl_mip_filter(sg_filter f) { + switch (f) { + case SG_FILTER_NEAREST: + case SG_FILTER_LINEAR: + return MTLSamplerMipFilterNotMipmapped; + case SG_FILTER_NEAREST_MIPMAP_NEAREST: + case SG_FILTER_LINEAR_MIPMAP_NEAREST: + return MTLSamplerMipFilterNearest; + case SG_FILTER_NEAREST_MIPMAP_LINEAR: + case SG_FILTER_LINEAR_MIPMAP_LINEAR: + return MTLSamplerMipFilterLinear; + default: + SOKOL_UNREACHABLE; return (MTLSamplerMipFilter)0; + } +} + +/*-- a pool for all Metal resource objects, with deferred release queue -------*/ + +_SOKOL_PRIVATE void _sg_mtl_init_pool(const sg_desc* desc) { + _sg.mtl.idpool.num_slots = 2 * + ( + 2 * desc->buffer_pool_size + + 5 * desc->image_pool_size + + 4 * desc->shader_pool_size + + 2 * desc->pipeline_pool_size + + desc->pass_pool_size + ); + _sg.mtl.idpool.pool = [NSMutableArray arrayWithCapacity:(NSUInteger)_sg.mtl.idpool.num_slots]; + _SG_OBJC_RETAIN(_sg.mtl.idpool.pool); + NSNull* null = [NSNull null]; + for (int i = 0; i < _sg.mtl.idpool.num_slots; i++) { + [_sg.mtl.idpool.pool addObject:null]; + } + SOKOL_ASSERT([_sg.mtl.idpool.pool count] == (NSUInteger)_sg.mtl.idpool.num_slots); + /* a queue of currently free slot indices */ + _sg.mtl.idpool.free_queue_top = 0; + _sg.mtl.idpool.free_queue = (int*)SOKOL_MALLOC((size_t)_sg.mtl.idpool.num_slots * sizeof(int)); + /* pool slot 0 is reserved! */ + for (int i = _sg.mtl.idpool.num_slots-1; i >= 1; i--) { + _sg.mtl.idpool.free_queue[_sg.mtl.idpool.free_queue_top++] = i; + } + /* a circular queue which holds release items (frame index + when a resource is to be released, and the resource's + pool index + */ + _sg.mtl.idpool.release_queue_front = 0; + _sg.mtl.idpool.release_queue_back = 0; + _sg.mtl.idpool.release_queue = (_sg_mtl_release_item_t*)SOKOL_MALLOC((size_t)_sg.mtl.idpool.num_slots * sizeof(_sg_mtl_release_item_t)); + for (int i = 0; i < _sg.mtl.idpool.num_slots; i++) { + _sg.mtl.idpool.release_queue[i].frame_index = 0; + _sg.mtl.idpool.release_queue[i].slot_index = _SG_MTL_INVALID_SLOT_INDEX; + } +} + +_SOKOL_PRIVATE void _sg_mtl_destroy_pool(void) { + SOKOL_FREE(_sg.mtl.idpool.release_queue); _sg.mtl.idpool.release_queue = 0; + SOKOL_FREE(_sg.mtl.idpool.free_queue); _sg.mtl.idpool.free_queue = 0; + _SG_OBJC_RELEASE(_sg.mtl.idpool.pool); +} + +/* get a new free resource pool slot */ +_SOKOL_PRIVATE int _sg_mtl_alloc_pool_slot(void) { + SOKOL_ASSERT(_sg.mtl.idpool.free_queue_top > 0); + const int slot_index = _sg.mtl.idpool.free_queue[--_sg.mtl.idpool.free_queue_top]; + SOKOL_ASSERT((slot_index > 0) && (slot_index < _sg.mtl.idpool.num_slots)); + return slot_index; +} + +/* put a free resource pool slot back into the free-queue */ +_SOKOL_PRIVATE void _sg_mtl_free_pool_slot(int slot_index) { + SOKOL_ASSERT(_sg.mtl.idpool.free_queue_top < _sg.mtl.idpool.num_slots); + SOKOL_ASSERT((slot_index > 0) && (slot_index < _sg.mtl.idpool.num_slots)); + _sg.mtl.idpool.free_queue[_sg.mtl.idpool.free_queue_top++] = slot_index; +} + +/* add an MTLResource to the pool, return pool index or 0 if input was 'nil' */ +_SOKOL_PRIVATE int _sg_mtl_add_resource(id res) { + if (nil == res) { + return _SG_MTL_INVALID_SLOT_INDEX; + } + const int slot_index = _sg_mtl_alloc_pool_slot(); + SOKOL_ASSERT([NSNull null] == _sg.mtl.idpool.pool[(NSUInteger)slot_index]); + _sg.mtl.idpool.pool[(NSUInteger)slot_index] = res; + return slot_index; +} + +/* mark an MTLResource for release, this will put the resource into the + deferred-release queue, and the resource will then be released N frames later, + the special pool index 0 will be ignored (this means that a nil + value was provided to _sg_mtl_add_resource() +*/ +_SOKOL_PRIVATE void _sg_mtl_release_resource(uint32_t frame_index, int slot_index) { + if (slot_index == _SG_MTL_INVALID_SLOT_INDEX) { + return; + } + SOKOL_ASSERT((slot_index > 0) && (slot_index < _sg.mtl.idpool.num_slots)); + SOKOL_ASSERT([NSNull null] != _sg.mtl.idpool.pool[(NSUInteger)slot_index]); + int release_index = _sg.mtl.idpool.release_queue_front++; + if (_sg.mtl.idpool.release_queue_front >= _sg.mtl.idpool.num_slots) { + /* wrap-around */ + _sg.mtl.idpool.release_queue_front = 0; + } + /* release queue full? */ + SOKOL_ASSERT(_sg.mtl.idpool.release_queue_front != _sg.mtl.idpool.release_queue_back); + SOKOL_ASSERT(0 == _sg.mtl.idpool.release_queue[release_index].frame_index); + const uint32_t safe_to_release_frame_index = frame_index + SG_NUM_INFLIGHT_FRAMES + 1; + _sg.mtl.idpool.release_queue[release_index].frame_index = safe_to_release_frame_index; + _sg.mtl.idpool.release_queue[release_index].slot_index = slot_index; +} + +/* run garbage-collection pass on all resources in the release-queue */ +_SOKOL_PRIVATE void _sg_mtl_garbage_collect(uint32_t frame_index) { + while (_sg.mtl.idpool.release_queue_back != _sg.mtl.idpool.release_queue_front) { + if (frame_index < _sg.mtl.idpool.release_queue[_sg.mtl.idpool.release_queue_back].frame_index) { + /* don't need to check further, release-items past this are too young */ + break; + } + /* safe to release this resource */ + const int slot_index = _sg.mtl.idpool.release_queue[_sg.mtl.idpool.release_queue_back].slot_index; + SOKOL_ASSERT((slot_index > 0) && (slot_index < _sg.mtl.idpool.num_slots)); + SOKOL_ASSERT(_sg.mtl.idpool.pool[(NSUInteger)slot_index] != [NSNull null]); + _SG_OBJC_RELEASE_WITH_NULL(_sg.mtl.idpool.pool[(NSUInteger)slot_index]); + /* put the now free pool index back on the free queue */ + _sg_mtl_free_pool_slot(slot_index); + /* reset the release queue slot and advance the back index */ + _sg.mtl.idpool.release_queue[_sg.mtl.idpool.release_queue_back].frame_index = 0; + _sg.mtl.idpool.release_queue[_sg.mtl.idpool.release_queue_back].slot_index = _SG_MTL_INVALID_SLOT_INDEX; + _sg.mtl.idpool.release_queue_back++; + if (_sg.mtl.idpool.release_queue_back >= _sg.mtl.idpool.num_slots) { + /* wrap-around */ + _sg.mtl.idpool.release_queue_back = 0; + } + } +} + +_SOKOL_PRIVATE id _sg_mtl_id(int slot_index) { + return _sg.mtl.idpool.pool[(NSUInteger)slot_index]; +} + +_SOKOL_PRIVATE void _sg_mtl_init_sampler_cache(const sg_desc* desc) { + SOKOL_ASSERT(desc->sampler_cache_size > 0); + _sg_smpcache_init(&_sg.mtl.sampler_cache, desc->sampler_cache_size); +} + +/* destroy the sampler cache, and release all sampler objects */ +_SOKOL_PRIVATE void _sg_mtl_destroy_sampler_cache(uint32_t frame_index) { + SOKOL_ASSERT(_sg.mtl.sampler_cache.items); + SOKOL_ASSERT(_sg.mtl.sampler_cache.num_items <= _sg.mtl.sampler_cache.capacity); + for (int i = 0; i < _sg.mtl.sampler_cache.num_items; i++) { + _sg_mtl_release_resource(frame_index, (int)_sg_smpcache_sampler(&_sg.mtl.sampler_cache, i)); + } + _sg_smpcache_discard(&_sg.mtl.sampler_cache); +} + +/* + create and add an MTLSamplerStateObject and return its resource pool index, + reuse identical sampler state if one exists +*/ +_SOKOL_PRIVATE int _sg_mtl_create_sampler(id<MTLDevice> mtl_device, const sg_image_desc* img_desc) { + SOKOL_ASSERT(img_desc); + int index = _sg_smpcache_find_item(&_sg.mtl.sampler_cache, img_desc); + if (index >= 0) { + /* reuse existing sampler */ + return (int)_sg_smpcache_sampler(&_sg.mtl.sampler_cache, index); + } + else { + /* create a new Metal sampler state object and add to sampler cache */ + MTLSamplerDescriptor* mtl_desc = [[MTLSamplerDescriptor alloc] init]; + mtl_desc.sAddressMode = _sg_mtl_address_mode(img_desc->wrap_u); + mtl_desc.tAddressMode = _sg_mtl_address_mode(img_desc->wrap_v); + if (SG_IMAGETYPE_3D == img_desc->type) { + mtl_desc.rAddressMode = _sg_mtl_address_mode(img_desc->wrap_w); + } +#if defined(_SG_TARGET_MACOS) + mtl_desc.borderColor = _sg_mtl_border_color(img_desc->border_color); +#endif + mtl_desc.minFilter = _sg_mtl_minmag_filter(img_desc->min_filter); + mtl_desc.magFilter = _sg_mtl_minmag_filter(img_desc->mag_filter); + mtl_desc.mipFilter = _sg_mtl_mip_filter(img_desc->min_filter); + mtl_desc.lodMinClamp = img_desc->min_lod; + mtl_desc.lodMaxClamp = img_desc->max_lod; + mtl_desc.maxAnisotropy = img_desc->max_anisotropy; + mtl_desc.normalizedCoordinates = YES; + id<MTLSamplerState> mtl_sampler = [mtl_device newSamplerStateWithDescriptor:mtl_desc]; + _SG_OBJC_RELEASE(mtl_desc); + int sampler_handle = _sg_mtl_add_resource(mtl_sampler); + _sg_smpcache_add_item(&_sg.mtl.sampler_cache, img_desc, (uintptr_t)sampler_handle); + return sampler_handle; + } +} + +_SOKOL_PRIVATE void _sg_mtl_clear_state_cache(void) { + memset(&_sg.mtl.state_cache, 0, sizeof(_sg.mtl.state_cache)); +} + +/* https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf */ +_SOKOL_PRIVATE void _sg_mtl_init_caps(void) { +#if defined(_SG_TARGET_MACOS) + _sg.backend = SG_BACKEND_METAL_MACOS; +#elif defined(_SG_TARGET_IOS) +#if defined(_SG_TARGET_IOS_SIMULATOR) + _sg.backend = SG_BACKEND_METAL_SIMULATOR; +#else + _sg.backend = SG_BACKEND_METAL_IOS; +#endif +#endif + _sg.features.instancing = true; + _sg.features.origin_top_left = true; + _sg.features.multiple_render_targets = true; + _sg.features.msaa_render_targets = true; + _sg.features.imagetype_3d = true; + _sg.features.imagetype_array = true; +#if defined(_SG_TARGET_MACOS) + _sg.features.image_clamp_to_border = true; +#else + _sg.features.image_clamp_to_border = false; +#endif + _sg.features.mrt_independent_blend_state = true; + _sg.features.mrt_independent_write_mask = true; + +#if defined(_SG_TARGET_MACOS) + _sg.limits.max_image_size_2d = 16 * 1024; + _sg.limits.max_image_size_cube = 16 * 1024; + _sg.limits.max_image_size_3d = 2 * 1024; + _sg.limits.max_image_size_array = 16 * 1024; + _sg.limits.max_image_array_layers = 2 * 1024; +#else + /* newer iOS devices support 16k textures */ + _sg.limits.max_image_size_2d = 8 * 1024; + _sg.limits.max_image_size_cube = 8 * 1024; + _sg.limits.max_image_size_3d = 2 * 1024; + _sg.limits.max_image_size_array = 8 * 1024; + _sg.limits.max_image_array_layers = 2 * 1024; +#endif + _sg.limits.max_vertex_attrs = SG_MAX_VERTEX_ATTRIBUTES; + + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R8]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R8SI]); +#if defined(_SG_TARGET_MACOS) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16SN]); +#else + _sg_pixelformat_sfbr(&_sg.formats[SG_PIXELFORMAT_R16]); + _sg_pixelformat_sfbr(&_sg.formats[SG_PIXELFORMAT_R16SN]); +#endif + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R16SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG8]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG8SI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32UI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32SI]); +#if defined(_SG_TARGET_MACOS) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R32F]); +#else + _sg_pixelformat_sbr(&_sg.formats[SG_PIXELFORMAT_R32F]); +#endif +#if defined(_SG_TARGET_MACOS) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16SN]); +#else + _sg_pixelformat_sfbr(&_sg.formats[SG_PIXELFORMAT_RG16]); + _sg_pixelformat_sfbr(&_sg.formats[SG_PIXELFORMAT_RG16SN]); +#endif + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA8]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA8SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_BGRA8]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGB10A2]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG11B10F]); +#if defined(_SG_TARGET_MACOS) + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG32UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG32SI]); +#else + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RG32UI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RG32SI]); +#endif +#if defined(_SG_TARGET_MACOS) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG32F]); +#else + _sg_pixelformat_sbr(&_sg.formats[SG_PIXELFORMAT_RG32F]); +#endif +#if defined(_SG_TARGET_MACOS) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16SN]); +#else + _sg_pixelformat_sfbr(&_sg.formats[SG_PIXELFORMAT_RGBA16]); + _sg_pixelformat_sfbr(&_sg.formats[SG_PIXELFORMAT_RGBA16SN]); +#endif + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA16SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); +#if defined(_SG_TARGET_MACOS) + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA32UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA32SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); +#else + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RGBA32UI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RGBA32SI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); +#endif + _sg_pixelformat_srmd(&_sg.formats[SG_PIXELFORMAT_DEPTH]); + _sg_pixelformat_srmd(&_sg.formats[SG_PIXELFORMAT_DEPTH_STENCIL]); +#if defined(_SG_TARGET_MACOS) + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC1_RGBA]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC2_RGBA]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC3_RGBA]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC4_R]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC4_RSN]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC5_RG]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC5_RGSN]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC6H_RGBF]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC6H_RGBUF]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC7_RGBA]); +#else + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_PVRTC_RGB_2BPP]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_PVRTC_RGB_4BPP]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_PVRTC_RGBA_2BPP]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_PVRTC_RGBA_4BPP]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_ETC2_RGB8]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_ETC2_RGB8A1]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_ETC2_RGBA8]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_ETC2_RG11]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_ETC2_RG11SN]); +#endif +} + +/*-- main Metal backend state and functions ----------------------------------*/ +_SOKOL_PRIVATE void _sg_mtl_setup_backend(const sg_desc* desc) { + /* assume already zero-initialized */ + SOKOL_ASSERT(desc); + SOKOL_ASSERT(desc->context.metal.device); + SOKOL_ASSERT(desc->context.metal.renderpass_descriptor_cb || desc->context.metal.renderpass_descriptor_userdata_cb); + SOKOL_ASSERT(desc->context.metal.drawable_cb || desc->context.metal.drawable_userdata_cb); + SOKOL_ASSERT(desc->uniform_buffer_size > 0); + _sg_mtl_init_pool(desc); + _sg_mtl_init_sampler_cache(desc); + _sg_mtl_clear_state_cache(); + _sg.mtl.valid = true; + _sg.mtl.renderpass_descriptor_cb = desc->context.metal.renderpass_descriptor_cb; + _sg.mtl.renderpass_descriptor_userdata_cb = desc->context.metal.renderpass_descriptor_userdata_cb; + _sg.mtl.drawable_cb = desc->context.metal.drawable_cb; + _sg.mtl.drawable_userdata_cb = desc->context.metal.drawable_userdata_cb; + _sg.mtl.user_data = desc->context.metal.user_data; + _sg.mtl.frame_index = 1; + _sg.mtl.ub_size = desc->uniform_buffer_size; + _sg.mtl.sem = dispatch_semaphore_create(SG_NUM_INFLIGHT_FRAMES); + _sg.mtl.device = (__bridge id<MTLDevice>) desc->context.metal.device; + _sg.mtl.cmd_queue = [_sg.mtl.device newCommandQueue]; + for (int i = 0; i < SG_NUM_INFLIGHT_FRAMES; i++) { + _sg.mtl.uniform_buffers[i] = [_sg.mtl.device + newBufferWithLength:(NSUInteger)_sg.mtl.ub_size + options:MTLResourceCPUCacheModeWriteCombined|MTLResourceStorageModeShared + ]; + } + _sg_mtl_init_caps(); +} + +_SOKOL_PRIVATE void _sg_mtl_discard_backend(void) { + SOKOL_ASSERT(_sg.mtl.valid); + /* wait for the last frame to finish */ + for (int i = 0; i < SG_NUM_INFLIGHT_FRAMES; i++) { + dispatch_semaphore_wait(_sg.mtl.sem, DISPATCH_TIME_FOREVER); + } + /* semaphore must be "relinquished" before destruction */ + for (int i = 0; i < SG_NUM_INFLIGHT_FRAMES; i++) { + dispatch_semaphore_signal(_sg.mtl.sem); + } + _sg_mtl_destroy_sampler_cache(_sg.mtl.frame_index); + _sg_mtl_garbage_collect(_sg.mtl.frame_index + SG_NUM_INFLIGHT_FRAMES + 2); + _sg_mtl_destroy_pool(); + _sg.mtl.valid = false; + + _SG_OBJC_RELEASE(_sg.mtl.sem); + _SG_OBJC_RELEASE(_sg.mtl.device); + _SG_OBJC_RELEASE(_sg.mtl.cmd_queue); + for (int i = 0; i < SG_NUM_INFLIGHT_FRAMES; i++) { + _SG_OBJC_RELEASE(_sg.mtl.uniform_buffers[i]); + } + /* NOTE: MTLCommandBuffer and MTLRenderCommandEncoder are auto-released */ + _sg.mtl.cmd_buffer = nil; + _sg.mtl.cmd_encoder = nil; +} + +_SOKOL_PRIVATE void _sg_mtl_bind_uniform_buffers(void) { + SOKOL_ASSERT(nil != _sg.mtl.cmd_encoder); + for (int slot = 0; slot < SG_MAX_SHADERSTAGE_UBS; slot++) { + [_sg.mtl.cmd_encoder + setVertexBuffer:_sg.mtl.uniform_buffers[_sg.mtl.cur_frame_rotate_index] + offset:0 + atIndex:(NSUInteger)slot]; + [_sg.mtl.cmd_encoder + setFragmentBuffer:_sg.mtl.uniform_buffers[_sg.mtl.cur_frame_rotate_index] + offset:0 + atIndex:(NSUInteger)slot]; + } +} + +_SOKOL_PRIVATE void _sg_mtl_reset_state_cache(void) { + _sg_mtl_clear_state_cache(); + + /* need to restore the uniform buffer binding (normally happens in + _sg_mtl_begin_pass() + */ + if (nil != _sg.mtl.cmd_encoder) { + _sg_mtl_bind_uniform_buffers(); + } +} + +_SOKOL_PRIVATE sg_resource_state _sg_mtl_create_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + _SOKOL_UNUSED(ctx); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_mtl_destroy_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + _SOKOL_UNUSED(ctx); + /* empty */ +} + +_SOKOL_PRIVATE void _sg_mtl_activate_context(_sg_context_t* ctx) { + _SOKOL_UNUSED(ctx); + _sg_mtl_clear_state_cache(); +} + +_SOKOL_PRIVATE sg_resource_state _sg_mtl_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) { + SOKOL_ASSERT(buf && desc); + _sg_buffer_common_init(&buf->cmn, desc); + const bool injected = (0 != desc->mtl_buffers[0]); + MTLResourceOptions mtl_options = _sg_mtl_buffer_resource_options(buf->cmn.usage); + for (int slot = 0; slot < buf->cmn.num_slots; slot++) { + id<MTLBuffer> mtl_buf; + if (injected) { + SOKOL_ASSERT(desc->mtl_buffers[slot]); + mtl_buf = (__bridge id<MTLBuffer>) desc->mtl_buffers[slot]; + } + else { + if (buf->cmn.usage == SG_USAGE_IMMUTABLE) { + SOKOL_ASSERT(desc->data.ptr); + mtl_buf = [_sg.mtl.device newBufferWithBytes:desc->data.ptr length:(NSUInteger)buf->cmn.size options:mtl_options]; + } + else { + mtl_buf = [_sg.mtl.device newBufferWithLength:(NSUInteger)buf->cmn.size options:mtl_options]; + } + } + buf->mtl.buf[slot] = _sg_mtl_add_resource(mtl_buf); + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_mtl_destroy_buffer(_sg_buffer_t* buf) { + SOKOL_ASSERT(buf); + for (int slot = 0; slot < buf->cmn.num_slots; slot++) { + /* it's valid to call release resource with '0' */ + _sg_mtl_release_resource(_sg.mtl.frame_index, buf->mtl.buf[slot]); + } +} + +_SOKOL_PRIVATE void _sg_mtl_copy_image_data(const _sg_image_t* img, __unsafe_unretained id<MTLTexture> mtl_tex, const sg_image_data* data) { + const int num_faces = (img->cmn.type == SG_IMAGETYPE_CUBE) ? 6:1; + const int num_slices = (img->cmn.type == SG_IMAGETYPE_ARRAY) ? img->cmn.num_slices : 1; + for (int face_index = 0; face_index < num_faces; face_index++) { + for (int mip_index = 0; mip_index < img->cmn.num_mipmaps; mip_index++) { + SOKOL_ASSERT(data->subimage[face_index][mip_index].ptr); + SOKOL_ASSERT(data->subimage[face_index][mip_index].size > 0); + const uint8_t* data_ptr = (const uint8_t*)data->subimage[face_index][mip_index].ptr; + const int mip_width = _sg_max(img->cmn.width >> mip_index, 1); + const int mip_height = _sg_max(img->cmn.height >> mip_index, 1); + /* special case PVRTC formats: bytePerRow and bytesPerImage must be 0 */ + int bytes_per_row = 0; + int bytes_per_slice = 0; + if (!_sg_mtl_is_pvrtc(img->cmn.pixel_format)) { + bytes_per_row = _sg_row_pitch(img->cmn.pixel_format, mip_width, 1); + bytes_per_slice = _sg_surface_pitch(img->cmn.pixel_format, mip_width, mip_height, 1); + } + /* bytesPerImage special case: https://developer.apple.com/documentation/metal/mtltexture/1515679-replaceregion + + "Supply a nonzero value only when you copy data to a MTLTextureType3D type texture" + */ + MTLRegion region; + int bytes_per_image; + if (img->cmn.type == SG_IMAGETYPE_3D) { + const int mip_depth = _sg_max(img->cmn.num_slices >> mip_index, 1); + region = MTLRegionMake3D(0, 0, 0, (NSUInteger)mip_width, (NSUInteger)mip_height, (NSUInteger)mip_depth); + bytes_per_image = bytes_per_slice; + /* FIXME: apparently the minimal bytes_per_image size for 3D texture + is 4 KByte... somehow need to handle this */ + } + else { + region = MTLRegionMake2D(0, 0, (NSUInteger)mip_width, (NSUInteger)mip_height); + bytes_per_image = 0; + } + + for (int slice_index = 0; slice_index < num_slices; slice_index++) { + const int mtl_slice_index = (img->cmn.type == SG_IMAGETYPE_CUBE) ? face_index : slice_index; + const int slice_offset = slice_index * bytes_per_slice; + SOKOL_ASSERT((slice_offset + bytes_per_slice) <= (int)data->subimage[face_index][mip_index].size); + [mtl_tex replaceRegion:region + mipmapLevel:(NSUInteger)mip_index + slice:(NSUInteger)mtl_slice_index + withBytes:data_ptr + slice_offset + bytesPerRow:(NSUInteger)bytes_per_row + bytesPerImage:(NSUInteger)bytes_per_image]; + } + } + } +} + +/* + FIXME: METAL RESOURCE STORAGE MODE FOR macOS AND iOS + + For immutable textures on macOS, the recommended procedure is to create + a MTLStorageModeManaged texture with the immutable content first, + and then use the GPU to blit the content into a MTLStorageModePrivate + texture before the first use. + + On iOS use the same one-time-blit procedure, but from a + MTLStorageModeShared to a MTLStorageModePrivate texture. + + It probably makes sense to handle this in a separate 'resource manager' + with a recycable pool of blit-source-textures? +*/ + +/* initialize MTLTextureDescritor with common attributes */ +_SOKOL_PRIVATE bool _sg_mtl_init_texdesc_common(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) { + mtl_desc.textureType = _sg_mtl_texture_type(img->cmn.type); + mtl_desc.pixelFormat = _sg_mtl_pixel_format(img->cmn.pixel_format); + if (MTLPixelFormatInvalid == mtl_desc.pixelFormat) { + SOKOL_LOG("Unsupported texture pixel format!\n"); + return false; + } + mtl_desc.width = (NSUInteger)img->cmn.width; + mtl_desc.height = (NSUInteger)img->cmn.height; + if (SG_IMAGETYPE_3D == img->cmn.type) { + mtl_desc.depth = (NSUInteger)img->cmn.num_slices; + } + else { + mtl_desc.depth = 1; + } + mtl_desc.mipmapLevelCount = (NSUInteger)img->cmn.num_mipmaps; + if (SG_IMAGETYPE_ARRAY == img->cmn.type) { + mtl_desc.arrayLength = (NSUInteger)img->cmn.num_slices; + } + else { + mtl_desc.arrayLength = 1; + } + mtl_desc.usage = MTLTextureUsageShaderRead; + MTLResourceOptions res_options = 0; + if (img->cmn.usage != SG_USAGE_IMMUTABLE) { + res_options |= MTLResourceCPUCacheModeWriteCombined; + } +#if defined(_SG_TARGET_MACOS) + /* macOS: use managed textures */ + res_options |= MTLResourceStorageModeManaged; +#else + /* iOS: use CPU/GPU shared memory */ + res_options |= MTLResourceStorageModeShared; +#endif + mtl_desc.resourceOptions = res_options; + return true; +} + +/* initialize MTLTextureDescritor with rendertarget attributes */ +_SOKOL_PRIVATE void _sg_mtl_init_texdesc_rt(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) { + SOKOL_ASSERT(img->cmn.render_target); + _SOKOL_UNUSED(img); + /* render targets are only visible to the GPU */ + mtl_desc.resourceOptions = MTLResourceStorageModePrivate; + /* non-MSAA render targets are shader-readable */ + mtl_desc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget; +} + +/* initialize MTLTextureDescritor with MSAA attributes */ +_SOKOL_PRIVATE void _sg_mtl_init_texdesc_rt_msaa(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) { + SOKOL_ASSERT(img->cmn.sample_count > 1); + /* render targets are only visible to the GPU */ + mtl_desc.resourceOptions = MTLResourceStorageModePrivate; + /* MSAA render targets are not shader-readable (instead they are resolved) */ + mtl_desc.usage = MTLTextureUsageRenderTarget; + mtl_desc.textureType = MTLTextureType2DMultisample; + mtl_desc.depth = 1; + mtl_desc.arrayLength = 1; + mtl_desc.mipmapLevelCount = 1; + mtl_desc.sampleCount = (NSUInteger)img->cmn.sample_count; +} + +_SOKOL_PRIVATE sg_resource_state _sg_mtl_create_image(_sg_image_t* img, const sg_image_desc* desc) { + SOKOL_ASSERT(img && desc); + _sg_image_common_init(&img->cmn, desc); + const bool injected = (0 != desc->mtl_textures[0]); + const bool msaa = (img->cmn.sample_count > 1); + + /* first initialize all Metal resource pool slots to 'empty' */ + for (int i = 0; i < SG_NUM_INFLIGHT_FRAMES; i++) { + img->mtl.tex[i] = _sg_mtl_add_resource(nil); + } + img->mtl.sampler_state = _sg_mtl_add_resource(nil); + img->mtl.depth_tex = _sg_mtl_add_resource(nil); + img->mtl.msaa_tex = _sg_mtl_add_resource(nil); + + /* initialize a Metal texture descriptor with common attributes */ + MTLTextureDescriptor* mtl_desc = [[MTLTextureDescriptor alloc] init]; + if (!_sg_mtl_init_texdesc_common(mtl_desc, img)) { + _SG_OBJC_RELEASE(mtl_desc); + return SG_RESOURCESTATE_FAILED; + } + + /* special case depth-stencil-buffer? */ + if (_sg_is_valid_rendertarget_depth_format(img->cmn.pixel_format)) { + /* depth-stencil buffer texture must always be a render target */ + SOKOL_ASSERT(img->cmn.render_target); + SOKOL_ASSERT(img->cmn.type == SG_IMAGETYPE_2D); + SOKOL_ASSERT(img->cmn.num_mipmaps == 1); + SOKOL_ASSERT(!injected); + if (msaa) { + _sg_mtl_init_texdesc_rt_msaa(mtl_desc, img); + } + else { + _sg_mtl_init_texdesc_rt(mtl_desc, img); + } + id<MTLTexture> tex = [_sg.mtl.device newTextureWithDescriptor:mtl_desc]; + SOKOL_ASSERT(nil != tex); + img->mtl.depth_tex = _sg_mtl_add_resource(tex); + } + else { + /* create the color texture + In case this is a render target without MSAA, add the relevant + render-target descriptor attributes. + In case this is a render target *with* MSAA, the color texture + will serve as MSAA-resolve target (not as render target), and rendering + will go into a separate render target texture of type + MTLTextureType2DMultisample. + */ + if (img->cmn.render_target && !msaa) { + _sg_mtl_init_texdesc_rt(mtl_desc, img); + } + for (int slot = 0; slot < img->cmn.num_slots; slot++) { + id<MTLTexture> tex; + if (injected) { + SOKOL_ASSERT(desc->mtl_textures[slot]); + tex = (__bridge id<MTLTexture>) desc->mtl_textures[slot]; + } + else { + tex = [_sg.mtl.device newTextureWithDescriptor:mtl_desc]; + if ((img->cmn.usage == SG_USAGE_IMMUTABLE) && !img->cmn.render_target) { + _sg_mtl_copy_image_data(img, tex, &desc->data); + } + } + img->mtl.tex[slot] = _sg_mtl_add_resource(tex); + } + + /* if MSAA color render target, create an additional MSAA render-surface texture */ + if (img->cmn.render_target && msaa) { + _sg_mtl_init_texdesc_rt_msaa(mtl_desc, img); + id<MTLTexture> tex = [_sg.mtl.device newTextureWithDescriptor:mtl_desc]; + img->mtl.msaa_tex = _sg_mtl_add_resource(tex); + } + + /* create (possibly shared) sampler state */ + img->mtl.sampler_state = _sg_mtl_create_sampler(_sg.mtl.device, desc); + } + _SG_OBJC_RELEASE(mtl_desc); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_mtl_destroy_image(_sg_image_t* img) { + SOKOL_ASSERT(img); + /* it's valid to call release resource with a 'null resource' */ + for (int slot = 0; slot < img->cmn.num_slots; slot++) { + _sg_mtl_release_resource(_sg.mtl.frame_index, img->mtl.tex[slot]); + } + _sg_mtl_release_resource(_sg.mtl.frame_index, img->mtl.depth_tex); + _sg_mtl_release_resource(_sg.mtl.frame_index, img->mtl.msaa_tex); + /* NOTE: sampler state objects are shared and not released until shutdown */ +} + +_SOKOL_PRIVATE id<MTLLibrary> _sg_mtl_compile_library(const char* src) { + NSError* err = NULL; + id<MTLLibrary> lib = [_sg.mtl.device + newLibraryWithSource:[NSString stringWithUTF8String:src] + options:nil + error:&err + ]; + if (err) { + SOKOL_LOG([err.localizedDescription UTF8String]); + } + return lib; +} + +_SOKOL_PRIVATE id<MTLLibrary> _sg_mtl_library_from_bytecode(const void* ptr, size_t num_bytes) { + NSError* err = NULL; + dispatch_data_t lib_data = dispatch_data_create(ptr, num_bytes, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT); + id<MTLLibrary> lib = [_sg.mtl.device newLibraryWithData:lib_data error:&err]; + if (err) { + SOKOL_LOG([err.localizedDescription UTF8String]); + } + _SG_OBJC_RELEASE(lib_data); + return lib; +} + +_SOKOL_PRIVATE sg_resource_state _sg_mtl_create_shader(_sg_shader_t* shd, const sg_shader_desc* desc) { + SOKOL_ASSERT(shd && desc); + + _sg_shader_common_init(&shd->cmn, desc); + + /* create metal libray objects and lookup entry functions */ + id<MTLLibrary> vs_lib; + id<MTLLibrary> fs_lib; + id<MTLFunction> vs_func; + id<MTLFunction> fs_func; + const char* vs_entry = desc->vs.entry; + const char* fs_entry = desc->fs.entry; + if (desc->vs.bytecode.ptr && desc->fs.bytecode.ptr) { + /* separate byte code provided */ + vs_lib = _sg_mtl_library_from_bytecode(desc->vs.bytecode.ptr, desc->vs.bytecode.size); + fs_lib = _sg_mtl_library_from_bytecode(desc->fs.bytecode.ptr, desc->fs.bytecode.size); + if (nil == vs_lib || nil == fs_lib) { + return SG_RESOURCESTATE_FAILED; + } + vs_func = [vs_lib newFunctionWithName:[NSString stringWithUTF8String:vs_entry]]; + fs_func = [fs_lib newFunctionWithName:[NSString stringWithUTF8String:fs_entry]]; + } + else if (desc->vs.source && desc->fs.source) { + /* separate sources provided */ + vs_lib = _sg_mtl_compile_library(desc->vs.source); + fs_lib = _sg_mtl_compile_library(desc->fs.source); + if (nil == vs_lib || nil == fs_lib) { + return SG_RESOURCESTATE_FAILED; + } + vs_func = [vs_lib newFunctionWithName:[NSString stringWithUTF8String:vs_entry]]; + fs_func = [fs_lib newFunctionWithName:[NSString stringWithUTF8String:fs_entry]]; + } + else { + return SG_RESOURCESTATE_FAILED; + } + if (nil == vs_func) { + SOKOL_LOG("vertex shader entry function not found\n"); + return SG_RESOURCESTATE_FAILED; + } + if (nil == fs_func) { + SOKOL_LOG("fragment shader entry function not found\n"); + return SG_RESOURCESTATE_FAILED; + } + /* it is legal to call _sg_mtl_add_resource with a nil value, this will return a special 0xFFFFFFFF index */ + shd->mtl.stage[SG_SHADERSTAGE_VS].mtl_lib = _sg_mtl_add_resource(vs_lib); + shd->mtl.stage[SG_SHADERSTAGE_FS].mtl_lib = _sg_mtl_add_resource(fs_lib); + shd->mtl.stage[SG_SHADERSTAGE_VS].mtl_func = _sg_mtl_add_resource(vs_func); + shd->mtl.stage[SG_SHADERSTAGE_FS].mtl_func = _sg_mtl_add_resource(fs_func); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_mtl_destroy_shader(_sg_shader_t* shd) { + SOKOL_ASSERT(shd); + /* it is valid to call _sg_mtl_release_resource with a 'null resource' */ + _sg_mtl_release_resource(_sg.mtl.frame_index, shd->mtl.stage[SG_SHADERSTAGE_VS].mtl_func); + _sg_mtl_release_resource(_sg.mtl.frame_index, shd->mtl.stage[SG_SHADERSTAGE_VS].mtl_lib); + _sg_mtl_release_resource(_sg.mtl.frame_index, shd->mtl.stage[SG_SHADERSTAGE_FS].mtl_func); + _sg_mtl_release_resource(_sg.mtl.frame_index, shd->mtl.stage[SG_SHADERSTAGE_FS].mtl_lib); +} + +_SOKOL_PRIVATE sg_resource_state _sg_mtl_create_pipeline(_sg_pipeline_t* pip, _sg_shader_t* shd, const sg_pipeline_desc* desc) { + SOKOL_ASSERT(pip && shd && desc); + SOKOL_ASSERT(desc->shader.id == shd->slot.id); + + pip->shader = shd; + _sg_pipeline_common_init(&pip->cmn, desc); + + sg_primitive_type prim_type = desc->primitive_type; + pip->mtl.prim_type = _sg_mtl_primitive_type(prim_type); + pip->mtl.index_size = _sg_mtl_index_size(pip->cmn.index_type); + if (SG_INDEXTYPE_NONE != pip->cmn.index_type) { + pip->mtl.index_type = _sg_mtl_index_type(pip->cmn.index_type); + } + pip->mtl.cull_mode = _sg_mtl_cull_mode(desc->cull_mode); + pip->mtl.winding = _sg_mtl_winding(desc->face_winding); + pip->mtl.stencil_ref = desc->stencil.ref; + + /* create vertex-descriptor */ + MTLVertexDescriptor* vtx_desc = [MTLVertexDescriptor vertexDescriptor]; + for (NSUInteger attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) { + const sg_vertex_attr_desc* a_desc = &desc->layout.attrs[attr_index]; + if (a_desc->format == SG_VERTEXFORMAT_INVALID) { + break; + } + SOKOL_ASSERT(a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS); + vtx_desc.attributes[attr_index].format = _sg_mtl_vertex_format(a_desc->format); + vtx_desc.attributes[attr_index].offset = (NSUInteger)a_desc->offset; + vtx_desc.attributes[attr_index].bufferIndex = (NSUInteger)(a_desc->buffer_index + SG_MAX_SHADERSTAGE_UBS); + pip->cmn.vertex_layout_valid[a_desc->buffer_index] = true; + } + for (NSUInteger layout_index = 0; layout_index < SG_MAX_SHADERSTAGE_BUFFERS; layout_index++) { + if (pip->cmn.vertex_layout_valid[layout_index]) { + const sg_buffer_layout_desc* l_desc = &desc->layout.buffers[layout_index]; + const NSUInteger mtl_vb_slot = layout_index + SG_MAX_SHADERSTAGE_UBS; + SOKOL_ASSERT(l_desc->stride > 0); + vtx_desc.layouts[mtl_vb_slot].stride = (NSUInteger)l_desc->stride; + vtx_desc.layouts[mtl_vb_slot].stepFunction = _sg_mtl_step_function(l_desc->step_func); + vtx_desc.layouts[mtl_vb_slot].stepRate = (NSUInteger)l_desc->step_rate; + if (SG_VERTEXSTEP_PER_INSTANCE == l_desc->step_func) { + // NOTE: not actually used in _sg_mtl_draw() + pip->cmn.use_instanced_draw = true; + } + } + } + + /* render-pipeline descriptor */ + MTLRenderPipelineDescriptor* rp_desc = [[MTLRenderPipelineDescriptor alloc] init]; + rp_desc.vertexDescriptor = vtx_desc; + SOKOL_ASSERT(shd->mtl.stage[SG_SHADERSTAGE_VS].mtl_func != _SG_MTL_INVALID_SLOT_INDEX); + rp_desc.vertexFunction = _sg_mtl_id(shd->mtl.stage[SG_SHADERSTAGE_VS].mtl_func); + SOKOL_ASSERT(shd->mtl.stage[SG_SHADERSTAGE_FS].mtl_func != _SG_MTL_INVALID_SLOT_INDEX); + rp_desc.fragmentFunction = _sg_mtl_id(shd->mtl.stage[SG_SHADERSTAGE_FS].mtl_func); + rp_desc.sampleCount = (NSUInteger)desc->sample_count; + rp_desc.alphaToCoverageEnabled = desc->alpha_to_coverage_enabled; + rp_desc.alphaToOneEnabled = NO; + rp_desc.rasterizationEnabled = YES; + rp_desc.depthAttachmentPixelFormat = _sg_mtl_pixel_format(desc->depth.pixel_format); + if (desc->depth.pixel_format == SG_PIXELFORMAT_DEPTH_STENCIL) { + rp_desc.stencilAttachmentPixelFormat = _sg_mtl_pixel_format(desc->depth.pixel_format); + } + /* FIXME: this only works on macOS 10.13! + for (int i = 0; i < (SG_MAX_SHADERSTAGE_UBS+SG_MAX_SHADERSTAGE_BUFFERS); i++) { + rp_desc.vertexBuffers[i].mutability = MTLMutabilityImmutable; + } + for (int i = 0; i < SG_MAX_SHADERSTAGE_UBS; i++) { + rp_desc.fragmentBuffers[i].mutability = MTLMutabilityImmutable; + } + */ + for (NSUInteger i = 0; i < (NSUInteger)desc->color_count; i++) { + SOKOL_ASSERT(i < SG_MAX_COLOR_ATTACHMENTS); + const sg_color_state* cs = &desc->colors[i]; + rp_desc.colorAttachments[i].pixelFormat = _sg_mtl_pixel_format(cs->pixel_format); + rp_desc.colorAttachments[i].writeMask = _sg_mtl_color_write_mask(cs->write_mask); + rp_desc.colorAttachments[i].blendingEnabled = cs->blend.enabled; + rp_desc.colorAttachments[i].alphaBlendOperation = _sg_mtl_blend_op(cs->blend.op_alpha); + rp_desc.colorAttachments[i].rgbBlendOperation = _sg_mtl_blend_op(cs->blend.op_rgb); + rp_desc.colorAttachments[i].destinationAlphaBlendFactor = _sg_mtl_blend_factor(cs->blend.dst_factor_alpha); + rp_desc.colorAttachments[i].destinationRGBBlendFactor = _sg_mtl_blend_factor(cs->blend.dst_factor_rgb); + rp_desc.colorAttachments[i].sourceAlphaBlendFactor = _sg_mtl_blend_factor(cs->blend.src_factor_alpha); + rp_desc.colorAttachments[i].sourceRGBBlendFactor = _sg_mtl_blend_factor(cs->blend.src_factor_rgb); + } + NSError* err = NULL; + id<MTLRenderPipelineState> mtl_rps = [_sg.mtl.device newRenderPipelineStateWithDescriptor:rp_desc error:&err]; + _SG_OBJC_RELEASE(rp_desc); + if (nil == mtl_rps) { + SOKOL_ASSERT(err); + SOKOL_LOG([err.localizedDescription UTF8String]); + return SG_RESOURCESTATE_FAILED; + } + + /* depth-stencil-state */ + MTLDepthStencilDescriptor* ds_desc = [[MTLDepthStencilDescriptor alloc] init]; + ds_desc.depthCompareFunction = _sg_mtl_compare_func(desc->depth.compare); + ds_desc.depthWriteEnabled = desc->depth.write_enabled; + if (desc->stencil.enabled) { + const sg_stencil_face_state* sb = &desc->stencil.back; + ds_desc.backFaceStencil = [[MTLStencilDescriptor alloc] init]; + ds_desc.backFaceStencil.stencilFailureOperation = _sg_mtl_stencil_op(sb->fail_op); + ds_desc.backFaceStencil.depthFailureOperation = _sg_mtl_stencil_op(sb->depth_fail_op); + ds_desc.backFaceStencil.depthStencilPassOperation = _sg_mtl_stencil_op(sb->pass_op); + ds_desc.backFaceStencil.stencilCompareFunction = _sg_mtl_compare_func(sb->compare); + ds_desc.backFaceStencil.readMask = desc->stencil.read_mask; + ds_desc.backFaceStencil.writeMask = desc->stencil.write_mask; + const sg_stencil_face_state* sf = &desc->stencil.front; + ds_desc.frontFaceStencil = [[MTLStencilDescriptor alloc] init]; + ds_desc.frontFaceStencil.stencilFailureOperation = _sg_mtl_stencil_op(sf->fail_op); + ds_desc.frontFaceStencil.depthFailureOperation = _sg_mtl_stencil_op(sf->depth_fail_op); + ds_desc.frontFaceStencil.depthStencilPassOperation = _sg_mtl_stencil_op(sf->pass_op); + ds_desc.frontFaceStencil.stencilCompareFunction = _sg_mtl_compare_func(sf->compare); + ds_desc.frontFaceStencil.readMask = desc->stencil.read_mask; + ds_desc.frontFaceStencil.writeMask = desc->stencil.write_mask; + } + id<MTLDepthStencilState> mtl_dss = [_sg.mtl.device newDepthStencilStateWithDescriptor:ds_desc]; + _SG_OBJC_RELEASE(ds_desc); + pip->mtl.rps = _sg_mtl_add_resource(mtl_rps); + pip->mtl.dss = _sg_mtl_add_resource(mtl_dss); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_mtl_destroy_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + /* it's valid to call release resource with a 'null resource' */ + _sg_mtl_release_resource(_sg.mtl.frame_index, pip->mtl.rps); + _sg_mtl_release_resource(_sg.mtl.frame_index, pip->mtl.dss); +} + +_SOKOL_PRIVATE sg_resource_state _sg_mtl_create_pass(_sg_pass_t* pass, _sg_image_t** att_images, const sg_pass_desc* desc) { + SOKOL_ASSERT(pass && desc); + SOKOL_ASSERT(att_images && att_images[0]); + + _sg_pass_common_init(&pass->cmn, desc); + + /* copy image pointers */ + const sg_pass_attachment_desc* att_desc; + for (int i = 0; i < pass->cmn.num_color_atts; i++) { + att_desc = &desc->color_attachments[i]; + if (att_desc->image.id != SG_INVALID_ID) { + SOKOL_ASSERT(att_desc->image.id != SG_INVALID_ID); + SOKOL_ASSERT(0 == pass->mtl.color_atts[i].image); + SOKOL_ASSERT(att_images[i] && (att_images[i]->slot.id == att_desc->image.id)); + SOKOL_ASSERT(_sg_is_valid_rendertarget_color_format(att_images[i]->cmn.pixel_format)); + pass->mtl.color_atts[i].image = att_images[i]; + } + } + SOKOL_ASSERT(0 == pass->mtl.ds_att.image); + att_desc = &desc->depth_stencil_attachment; + if (att_desc->image.id != SG_INVALID_ID) { + const int ds_img_index = SG_MAX_COLOR_ATTACHMENTS; + SOKOL_ASSERT(att_images[ds_img_index] && (att_images[ds_img_index]->slot.id == att_desc->image.id)); + SOKOL_ASSERT(_sg_is_valid_rendertarget_depth_format(att_images[ds_img_index]->cmn.pixel_format)); + pass->mtl.ds_att.image = att_images[ds_img_index]; + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_mtl_destroy_pass(_sg_pass_t* pass) { + SOKOL_ASSERT(pass); + _SOKOL_UNUSED(pass); +} + +_SOKOL_PRIVATE _sg_image_t* _sg_mtl_pass_color_image(const _sg_pass_t* pass, int index) { + SOKOL_ASSERT(pass && (index >= 0) && (index < SG_MAX_COLOR_ATTACHMENTS)); + /* NOTE: may return null */ + return pass->mtl.color_atts[index].image; +} + +_SOKOL_PRIVATE _sg_image_t* _sg_mtl_pass_ds_image(const _sg_pass_t* pass) { + /* NOTE: may return null */ + SOKOL_ASSERT(pass); + return pass->mtl.ds_att.image; +} + +_SOKOL_PRIVATE void _sg_mtl_begin_pass(_sg_pass_t* pass, const sg_pass_action* action, int w, int h) { + SOKOL_ASSERT(action); + SOKOL_ASSERT(!_sg.mtl.in_pass); + SOKOL_ASSERT(_sg.mtl.cmd_queue); + SOKOL_ASSERT(nil == _sg.mtl.cmd_encoder); + SOKOL_ASSERT(_sg.mtl.renderpass_descriptor_cb || _sg.mtl.renderpass_descriptor_userdata_cb); + _sg.mtl.in_pass = true; + _sg.mtl.cur_width = w; + _sg.mtl.cur_height = h; + _sg_mtl_clear_state_cache(); + + /* if this is the first pass in the frame, create a command buffer */ + if (nil == _sg.mtl.cmd_buffer) { + /* block until the oldest frame in flight has finished */ + dispatch_semaphore_wait(_sg.mtl.sem, DISPATCH_TIME_FOREVER); + _sg.mtl.cmd_buffer = [_sg.mtl.cmd_queue commandBufferWithUnretainedReferences]; + [_sg.mtl.cmd_buffer addCompletedHandler:^(id<MTLCommandBuffer> cmd_buffer) { + // NOTE: this code is called on a different thread! + _SOKOL_UNUSED(cmd_buffer); + dispatch_semaphore_signal(_sg.mtl.sem); + }]; + } + + /* if this is first pass in frame, get uniform buffer base pointer */ + if (0 == _sg.mtl.cur_ub_base_ptr) { + _sg.mtl.cur_ub_base_ptr = (uint8_t*)[_sg.mtl.uniform_buffers[_sg.mtl.cur_frame_rotate_index] contents]; + } + + /* initialize a render pass descriptor */ + MTLRenderPassDescriptor* pass_desc = nil; + if (pass) { + /* offscreen render pass */ + pass_desc = [MTLRenderPassDescriptor renderPassDescriptor]; + } + else { + /* default render pass, call user-provided callback to provide render pass descriptor */ + if (_sg.mtl.renderpass_descriptor_cb) { + pass_desc = (__bridge MTLRenderPassDescriptor*) _sg.mtl.renderpass_descriptor_cb(); + } + else { + pass_desc = (__bridge MTLRenderPassDescriptor*) _sg.mtl.renderpass_descriptor_userdata_cb(_sg.mtl.user_data); + } + + } + if (pass_desc) { + _sg.mtl.pass_valid = true; + } + else { + /* default pass descriptor will not be valid if window is minimized, + don't do any rendering in this case */ + _sg.mtl.pass_valid = false; + return; + } + if (pass) { + /* setup pass descriptor for offscreen rendering */ + SOKOL_ASSERT(pass->slot.state == SG_RESOURCESTATE_VALID); + for (NSUInteger i = 0; i < (NSUInteger)pass->cmn.num_color_atts; i++) { + const _sg_pass_attachment_t* cmn_att = &pass->cmn.color_atts[i]; + const _sg_mtl_attachment_t* mtl_att = &pass->mtl.color_atts[i]; + const _sg_image_t* att_img = mtl_att->image; + SOKOL_ASSERT(att_img->slot.state == SG_RESOURCESTATE_VALID); + SOKOL_ASSERT(att_img->slot.id == cmn_att->image_id.id); + const bool is_msaa = (att_img->cmn.sample_count > 1); + pass_desc.colorAttachments[i].loadAction = _sg_mtl_load_action(action->colors[i].action); + pass_desc.colorAttachments[i].storeAction = is_msaa ? MTLStoreActionMultisampleResolve : MTLStoreActionStore; + sg_color c = action->colors[i].value; + pass_desc.colorAttachments[i].clearColor = MTLClearColorMake(c.r, c.g, c.b, c.a); + if (is_msaa) { + SOKOL_ASSERT(att_img->mtl.msaa_tex != _SG_MTL_INVALID_SLOT_INDEX); + SOKOL_ASSERT(att_img->mtl.tex[mtl_att->image->cmn.active_slot] != _SG_MTL_INVALID_SLOT_INDEX); + pass_desc.colorAttachments[i].texture = _sg_mtl_id(att_img->mtl.msaa_tex); + pass_desc.colorAttachments[i].resolveTexture = _sg_mtl_id(att_img->mtl.tex[att_img->cmn.active_slot]); + pass_desc.colorAttachments[i].resolveLevel = (NSUInteger)cmn_att->mip_level; + switch (att_img->cmn.type) { + case SG_IMAGETYPE_CUBE: + case SG_IMAGETYPE_ARRAY: + pass_desc.colorAttachments[i].resolveSlice = (NSUInteger)cmn_att->slice; + break; + case SG_IMAGETYPE_3D: + pass_desc.colorAttachments[i].resolveDepthPlane = (NSUInteger)cmn_att->slice; + break; + default: break; + } + } + else { + SOKOL_ASSERT(att_img->mtl.tex[att_img->cmn.active_slot] != _SG_MTL_INVALID_SLOT_INDEX); + pass_desc.colorAttachments[i].texture = _sg_mtl_id(att_img->mtl.tex[att_img->cmn.active_slot]); + pass_desc.colorAttachments[i].level = (NSUInteger)cmn_att->mip_level; + switch (att_img->cmn.type) { + case SG_IMAGETYPE_CUBE: + case SG_IMAGETYPE_ARRAY: + pass_desc.colorAttachments[i].slice = (NSUInteger)cmn_att->slice; + break; + case SG_IMAGETYPE_3D: + pass_desc.colorAttachments[i].depthPlane = (NSUInteger)cmn_att->slice; + break; + default: break; + } + } + } + const _sg_image_t* ds_att_img = pass->mtl.ds_att.image; + if (0 != ds_att_img) { + SOKOL_ASSERT(ds_att_img->slot.state == SG_RESOURCESTATE_VALID); + SOKOL_ASSERT(ds_att_img->slot.id == pass->cmn.ds_att.image_id.id); + SOKOL_ASSERT(ds_att_img->mtl.depth_tex != _SG_MTL_INVALID_SLOT_INDEX); + pass_desc.depthAttachment.texture = _sg_mtl_id(ds_att_img->mtl.depth_tex); + pass_desc.depthAttachment.loadAction = _sg_mtl_load_action(action->depth.action); + pass_desc.depthAttachment.clearDepth = action->depth.value; + if (_sg_is_depth_stencil_format(ds_att_img->cmn.pixel_format)) { + pass_desc.stencilAttachment.texture = _sg_mtl_id(ds_att_img->mtl.depth_tex); + pass_desc.stencilAttachment.loadAction = _sg_mtl_load_action(action->stencil.action); + pass_desc.stencilAttachment.clearStencil = action->stencil.value; + } + } + } + else { + /* setup pass descriptor for default rendering */ + pass_desc.colorAttachments[0].loadAction = _sg_mtl_load_action(action->colors[0].action); + sg_color c = action->colors[0].value; + pass_desc.colorAttachments[0].clearColor = MTLClearColorMake(c.r, c.g, c.b, c.a); + pass_desc.depthAttachment.loadAction = _sg_mtl_load_action(action->depth.action); + pass_desc.depthAttachment.clearDepth = action->depth.value; + pass_desc.stencilAttachment.loadAction = _sg_mtl_load_action(action->stencil.action); + pass_desc.stencilAttachment.clearStencil = action->stencil.value; + } + + /* create a render command encoder, this might return nil if window is minimized */ + _sg.mtl.cmd_encoder = [_sg.mtl.cmd_buffer renderCommandEncoderWithDescriptor:pass_desc]; + if (nil == _sg.mtl.cmd_encoder) { + _sg.mtl.pass_valid = false; + return; + } + + /* bind the global uniform buffer, this only happens once per pass */ + _sg_mtl_bind_uniform_buffers(); +} + +_SOKOL_PRIVATE void _sg_mtl_end_pass(void) { + SOKOL_ASSERT(_sg.mtl.in_pass); + _sg.mtl.in_pass = false; + _sg.mtl.pass_valid = false; + if (nil != _sg.mtl.cmd_encoder) { + [_sg.mtl.cmd_encoder endEncoding]; + /* NOTE: MTLRenderCommandEncoder is autoreleased */ + _sg.mtl.cmd_encoder = nil; + } +} + +_SOKOL_PRIVATE void _sg_mtl_commit(void) { + SOKOL_ASSERT(!_sg.mtl.in_pass); + SOKOL_ASSERT(!_sg.mtl.pass_valid); + SOKOL_ASSERT(_sg.mtl.drawable_cb || _sg.mtl.drawable_userdata_cb); + SOKOL_ASSERT(nil == _sg.mtl.cmd_encoder); + SOKOL_ASSERT(nil != _sg.mtl.cmd_buffer); + + /* present, commit and signal semaphore when done */ + id<MTLDrawable> cur_drawable = nil; + if (_sg.mtl.drawable_cb) { + cur_drawable = (__bridge id<MTLDrawable>) _sg.mtl.drawable_cb(); + } + else { + cur_drawable = (__bridge id<MTLDrawable>) _sg.mtl.drawable_userdata_cb(_sg.mtl.user_data); + } + if (nil != cur_drawable) { + [_sg.mtl.cmd_buffer presentDrawable:cur_drawable]; + } + [_sg.mtl.cmd_buffer commit]; + + /* garbage-collect resources pending for release */ + _sg_mtl_garbage_collect(_sg.mtl.frame_index); + + /* rotate uniform buffer slot */ + if (++_sg.mtl.cur_frame_rotate_index >= SG_NUM_INFLIGHT_FRAMES) { + _sg.mtl.cur_frame_rotate_index = 0; + } + _sg.mtl.frame_index++; + _sg.mtl.cur_ub_offset = 0; + _sg.mtl.cur_ub_base_ptr = 0; + /* NOTE: MTLCommandBuffer is autoreleased */ + _sg.mtl.cmd_buffer = nil; +} + +_SOKOL_PRIVATE void _sg_mtl_apply_viewport(int x, int y, int w, int h, bool origin_top_left) { + SOKOL_ASSERT(_sg.mtl.in_pass); + if (!_sg.mtl.pass_valid) { + return; + } + SOKOL_ASSERT(nil != _sg.mtl.cmd_encoder); + MTLViewport vp; + vp.originX = (double) x; + vp.originY = (double) (origin_top_left ? y : (_sg.mtl.cur_height - (y + h))); + vp.width = (double) w; + vp.height = (double) h; + vp.znear = 0.0; + vp.zfar = 1.0; + [_sg.mtl.cmd_encoder setViewport:vp]; +} + +_SOKOL_PRIVATE void _sg_mtl_apply_scissor_rect(int x, int y, int w, int h, bool origin_top_left) { + SOKOL_ASSERT(_sg.mtl.in_pass); + if (!_sg.mtl.pass_valid) { + return; + } + SOKOL_ASSERT(nil != _sg.mtl.cmd_encoder); + /* clip against framebuffer rect */ + x = _sg_min(_sg_max(0, x), _sg.mtl.cur_width-1); + y = _sg_min(_sg_max(0, y), _sg.mtl.cur_height-1); + if ((x + w) > _sg.mtl.cur_width) { + w = _sg.mtl.cur_width - x; + } + if ((y + h) > _sg.mtl.cur_height) { + h = _sg.mtl.cur_height - y; + } + w = _sg_max(w, 1); + h = _sg_max(h, 1); + + MTLScissorRect r; + r.x = (NSUInteger)x; + r.y = (NSUInteger) (origin_top_left ? y : (_sg.mtl.cur_height - (y + h))); + r.width = (NSUInteger)w; + r.height = (NSUInteger)h; + [_sg.mtl.cmd_encoder setScissorRect:r]; +} + +_SOKOL_PRIVATE void _sg_mtl_apply_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + SOKOL_ASSERT(pip->shader && (pip->cmn.shader_id.id == pip->shader->slot.id)); + SOKOL_ASSERT(_sg.mtl.in_pass); + if (!_sg.mtl.pass_valid) { + return; + } + SOKOL_ASSERT(nil != _sg.mtl.cmd_encoder); + + if ((_sg.mtl.state_cache.cur_pipeline != pip) || (_sg.mtl.state_cache.cur_pipeline_id.id != pip->slot.id)) { + _sg.mtl.state_cache.cur_pipeline = pip; + _sg.mtl.state_cache.cur_pipeline_id.id = pip->slot.id; + sg_color c = pip->cmn.blend_color; + [_sg.mtl.cmd_encoder setBlendColorRed:c.r green:c.g blue:c.b alpha:c.a]; + [_sg.mtl.cmd_encoder setCullMode:pip->mtl.cull_mode]; + [_sg.mtl.cmd_encoder setFrontFacingWinding:pip->mtl.winding]; + [_sg.mtl.cmd_encoder setStencilReferenceValue:pip->mtl.stencil_ref]; + [_sg.mtl.cmd_encoder setDepthBias:pip->cmn.depth_bias slopeScale:pip->cmn.depth_bias_slope_scale clamp:pip->cmn.depth_bias_clamp]; + SOKOL_ASSERT(pip->mtl.rps != _SG_MTL_INVALID_SLOT_INDEX); + [_sg.mtl.cmd_encoder setRenderPipelineState:_sg_mtl_id(pip->mtl.rps)]; + SOKOL_ASSERT(pip->mtl.dss != _SG_MTL_INVALID_SLOT_INDEX); + [_sg.mtl.cmd_encoder setDepthStencilState:_sg_mtl_id(pip->mtl.dss)]; + } +} + +_SOKOL_PRIVATE void _sg_mtl_apply_bindings( + _sg_pipeline_t* pip, + _sg_buffer_t** vbs, const int* vb_offsets, int num_vbs, + _sg_buffer_t* ib, int ib_offset, + _sg_image_t** vs_imgs, int num_vs_imgs, + _sg_image_t** fs_imgs, int num_fs_imgs) +{ + _SOKOL_UNUSED(pip); + SOKOL_ASSERT(_sg.mtl.in_pass); + if (!_sg.mtl.pass_valid) { + return; + } + SOKOL_ASSERT(nil != _sg.mtl.cmd_encoder); + + /* store index buffer binding, this will be needed later in sg_draw() */ + _sg.mtl.state_cache.cur_indexbuffer = ib; + _sg.mtl.state_cache.cur_indexbuffer_offset = ib_offset; + if (ib) { + SOKOL_ASSERT(pip->cmn.index_type != SG_INDEXTYPE_NONE); + _sg.mtl.state_cache.cur_indexbuffer_id.id = ib->slot.id; + } + else { + SOKOL_ASSERT(pip->cmn.index_type == SG_INDEXTYPE_NONE); + _sg.mtl.state_cache.cur_indexbuffer_id.id = SG_INVALID_ID; + } + + /* apply vertex buffers */ + NSUInteger slot; + for (slot = 0; slot < (NSUInteger)num_vbs; slot++) { + const _sg_buffer_t* vb = vbs[slot]; + if ((_sg.mtl.state_cache.cur_vertexbuffers[slot] != vb) || + (_sg.mtl.state_cache.cur_vertexbuffer_offsets[slot] != vb_offsets[slot]) || + (_sg.mtl.state_cache.cur_vertexbuffer_ids[slot].id != vb->slot.id)) + { + _sg.mtl.state_cache.cur_vertexbuffers[slot] = vb; + _sg.mtl.state_cache.cur_vertexbuffer_offsets[slot] = vb_offsets[slot]; + _sg.mtl.state_cache.cur_vertexbuffer_ids[slot].id = vb->slot.id; + const NSUInteger mtl_slot = SG_MAX_SHADERSTAGE_UBS + slot; + SOKOL_ASSERT(vb->mtl.buf[vb->cmn.active_slot] != _SG_MTL_INVALID_SLOT_INDEX); + [_sg.mtl.cmd_encoder setVertexBuffer:_sg_mtl_id(vb->mtl.buf[vb->cmn.active_slot]) + offset:(NSUInteger)vb_offsets[slot] + atIndex:mtl_slot]; + } + } + + /* apply vertex shader images */ + for (slot = 0; slot < (NSUInteger)num_vs_imgs; slot++) { + const _sg_image_t* img = vs_imgs[slot]; + if ((_sg.mtl.state_cache.cur_vs_images[slot] != img) || (_sg.mtl.state_cache.cur_vs_image_ids[slot].id != img->slot.id)) { + _sg.mtl.state_cache.cur_vs_images[slot] = img; + _sg.mtl.state_cache.cur_vs_image_ids[slot].id = img->slot.id; + SOKOL_ASSERT(img->mtl.tex[img->cmn.active_slot] != _SG_MTL_INVALID_SLOT_INDEX); + [_sg.mtl.cmd_encoder setVertexTexture:_sg_mtl_id(img->mtl.tex[img->cmn.active_slot]) atIndex:slot]; + SOKOL_ASSERT(img->mtl.sampler_state != _SG_MTL_INVALID_SLOT_INDEX); + [_sg.mtl.cmd_encoder setVertexSamplerState:_sg_mtl_id(img->mtl.sampler_state) atIndex:slot]; + } + } + + /* apply fragment shader images */ + for (slot = 0; slot < (NSUInteger)num_fs_imgs; slot++) { + const _sg_image_t* img = fs_imgs[slot]; + if ((_sg.mtl.state_cache.cur_fs_images[slot] != img) || (_sg.mtl.state_cache.cur_fs_image_ids[slot].id != img->slot.id)) { + _sg.mtl.state_cache.cur_fs_images[slot] = img; + _sg.mtl.state_cache.cur_fs_image_ids[slot].id = img->slot.id; + SOKOL_ASSERT(img->mtl.tex[img->cmn.active_slot] != _SG_MTL_INVALID_SLOT_INDEX); + [_sg.mtl.cmd_encoder setFragmentTexture:_sg_mtl_id(img->mtl.tex[img->cmn.active_slot]) atIndex:slot]; + SOKOL_ASSERT(img->mtl.sampler_state != _SG_MTL_INVALID_SLOT_INDEX); + [_sg.mtl.cmd_encoder setFragmentSamplerState:_sg_mtl_id(img->mtl.sampler_state) atIndex:slot]; + } + } +} + +_SOKOL_PRIVATE void _sg_mtl_apply_uniforms(sg_shader_stage stage_index, int ub_index, const sg_range* data) { + SOKOL_ASSERT(_sg.mtl.in_pass); + if (!_sg.mtl.pass_valid) { + return; + } + SOKOL_ASSERT(nil != _sg.mtl.cmd_encoder); + SOKOL_ASSERT(((size_t)_sg.mtl.cur_ub_offset + data->size) <= (size_t)_sg.mtl.ub_size); + SOKOL_ASSERT((_sg.mtl.cur_ub_offset & (_SG_MTL_UB_ALIGN-1)) == 0); + SOKOL_ASSERT(_sg.mtl.state_cache.cur_pipeline && _sg.mtl.state_cache.cur_pipeline->shader); + SOKOL_ASSERT(_sg.mtl.state_cache.cur_pipeline->slot.id == _sg.mtl.state_cache.cur_pipeline_id.id); + SOKOL_ASSERT(_sg.mtl.state_cache.cur_pipeline->shader->slot.id == _sg.mtl.state_cache.cur_pipeline->cmn.shader_id.id); + SOKOL_ASSERT(ub_index < _sg.mtl.state_cache.cur_pipeline->shader->cmn.stage[stage_index].num_uniform_blocks); + SOKOL_ASSERT(data->size <= _sg.mtl.state_cache.cur_pipeline->shader->cmn.stage[stage_index].uniform_blocks[ub_index].size); + + /* copy to global uniform buffer, record offset into cmd encoder, and advance offset */ + uint8_t* dst = &_sg.mtl.cur_ub_base_ptr[_sg.mtl.cur_ub_offset]; + memcpy(dst, data->ptr, data->size); + if (stage_index == SG_SHADERSTAGE_VS) { + [_sg.mtl.cmd_encoder setVertexBufferOffset:(NSUInteger)_sg.mtl.cur_ub_offset atIndex:(NSUInteger)ub_index]; + } + else { + [_sg.mtl.cmd_encoder setFragmentBufferOffset:(NSUInteger)_sg.mtl.cur_ub_offset atIndex:(NSUInteger)ub_index]; + } + _sg.mtl.cur_ub_offset = _sg_roundup(_sg.mtl.cur_ub_offset + (int)data->size, _SG_MTL_UB_ALIGN); +} + +_SOKOL_PRIVATE void _sg_mtl_draw(int base_element, int num_elements, int num_instances) { + SOKOL_ASSERT(_sg.mtl.in_pass); + if (!_sg.mtl.pass_valid) { + return; + } + SOKOL_ASSERT(nil != _sg.mtl.cmd_encoder); + SOKOL_ASSERT(_sg.mtl.state_cache.cur_pipeline && (_sg.mtl.state_cache.cur_pipeline->slot.id == _sg.mtl.state_cache.cur_pipeline_id.id)); + if (SG_INDEXTYPE_NONE != _sg.mtl.state_cache.cur_pipeline->cmn.index_type) { + /* indexed rendering */ + SOKOL_ASSERT(_sg.mtl.state_cache.cur_indexbuffer && (_sg.mtl.state_cache.cur_indexbuffer->slot.id == _sg.mtl.state_cache.cur_indexbuffer_id.id)); + const _sg_buffer_t* ib = _sg.mtl.state_cache.cur_indexbuffer; + SOKOL_ASSERT(ib->mtl.buf[ib->cmn.active_slot] != _SG_MTL_INVALID_SLOT_INDEX); + const NSUInteger index_buffer_offset = (NSUInteger) (_sg.mtl.state_cache.cur_indexbuffer_offset + base_element * _sg.mtl.state_cache.cur_pipeline->mtl.index_size); + [_sg.mtl.cmd_encoder drawIndexedPrimitives:_sg.mtl.state_cache.cur_pipeline->mtl.prim_type + indexCount:(NSUInteger)num_elements + indexType:_sg.mtl.state_cache.cur_pipeline->mtl.index_type + indexBuffer:_sg_mtl_id(ib->mtl.buf[ib->cmn.active_slot]) + indexBufferOffset:index_buffer_offset + instanceCount:(NSUInteger)num_instances]; + } + else { + /* non-indexed rendering */ + [_sg.mtl.cmd_encoder drawPrimitives:_sg.mtl.state_cache.cur_pipeline->mtl.prim_type + vertexStart:(NSUInteger)base_element + vertexCount:(NSUInteger)num_elements + instanceCount:(NSUInteger)num_instances]; + } +} + +_SOKOL_PRIVATE void _sg_mtl_update_buffer(_sg_buffer_t* buf, const sg_range* data) { + SOKOL_ASSERT(buf && data && data->ptr && (data->size > 0)); + if (++buf->cmn.active_slot >= buf->cmn.num_slots) { + buf->cmn.active_slot = 0; + } + __unsafe_unretained id<MTLBuffer> mtl_buf = _sg_mtl_id(buf->mtl.buf[buf->cmn.active_slot]); + void* dst_ptr = [mtl_buf contents]; + memcpy(dst_ptr, data->ptr, data->size); +#if defined(_SG_TARGET_MACOS) + [mtl_buf didModifyRange:NSMakeRange(0, data->size)]; +#endif +} + +_SOKOL_PRIVATE int _sg_mtl_append_buffer(_sg_buffer_t* buf, const sg_range* data, bool new_frame) { + SOKOL_ASSERT(buf && data && data->ptr && (data->size > 0)); + if (new_frame) { + if (++buf->cmn.active_slot >= buf->cmn.num_slots) { + buf->cmn.active_slot = 0; + } + } + __unsafe_unretained id<MTLBuffer> mtl_buf = _sg_mtl_id(buf->mtl.buf[buf->cmn.active_slot]); + uint8_t* dst_ptr = (uint8_t*) [mtl_buf contents]; + dst_ptr += buf->cmn.append_pos; + memcpy(dst_ptr, data->ptr, data->size); +#if defined(_SG_TARGET_MACOS) + [mtl_buf didModifyRange:NSMakeRange((NSUInteger)buf->cmn.append_pos, (NSUInteger)data->size)]; +#endif + /* NOTE: this is a requirement from WebGPU, but we want identical behaviour across all backends */ + return _sg_roundup((int)data->size, 4); +} + +_SOKOL_PRIVATE void _sg_mtl_update_image(_sg_image_t* img, const sg_image_data* data) { + SOKOL_ASSERT(img && data); + if (++img->cmn.active_slot >= img->cmn.num_slots) { + img->cmn.active_slot = 0; + } + __unsafe_unretained id<MTLTexture> mtl_tex = _sg_mtl_id(img->mtl.tex[img->cmn.active_slot]); + _sg_mtl_copy_image_data(img, mtl_tex, data); +} + +/*== WEBGPU BACKEND IMPLEMENTATION ===========================================*/ +#elif defined(SOKOL_WGPU) + +_SOKOL_PRIVATE WGPUBufferUsageFlags _sg_wgpu_buffer_usage(sg_buffer_type t, sg_usage u) { + WGPUBufferUsageFlags res = 0; + if (SG_BUFFERTYPE_VERTEXBUFFER == t) { + res |= WGPUBufferUsage_Vertex; + } + else { + res |= WGPUBufferUsage_Index; + } + if (SG_USAGE_IMMUTABLE != u) { + res |= WGPUBufferUsage_CopyDst; + } + return res; +} + +_SOKOL_PRIVATE WGPULoadOp _sg_wgpu_load_op(sg_action a) { + switch (a) { + case SG_ACTION_CLEAR: + case SG_ACTION_DONTCARE: + return WGPULoadOp_Clear; + case SG_ACTION_LOAD: + return WGPULoadOp_Load; + default: + SOKOL_UNREACHABLE; + return (WGPULoadOp)0; + } +} + +_SOKOL_PRIVATE WGPUTextureViewDimension _sg_wgpu_tex_viewdim(sg_image_type t) { + switch (t) { + case SG_IMAGETYPE_2D: return WGPUTextureViewDimension_2D; + case SG_IMAGETYPE_CUBE: return WGPUTextureViewDimension_Cube; + case SG_IMAGETYPE_3D: return WGPUTextureViewDimension_3D; + case SG_IMAGETYPE_ARRAY: return WGPUTextureViewDimension_2DArray; + default: SOKOL_UNREACHABLE; return WGPUTextureViewDimension_Force32; + } +} + +_SOKOL_PRIVATE WGPUTextureComponentType _sg_wgpu_tex_comptype(sg_sampler_type t) { + switch (t) { + case SG_SAMPLERTYPE_FLOAT: return WGPUTextureComponentType_Float; + case SG_SAMPLERTYPE_SINT: return WGPUTextureComponentType_Sint; + case SG_SAMPLERTYPE_UINT: return WGPUTextureComponentType_Uint; + default: SOKOL_UNREACHABLE; return WGPUTextureComponentType_Force32; + } +} + +_SOKOL_PRIVATE WGPUTextureDimension _sg_wgpu_tex_dim(sg_image_type t) { + if (SG_IMAGETYPE_3D == t) { + return WGPUTextureDimension_3D; + } + else { + return WGPUTextureDimension_2D; + } +} + +_SOKOL_PRIVATE WGPUAddressMode _sg_wgpu_sampler_addrmode(sg_wrap m) { + switch (m) { + case SG_WRAP_REPEAT: + return WGPUAddressMode_Repeat; + case SG_WRAP_CLAMP_TO_EDGE: + case SG_WRAP_CLAMP_TO_BORDER: + return WGPUAddressMode_ClampToEdge; + case SG_WRAP_MIRRORED_REPEAT: + return WGPUAddressMode_MirrorRepeat; + default: + SOKOL_UNREACHABLE; + return WGPUAddressMode_Force32; + } +} + +_SOKOL_PRIVATE WGPUFilterMode _sg_wgpu_sampler_minmagfilter(sg_filter f) { + switch (f) { + case SG_FILTER_NEAREST: + case SG_FILTER_NEAREST_MIPMAP_NEAREST: + case SG_FILTER_NEAREST_MIPMAP_LINEAR: + return WGPUFilterMode_Nearest; + case SG_FILTER_LINEAR: + case SG_FILTER_LINEAR_MIPMAP_NEAREST: + case SG_FILTER_LINEAR_MIPMAP_LINEAR: + return WGPUFilterMode_Linear; + default: + SOKOL_UNREACHABLE; + return WGPUFilterMode_Force32; + } +} + +_SOKOL_PRIVATE WGPUFilterMode _sg_wgpu_sampler_mipfilter(sg_filter f) { + switch (f) { + case SG_FILTER_NEAREST: + case SG_FILTER_LINEAR: + case SG_FILTER_NEAREST_MIPMAP_NEAREST: + case SG_FILTER_LINEAR_MIPMAP_NEAREST: + return WGPUFilterMode_Nearest; + case SG_FILTER_NEAREST_MIPMAP_LINEAR: + case SG_FILTER_LINEAR_MIPMAP_LINEAR: + return WGPUFilterMode_Linear; + default: + SOKOL_UNREACHABLE; + return WGPUFilterMode_Force32; + } +} + +_SOKOL_PRIVATE WGPUIndexFormat _sg_wgpu_indexformat(sg_index_type t) { + /* NOTE: there's no WGPUIndexFormat_None */ + return (t == SG_INDEXTYPE_UINT16) ? WGPUIndexFormat_Uint16 : WGPUIndexFormat_Uint32; +} + +_SOKOL_PRIVATE WGPUInputStepMode _sg_wgpu_stepmode(sg_vertex_step s) { + return (s == SG_VERTEXSTEP_PER_VERTEX) ? WGPUInputStepMode_Vertex : WGPUInputStepMode_Instance; +} + +_SOKOL_PRIVATE WGPUVertexFormat _sg_wgpu_vertexformat(sg_vertex_format f) { + switch (f) { + case SG_VERTEXFORMAT_FLOAT: return WGPUVertexFormat_Float; + case SG_VERTEXFORMAT_FLOAT2: return WGPUVertexFormat_Float2; + case SG_VERTEXFORMAT_FLOAT3: return WGPUVertexFormat_Float3; + case SG_VERTEXFORMAT_FLOAT4: return WGPUVertexFormat_Float4; + case SG_VERTEXFORMAT_BYTE4: return WGPUVertexFormat_Char4; + case SG_VERTEXFORMAT_BYTE4N: return WGPUVertexFormat_Char4Norm; + case SG_VERTEXFORMAT_UBYTE4: return WGPUVertexFormat_UChar4; + case SG_VERTEXFORMAT_UBYTE4N: return WGPUVertexFormat_UChar4Norm; + case SG_VERTEXFORMAT_SHORT2: return WGPUVertexFormat_Short2; + case SG_VERTEXFORMAT_SHORT2N: return WGPUVertexFormat_Short2Norm; + case SG_VERTEXFORMAT_USHORT2N: return WGPUVertexFormat_UShort2Norm; + case SG_VERTEXFORMAT_SHORT4: return WGPUVertexFormat_Short4; + case SG_VERTEXFORMAT_SHORT4N: return WGPUVertexFormat_Short4Norm; + case SG_VERTEXFORMAT_USHORT4N: return WGPUVertexFormat_UShort4Norm; + /* FIXME! UINT10_N2 */ + case SG_VERTEXFORMAT_UINT10_N2: + default: + SOKOL_UNREACHABLE; + return WGPUVertexFormat_Force32; + } +} + +_SOKOL_PRIVATE WGPUPrimitiveTopology _sg_wgpu_topology(sg_primitive_type t) { + switch (t) { + case SG_PRIMITIVETYPE_POINTS: return WGPUPrimitiveTopology_PointList; + case SG_PRIMITIVETYPE_LINES: return WGPUPrimitiveTopology_LineList; + case SG_PRIMITIVETYPE_LINE_STRIP: return WGPUPrimitiveTopology_LineStrip; + case SG_PRIMITIVETYPE_TRIANGLES: return WGPUPrimitiveTopology_TriangleList; + case SG_PRIMITIVETYPE_TRIANGLE_STRIP: return WGPUPrimitiveTopology_TriangleStrip; + default: SOKOL_UNREACHABLE; return WGPUPrimitiveTopology_Force32; + } +} + +_SOKOL_PRIVATE WGPUFrontFace _sg_wgpu_frontface(sg_face_winding fw) { + return (fw == SG_FACEWINDING_CCW) ? WGPUFrontFace_CCW : WGPUFrontFace_CW; +} + +_SOKOL_PRIVATE WGPUCullMode _sg_wgpu_cullmode(sg_cull_mode cm) { + switch (cm) { + case SG_CULLMODE_NONE: return WGPUCullMode_None; + case SG_CULLMODE_FRONT: return WGPUCullMode_Front; + case SG_CULLMODE_BACK: return WGPUCullMode_Back; + default: SOKOL_UNREACHABLE; return WGPUCullMode_Force32; + } +} + +_SOKOL_PRIVATE WGPUTextureFormat _sg_wgpu_textureformat(sg_pixel_format p) { + switch (p) { + case SG_PIXELFORMAT_NONE: return WGPUTextureFormat_Undefined; + case SG_PIXELFORMAT_R8: return WGPUTextureFormat_R8Unorm; + case SG_PIXELFORMAT_R8SN: return WGPUTextureFormat_R8Snorm; + case SG_PIXELFORMAT_R8UI: return WGPUTextureFormat_R8Uint; + case SG_PIXELFORMAT_R8SI: return WGPUTextureFormat_R8Sint; + case SG_PIXELFORMAT_R16UI: return WGPUTextureFormat_R16Uint; + case SG_PIXELFORMAT_R16SI: return WGPUTextureFormat_R16Sint; + case SG_PIXELFORMAT_R16F: return WGPUTextureFormat_R16Float; + case SG_PIXELFORMAT_RG8: return WGPUTextureFormat_RG8Unorm; + case SG_PIXELFORMAT_RG8SN: return WGPUTextureFormat_RG8Snorm; + case SG_PIXELFORMAT_RG8UI: return WGPUTextureFormat_RG8Uint; + case SG_PIXELFORMAT_RG8SI: return WGPUTextureFormat_RG8Sint; + case SG_PIXELFORMAT_R32UI: return WGPUTextureFormat_R32Uint; + case SG_PIXELFORMAT_R32SI: return WGPUTextureFormat_R32Sint; + case SG_PIXELFORMAT_R32F: return WGPUTextureFormat_R32Float; + case SG_PIXELFORMAT_RG16UI: return WGPUTextureFormat_RG16Uint; + case SG_PIXELFORMAT_RG16SI: return WGPUTextureFormat_RG16Sint; + case SG_PIXELFORMAT_RG16F: return WGPUTextureFormat_RG16Float; + case SG_PIXELFORMAT_RGBA8: return WGPUTextureFormat_RGBA8Unorm; + case SG_PIXELFORMAT_RGBA8SN: return WGPUTextureFormat_RGBA8Snorm; + case SG_PIXELFORMAT_RGBA8UI: return WGPUTextureFormat_RGBA8Uint; + case SG_PIXELFORMAT_RGBA8SI: return WGPUTextureFormat_RGBA8Sint; + case SG_PIXELFORMAT_BGRA8: return WGPUTextureFormat_BGRA8Unorm; + case SG_PIXELFORMAT_RGB10A2: return WGPUTextureFormat_RGB10A2Unorm; + case SG_PIXELFORMAT_RG11B10F: return WGPUTextureFormat_RG11B10Float; + case SG_PIXELFORMAT_RG32UI: return WGPUTextureFormat_RG32Uint; + case SG_PIXELFORMAT_RG32SI: return WGPUTextureFormat_RG32Sint; + case SG_PIXELFORMAT_RG32F: return WGPUTextureFormat_RG32Float; + case SG_PIXELFORMAT_RGBA16UI: return WGPUTextureFormat_RGBA16Uint; + case SG_PIXELFORMAT_RGBA16SI: return WGPUTextureFormat_RGBA16Sint; + case SG_PIXELFORMAT_RGBA16F: return WGPUTextureFormat_RGBA16Float; + case SG_PIXELFORMAT_RGBA32UI: return WGPUTextureFormat_RGBA32Uint; + case SG_PIXELFORMAT_RGBA32SI: return WGPUTextureFormat_RGBA32Sint; + case SG_PIXELFORMAT_RGBA32F: return WGPUTextureFormat_RGBA32Float; + case SG_PIXELFORMAT_DEPTH: return WGPUTextureFormat_Depth24Plus; + case SG_PIXELFORMAT_DEPTH_STENCIL: return WGPUTextureFormat_Depth24PlusStencil8; + case SG_PIXELFORMAT_BC1_RGBA: return WGPUTextureFormat_BC1RGBAUnorm; + case SG_PIXELFORMAT_BC2_RGBA: return WGPUTextureFormat_BC2RGBAUnorm; + case SG_PIXELFORMAT_BC3_RGBA: return WGPUTextureFormat_BC3RGBAUnorm; + case SG_PIXELFORMAT_BC4_R: return WGPUTextureFormat_BC4RUnorm; + case SG_PIXELFORMAT_BC4_RSN: return WGPUTextureFormat_BC4RSnorm; + case SG_PIXELFORMAT_BC5_RG: return WGPUTextureFormat_BC5RGUnorm; + case SG_PIXELFORMAT_BC5_RGSN: return WGPUTextureFormat_BC5RGSnorm; + case SG_PIXELFORMAT_BC6H_RGBF: return WGPUTextureFormat_BC6HRGBSfloat; + case SG_PIXELFORMAT_BC6H_RGBUF: return WGPUTextureFormat_BC6HRGBUfloat; + case SG_PIXELFORMAT_BC7_RGBA: return WGPUTextureFormat_BC7RGBAUnorm; + + /* NOT SUPPORTED */ + case SG_PIXELFORMAT_R16: + case SG_PIXELFORMAT_R16SN: + case SG_PIXELFORMAT_RG16: + case SG_PIXELFORMAT_RG16SN: + case SG_PIXELFORMAT_RGBA16: + case SG_PIXELFORMAT_RGBA16SN: + case SG_PIXELFORMAT_PVRTC_RGB_2BPP: + case SG_PIXELFORMAT_PVRTC_RGB_4BPP: + case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: + case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: + case SG_PIXELFORMAT_ETC2_RGB8: + case SG_PIXELFORMAT_ETC2_RGB8A1: + case SG_PIXELFORMAT_ETC2_RGBA8: + case SG_PIXELFORMAT_ETC2_RG11: + case SG_PIXELFORMAT_ETC2_RG11SN: + default: + SOKOL_UNREACHABLE; + return WGPUTextureFormat_Force32; + } +} + +/* +FIXME ??? this isn't needed anywhere? +_SOKOL_PRIVATE WGPUTextureAspect _sg_wgpu_texture_aspect(sg_pixel_format fmt) { + if (_sg_is_valid_rendertarget_depth_format(fmt)) { + if (!_sg_is_depth_stencil_format(fmt)) { + return WGPUTextureAspect_DepthOnly; + } + } + return WGPUTextureAspect_All; +} +*/ + +_SOKOL_PRIVATE WGPUCompareFunction _sg_wgpu_comparefunc(sg_compare_func f) { + switch (f) { + case SG_COMPAREFUNC_NEVER: return WGPUCompareFunction_Never; + case SG_COMPAREFUNC_LESS: return WGPUCompareFunction_Less; + case SG_COMPAREFUNC_EQUAL: return WGPUCompareFunction_Equal; + case SG_COMPAREFUNC_LESS_EQUAL: return WGPUCompareFunction_LessEqual; + case SG_COMPAREFUNC_GREATER: return WGPUCompareFunction_Greater; + case SG_COMPAREFUNC_NOT_EQUAL: return WGPUCompareFunction_NotEqual; + case SG_COMPAREFUNC_GREATER_EQUAL: return WGPUCompareFunction_GreaterEqual; + case SG_COMPAREFUNC_ALWAYS: return WGPUCompareFunction_Always; + default: SOKOL_UNREACHABLE; return WGPUCompareFunction_Force32; + } +} + +_SOKOL_PRIVATE WGPUStencilOperation _sg_wgpu_stencilop(sg_stencil_op op) { + switch (op) { + case SG_STENCILOP_KEEP: return WGPUStencilOperation_Keep; + case SG_STENCILOP_ZERO: return WGPUStencilOperation_Zero; + case SG_STENCILOP_REPLACE: return WGPUStencilOperation_Replace; + case SG_STENCILOP_INCR_CLAMP: return WGPUStencilOperation_IncrementClamp; + case SG_STENCILOP_DECR_CLAMP: return WGPUStencilOperation_DecrementClamp; + case SG_STENCILOP_INVERT: return WGPUStencilOperation_Invert; + case SG_STENCILOP_INCR_WRAP: return WGPUStencilOperation_IncrementWrap; + case SG_STENCILOP_DECR_WRAP: return WGPUStencilOperation_DecrementWrap; + default: SOKOL_UNREACHABLE; return WGPUStencilOperation_Force32; + } +} + +_SOKOL_PRIVATE WGPUBlendOperation _sg_wgpu_blendop(sg_blend_op op) { + switch (op) { + case SG_BLENDOP_ADD: return WGPUBlendOperation_Add; + case SG_BLENDOP_SUBTRACT: return WGPUBlendOperation_Subtract; + case SG_BLENDOP_REVERSE_SUBTRACT: return WGPUBlendOperation_ReverseSubtract; + default: SOKOL_UNREACHABLE; return WGPUBlendOperation_Force32; + } +} + +_SOKOL_PRIVATE WGPUBlendFactor _sg_wgpu_blendfactor(sg_blend_factor f) { + switch (f) { + case SG_BLENDFACTOR_ZERO: return WGPUBlendFactor_Zero; + case SG_BLENDFACTOR_ONE: return WGPUBlendFactor_One; + case SG_BLENDFACTOR_SRC_COLOR: return WGPUBlendFactor_SrcColor; + case SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR: return WGPUBlendFactor_OneMinusSrcColor; + case SG_BLENDFACTOR_SRC_ALPHA: return WGPUBlendFactor_SrcAlpha; + case SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: return WGPUBlendFactor_OneMinusSrcAlpha; + case SG_BLENDFACTOR_DST_COLOR: return WGPUBlendFactor_DstColor; + case SG_BLENDFACTOR_ONE_MINUS_DST_COLOR: return WGPUBlendFactor_OneMinusDstColor; + case SG_BLENDFACTOR_DST_ALPHA: return WGPUBlendFactor_DstAlpha; + case SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA: return WGPUBlendFactor_OneMinusDstAlpha; + case SG_BLENDFACTOR_SRC_ALPHA_SATURATED: return WGPUBlendFactor_SrcAlphaSaturated; + case SG_BLENDFACTOR_BLEND_COLOR: return WGPUBlendFactor_BlendColor; + case SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR: return WGPUBlendFactor_OneMinusBlendColor; + /* FIXME: separate blend alpha value not supported? */ + case SG_BLENDFACTOR_BLEND_ALPHA: return WGPUBlendFactor_BlendColor; + case SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA: return WGPUBlendFactor_OneMinusBlendColor; + default: + SOKOL_UNREACHABLE; return WGPUBlendFactor_Force32; + } +} + +_SOKOL_PRIVATE WGPUColorWriteMaskFlags _sg_wgpu_colorwritemask(uint8_t m) { + WGPUColorWriteMaskFlags res = 0; + if (0 != (m & SG_COLORMASK_R)) { + res |= WGPUColorWriteMask_Red; + } + if (0 != (m & SG_COLORMASK_G)) { + res |= WGPUColorWriteMask_Green; + } + if (0 != (m & SG_COLORMASK_B)) { + res |= WGPUColorWriteMask_Blue; + } + if (0 != (m & SG_COLORMASK_A)) { + res |= WGPUColorWriteMask_Alpha; + } + return res; +} + +_SOKOL_PRIVATE void _sg_wgpu_init_caps(void) { + _sg.backend = SG_BACKEND_WGPU; + _sg.features.instancing = true; + _sg.features.origin_top_left = true; + _sg.features.multiple_render_targets = true; + _sg.features.msaa_render_targets = true; + _sg.features.imagetype_3d = true; + _sg.features.imagetype_array = true; + _sg.features.image_clamp_to_border = false; + _sg.features.mrt_independent_blend_state = true; + _sg.features.mrt_independent_write_mask = true; + + /* FIXME: max images size??? */ + _sg.limits.max_image_size_2d = 8 * 1024; + _sg.limits.max_image_size_cube = 8 * 1024; + _sg.limits.max_image_size_3d = 2 * 1024; + _sg.limits.max_image_size_array = 8 * 1024; + _sg.limits.max_image_array_layers = 2 * 1024; + _sg.limits.max_vertex_attrs = SG_MAX_VERTEX_ATTRIBUTES; + + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R8]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R8SI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R16SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG8]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG8SI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32UI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32SI]); + _sg_pixelformat_sbr(&_sg.formats[SG_PIXELFORMAT_R32F]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA8]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA8SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_BGRA8]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGB10A2]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RG32UI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RG32SI]); + _sg_pixelformat_sbr(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA16SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RGBA32UI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RGBA32SI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + _sg_pixelformat_srmd(&_sg.formats[SG_PIXELFORMAT_DEPTH]); + _sg_pixelformat_srmd(&_sg.formats[SG_PIXELFORMAT_DEPTH_STENCIL]); + + /* FIXME FIXME FIXME: need to check if BC texture compression is + actually supported, currently the WebGPU C-API doesn't allow this + */ + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC1_RGBA]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC2_RGBA]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC3_RGBA]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC4_R]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC4_RSN]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC5_RG]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC5_RGSN]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC6H_RGBF]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC6H_RGBUF]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_BC7_RGBA]); +} + +/* + WGPU uniform buffer pool implementation: + + At start of frame, a mapped buffer is grabbed from the pool, + or a new buffer is created if there is no mapped buffer available. + + At end of frame, the current buffer is unmapped before queue submit, + and async-mapped immediately again. + + UNIFORM BUFFER FIXME: + + - As per WebGPU spec, it should be possible to create a Uniform|MapWrite + buffer, but this isn't currently allowed in Dawn. +*/ +_SOKOL_PRIVATE void _sg_wgpu_ubpool_init(const sg_desc* desc) { + + /* Add the max-uniform-update size (64 KB) to the requested buffer size, + this is to prevent validation errors in the WebGPU implementation + if the entire buffer size is used per frame. 64 KB is the allowed + max uniform update size on NVIDIA + */ + _sg.wgpu.ub.num_bytes = desc->uniform_buffer_size + _SG_WGPU_MAX_UNIFORM_UPDATE_SIZE; + + WGPUBufferDescriptor ub_desc; + memset(&ub_desc, 0, sizeof(ub_desc)); + ub_desc.size = _sg.wgpu.ub.num_bytes; + ub_desc.usage = WGPUBufferUsage_Uniform|WGPUBufferUsage_CopyDst; + _sg.wgpu.ub.buf = wgpuDeviceCreateBuffer(_sg.wgpu.dev, &ub_desc); + SOKOL_ASSERT(_sg.wgpu.ub.buf); + + WGPUBindGroupLayoutBinding ub_bglb_desc[SG_NUM_SHADER_STAGES][SG_MAX_SHADERSTAGE_UBS]; + memset(ub_bglb_desc, 0, sizeof(ub_bglb_desc)); + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + WGPUShaderStage vis = (stage_index == SG_SHADERSTAGE_VS) ? WGPUShaderStage_Vertex : WGPUShaderStage_Fragment; + for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBS; ub_index++) { + int bind_index = stage_index * SG_MAX_SHADERSTAGE_UBS + ub_index; + ub_bglb_desc[stage_index][ub_index].binding = bind_index; + ub_bglb_desc[stage_index][ub_index].visibility = vis; + ub_bglb_desc[stage_index][ub_index].type = WGPUBindingType_UniformBuffer; + ub_bglb_desc[stage_index][ub_index].hasDynamicOffset = true; + } + } + + WGPUBindGroupLayoutDescriptor ub_bgl_desc; + memset(&ub_bgl_desc, 0, sizeof(ub_bgl_desc)); + ub_bgl_desc.bindingCount = SG_NUM_SHADER_STAGES * SG_MAX_SHADERSTAGE_UBS; + ub_bgl_desc.bindings = &ub_bglb_desc[0][0]; + _sg.wgpu.ub.bindgroup_layout = wgpuDeviceCreateBindGroupLayout(_sg.wgpu.dev, &ub_bgl_desc); + SOKOL_ASSERT(_sg.wgpu.ub.bindgroup_layout); + + WGPUBindGroupBinding ub_bgb[SG_NUM_SHADER_STAGES][SG_MAX_SHADERSTAGE_UBS]; + memset(ub_bgb, 0, sizeof(ub_bgb)); + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBS; ub_index++) { + int bind_index = stage_index * SG_MAX_SHADERSTAGE_UBS + ub_index; + ub_bgb[stage_index][ub_index].binding = bind_index; + ub_bgb[stage_index][ub_index].buffer = _sg.wgpu.ub.buf; + // FIXME FIXME FIXME FIXME: HACK FOR VALIDATION BUG IN DAWN + ub_bgb[stage_index][ub_index].size = (1<<16); + } + } + WGPUBindGroupDescriptor bg_desc; + memset(&bg_desc, 0, sizeof(bg_desc)); + bg_desc.layout = _sg.wgpu.ub.bindgroup_layout; + bg_desc.bindingCount = SG_NUM_SHADER_STAGES * SG_MAX_SHADERSTAGE_UBS; + bg_desc.bindings = &ub_bgb[0][0]; + _sg.wgpu.ub.bindgroup = wgpuDeviceCreateBindGroup(_sg.wgpu.dev, &bg_desc); + SOKOL_ASSERT(_sg.wgpu.ub.bindgroup); +} + +_SOKOL_PRIVATE void _sg_wgpu_ubpool_discard(void) { + if (_sg.wgpu.ub.buf) { + wgpuBufferRelease(_sg.wgpu.ub.buf); + _sg.wgpu.ub.buf = 0; + } + if (_sg.wgpu.ub.bindgroup) { + wgpuBindGroupRelease(_sg.wgpu.ub.bindgroup); + _sg.wgpu.ub.bindgroup = 0; + } + if (_sg.wgpu.ub.bindgroup_layout) { + wgpuBindGroupLayoutRelease(_sg.wgpu.ub.bindgroup_layout); + _sg.wgpu.ub.bindgroup_layout = 0; + } + for (int i = 0; i < _sg.wgpu.ub.stage.num; i++) { + if (_sg.wgpu.ub.stage.buf[i]) { + wgpuBufferRelease(_sg.wgpu.ub.stage.buf[i]); + _sg.wgpu.ub.stage.buf[i] = 0; + _sg.wgpu.ub.stage.ptr[i] = 0; + } + } +} + +_SOKOL_PRIVATE void _sg_wgpu_ubpool_mapped_callback(WGPUBufferMapAsyncStatus status, void* data, uint64_t data_len, void* user_data) { + if (!_sg.wgpu.valid) { + return; + } + /* FIXME: better handling for this */ + if (WGPUBufferMapAsyncStatus_Success != status) { + SOKOL_LOG("Mapping uniform buffer failed!\n"); + SOKOL_ASSERT(false); + } + SOKOL_ASSERT(data && (data_len == _sg.wgpu.ub.num_bytes)); + int index = (int)(intptr_t) user_data; + SOKOL_ASSERT(index < _sg.wgpu.ub.stage.num); + SOKOL_ASSERT(0 == _sg.wgpu.ub.stage.ptr[index]); + _sg.wgpu.ub.stage.ptr[index] = (uint8_t*) data; +} + +_SOKOL_PRIVATE void _sg_wgpu_ubpool_next_frame(bool first_frame) { + + /* immediately request a new mapping for the last frame's current staging buffer */ + if (!first_frame) { + WGPUBuffer ub_src = _sg.wgpu.ub.stage.buf[_sg.wgpu.ub.stage.cur]; + wgpuBufferMapWriteAsync(ub_src, _sg_wgpu_ubpool_mapped_callback, (void*)(intptr_t)_sg.wgpu.ub.stage.cur); + } + + /* rewind per-frame offsets */ + _sg.wgpu.ub.offset = 0; + memset(&_sg.wgpu.ub.bind_offsets, 0, sizeof(_sg.wgpu.ub.bind_offsets)); + + /* check if a mapped staging buffer is available, otherwise create one */ + for (int i = 0; i < _sg.wgpu.ub.stage.num; i++) { + if (_sg.wgpu.ub.stage.ptr[i]) { + _sg.wgpu.ub.stage.cur = i; + return; + } + } + + /* no mapped uniform buffer available, create one */ + SOKOL_ASSERT(_sg.wgpu.ub.stage.num < _SG_WGPU_STAGING_PIPELINE_SIZE); + _sg.wgpu.ub.stage.cur = _sg.wgpu.ub.stage.num++; + const int cur = _sg.wgpu.ub.stage.cur; + + WGPUBufferDescriptor desc; + memset(&desc, 0, sizeof(desc)); + desc.size = _sg.wgpu.ub.num_bytes; + desc.usage = WGPUBufferUsage_CopySrc|WGPUBufferUsage_MapWrite; + WGPUCreateBufferMappedResult res = wgpuDeviceCreateBufferMapped(_sg.wgpu.dev, &desc); + _sg.wgpu.ub.stage.buf[cur] = res.buffer; + _sg.wgpu.ub.stage.ptr[cur] = (uint8_t*) res.data; + SOKOL_ASSERT(_sg.wgpu.ub.stage.buf[cur]); + SOKOL_ASSERT(_sg.wgpu.ub.stage.ptr[cur]); + SOKOL_ASSERT(res.dataLength == _sg.wgpu.ub.num_bytes); +} + +_SOKOL_PRIVATE void _sg_wgpu_ubpool_flush(void) { + /* unmap staging buffer and copy to uniform buffer */ + const int cur = _sg.wgpu.ub.stage.cur; + SOKOL_ASSERT(_sg.wgpu.ub.stage.ptr[cur]); + _sg.wgpu.ub.stage.ptr[cur] = 0; + WGPUBuffer src_buf = _sg.wgpu.ub.stage.buf[cur]; + wgpuBufferUnmap(src_buf); + if (_sg.wgpu.ub.offset > 0) { + WGPUBuffer dst_buf = _sg.wgpu.ub.buf; + wgpuCommandEncoderCopyBufferToBuffer(_sg.wgpu.render_cmd_enc, src_buf, 0, dst_buf, 0, _sg.wgpu.ub.offset); + } +} + +/* helper function to compute number of bytes needed in staging buffer to copy image data */ +_SOKOL_PRIVATE uint32_t _sg_wgpu_image_data_buffer_size(const _sg_image_t* img) { + uint32_t num_bytes = 0; + const uint32_t num_faces = (img->cmn.type == SG_IMAGETYPE_CUBE) ? 6:1; + const uint32_t num_slices = (img->cmn.type == SG_IMAGETYPE_ARRAY) ? img->cmn.num_slices : 1; + for (int mip_index = 0; mip_index < img->cmn.num_mipmaps; mip_index++) { + const uint32_t mip_width = _sg_max(img->cmn.width >> mip_index, 1); + const uint32_t mip_height = _sg_max(img->cmn.height >> mip_index, 1); + /* row-pitch must be 256-aligend */ + const uint32_t bytes_per_slice = _sg_surface_pitch(img->cmn.pixel_format, mip_width, mip_height, _SG_WGPU_ROWPITCH_ALIGN); + num_bytes += bytes_per_slice * num_slices * num_faces; + } + return num_bytes; +} + +/* helper function to copy image data into a texture via a staging buffer, returns number of + bytes copied +*/ +_SOKOL_PRIVATE uint32_t _sg_wgpu_copy_image_data(WGPUBuffer stg_buf, uint8_t* stg_base_ptr, uint32_t stg_base_offset, _sg_image_t* img, const sg_image_data* data) { + SOKOL_ASSERT(_sg.wgpu.staging_cmd_enc); + SOKOL_ASSERT(stg_buf && stg_base_ptr); + SOKOL_ASSERT(img); + SOKOL_ASSERT(data); + uint32_t stg_offset = stg_base_offset; + const uint32_t num_faces = (img->cmn.type == SG_IMAGETYPE_CUBE) ? 6:1; + const uint32_t num_slices = (img->cmn.type == SG_IMAGETYPE_ARRAY) ? img->cmn.num_slices : 1; + const sg_pixel_format fmt = img->cmn.pixel_format; + WGPUBufferCopyView src_view; + memset(&src_view, 0, sizeof(src_view)); + src_view.buffer = stg_buf; + WGPUTextureCopyView dst_view; + memset(&dst_view, 0, sizeof(dst_view)); + dst_view.texture = img->wgpu.tex; + WGPUExtent3D extent; + memset(&extent, 0, sizeof(extent)); + + for (uint32_t face_index = 0; face_index < num_faces; face_index++) { + for (uint32_t mip_index = 0; mip_index < (uint32_t)img->cmn.num_mipmaps; mip_index++) { + SOKOL_ASSERT(data->subimage[face_index][mip_index].ptr); + SOKOL_ASSERT(data->subimage[face_index][mip_index].size > 0); + const uint8_t* src_base_ptr = (const uint8_t*)data->subimage[face_index][mip_index].ptr; + SOKOL_ASSERT(src_base_ptr); + uint8_t* dst_base_ptr = stg_base_ptr + stg_offset; + + const uint32_t mip_width = _sg_max(img->cmn.width >> mip_index, 1); + const uint32_t mip_height = _sg_max(img->cmn.height >> mip_index, 1); + const uint32_t mip_depth = (img->cmn.type == SG_IMAGETYPE_3D) ? _sg_max(img->cmn.num_slices >> mip_index, 1) : 1; + const uint32_t num_rows = _sg_num_rows(fmt, mip_height); + const uint32_t src_bytes_per_row = _sg_row_pitch(fmt, mip_width, 1); + const uint32_t dst_bytes_per_row = _sg_row_pitch(fmt, mip_width, _SG_WGPU_ROWPITCH_ALIGN); + const uint32_t src_bytes_per_slice = _sg_surface_pitch(fmt, mip_width, mip_height, 1); + const uint32_t dst_bytes_per_slice = _sg_surface_pitch(fmt, mip_width, mip_height, _SG_WGPU_ROWPITCH_ALIGN); + SOKOL_ASSERT((uint32_t)data->subimage[face_index][mip_index].size == (src_bytes_per_slice * num_slices)); + SOKOL_ASSERT(src_bytes_per_row <= dst_bytes_per_row); + SOKOL_ASSERT(src_bytes_per_slice == (src_bytes_per_row * num_rows)); + SOKOL_ASSERT(dst_bytes_per_slice == (dst_bytes_per_row * num_rows)); + _SOKOL_UNUSED(src_bytes_per_slice); + + /* copy data into mapped staging buffer */ + if (src_bytes_per_row == dst_bytes_per_row) { + /* can do a single memcpy */ + uint32_t num_bytes = data->subimage[face_index][mip_index].size; + memcpy(dst_base_ptr, src_base_ptr, num_bytes); + } + else { + /* src/dst pitch doesn't match, need to copy row by row */ + uint8_t* dst_ptr = dst_base_ptr; + const uint8_t* src_ptr = src_base_ptr; + for (uint32_t slice_index = 0; slice_index < num_slices; slice_index++) { + SOKOL_ASSERT(dst_ptr == dst_base_ptr + slice_index * dst_bytes_per_slice); + for (uint32_t row_index = 0; row_index < num_rows; row_index++) { + memcpy(dst_ptr, src_ptr, src_bytes_per_row); + src_ptr += src_bytes_per_row; + dst_ptr += dst_bytes_per_row; + } + } + } + + /* record the staging copy operation into command encoder */ + src_view.imageHeight = mip_height; + src_view.rowPitch = dst_bytes_per_row; + dst_view.mipLevel = mip_index; + extent.width = mip_width; + extent.height = mip_height; + extent.depth = mip_depth; + SOKOL_ASSERT((img->cmn.type != SG_IMAGETYPE_CUBE) || (num_slices == 1)); + for (uint32_t slice_index = 0; slice_index < num_slices; slice_index++) { + const uint32_t layer_index = (img->cmn.type == SG_IMAGETYPE_ARRAY) ? slice_index : face_index; + src_view.offset = stg_offset; + dst_view.arrayLayer = layer_index; + wgpuCommandEncoderCopyBufferToTexture(_sg.wgpu.staging_cmd_enc, &src_view, &dst_view, &extent); + stg_offset += dst_bytes_per_slice; + SOKOL_ASSERT(stg_offset <= _sg.wgpu.staging.num_bytes); + } + } + } + SOKOL_ASSERT(stg_offset >= stg_base_offset); + return (stg_offset - stg_base_offset); +} + +/* + The WGPU staging buffer implementation: + + Very similar to the uniform buffer pool, there's a pool of big + per-frame staging buffers, each must be big enough to hold + all data uploaded to dynamic resources for one frame. + + Staging buffers are created on demand and reused, because the + 'frame pipeline depth' of WGPU isn't predictable. + + The difference to the uniform buffer system is that there isn't + a 1:1 relationship for source- and destination for the + data-copy operation. There's always one staging buffer as copy-source + per frame, but many copy-destinations (regular vertex/index buffers + or images). Instead of one big copy-operation at the end of the frame, + multiple copy-operations will be written throughout the frame. +*/ +_SOKOL_PRIVATE void _sg_wgpu_staging_init(const sg_desc* desc) { + SOKOL_ASSERT(desc && (desc->staging_buffer_size > 0)); + _sg.wgpu.staging.num_bytes = desc->staging_buffer_size; + /* there's actually nothing more to do here */ +} + +_SOKOL_PRIVATE void _sg_wgpu_staging_discard(void) { + for (int i = 0; i < _sg.wgpu.staging.num; i++) { + if (_sg.wgpu.staging.buf[i]) { + wgpuBufferRelease(_sg.wgpu.staging.buf[i]); + _sg.wgpu.staging.buf[i] = 0; + _sg.wgpu.staging.ptr[i] = 0; + } + } +} + +_SOKOL_PRIVATE void _sg_wgpu_staging_mapped_callback(WGPUBufferMapAsyncStatus status, void* data, uint64_t data_len, void* user_data) { + if (!_sg.wgpu.valid) { + return; + } + /* FIXME: better handling for this */ + if (WGPUBufferMapAsyncStatus_Success != status) { + SOKOL_ASSERT("Mapping staging buffer failed!\n"); + SOKOL_ASSERT(false); + } + SOKOL_ASSERT(data && (data_len == _sg.wgpu.staging.num_bytes)); + int index = (int)(intptr_t) user_data; + SOKOL_ASSERT(index < _sg.wgpu.staging.num); + SOKOL_ASSERT(0 == _sg.wgpu.staging.ptr[index]); + _sg.wgpu.staging.ptr[index] = (uint8_t*) data; +} + +_SOKOL_PRIVATE void _sg_wgpu_staging_next_frame(bool first_frame) { + + /* immediately request a new mapping for the last frame's current staging buffer */ + if (!first_frame) { + WGPUBuffer cur_buf = _sg.wgpu.staging.buf[_sg.wgpu.staging.cur]; + wgpuBufferMapWriteAsync(cur_buf, _sg_wgpu_staging_mapped_callback, (void*)(intptr_t)_sg.wgpu.staging.cur); + } + + /* rewind staging-buffer offset */ + _sg.wgpu.staging.offset = 0; + + /* check if mapped staging buffer is available, otherwise create one */ + for (int i = 0; i < _sg.wgpu.staging.num; i++) { + if (_sg.wgpu.staging.ptr[i]) { + _sg.wgpu.staging.cur = i; + return; + } + } + + /* no mapped buffer available, create one */ + SOKOL_ASSERT(_sg.wgpu.staging.num < _SG_WGPU_STAGING_PIPELINE_SIZE); + _sg.wgpu.staging.cur = _sg.wgpu.staging.num++; + const int cur = _sg.wgpu.staging.cur; + + WGPUBufferDescriptor desc; + memset(&desc, 0, sizeof(desc)); + desc.size = _sg.wgpu.staging.num_bytes; + desc.usage = WGPUBufferUsage_CopySrc|WGPUBufferUsage_MapWrite; + WGPUCreateBufferMappedResult res = wgpuDeviceCreateBufferMapped(_sg.wgpu.dev, &desc); + _sg.wgpu.staging.buf[cur] = res.buffer; + _sg.wgpu.staging.ptr[cur] = (uint8_t*) res.data; + SOKOL_ASSERT(_sg.wgpu.staging.buf[cur]); + SOKOL_ASSERT(_sg.wgpu.staging.ptr[cur]); + SOKOL_ASSERT(res.dataLength == _sg.wgpu.staging.num_bytes); +} + +_SOKOL_PRIVATE uint32_t _sg_wgpu_staging_copy_to_buffer(WGPUBuffer dst_buf, uint32_t dst_buf_offset, const void* data, uint32_t data_num_bytes) { + /* Copy a chunk of data into the staging buffer, and record a blit-operation into + the command encoder, bump the offset for the next data chunk, return 0 if there + was not enough room in the staging buffer, return the number of actually + copied bytes on success. + + NOTE: that the number of staging bytes to be copied must be a multiple of 4. + + */ + SOKOL_ASSERT(_sg.wgpu.staging_cmd_enc); + SOKOL_ASSERT((dst_buf_offset & 3) == 0); + SOKOL_ASSERT(data_num_bytes > 0); + uint32_t copy_num_bytes = _sg_roundup(data_num_bytes, 4); + if ((_sg.wgpu.staging.offset + copy_num_bytes) >= _sg.wgpu.staging.num_bytes) { + SOKOL_LOG("WGPU: Per frame staging buffer full (in _sg_wgpu_staging_copy_to_buffer())!\n"); + return false; + } + const int cur = _sg.wgpu.staging.cur; + SOKOL_ASSERT(_sg.wgpu.staging.ptr[cur]); + uint32_t stg_buf_offset = _sg.wgpu.staging.offset; + uint8_t* stg_ptr = _sg.wgpu.staging.ptr[cur] + stg_buf_offset; + memcpy(stg_ptr, data, data_num_bytes); + WGPUBuffer stg_buf = _sg.wgpu.staging.buf[cur]; + wgpuCommandEncoderCopyBufferToBuffer(_sg.wgpu.staging_cmd_enc, stg_buf, stg_buf_offset, dst_buf, dst_buf_offset, copy_num_bytes); + _sg.wgpu.staging.offset = stg_buf_offset + copy_num_bytes; + return copy_num_bytes; +} + +_SOKOL_PRIVATE bool _sg_wgpu_staging_copy_to_texture(_sg_image_t* img, const sg_image_data* data) { + /* similar to _sg_wgpu_staging_copy_to_buffer(), but with image data instead */ + SOKOL_ASSERT(_sg.wgpu.staging_cmd_enc); + uint32_t num_bytes = _sg_wgpu_image_data_buffer_size(img); + if ((_sg.wgpu.staging.offset + num_bytes) >= _sg.wgpu.staging.num_bytes) { + SOKOL_LOG("WGPU: Per frame staging buffer full (in _sg_wgpu_staging_copy_to_texture)!\n"); + return false; + } + const int cur = _sg.wgpu.staging.cur; + SOKOL_ASSERT(_sg.wgpu.staging.ptr[cur]); + uint32_t stg_offset = _sg.wgpu.staging.offset; + uint8_t* stg_ptr = _sg.wgpu.staging.ptr[cur]; + WGPUBuffer stg_buf = _sg.wgpu.staging.buf[cur]; + uint32_t bytes_copied = _sg_wgpu_copy_image_data(stg_buf, stg_ptr, stg_offset, img, data); + _SOKOL_UNUSED(bytes_copied); + SOKOL_ASSERT(bytes_copied == num_bytes); + _sg.wgpu.staging.offset = _sg_roundup(stg_offset + num_bytes, _SG_WGPU_STAGING_ALIGN); + return true; +} + +_SOKOL_PRIVATE void _sg_wgpu_staging_unmap(void) { + /* called at end of frame before queue-submit */ + const int cur = _sg.wgpu.staging.cur; + SOKOL_ASSERT(_sg.wgpu.staging.ptr[cur]); + _sg.wgpu.staging.ptr[cur] = 0; + wgpuBufferUnmap(_sg.wgpu.staging.buf[cur]); +} + +/*--- WGPU sampler cache functions ---*/ +_SOKOL_PRIVATE void _sg_wgpu_init_sampler_cache(const sg_desc* desc) { + SOKOL_ASSERT(desc->sampler_cache_size > 0); + _sg_smpcache_init(&_sg.wgpu.sampler_cache, desc->sampler_cache_size); +} + +_SOKOL_PRIVATE void _sg_wgpu_destroy_sampler_cache(void) { + SOKOL_ASSERT(_sg.wgpu.sampler_cache.items); + SOKOL_ASSERT(_sg.wgpu.sampler_cache.num_items <= _sg.wgpu.sampler_cache.capacity); + for (int i = 0; i < _sg.wgpu.sampler_cache.num_items; i++) { + wgpuSamplerRelease((WGPUSampler)_sg_smpcache_sampler(&_sg.wgpu.sampler_cache, i)); + } + _sg_smpcache_discard(&_sg.wgpu.sampler_cache); +} + +_SOKOL_PRIVATE WGPUSampler _sg_wgpu_create_sampler(const sg_image_desc* img_desc) { + SOKOL_ASSERT(img_desc); + int index = _sg_smpcache_find_item(&_sg.wgpu.sampler_cache, img_desc); + if (index >= 0) { + /* reuse existing sampler */ + return (WGPUSampler) _sg_smpcache_sampler(&_sg.wgpu.sampler_cache, index); + } + else { + /* create a new WGPU sampler and add to sampler cache */ + /* FIXME: anisotropic filtering not supported? */ + WGPUSamplerDescriptor smp_desc; + memset(&smp_desc, 0, sizeof(smp_desc)); + smp_desc.addressModeU = _sg_wgpu_sampler_addrmode(img_desc->wrap_u); + smp_desc.addressModeV = _sg_wgpu_sampler_addrmode(img_desc->wrap_v); + smp_desc.addressModeW = _sg_wgpu_sampler_addrmode(img_desc->wrap_w); + smp_desc.magFilter = _sg_wgpu_sampler_minmagfilter(img_desc->mag_filter); + smp_desc.minFilter = _sg_wgpu_sampler_minmagfilter(img_desc->min_filter); + smp_desc.mipmapFilter = _sg_wgpu_sampler_mipfilter(img_desc->min_filter); + smp_desc.lodMinClamp = img_desc->min_lod; + smp_desc.lodMaxClamp = img_desc->max_lod; + WGPUSampler smp = wgpuDeviceCreateSampler(_sg.wgpu.dev, &smp_desc); + SOKOL_ASSERT(smp); + _sg_smpcache_add_item(&_sg.wgpu.sampler_cache, img_desc, (uintptr_t)smp); + return smp; + } +} + +/*--- WGPU backend API functions ---*/ +_SOKOL_PRIVATE void _sg_wgpu_setup_backend(const sg_desc* desc) { + SOKOL_ASSERT(desc); + SOKOL_ASSERT(desc->context.wgpu.device); + SOKOL_ASSERT(desc->context.wgpu.render_view_cb || desc->context.wgpu.render_view_userdata_cb); + SOKOL_ASSERT(desc->context.wgpu.resolve_view_cb || desc->context.wgpu.resolve_view_userdata_cb); + SOKOL_ASSERT(desc->context.wgpu.depth_stencil_view_cb || desc->context.wgpu.depth_stencil_view_userdata_cb); + SOKOL_ASSERT(desc->uniform_buffer_size > 0); + SOKOL_ASSERT(desc->staging_buffer_size > 0); + _sg.backend = SG_BACKEND_WGPU; + _sg.wgpu.valid = true; + _sg.wgpu.dev = (WGPUDevice) desc->context.wgpu.device; + _sg.wgpu.render_view_cb = (WGPUTextureView(*)(void)) desc->context.wgpu.render_view_cb; + _sg.wgpu.render_view_userdata_cb = (WGPUTextureView(*)(void*)) desc->context.wgpu.render_view_userdata_cb; + _sg.wgpu.resolve_view_cb = (WGPUTextureView(*)(void)) desc->context.wgpu.resolve_view_cb; + _sg.wgpu.resolve_view_userdata_cb = (WGPUTextureView(*)(void*)) desc->context.wgpu.resolve_view_userdata_cb; + _sg.wgpu.depth_stencil_view_cb = (WGPUTextureView(*)(void)) desc->context.wgpu.depth_stencil_view_cb; + _sg.wgpu.depth_stencil_view_userdata_cb = (WGPUTextureView(*)(void*)) desc->context.wgpu.depth_stencil_view_userdata_cb; + _sg.wgpu.user_data = desc->context.wgpu.user_data; + _sg.wgpu.queue = wgpuDeviceCreateQueue(_sg.wgpu.dev); + SOKOL_ASSERT(_sg.wgpu.queue); + + /* setup WebGPU features and limits */ + _sg_wgpu_init_caps(); + + /* setup the sampler cache, uniform and staging buffer pools */ + _sg_wgpu_init_sampler_cache(&_sg.desc); + _sg_wgpu_ubpool_init(desc); + _sg_wgpu_ubpool_next_frame(true); + _sg_wgpu_staging_init(desc); + _sg_wgpu_staging_next_frame(true); + + /* create an empty bind group for shader stages without bound images */ + WGPUBindGroupLayoutDescriptor bgl_desc; + memset(&bgl_desc, 0, sizeof(bgl_desc)); + WGPUBindGroupLayout empty_bgl = wgpuDeviceCreateBindGroupLayout(_sg.wgpu.dev, &bgl_desc); + SOKOL_ASSERT(empty_bgl); + WGPUBindGroupDescriptor bg_desc; + memset(&bg_desc, 0, sizeof(bg_desc)); + bg_desc.layout = empty_bgl; + _sg.wgpu.empty_bind_group = wgpuDeviceCreateBindGroup(_sg.wgpu.dev, &bg_desc); + SOKOL_ASSERT(_sg.wgpu.empty_bind_group); + wgpuBindGroupLayoutRelease(empty_bgl); + + /* create initial per-frame command encoders */ + WGPUCommandEncoderDescriptor cmd_enc_desc; + memset(&cmd_enc_desc, 0, sizeof(cmd_enc_desc)); + _sg.wgpu.render_cmd_enc = wgpuDeviceCreateCommandEncoder(_sg.wgpu.dev, &cmd_enc_desc); + SOKOL_ASSERT(_sg.wgpu.render_cmd_enc); + _sg.wgpu.staging_cmd_enc = wgpuDeviceCreateCommandEncoder(_sg.wgpu.dev, &cmd_enc_desc); + SOKOL_ASSERT(_sg.wgpu.staging_cmd_enc); +} + +_SOKOL_PRIVATE void _sg_wgpu_discard_backend(void) { + SOKOL_ASSERT(_sg.wgpu.valid); + SOKOL_ASSERT(_sg.wgpu.render_cmd_enc); + SOKOL_ASSERT(_sg.wgpu.staging_cmd_enc); + _sg.wgpu.valid = false; + _sg_wgpu_ubpool_discard(); + _sg_wgpu_staging_discard(); + _sg_wgpu_destroy_sampler_cache(); + wgpuBindGroupRelease(_sg.wgpu.empty_bind_group); + wgpuCommandEncoderRelease(_sg.wgpu.render_cmd_enc); + _sg.wgpu.render_cmd_enc = 0; + wgpuCommandEncoderRelease(_sg.wgpu.staging_cmd_enc); + _sg.wgpu.staging_cmd_enc = 0; + if (_sg.wgpu.queue) { + wgpuQueueRelease(_sg.wgpu.queue); + _sg.wgpu.queue = 0; + } +} + +_SOKOL_PRIVATE void _sg_wgpu_reset_state_cache(void) { + SOKOL_LOG("_sg_wgpu_reset_state_cache: FIXME\n"); +} + +_SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + _SOKOL_UNUSED(ctx); + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_wgpu_destroy_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + _SOKOL_UNUSED(ctx); +} + +_SOKOL_PRIVATE void _sg_wgpu_activate_context(_sg_context_t* ctx) { + (void)ctx; + SOKOL_LOG("_sg_wgpu_activate_context: FIXME\n"); +} + +_SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) { + SOKOL_ASSERT(buf && desc); + const bool injected = (0 != desc->wgpu_buffer); + _sg_buffer_common_init(&buf->cmn, desc); + if (injected) { + buf->wgpu.buf = (WGPUBuffer) desc->wgpu_buffer; + wgpuBufferReference(buf->wgpu.buf); + } + else { + WGPUBufferDescriptor wgpu_buf_desc; + memset(&wgpu_buf_desc, 0, sizeof(wgpu_buf_desc)); + wgpu_buf_desc.usage = _sg_wgpu_buffer_usage(buf->cmn.type, buf->cmn.usage); + wgpu_buf_desc.size = buf->cmn.size; + if (SG_USAGE_IMMUTABLE == buf->cmn.usage) { + SOKOL_ASSERT(desc->data.ptr); + WGPUCreateBufferMappedResult res = wgpuDeviceCreateBufferMapped(_sg.wgpu.dev, &wgpu_buf_desc); + buf->wgpu.buf = res.buffer; + SOKOL_ASSERT(res.data && (res.dataLength == buf->cmn.size)); + memcpy(res.data, desc->data.ptr, buf->cmn.size); + wgpuBufferUnmap(res.buffer); + } + else { + buf->wgpu.buf = wgpuDeviceCreateBuffer(_sg.wgpu.dev, &wgpu_buf_desc); + } + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_wgpu_destroy_buffer(_sg_buffer_t* buf) { + SOKOL_ASSERT(buf); + WGPUBuffer wgpu_buf = buf->wgpu.buf; + if (0 != wgpu_buf) { + wgpuBufferRelease(wgpu_buf); + } +} + +_SOKOL_PRIVATE void _sg_wgpu_init_texdesc_common(WGPUTextureDescriptor* wgpu_tex_desc, const sg_image_desc* desc) { + wgpu_tex_desc->usage = WGPUTextureUsage_Sampled|WGPUTextureUsage_CopyDst; + wgpu_tex_desc->dimension = _sg_wgpu_tex_dim(desc->type); + wgpu_tex_desc->size.width = desc->width; + wgpu_tex_desc->size.height = desc->height; + if (desc->type == SG_IMAGETYPE_3D) { + wgpu_tex_desc->size.depth = desc->num_slices; + wgpu_tex_desc->arrayLayerCount = 1; + } + else if (desc->type == SG_IMAGETYPE_CUBE) { + wgpu_tex_desc->size.depth = 1; + wgpu_tex_desc->arrayLayerCount = 6; + } + else { + wgpu_tex_desc->size.depth = 1; + wgpu_tex_desc->arrayLayerCount = desc->num_slices; + } + wgpu_tex_desc->format = _sg_wgpu_textureformat(desc->pixel_format); + wgpu_tex_desc->mipLevelCount = desc->num_mipmaps; + wgpu_tex_desc->sampleCount = 1; +} + +_SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_image(_sg_image_t* img, const sg_image_desc* desc) { + SOKOL_ASSERT(img && desc); + SOKOL_ASSERT(_sg.wgpu.dev); + SOKOL_ASSERT(_sg.wgpu.staging_cmd_enc); + + _sg_image_common_init(&img->cmn, desc); + + const bool injected = (0 != desc->wgpu_texture); + const bool is_msaa = desc->sample_count > 1; + WGPUTextureDescriptor wgpu_tex_desc; + memset(&wgpu_tex_desc, 0, sizeof(wgpu_tex_desc)); + _sg_wgpu_init_texdesc_common(&wgpu_tex_desc, desc); + if (_sg_is_valid_rendertarget_depth_format(img->cmn.pixel_format)) { + SOKOL_ASSERT(img->cmn.render_target); + SOKOL_ASSERT(img->cmn.type == SG_IMAGETYPE_2D); + SOKOL_ASSERT(img->cmn.num_mipmaps == 1); + SOKOL_ASSERT(!injected); + /* NOTE: a depth-stencil texture will never be MSAA-resolved, so there + won't be a separate MSAA- and resolve-texture + */ + wgpu_tex_desc.usage = WGPUTextureUsage_OutputAttachment; + wgpu_tex_desc.sampleCount = desc->sample_count; + img->wgpu.tex = wgpuDeviceCreateTexture(_sg.wgpu.dev, &wgpu_tex_desc); + SOKOL_ASSERT(img->wgpu.tex); + } + else { + if (injected) { + img->wgpu.tex = (WGPUTexture) desc->wgpu_texture; + wgpuTextureReference(img->wgpu.tex); + } + else { + /* NOTE: in the MSAA-rendertarget case, both the MSAA texture *and* + the resolve texture need OutputAttachment usage + */ + if (img->cmn.render_target) { + wgpu_tex_desc.usage = WGPUTextureUsage_Sampled|WGPUTextureUsage_OutputAttachment; + } + img->wgpu.tex = wgpuDeviceCreateTexture(_sg.wgpu.dev, &wgpu_tex_desc); + SOKOL_ASSERT(img->wgpu.tex); + + /* copy content into texture via a throw-away staging buffer */ + if (desc->usage == SG_USAGE_IMMUTABLE && !desc->render_target) { + WGPUBufferDescriptor wgpu_buf_desc; + memset(&wgpu_buf_desc, 0, sizeof(wgpu_buf_desc)); + wgpu_buf_desc.size = _sg_wgpu_image_data_buffer_size(img); + wgpu_buf_desc.usage = WGPUBufferUsage_CopySrc|WGPUBufferUsage_CopyDst; + WGPUCreateBufferMappedResult map = wgpuDeviceCreateBufferMapped(_sg.wgpu.dev, &wgpu_buf_desc); + SOKOL_ASSERT(map.buffer && map.data); + uint32_t num_bytes = _sg_wgpu_copy_image_data(map.buffer, (uint8_t*)map.data, 0, img, &desc->data); + _SOKOL_UNUSED(num_bytes); + SOKOL_ASSERT(num_bytes == wgpu_buf_desc.size); + wgpuBufferUnmap(map.buffer); + wgpuBufferRelease(map.buffer); + } + } + + /* create texture view object */ + WGPUTextureViewDescriptor wgpu_view_desc; + memset(&wgpu_view_desc, 0, sizeof(wgpu_view_desc)); + wgpu_view_desc.dimension = _sg_wgpu_tex_viewdim(desc->type); + img->wgpu.tex_view = wgpuTextureCreateView(img->wgpu.tex, &wgpu_view_desc); + + /* if render target and MSAA, then a separate texture in MSAA format is needed + which will be resolved into the regular texture at the end of the + offscreen-render pass + */ + if (desc->render_target && is_msaa) { + wgpu_tex_desc.dimension = WGPUTextureDimension_2D; + wgpu_tex_desc.size.depth = 1; + wgpu_tex_desc.arrayLayerCount = 1; + wgpu_tex_desc.mipLevelCount = 1; + wgpu_tex_desc.usage = WGPUTextureUsage_OutputAttachment; + wgpu_tex_desc.sampleCount = desc->sample_count; + img->wgpu.msaa_tex = wgpuDeviceCreateTexture(_sg.wgpu.dev, &wgpu_tex_desc); + SOKOL_ASSERT(img->wgpu.msaa_tex); + } + + /* create sampler via shared-sampler-cache */ + img->wgpu.sampler = _sg_wgpu_create_sampler(desc); + SOKOL_ASSERT(img->wgpu.sampler); + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_wgpu_destroy_image(_sg_image_t* img) { + SOKOL_ASSERT(img); + if (img->wgpu.tex) { + wgpuTextureRelease(img->wgpu.tex); + img->wgpu.tex = 0; + } + if (img->wgpu.tex_view) { + wgpuTextureViewRelease(img->wgpu.tex_view); + img->wgpu.tex_view = 0; + } + if (img->wgpu.msaa_tex) { + wgpuTextureRelease(img->wgpu.msaa_tex); + img->wgpu.msaa_tex = 0; + } + /* NOTE: do *not* destroy the sampler from the shared-sampler-cache */ + img->wgpu.sampler = 0; +} + +/* + How BindGroups work in WebGPU: + + - up to 4 bind groups can be bound simultaneously + - up to 16 bindings per bind group + - 'binding' slots are local per bind group + - in the shader: + layout(set=0, binding=1) corresponds to bind group 0, binding 1 + + Now how to map this to sokol-gfx's bind model: + + Reduce SG_MAX_SHADERSTAGE_IMAGES to 8, then: + + 1 bind group for all 8 uniform buffers + 1 bind group for vertex shader textures + samplers + 1 bind group for fragment shader textures + samples + + Alternatively: + + 1 bind group for 8 uniform buffer slots + 1 bind group for 8 vs images + 8 vs samplers + 1 bind group for 12 fs images + 1 bind group for 12 fs samplers + + I guess this means that we need to create BindGroups on the + fly during sg_apply_bindings() :/ +*/ +_SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_shader(_sg_shader_t* shd, const sg_shader_desc* desc) { + SOKOL_ASSERT(shd && desc); + SOKOL_ASSERT(desc->vs.bytecode.ptr && desc->fs.bytecode.ptr); + _sg_shader_common_init(&shd->cmn, desc); + + bool success = true; + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + const sg_shader_stage_desc* stage_desc = (stage_index == SG_SHADERSTAGE_VS) ? &desc->vs : &desc->fs; + SOKOL_ASSERT((stage_desc->bytecode.size & 3) == 0); + + _sg_shader_stage_t* cmn_stage = &shd->cmn.stage[stage_index]; + _sg_wgpu_shader_stage_t* wgpu_stage = &shd->wgpu.stage[stage_index]; + + _sg_strcpy(&wgpu_stage->entry, stage_desc->entry); + WGPUShaderModuleDescriptor wgpu_shdmod_desc; + memset(&wgpu_shdmod_desc, 0, sizeof(wgpu_shdmod_desc)); + wgpu_shdmod_desc.codeSize = stage_desc->bytecode.size >> 2; + wgpu_shdmod_desc.code = (const uint32_t*) stage_desc->bytecode.ptr; + wgpu_stage->module = wgpuDeviceCreateShaderModule(_sg.wgpu.dev, &wgpu_shdmod_desc); + if (0 == wgpu_stage->module) { + success = false; + } + + /* create image/sampler bind group for the shader stage */ + WGPUShaderStage vis = (stage_index == SG_SHADERSTAGE_VS) ? WGPUShaderStage_Vertex : WGPUShaderStage_Fragment; + int num_imgs = cmn_stage->num_images; + if (num_imgs > _SG_WGPU_MAX_SHADERSTAGE_IMAGES) { + num_imgs = _SG_WGPU_MAX_SHADERSTAGE_IMAGES; + } + WGPUBindGroupLayoutBinding bglb_desc[_SG_WGPU_MAX_SHADERSTAGE_IMAGES * 2]; + memset(bglb_desc, 0, sizeof(bglb_desc)); + for (int img_index = 0; img_index < num_imgs; img_index++) { + /* texture- and sampler-bindings */ + WGPUBindGroupLayoutBinding* tex_desc = &bglb_desc[img_index*2 + 0]; + WGPUBindGroupLayoutBinding* smp_desc = &bglb_desc[img_index*2 + 1]; + + tex_desc->binding = img_index; + tex_desc->visibility = vis; + tex_desc->type = WGPUBindingType_SampledTexture; + tex_desc->textureDimension = _sg_wgpu_tex_viewdim(cmn_stage->images[img_index].image_type); + tex_desc->textureComponentType = _sg_wgpu_tex_comptype(cmn_stage->images[img_index].sampler_type); + + smp_desc->binding = img_index + _SG_WGPU_MAX_SHADERSTAGE_IMAGES; + smp_desc->visibility = vis; + smp_desc->type = WGPUBindingType_Sampler; + } + WGPUBindGroupLayoutDescriptor img_bgl_desc; + memset(&img_bgl_desc, 0, sizeof(img_bgl_desc)); + img_bgl_desc.bindingCount = num_imgs * 2; + img_bgl_desc.bindings = &bglb_desc[0]; + wgpu_stage->bind_group_layout = wgpuDeviceCreateBindGroupLayout(_sg.wgpu.dev, &img_bgl_desc); + SOKOL_ASSERT(wgpu_stage->bind_group_layout); + } + return success ? SG_RESOURCESTATE_VALID : SG_RESOURCESTATE_FAILED; +} + +_SOKOL_PRIVATE void _sg_wgpu_destroy_shader(_sg_shader_t* shd) { + SOKOL_ASSERT(shd); + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + _sg_wgpu_shader_stage_t* wgpu_stage = &shd->wgpu.stage[stage_index]; + if (wgpu_stage->module) { + wgpuShaderModuleRelease(wgpu_stage->module); + wgpu_stage->module = 0; + } + if (wgpu_stage->bind_group_layout) { + wgpuBindGroupLayoutRelease(wgpu_stage->bind_group_layout); + wgpu_stage->bind_group_layout = 0; + } + } +} + +_SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_pipeline(_sg_pipeline_t* pip, _sg_shader_t* shd, const sg_pipeline_desc* desc) { + SOKOL_ASSERT(pip && shd && desc); + SOKOL_ASSERT(desc->shader.id == shd->slot.id); + SOKOL_ASSERT(shd->wgpu.stage[SG_SHADERSTAGE_VS].bind_group_layout); + SOKOL_ASSERT(shd->wgpu.stage[SG_SHADERSTAGE_FS].bind_group_layout); + pip->shader = shd; + _sg_pipeline_common_init(&pip->cmn, desc); + pip->wgpu.stencil_ref = (uint32_t) desc->stencil.ref; + + WGPUBindGroupLayout pip_bgl[3] = { + _sg.wgpu.ub.bindgroup_layout, + shd->wgpu.stage[SG_SHADERSTAGE_VS].bind_group_layout, + shd->wgpu.stage[SG_SHADERSTAGE_FS].bind_group_layout + }; + WGPUPipelineLayoutDescriptor pl_desc; + memset(&pl_desc, 0, sizeof(pl_desc)); + pl_desc.bindGroupLayoutCount = 3; + pl_desc.bindGroupLayouts = &pip_bgl[0]; + WGPUPipelineLayout pip_layout = wgpuDeviceCreatePipelineLayout(_sg.wgpu.dev, &pl_desc); + + WGPUVertexBufferLayoutDescriptor vb_desc[SG_MAX_SHADERSTAGE_BUFFERS]; + memset(&vb_desc, 0, sizeof(vb_desc)); + WGPUVertexAttributeDescriptor va_desc[SG_MAX_SHADERSTAGE_BUFFERS][SG_MAX_VERTEX_ATTRIBUTES]; + memset(&va_desc, 0, sizeof(va_desc)); + int vb_idx = 0; + for (; vb_idx < SG_MAX_SHADERSTAGE_BUFFERS; vb_idx++) { + const sg_buffer_layout_desc* src_vb_desc = &desc->layout.buffers[vb_idx]; + if (0 == src_vb_desc->stride) { + break; + } + vb_desc[vb_idx].arrayStride = src_vb_desc->stride; + vb_desc[vb_idx].stepMode = _sg_wgpu_stepmode(src_vb_desc->step_func); + /* NOTE: WebGPU has no support for vertex step rate (because that's + not supported by Core Vulkan + */ + int va_idx = 0; + for (int va_loc = 0; va_loc < SG_MAX_VERTEX_ATTRIBUTES; va_loc++) { + const sg_vertex_attr_desc* src_va_desc = &desc->layout.attrs[va_loc]; + if (SG_VERTEXFORMAT_INVALID == src_va_desc->format) { + break; + } + pip->cmn.vertex_layout_valid[src_va_desc->buffer_index] = true; + if (vb_idx == src_va_desc->buffer_index) { + va_desc[vb_idx][va_idx].format = _sg_wgpu_vertexformat(src_va_desc->format); + va_desc[vb_idx][va_idx].offset = src_va_desc->offset; + va_desc[vb_idx][va_idx].shaderLocation = va_loc; + va_idx++; + } + } + vb_desc[vb_idx].attributeCount = va_idx; + vb_desc[vb_idx].attributes = &va_desc[vb_idx][0]; + } + WGPUVertexStateDescriptor vx_state_desc; + memset(&vx_state_desc, 0, sizeof(vx_state_desc)); + vx_state_desc.indexFormat = _sg_wgpu_indexformat(desc->index_type); + vx_state_desc.vertexBufferCount = vb_idx; + vx_state_desc.vertexBuffers = vb_desc; + + WGPURasterizationStateDescriptor rs_desc; + memset(&rs_desc, 0, sizeof(rs_desc)); + rs_desc.frontFace = _sg_wgpu_frontface(desc->face_winding); + rs_desc.cullMode = _sg_wgpu_cullmode(desc->cull_mode); + rs_desc.depthBias = (int32_t) desc->depth.bias; + rs_desc.depthBiasClamp = desc->depth.bias_clamp; + rs_desc.depthBiasSlopeScale = desc->depth.bias_slope_scale; + + WGPUDepthStencilStateDescriptor ds_desc; + memset(&ds_desc, 0, sizeof(ds_desc)); + ds_desc.format = _sg_wgpu_textureformat(desc->depth.pixel_format); + ds_desc.depthWriteEnabled = desc->depth.write_enabled; + ds_desc.depthCompare = _sg_wgpu_comparefunc(desc->depth.compare); + ds_desc.stencilReadMask = desc->stencil.read_mask; + ds_desc.stencilWriteMask = desc->stencil.write_mask; + ds_desc.stencilFront.compare = _sg_wgpu_comparefunc(desc->stencil.front.compare); + ds_desc.stencilFront.failOp = _sg_wgpu_stencilop(desc->stencil.front.fail_op); + ds_desc.stencilFront.depthFailOp = _sg_wgpu_stencilop(desc->stencil.front.depth_fail_op); + ds_desc.stencilFront.passOp = _sg_wgpu_stencilop(desc->stencil.front.pass_op); + ds_desc.stencilBack.compare = _sg_wgpu_comparefunc(desc->stencil.back.compare); + ds_desc.stencilBack.failOp = _sg_wgpu_stencilop(desc->stencil.back.fail_op); + ds_desc.stencilBack.depthFailOp = _sg_wgpu_stencilop(desc->stencil.back.depth_fail_op); + ds_desc.stencilBack.passOp = _sg_wgpu_stencilop(desc->stencil.back.pass_op); + + WGPUProgrammableStageDescriptor fs_desc; + memset(&fs_desc, 0, sizeof(fs_desc)); + fs_desc.module = shd->wgpu.stage[SG_SHADERSTAGE_FS].module; + fs_desc.entryPoint = shd->wgpu.stage[SG_SHADERSTAGE_VS].entry.buf; + + WGPUColorStateDescriptor cs_desc[SG_MAX_COLOR_ATTACHMENTS]; + memset(cs_desc, 0, sizeof(cs_desc)); + for (uint32_t i = 0; i < desc->color_count; i++) { + SOKOL_ASSERT(i < SG_MAX_COLOR_ATTACHMENTS); + cs_desc[i].format = _sg_wgpu_textureformat(desc->colors[i].pixel_format); + cs_desc[i].colorBlend.operation = _sg_wgpu_blendop(desc->colors[i].blend.op_rgb); + cs_desc[i].colorBlend.srcFactor = _sg_wgpu_blendfactor(desc->colors[i].blend.src_factor_rgb); + cs_desc[i].colorBlend.dstFactor = _sg_wgpu_blendfactor(desc->colors[i].blend.dst_factor_rgb); + cs_desc[i].alphaBlend.operation = _sg_wgpu_blendop(desc->colors[i].blend.op_alpha); + cs_desc[i].alphaBlend.srcFactor = _sg_wgpu_blendfactor(desc->colors[i].blend.src_factor_alpha); + cs_desc[i].alphaBlend.dstFactor = _sg_wgpu_blendfactor(desc->colors[i].blend.dst_factor_alpha); + cs_desc[i].writeMask = _sg_wgpu_colorwritemask(desc->colors[i].write_mask); + } + + WGPURenderPipelineDescriptor pip_desc; + memset(&pip_desc, 0, sizeof(pip_desc)); + pip_desc.layout = pip_layout; + pip_desc.vertexStage.module = shd->wgpu.stage[SG_SHADERSTAGE_VS].module; + pip_desc.vertexStage.entryPoint = shd->wgpu.stage[SG_SHADERSTAGE_VS].entry.buf; + pip_desc.fragmentStage = &fs_desc; + pip_desc.vertexState = &vx_state_desc; + pip_desc.primitiveTopology = _sg_wgpu_topology(desc->primitive_type); + pip_desc.rasterizationState = &rs_desc; + pip_desc.sampleCount = desc->sample_count; + if (SG_PIXELFORMAT_NONE != desc->depth.pixel_format) { + pip_desc.depthStencilState = &ds_desc; + } + pip_desc.colorStateCount = desc->color_count; + pip_desc.colorStates = cs_desc; + pip_desc.sampleMask = 0xFFFFFFFF; /* FIXME: ??? */ + pip->wgpu.pip = wgpuDeviceCreateRenderPipeline(_sg.wgpu.dev, &pip_desc); + SOKOL_ASSERT(0 != pip->wgpu.pip); + wgpuPipelineLayoutRelease(pip_layout); + + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_wgpu_destroy_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + if (pip == _sg.wgpu.cur_pipeline) { + _sg.wgpu.cur_pipeline = 0; + _Sg.wgpu.cur_pipeline_id.id = SG_INVALID_ID; + } + if (pip->wgpu.pip) { + wgpuRenderPipelineRelease(pip->wgpu.pip); + pip->wgpu.pip = 0; + } +} + +_SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_pass(_sg_pass_t* pass, _sg_image_t** att_images, const sg_pass_desc* desc) { + SOKOL_ASSERT(pass && desc); + SOKOL_ASSERT(att_images && att_images[0]); + _sg_pass_common_init(&pass->cmn, desc); + + /* copy image pointers and create render-texture views */ + const sg_pass_attachment_desc* att_desc; + for (uint32_t i = 0; i < pass->cmn.num_color_atts; i++) { + att_desc = &desc->color_attachments[i]; + if (att_desc->image.id != SG_INVALID_ID) { + SOKOL_ASSERT(att_desc->image.id != SG_INVALID_ID); + SOKOL_ASSERT(0 == pass->wgpu.color_atts[i].image); + _sg_image_t* img = att_images[i]; + SOKOL_ASSERT(img && (img->slot.id == att_desc->image.id)); + SOKOL_ASSERT(_sg_is_valid_rendertarget_color_format(img->cmn.pixel_format)); + pass->wgpu.color_atts[i].image = img; + /* create a render-texture-view to render into the right sub-surface */ + const bool is_msaa = img->cmn.sample_count > 1; + WGPUTextureViewDescriptor view_desc; + memset(&view_desc, 0, sizeof(view_desc)); + view_desc.baseMipLevel = is_msaa ? 0 : att_desc->mip_level; + view_desc.mipLevelCount = 1; + view_desc.baseArrayLayer = is_msaa ? 0 : att_desc->slice; + view_desc.arrayLayerCount = 1; + WGPUTexture wgpu_tex = is_msaa ? img->wgpu.msaa_tex : img->wgpu.tex; + SOKOL_ASSERT(wgpu_tex); + pass->wgpu.color_atts[i].render_tex_view = wgpuTextureCreateView(wgpu_tex, &view_desc); + SOKOL_ASSERT(pass->wgpu.color_atts[i].render_tex_view); + /* ... and if needed a separate resolve texture view */ + if (is_msaa) { + view_desc.baseMipLevel = att_desc->mip_level; + view_desc.baseArrayLayer = att_desc->slice; + WGPUTexture wgpu_tex = img->wgpu.tex; + pass->wgpu.color_atts[i].resolve_tex_view = wgpuTextureCreateView(wgpu_tex, &view_desc); + SOKOL_ASSERT(pass->wgpu.color_atts[i].resolve_tex_view); + } + } + } + SOKOL_ASSERT(0 == pass->wgpu.ds_att.image); + att_desc = &desc->depth_stencil_attachment; + if (att_desc->image.id != SG_INVALID_ID) { + const int ds_img_index = SG_MAX_COLOR_ATTACHMENTS; + SOKOL_ASSERT(att_images[ds_img_index] && (att_images[ds_img_index]->slot.id == att_desc->image.id)); + SOKOL_ASSERT(_sg_is_valid_rendertarget_depth_format(att_images[ds_img_index]->cmn.pixel_format)); + _sg_image_t* ds_img = att_images[ds_img_index]; + pass->wgpu.ds_att.image = ds_img; + /* create a render-texture view */ + SOKOL_ASSERT(0 == att_desc->mip_level); + SOKOL_ASSERT(0 == att_desc->slice); + WGPUTextureViewDescriptor view_desc; + memset(&view_desc, 0, sizeof(view_desc)); + WGPUTexture wgpu_tex = ds_img->wgpu.tex; + SOKOL_ASSERT(wgpu_tex); + pass->wgpu.ds_att.render_tex_view = wgpuTextureCreateView(wgpu_tex, &view_desc); + SOKOL_ASSERT(pass->wgpu.ds_att.render_tex_view); + } + return SG_RESOURCESTATE_VALID; +} + +_SOKOL_PRIVATE void _sg_wgpu_destroy_pass(_sg_pass_t* pass) { + SOKOL_ASSERT(pass); + for (uint32_t i = 0; i < pass->cmn.num_color_atts; i++) { + if (pass->wgpu.color_atts[i].render_tex_view) { + wgpuTextureViewRelease(pass->wgpu.color_atts[i].render_tex_view); + pass->wgpu.color_atts[i].render_tex_view = 0; + } + if (pass->wgpu.color_atts[i].resolve_tex_view) { + wgpuTextureViewRelease(pass->wgpu.color_atts[i].resolve_tex_view); + pass->wgpu.color_atts[i].resolve_tex_view = 0; + } + } + if (pass->wgpu.ds_att.render_tex_view) { + wgpuTextureViewRelease(pass->wgpu.ds_att.render_tex_view); + pass->wgpu.ds_att.render_tex_view = 0; + } +} + +_SOKOL_PRIVATE _sg_image_t* _sg_wgpu_pass_color_image(const _sg_pass_t* pass, int index) { + SOKOL_ASSERT(pass && (index >= 0) && (index < SG_MAX_COLOR_ATTACHMENTS)); + /* NOTE: may return null */ + return pass->wgpu.color_atts[index].image; +} + +_SOKOL_PRIVATE _sg_image_t* _sg_wgpu_pass_ds_image(const _sg_pass_t* pass) { + /* NOTE: may return null */ + SOKOL_ASSERT(pass); + return pass->wgpu.ds_att.image; +} + +_SOKOL_PRIVATE void _sg_wgpu_begin_pass(_sg_pass_t* pass, const sg_pass_action* action, int w, int h) { + SOKOL_ASSERT(action); + SOKOL_ASSERT(!_sg.wgpu.in_pass); + SOKOL_ASSERT(_sg.wgpu.render_cmd_enc); + SOKOL_ASSERT(_sg.wgpu.dev); + SOKOL_ASSERT(_sg.wgpu.render_view_cb || _sg.wgpu.render_view_userdata_cb); + SOKOL_ASSERT(_sg.wgpu.resolve_view_cb || _sg.wgpu.resolve_view_userdata_cb); + SOKOL_ASSERT(_sg.wgpu.depth_stencil_view_cb || _sg.wgpu.depth_stencil_view_userdata_cb); + _sg.wgpu.in_pass = true; + _sg.wgpu.cur_width = w; + _sg.wgpu.cur_height = h; + _sg.wgpu.cur_pipeline = 0; + _sg.wgpu.cur_pipeline_id.id = SG_INVALID_ID; + + SOKOL_ASSERT(_sg.wgpu.render_cmd_enc); + if (pass) { + WGPURenderPassDescriptor wgpu_pass_desc; + memset(&wgpu_pass_desc, 0, sizeof(wgpu_pass_desc)); + WGPURenderPassColorAttachmentDescriptor wgpu_color_att_desc[SG_MAX_COLOR_ATTACHMENTS]; + memset(&wgpu_color_att_desc, 0, sizeof(wgpu_color_att_desc)); + SOKOL_ASSERT(pass->slot.state == SG_RESOURCESTATE_VALID); + for (uint32_t i = 0; i < pass->cmn.num_color_atts; i++) { + const _sg_wgpu_attachment_t* wgpu_att = &pass->wgpu.color_atts[i]; + wgpu_color_att_desc[i].loadOp = _sg_wgpu_load_op(action->colors[i].action); + wgpu_color_att_desc[i].storeOp = WGPUStoreOp_Store; + wgpu_color_att_desc[i].clearColor.r = action->colors[i].value.r; + wgpu_color_att_desc[i].clearColor.g = action->colors[i].value.g; + wgpu_color_att_desc[i].clearColor.b = action->colors[i].value.b; + wgpu_color_att_desc[i].clearColor.a = action->colors[i].value.a; + wgpu_color_att_desc[i].attachment = wgpu_att->render_tex_view; + if (wgpu_att->image->cmn.sample_count > 1) { + wgpu_color_att_desc[i].resolveTarget = wgpu_att->resolve_tex_view; + } + } + wgpu_pass_desc.colorAttachmentCount = pass->cmn.num_color_atts; + wgpu_pass_desc.colorAttachments = &wgpu_color_att_desc[0]; + if (pass->wgpu.ds_att.image) { + WGPURenderPassDepthStencilAttachmentDescriptor wgpu_ds_att_desc; + memset(&wgpu_ds_att_desc, 0, sizeof(wgpu_ds_att_desc)); + wgpu_ds_att_desc.depthLoadOp = _sg_wgpu_load_op(action->depth.action); + wgpu_ds_att_desc.clearDepth = action->depth.value; + wgpu_ds_att_desc.stencilLoadOp = _sg_wgpu_load_op(action->stencil.action); + wgpu_ds_att_desc.clearStencil = action->stencil.value; + wgpu_ds_att_desc.attachment = pass->wgpu.ds_att.render_tex_view; + wgpu_pass_desc.depthStencilAttachment = &wgpu_ds_att_desc; + _sg.wgpu.pass_enc = wgpuCommandEncoderBeginRenderPass(_sg.wgpu.render_cmd_enc, &wgpu_pass_desc); + } + } + else { + /* default render pass */ + WGPUTextureView wgpu_render_view = _sg.wgpu.render_view_cb ? _sg.wgpu.render_view_cb() : _sg.wgpu.render_view_userdata_cb(_sg.wgpu.user_data); + WGPUTextureView wgpu_resolve_view = _sg.wgpu.resolve_view_cb ? _sg.wgpu.resolve_view_cb() : _sg.wgpu.resolve_view_userdata_cb(_sg.wgpu.user_data); + WGPUTextureView wgpu_depth_stencil_view = _sg.wgpu.depth_stencil_view_cb ? _sg.wgpu.depth_stencil_view_cb() : _sg.wgpu.depth_stencil_view_userdata_cb(_sg.wgpu.user_data); + + WGPURenderPassDescriptor pass_desc; + memset(&pass_desc, 0, sizeof(pass_desc)); + WGPURenderPassColorAttachmentDescriptor color_att_desc; + memset(&color_att_desc, 0, sizeof(color_att_desc)); + color_att_desc.loadOp = _sg_wgpu_load_op(action->colors[0].action); + color_att_desc.clearColor.r = action->colors[0].value.r; + color_att_desc.clearColor.g = action->colors[0].value.g; + color_att_desc.clearColor.b = action->colors[0].value.b; + color_att_desc.clearColor.a = action->colors[0].value.a; + color_att_desc.attachment = wgpu_render_view; + color_att_desc.resolveTarget = wgpu_resolve_view; /* null if no MSAA rendering */ + pass_desc.colorAttachmentCount = 1; + pass_desc.colorAttachments = &color_att_desc; + WGPURenderPassDepthStencilAttachmentDescriptor ds_att_desc; + memset(&ds_att_desc, 0, sizeof(ds_att_desc)); + ds_att_desc.attachment = wgpu_depth_stencil_view; + SOKOL_ASSERT(0 != ds_att_desc.attachment); + ds_att_desc.depthLoadOp = _sg_wgpu_load_op(action->depth.action); + ds_att_desc.clearDepth = action->depth.value; + ds_att_desc.stencilLoadOp = _sg_wgpu_load_op(action->stencil.action); + ds_att_desc.clearStencil = action->stencil.value; + pass_desc.depthStencilAttachment = &ds_att_desc; + _sg.wgpu.pass_enc = wgpuCommandEncoderBeginRenderPass(_sg.wgpu.render_cmd_enc, &pass_desc); + } + SOKOL_ASSERT(_sg.wgpu.pass_enc); + + /* initial uniform buffer binding (required even if no uniforms are set in the frame) */ + wgpuRenderPassEncoderSetBindGroup(_sg.wgpu.pass_enc, + 0, /* groupIndex 0 is reserved for uniform buffers */ + _sg.wgpu.ub.bindgroup, + SG_NUM_SHADER_STAGES * SG_MAX_SHADERSTAGE_UBS, + &_sg.wgpu.ub.bind_offsets[0][0]); +} + +_SOKOL_PRIVATE void _sg_wgpu_end_pass(void) { + SOKOL_ASSERT(_sg.wgpu.in_pass); + SOKOL_ASSERT(_sg.wgpu.pass_enc); + _sg.wgpu.in_pass = false; + wgpuRenderPassEncoderEndPass(_sg.wgpu.pass_enc); + wgpuRenderPassEncoderRelease(_sg.wgpu.pass_enc); + _sg.wgpu.pass_enc = 0; +} + +_SOKOL_PRIVATE void _sg_wgpu_commit(void) { + SOKOL_ASSERT(!_sg.wgpu.in_pass); + SOKOL_ASSERT(_sg.wgpu.queue); + SOKOL_ASSERT(_sg.wgpu.render_cmd_enc); + SOKOL_ASSERT(_sg.wgpu.staging_cmd_enc); + + /* finish and submit this frame's work */ + _sg_wgpu_ubpool_flush(); + _sg_wgpu_staging_unmap(); + + WGPUCommandBuffer cmd_bufs[2]; + + WGPUCommandBufferDescriptor cmd_buf_desc; + memset(&cmd_buf_desc, 0, sizeof(cmd_buf_desc)); + cmd_bufs[0] = wgpuCommandEncoderFinish(_sg.wgpu.staging_cmd_enc, &cmd_buf_desc); + SOKOL_ASSERT(cmd_bufs[0]); + wgpuCommandEncoderRelease(_sg.wgpu.staging_cmd_enc); + _sg.wgpu.staging_cmd_enc = 0; + + cmd_bufs[1] = wgpuCommandEncoderFinish(_sg.wgpu.render_cmd_enc, &cmd_buf_desc); + SOKOL_ASSERT(cmd_bufs[1]); + wgpuCommandEncoderRelease(_sg.wgpu.render_cmd_enc); + _sg.wgpu.render_cmd_enc = 0; + + wgpuQueueSubmit(_sg.wgpu.queue, 2, &cmd_bufs[0]); + + wgpuCommandBufferRelease(cmd_bufs[0]); + wgpuCommandBufferRelease(cmd_bufs[1]); + + /* create a new render- and staging-command-encoders for next frame */ + WGPUCommandEncoderDescriptor cmd_enc_desc; + memset(&cmd_enc_desc, 0, sizeof(cmd_enc_desc)); + _sg.wgpu.staging_cmd_enc = wgpuDeviceCreateCommandEncoder(_sg.wgpu.dev, &cmd_enc_desc); + _sg.wgpu.render_cmd_enc = wgpuDeviceCreateCommandEncoder(_sg.wgpu.dev, &cmd_enc_desc); + + /* grab new staging buffers for uniform- and vertex/image-updates */ + _sg_wgpu_ubpool_next_frame(false); + _sg_wgpu_staging_next_frame(false); +} + +_SOKOL_PRIVATE void _sg_wgpu_apply_viewport(int x, int y, int w, int h, bool origin_top_left) { + SOKOL_ASSERT(_sg.wgpu.in_pass); + SOKOL_ASSERT(_sg.wgpu.pass_enc); + float xf = (float) x; + float yf = (float) (origin_top_left ? y : (_sg.wgpu.cur_height - (y + h))); + float wf = (float) w; + float hf = (float) h; + wgpuRenderPassEncoderSetViewport(_sg.wgpu.pass_enc, xf, yf, wf, hf, 0.0f, 1.0f); +} + +_SOKOL_PRIVATE void _sg_wgpu_apply_scissor_rect(int x, int y, int w, int h, bool origin_top_left) { + SOKOL_ASSERT(_sg.wgpu.in_pass); + SOKOL_ASSERT(_sg.wgpu.pass_enc); + SOKOL_ASSERT(_sg.wgpu.in_pass); + SOKOL_ASSERT(_sg.wgpu.pass_enc); + + /* clip against framebuffer rect */ + x = _sg_min(_sg_max(0, x), _sg.wgpu.cur_width-1); + y = _sg_min(_sg_max(0, y), _sg.wgpu.cur_height-1); + if ((x + w) > _sg.wgpu.cur_width) { + w = _sg.wgpu.cur_width - x; + } + if ((y + h) > _sg.wgpu.cur_height) { + h = _sg.wgpu.cur_height - y; + } + w = _sg_max(w, 1); + h = _sg_max(h, 1); + + uint32_t sx = (uint32_t) x; + uint32_t sy = origin_top_left ? y : (_sg.wgpu.cur_height - (y + h)); + uint32_t sw = w; + uint32_t sh = h; + wgpuRenderPassEncoderSetScissorRect(_sg.wgpu.pass_enc, sx, sy, sw, sh); +} + +_SOKOL_PRIVATE void _sg_wgpu_apply_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + SOKOL_ASSERT(pip->wgpu.pip); + SOKOL_ASSERT(_sg.wgpu.in_pass); + SOKOL_ASSERT(_sg.wgpu.pass_enc); + _sg.wgpu.draw_indexed = (pip->cmn.index_type != SG_INDEXTYPE_NONE); + _sg.wgpu.cur_pipeline = pip; + _sg.wgpu.cur_pipeline_id.id = pip->slot.id; + wgpuRenderPassEncoderSetPipeline(_sg.wgpu.pass_enc, pip->wgpu.pip); + wgpuRenderPassEncoderSetBlendColor(_sg.wgpu.pass_enc, (WGPUColor*)&pip->cmn.blend_color); + wgpuRenderPassEncoderSetStencilReference(_sg.wgpu.pass_enc, pip->wgpu.stencil_ref); +} + +_SOKOL_PRIVATE WGPUBindGroup _sg_wgpu_create_images_bindgroup(WGPUBindGroupLayout bgl, _sg_image_t** imgs, int num_imgs) { + SOKOL_ASSERT(_sg.wgpu.dev); + SOKOL_ASSERT(num_imgs <= _SG_WGPU_MAX_SHADERSTAGE_IMAGES); + WGPUBindGroupBinding img_bgb[_SG_WGPU_MAX_SHADERSTAGE_IMAGES * 2]; + memset(&img_bgb, 0, sizeof(img_bgb)); + for (int img_index = 0; img_index < num_imgs; img_index++) { + WGPUBindGroupBinding* tex_bdg = &img_bgb[img_index*2 + 0]; + WGPUBindGroupBinding* smp_bdg = &img_bgb[img_index*2 + 1]; + tex_bdg->binding = img_index; + tex_bdg->textureView = imgs[img_index]->wgpu.tex_view; + smp_bdg->binding = img_index + _SG_WGPU_MAX_SHADERSTAGE_IMAGES; + smp_bdg->sampler = imgs[img_index]->wgpu.sampler; + } + WGPUBindGroupDescriptor bg_desc; + memset(&bg_desc, 0, sizeof(bg_desc)); + bg_desc.layout = bgl; + bg_desc.bindingCount = 2 * num_imgs; + bg_desc.bindings = &img_bgb[0]; + WGPUBindGroup bg = wgpuDeviceCreateBindGroup(_sg.wgpu.dev, &bg_desc); + SOKOL_ASSERT(bg); + return bg; +} + +_SOKOL_PRIVATE void _sg_wgpu_apply_bindings( + _sg_pipeline_t* pip, + _sg_buffer_t** vbs, const int* vb_offsets, int num_vbs, + _sg_buffer_t* ib, int ib_offset, + _sg_image_t** vs_imgs, int num_vs_imgs, + _sg_image_t** fs_imgs, int num_fs_imgs) +{ + SOKOL_ASSERT(_sg.wgpu.in_pass); + SOKOL_ASSERT(_sg.wgpu.pass_enc); + SOKOL_ASSERT(pip->shader && (pip->cmn.shader_id.id == pip->shader->slot.id)); + + /* index buffer */ + if (ib) { + wgpuRenderPassEncoderSetIndexBuffer(_sg.wgpu.pass_enc, ib->wgpu.buf, ib_offset); + } + + /* vertex buffers */ + for (uint32_t slot = 0; slot < (uint32_t)num_vbs; slot++) { + wgpuRenderPassEncoderSetVertexBuffer(_sg.wgpu.pass_enc, slot, vbs[slot]->wgpu.buf, (uint64_t)vb_offsets[slot]); + } + + /* need to create throw-away bind groups for images */ + if (num_vs_imgs > 0) { + if (num_vs_imgs > _SG_WGPU_MAX_SHADERSTAGE_IMAGES) { + num_vs_imgs = _SG_WGPU_MAX_SHADERSTAGE_IMAGES; + } + WGPUBindGroupLayout vs_bgl = pip->shader->wgpu.stage[SG_SHADERSTAGE_VS].bind_group_layout; + SOKOL_ASSERT(vs_bgl); + WGPUBindGroup vs_img_bg = _sg_wgpu_create_images_bindgroup(vs_bgl, vs_imgs, num_vs_imgs); + wgpuRenderPassEncoderSetBindGroup(_sg.wgpu.pass_enc, 1, vs_img_bg, 0, 0); + wgpuBindGroupRelease(vs_img_bg); + } + else { + wgpuRenderPassEncoderSetBindGroup(_sg.wgpu.pass_enc, 1, _sg.wgpu.empty_bind_group, 0, 0); + } + if (num_fs_imgs > 0) { + if (num_fs_imgs > _SG_WGPU_MAX_SHADERSTAGE_IMAGES) { + num_fs_imgs = _SG_WGPU_MAX_SHADERSTAGE_IMAGES; + } + WGPUBindGroupLayout fs_bgl = pip->shader->wgpu.stage[SG_SHADERSTAGE_FS].bind_group_layout; + SOKOL_ASSERT(fs_bgl); + WGPUBindGroup fs_img_bg = _sg_wgpu_create_images_bindgroup(fs_bgl, fs_imgs, num_fs_imgs); + wgpuRenderPassEncoderSetBindGroup(_sg.wgpu.pass_enc, 2, fs_img_bg, 0, 0); + wgpuBindGroupRelease(fs_img_bg); + } + else { + wgpuRenderPassEncoderSetBindGroup(_sg.wgpu.pass_enc, 2, _sg.wgpu.empty_bind_group, 0, 0); + } +} + +_SOKOL_PRIVATE void _sg_wgpu_apply_uniforms(sg_shader_stage stage_index, int ub_index, const sg_range* data) { + SOKOL_ASSERT(_sg.wgpu.in_pass); + SOKOL_ASSERT(_sg.wgpu.pass_enc); + SOKOL_ASSERT((_sg.wgpu.ub.offset + data->size) <= _sg.wgpu.ub.num_bytes); + SOKOL_ASSERT((_sg.wgpu.ub.offset & (_SG_WGPU_STAGING_ALIGN-1)) == 0); + SOKOL_ASSERT(_sg.wgpu.cur_pipeline && _sg.wgpu.cur_pipeline->shader); + SOKOL_ASSERT(_sg.wgpu.cur_pipeline->slot.id == _sg.wgpu.cur_pipeline_id.id); + SOKOL_ASSERT(_sg.wgpu.cur_pipeline->shader->slot.id == _sg.wgpu.cur_pipeline->cmn.shader_id.id); + SOKOL_ASSERT(ub_index < _sg.wgpu.cur_pipeline->shader->cmn.stage[stage_index].num_uniform_blocks); + SOKOL_ASSERT(data->size <= _sg.wgpu.cur_pipeline->shader->cmn.stage[stage_index].uniform_blocks[ub_index].size); + SOKOL_ASSERT(data->size <= _SG_WGPU_MAX_UNIFORM_UPDATE_SIZE); + SOKOL_ASSERT(0 != _sg.wgpu.ub.stage.ptr[_sg.wgpu.ub.stage.cur]); + + uint8_t* dst_ptr = _sg.wgpu.ub.stage.ptr[_sg.wgpu.ub.stage.cur] + _sg.wgpu.ub.offset; + memcpy(dst_ptr, data->ptr, data->size); + _sg.wgpu.ub.bind_offsets[stage_index][ub_index] = _sg.wgpu.ub.offset; + wgpuRenderPassEncoderSetBindGroup(_sg.wgpu.pass_enc, + 0, /* groupIndex 0 is reserved for uniform buffers */ + _sg.wgpu.ub.bindgroup, + SG_NUM_SHADER_STAGES * SG_MAX_SHADERSTAGE_UBS, + &_sg.wgpu.ub.bind_offsets[0][0]); + _sg.wgpu.ub.offset = _sg_roundup(_sg.wgpu.ub.offset + data->size, _SG_WGPU_STAGING_ALIGN); +} + +_SOKOL_PRIVATE void _sg_wgpu_draw(int base_element, int num_elements, int num_instances) { + SOKOL_ASSERT(_sg.wgpu.in_pass); + SOKOL_ASSERT(_sg.wgpu.pass_enc); + if (_sg.wgpu.draw_indexed) { + wgpuRenderPassEncoderDrawIndexed(_sg.wgpu.pass_enc, num_elements, num_instances, base_element, 0, 0); + } + else { + wgpuRenderPassEncoderDraw(_sg.wgpu.pass_enc, num_elements, num_instances, base_element, 0); + } +} + +_SOKOL_PRIVATE void _sg_wgpu_update_buffer(_sg_buffer_t* buf, const sg_range* data) { + SOKOL_ASSERT(buf && data && data->ptr && (data->size > 0)); + uint32_t copied_num_bytes = _sg_wgpu_staging_copy_to_buffer(buf->wgpu.buf, 0, data->ptr, data->size); + SOKOL_ASSERT(copied_num_bytes > 0); _SOKOL_UNUSED(copied_num_bytes); +} + +_SOKOL_PRIVATE int _sg_wgpu_append_buffer(_sg_buffer_t* buf, const sg_range* data, bool new_frame) { + SOKOL_ASSERT(buf && data && data->ptr && (data->size > 0)); + _SOKOL_UNUSED(new_frame); + uint32_t copied_num_bytes = _sg_wgpu_staging_copy_to_buffer(buf->wgpu.buf, buf->cmn.append_pos, data->ptr, data->size); + SOKOL_ASSERT(copied_num_bytes > 0); _SOKOL_UNUSED(copied_num_bytes); + return (int)copied_num_bytes; +} + +_SOKOL_PRIVATE void _sg_wgpu_update_image(_sg_image_t* img, const sg_image_data* data) { + SOKOL_ASSERT(img && data); + bool success = _sg_wgpu_staging_copy_to_texture(img, data); + SOKOL_ASSERT(success); + _SOKOL_UNUSED(success); +} +#endif + +/*== BACKEND API WRAPPERS ====================================================*/ +static inline void _sg_setup_backend(const sg_desc* desc) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_setup_backend(desc); +#elif defined(SOKOL_METAL) + _sg_mtl_setup_backend(desc); +#elif defined(SOKOL_D3D11) + _sg_d3d11_setup_backend(desc); +#elif defined(SOKOL_WGPU) + _sg_wgpu_setup_backend(desc); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_setup_backend(desc); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_discard_backend(void) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_discard_backend(); +#elif defined(SOKOL_METAL) + _sg_mtl_discard_backend(); +#elif defined(SOKOL_D3D11) + _sg_d3d11_discard_backend(); +#elif defined(SOKOL_WGPU) + _sg_wgpu_discard_backend(); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_discard_backend(); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_reset_state_cache(void) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_reset_state_cache(); +#elif defined(SOKOL_METAL) + _sg_mtl_reset_state_cache(); +#elif defined(SOKOL_D3D11) + _sg_d3d11_reset_state_cache(); +#elif defined(SOKOL_WGPU) + _sg_wgpu_reset_state_cache(); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_reset_state_cache(); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_activate_context(_sg_context_t* ctx) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_activate_context(ctx); +#elif defined(SOKOL_METAL) + _sg_mtl_activate_context(ctx); +#elif defined(SOKOL_D3D11) + _sg_d3d11_activate_context(ctx); +#elif defined(SOKOL_WGPU) + _sg_wgpu_activate_context(ctx); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_activate_context(ctx); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline sg_resource_state _sg_create_context(_sg_context_t* ctx) { +#if defined(_SOKOL_ANY_GL) + return _sg_gl_create_context(ctx); +#elif defined(SOKOL_METAL) + return _sg_mtl_create_context(ctx); +#elif defined(SOKOL_D3D11) + return _sg_d3d11_create_context(ctx); +#elif defined(SOKOL_WGPU) + return _sg_wgpu_create_context(ctx); +#elif defined(SOKOL_DUMMY_BACKEND) + return _sg_dummy_create_context(ctx); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_destroy_context(_sg_context_t* ctx) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_destroy_context(ctx); +#elif defined(SOKOL_METAL) + _sg_mtl_destroy_context(ctx); +#elif defined(SOKOL_D3D11) + _sg_d3d11_destroy_context(ctx); +#elif defined(SOKOL_WGPU) + _sg_wgpu_destroy_context(ctx); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_destroy_context(ctx); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline sg_resource_state _sg_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) { +#if defined(_SOKOL_ANY_GL) + return _sg_gl_create_buffer(buf, desc); +#elif defined(SOKOL_METAL) + return _sg_mtl_create_buffer(buf, desc); +#elif defined(SOKOL_D3D11) + return _sg_d3d11_create_buffer(buf, desc); +#elif defined(SOKOL_WGPU) + return _sg_wgpu_create_buffer(buf, desc); +#elif defined(SOKOL_DUMMY_BACKEND) + return _sg_dummy_create_buffer(buf, desc); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_destroy_buffer(_sg_buffer_t* buf) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_destroy_buffer(buf); +#elif defined(SOKOL_METAL) + _sg_mtl_destroy_buffer(buf); +#elif defined(SOKOL_D3D11) + _sg_d3d11_destroy_buffer(buf); +#elif defined(SOKOL_WGPU) + _sg_wgpu_destroy_buffer(buf); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_destroy_buffer(buf); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline sg_resource_state _sg_create_image(_sg_image_t* img, const sg_image_desc* desc) { +#if defined(_SOKOL_ANY_GL) + return _sg_gl_create_image(img, desc); +#elif defined(SOKOL_METAL) + return _sg_mtl_create_image(img, desc); +#elif defined(SOKOL_D3D11) + return _sg_d3d11_create_image(img, desc); +#elif defined(SOKOL_WGPU) + return _sg_wgpu_create_image(img, desc); +#elif defined(SOKOL_DUMMY_BACKEND) + return _sg_dummy_create_image(img, desc); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_destroy_image(_sg_image_t* img) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_destroy_image(img); +#elif defined(SOKOL_METAL) + _sg_mtl_destroy_image(img); +#elif defined(SOKOL_D3D11) + _sg_d3d11_destroy_image(img); +#elif defined(SOKOL_WGPU) + _sg_wgpu_destroy_image(img); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_destroy_image(img); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline sg_resource_state _sg_create_shader(_sg_shader_t* shd, const sg_shader_desc* desc) { +#if defined(_SOKOL_ANY_GL) + return _sg_gl_create_shader(shd, desc); +#elif defined(SOKOL_METAL) + return _sg_mtl_create_shader(shd, desc); +#elif defined(SOKOL_D3D11) + return _sg_d3d11_create_shader(shd, desc); +#elif defined(SOKOL_WGPU) + return _sg_wgpu_create_shader(shd, desc); +#elif defined(SOKOL_DUMMY_BACKEND) + return _sg_dummy_create_shader(shd, desc); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_destroy_shader(_sg_shader_t* shd) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_destroy_shader(shd); +#elif defined(SOKOL_METAL) + _sg_mtl_destroy_shader(shd); +#elif defined(SOKOL_D3D11) + _sg_d3d11_destroy_shader(shd); +#elif defined(SOKOL_WGPU) + _sg_wgpu_destroy_shader(shd); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_destroy_shader(shd); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline sg_resource_state _sg_create_pipeline(_sg_pipeline_t* pip, _sg_shader_t* shd, const sg_pipeline_desc* desc) { +#if defined(_SOKOL_ANY_GL) + return _sg_gl_create_pipeline(pip, shd, desc); +#elif defined(SOKOL_METAL) + return _sg_mtl_create_pipeline(pip, shd, desc); +#elif defined(SOKOL_D3D11) + return _sg_d3d11_create_pipeline(pip, shd, desc); +#elif defined(SOKOL_WGPU) + return _sg_wgpu_create_pipeline(pip, shd, desc); +#elif defined(SOKOL_DUMMY_BACKEND) + return _sg_dummy_create_pipeline(pip, shd, desc); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_destroy_pipeline(_sg_pipeline_t* pip) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_destroy_pipeline(pip); +#elif defined(SOKOL_METAL) + _sg_mtl_destroy_pipeline(pip); +#elif defined(SOKOL_D3D11) + _sg_d3d11_destroy_pipeline(pip); +#elif defined(SOKOL_WGPU) + _sg_wgpu_destroy_pipeline(pip); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_destroy_pipeline(pip); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline sg_resource_state _sg_create_pass(_sg_pass_t* pass, _sg_image_t** att_images, const sg_pass_desc* desc) { +#if defined(_SOKOL_ANY_GL) + return _sg_gl_create_pass(pass, att_images, desc); +#elif defined(SOKOL_METAL) + return _sg_mtl_create_pass(pass, att_images, desc); +#elif defined(SOKOL_D3D11) + return _sg_d3d11_create_pass(pass, att_images, desc); +#elif defined(SOKOL_WGPU) + return _sg_wgpu_create_pass(pass, att_images, desc); +#elif defined(SOKOL_DUMMY_BACKEND) + return _sg_dummy_create_pass(pass, att_images, desc); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_destroy_pass(_sg_pass_t* pass) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_destroy_pass(pass); +#elif defined(SOKOL_METAL) + _sg_mtl_destroy_pass(pass); +#elif defined(SOKOL_D3D11) + _sg_d3d11_destroy_pass(pass); +#elif defined(SOKOL_WGPU) + return _sg_wgpu_destroy_pass(pass); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_destroy_pass(pass); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline _sg_image_t* _sg_pass_color_image(const _sg_pass_t* pass, int index) { +#if defined(_SOKOL_ANY_GL) + return _sg_gl_pass_color_image(pass, index); +#elif defined(SOKOL_METAL) + return _sg_mtl_pass_color_image(pass, index); +#elif defined(SOKOL_D3D11) + return _sg_d3d11_pass_color_image(pass, index); +#elif defined(SOKOL_WGPU) + return _sg_wgpu_pass_color_image(pass, index); +#elif defined(SOKOL_DUMMY_BACKEND) + return _sg_dummy_pass_color_image(pass, index); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline _sg_image_t* _sg_pass_ds_image(const _sg_pass_t* pass) { +#if defined(_SOKOL_ANY_GL) + return _sg_gl_pass_ds_image(pass); +#elif defined(SOKOL_METAL) + return _sg_mtl_pass_ds_image(pass); +#elif defined(SOKOL_D3D11) + return _sg_d3d11_pass_ds_image(pass); +#elif defined(SOKOL_WGPU) + return _sg_wgpu_pass_ds_image(pass); +#elif defined(SOKOL_DUMMY_BACKEND) + return _sg_dummy_pass_ds_image(pass); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_begin_pass(_sg_pass_t* pass, const sg_pass_action* action, int w, int h) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_begin_pass(pass, action, w, h); +#elif defined(SOKOL_METAL) + _sg_mtl_begin_pass(pass, action, w, h); +#elif defined(SOKOL_D3D11) + _sg_d3d11_begin_pass(pass, action, w, h); +#elif defined(SOKOL_WGPU) + _sg_wgpu_begin_pass(pass, action, w, h); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_begin_pass(pass, action, w, h); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_end_pass(void) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_end_pass(); +#elif defined(SOKOL_METAL) + _sg_mtl_end_pass(); +#elif defined(SOKOL_D3D11) + _sg_d3d11_end_pass(); +#elif defined(SOKOL_WGPU) + _sg_wgpu_end_pass(); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_end_pass(); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_apply_viewport(int x, int y, int w, int h, bool origin_top_left) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_apply_viewport(x, y, w, h, origin_top_left); +#elif defined(SOKOL_METAL) + _sg_mtl_apply_viewport(x, y, w, h, origin_top_left); +#elif defined(SOKOL_D3D11) + _sg_d3d11_apply_viewport(x, y, w, h, origin_top_left); +#elif defined(SOKOL_WGPU) + _sg_wgpu_apply_viewport(x, y, w, h, origin_top_left); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_apply_viewport(x, y, w, h, origin_top_left); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_apply_scissor_rect(int x, int y, int w, int h, bool origin_top_left) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_apply_scissor_rect(x, y, w, h, origin_top_left); +#elif defined(SOKOL_METAL) + _sg_mtl_apply_scissor_rect(x, y, w, h, origin_top_left); +#elif defined(SOKOL_D3D11) + _sg_d3d11_apply_scissor_rect(x, y, w, h, origin_top_left); +#elif defined(SOKOL_WGPU) + _sg_wgpu_apply_scissor_rect(x, y, w, h, origin_top_left); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_apply_scissor_rect(x, y, w, h, origin_top_left); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_apply_pipeline(_sg_pipeline_t* pip) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_apply_pipeline(pip); +#elif defined(SOKOL_METAL) + _sg_mtl_apply_pipeline(pip); +#elif defined(SOKOL_D3D11) + _sg_d3d11_apply_pipeline(pip); +#elif defined(SOKOL_WGPU) + _sg_wgpu_apply_pipeline(pip); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_apply_pipeline(pip); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_apply_bindings( + _sg_pipeline_t* pip, + _sg_buffer_t** vbs, const int* vb_offsets, int num_vbs, + _sg_buffer_t* ib, int ib_offset, + _sg_image_t** vs_imgs, int num_vs_imgs, + _sg_image_t** fs_imgs, int num_fs_imgs) +{ +#if defined(_SOKOL_ANY_GL) + _sg_gl_apply_bindings(pip, vbs, vb_offsets, num_vbs, ib, ib_offset, vs_imgs, num_vs_imgs, fs_imgs, num_fs_imgs); +#elif defined(SOKOL_METAL) + _sg_mtl_apply_bindings(pip, vbs, vb_offsets, num_vbs, ib, ib_offset, vs_imgs, num_vs_imgs, fs_imgs, num_fs_imgs); +#elif defined(SOKOL_D3D11) + _sg_d3d11_apply_bindings(pip, vbs, vb_offsets, num_vbs, ib, ib_offset, vs_imgs, num_vs_imgs, fs_imgs, num_fs_imgs); +#elif defined(SOKOL_WGPU) + _sg_wgpu_apply_bindings(pip, vbs, vb_offsets, num_vbs, ib, ib_offset, vs_imgs, num_vs_imgs, fs_imgs, num_fs_imgs); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_apply_bindings(pip, vbs, vb_offsets, num_vbs, ib, ib_offset, vs_imgs, num_vs_imgs, fs_imgs, num_fs_imgs); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_apply_uniforms(sg_shader_stage stage_index, int ub_index, const sg_range* data) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_apply_uniforms(stage_index, ub_index, data); +#elif defined(SOKOL_METAL) + _sg_mtl_apply_uniforms(stage_index, ub_index, data); +#elif defined(SOKOL_D3D11) + _sg_d3d11_apply_uniforms(stage_index, ub_index, data); +#elif defined(SOKOL_WGPU) + _sg_wgpu_apply_uniforms(stage_index, ub_index, data); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_apply_uniforms(stage_index, ub_index, data); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_draw(int base_element, int num_elements, int num_instances) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_draw(base_element, num_elements, num_instances); +#elif defined(SOKOL_METAL) + _sg_mtl_draw(base_element, num_elements, num_instances); +#elif defined(SOKOL_D3D11) + _sg_d3d11_draw(base_element, num_elements, num_instances); +#elif defined(SOKOL_WGPU) + _sg_wgpu_draw(base_element, num_elements, num_instances); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_draw(base_element, num_elements, num_instances); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_commit(void) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_commit(); +#elif defined(SOKOL_METAL) + _sg_mtl_commit(); +#elif defined(SOKOL_D3D11) + _sg_d3d11_commit(); +#elif defined(SOKOL_WGPU) + _sg_wgpu_commit(); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_commit(); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_update_buffer(_sg_buffer_t* buf, const sg_range* data) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_update_buffer(buf, data); +#elif defined(SOKOL_METAL) + _sg_mtl_update_buffer(buf, data); +#elif defined(SOKOL_D3D11) + _sg_d3d11_update_buffer(buf, data); +#elif defined(SOKOL_WGPU) + _sg_wgpu_update_buffer(buf, data); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_update_buffer(buf, data); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline int _sg_append_buffer(_sg_buffer_t* buf, const sg_range* data, bool new_frame) { +#if defined(_SOKOL_ANY_GL) + return _sg_gl_append_buffer(buf, data, new_frame); +#elif defined(SOKOL_METAL) + return _sg_mtl_append_buffer(buf, data, new_frame); +#elif defined(SOKOL_D3D11) + return _sg_d3d11_append_buffer(buf, data, new_frame); +#elif defined(SOKOL_WGPU) + return _sg_wgpu_append_buffer(buf, data, new_frame); +#elif defined(SOKOL_DUMMY_BACKEND) + return _sg_dummy_append_buffer(buf, data, new_frame); +#else +#error("INVALID BACKEND"); +#endif +} + +static inline void _sg_update_image(_sg_image_t* img, const sg_image_data* data) { +#if defined(_SOKOL_ANY_GL) + _sg_gl_update_image(img, data); +#elif defined(SOKOL_METAL) + _sg_mtl_update_image(img, data); +#elif defined(SOKOL_D3D11) + _sg_d3d11_update_image(img, data); +#elif defined(SOKOL_WGPU) + _sg_wgpu_update_image(img, data); +#elif defined(SOKOL_DUMMY_BACKEND) + _sg_dummy_update_image(img, data); +#else +#error("INVALID BACKEND"); +#endif +} + +/*== RESOURCE POOLS ==========================================================*/ + +_SOKOL_PRIVATE void _sg_init_pool(_sg_pool_t* pool, int num) { + SOKOL_ASSERT(pool && (num >= 1)); + /* slot 0 is reserved for the 'invalid id', so bump the pool size by 1 */ + pool->size = num + 1; + pool->queue_top = 0; + /* generation counters indexable by pool slot index, slot 0 is reserved */ + size_t gen_ctrs_size = sizeof(uint32_t) * (size_t)pool->size; + pool->gen_ctrs = (uint32_t*) SOKOL_MALLOC(gen_ctrs_size); + SOKOL_ASSERT(pool->gen_ctrs); + memset(pool->gen_ctrs, 0, gen_ctrs_size); + /* it's not a bug to only reserve 'num' here */ + pool->free_queue = (int*) SOKOL_MALLOC(sizeof(int) * (size_t)num); + SOKOL_ASSERT(pool->free_queue); + /* never allocate the zero-th pool item since the invalid id is 0 */ + for (int i = pool->size-1; i >= 1; i--) { + pool->free_queue[pool->queue_top++] = i; + } +} + +_SOKOL_PRIVATE void _sg_discard_pool(_sg_pool_t* pool) { + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + SOKOL_FREE(pool->free_queue); + pool->free_queue = 0; + SOKOL_ASSERT(pool->gen_ctrs); + SOKOL_FREE(pool->gen_ctrs); + pool->gen_ctrs = 0; + pool->size = 0; + pool->queue_top = 0; +} + +_SOKOL_PRIVATE int _sg_pool_alloc_index(_sg_pool_t* pool) { + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + if (pool->queue_top > 0) { + int slot_index = pool->free_queue[--pool->queue_top]; + SOKOL_ASSERT((slot_index > 0) && (slot_index < pool->size)); + return slot_index; + } + else { + /* pool exhausted */ + return _SG_INVALID_SLOT_INDEX; + } +} + +_SOKOL_PRIVATE void _sg_pool_free_index(_sg_pool_t* pool, int slot_index) { + SOKOL_ASSERT((slot_index > _SG_INVALID_SLOT_INDEX) && (slot_index < pool->size)); + SOKOL_ASSERT(pool); + SOKOL_ASSERT(pool->free_queue); + SOKOL_ASSERT(pool->queue_top < pool->size); +#ifdef SOKOL_DEBUG + /* debug check against double-free */ + for (int i = 0; i < pool->queue_top; i++) { + SOKOL_ASSERT(pool->free_queue[i] != slot_index); + } +#endif + pool->free_queue[pool->queue_top++] = slot_index; + SOKOL_ASSERT(pool->queue_top <= (pool->size-1)); +} + +_SOKOL_PRIVATE void _sg_reset_slot(_sg_slot_t* slot) { + SOKOL_ASSERT(slot); + memset(slot, 0, sizeof(_sg_slot_t)); +} + +_SOKOL_PRIVATE void _sg_reset_buffer(_sg_buffer_t* buf) { + SOKOL_ASSERT(buf); + _sg_slot_t slot = buf->slot; + memset(buf, 0, sizeof(_sg_buffer_t)); + buf->slot = slot; + buf->slot.state = SG_RESOURCESTATE_ALLOC; +} + +_SOKOL_PRIVATE void _sg_reset_image(_sg_image_t* img) { + SOKOL_ASSERT(img); + _sg_slot_t slot = img->slot; + memset(img, 0, sizeof(_sg_image_t)); + img->slot = slot; + img->slot.state = SG_RESOURCESTATE_ALLOC; +} + +_SOKOL_PRIVATE void _sg_reset_shader(_sg_shader_t* shd) { + SOKOL_ASSERT(shd); + _sg_slot_t slot = shd->slot; + memset(shd, 0, sizeof(_sg_shader_t)); + shd->slot = slot; + shd->slot.state = SG_RESOURCESTATE_ALLOC; +} + +_SOKOL_PRIVATE void _sg_reset_pipeline(_sg_pipeline_t* pip) { + SOKOL_ASSERT(pip); + _sg_slot_t slot = pip->slot; + memset(pip, 0, sizeof(_sg_pipeline_t)); + pip->slot = slot; + pip->slot.state = SG_RESOURCESTATE_ALLOC; +} + +_SOKOL_PRIVATE void _sg_reset_pass(_sg_pass_t* pass) { + SOKOL_ASSERT(pass); + _sg_slot_t slot = pass->slot; + memset(pass, 0, sizeof(_sg_pass_t)); + pass->slot = slot; + pass->slot.state = SG_RESOURCESTATE_ALLOC; +} + +_SOKOL_PRIVATE void _sg_reset_context(_sg_context_t* ctx) { + SOKOL_ASSERT(ctx); + _sg_slot_t slot = ctx->slot; + memset(ctx, 0, sizeof(_sg_context_t)); + ctx->slot = slot; + ctx->slot.state = SG_RESOURCESTATE_ALLOC; +} + +_SOKOL_PRIVATE void _sg_setup_pools(_sg_pools_t* p, const sg_desc* desc) { + SOKOL_ASSERT(p); + SOKOL_ASSERT(desc); + /* note: the pools here will have an additional item, since slot 0 is reserved */ + SOKOL_ASSERT((desc->buffer_pool_size > 0) && (desc->buffer_pool_size < _SG_MAX_POOL_SIZE)); + _sg_init_pool(&p->buffer_pool, desc->buffer_pool_size); + size_t buffer_pool_byte_size = sizeof(_sg_buffer_t) * (size_t)p->buffer_pool.size; + p->buffers = (_sg_buffer_t*) SOKOL_MALLOC(buffer_pool_byte_size); + SOKOL_ASSERT(p->buffers); + memset(p->buffers, 0, buffer_pool_byte_size); + + SOKOL_ASSERT((desc->image_pool_size > 0) && (desc->image_pool_size < _SG_MAX_POOL_SIZE)); + _sg_init_pool(&p->image_pool, desc->image_pool_size); + size_t image_pool_byte_size = sizeof(_sg_image_t) * (size_t)p->image_pool.size; + p->images = (_sg_image_t*) SOKOL_MALLOC(image_pool_byte_size); + SOKOL_ASSERT(p->images); + memset(p->images, 0, image_pool_byte_size); + + SOKOL_ASSERT((desc->shader_pool_size > 0) && (desc->shader_pool_size < _SG_MAX_POOL_SIZE)); + _sg_init_pool(&p->shader_pool, desc->shader_pool_size); + size_t shader_pool_byte_size = sizeof(_sg_shader_t) * (size_t)p->shader_pool.size; + p->shaders = (_sg_shader_t*) SOKOL_MALLOC(shader_pool_byte_size); + SOKOL_ASSERT(p->shaders); + memset(p->shaders, 0, shader_pool_byte_size); + + SOKOL_ASSERT((desc->pipeline_pool_size > 0) && (desc->pipeline_pool_size < _SG_MAX_POOL_SIZE)); + _sg_init_pool(&p->pipeline_pool, desc->pipeline_pool_size); + size_t pipeline_pool_byte_size = sizeof(_sg_pipeline_t) * (size_t)p->pipeline_pool.size; + p->pipelines = (_sg_pipeline_t*) SOKOL_MALLOC(pipeline_pool_byte_size); + SOKOL_ASSERT(p->pipelines); + memset(p->pipelines, 0, pipeline_pool_byte_size); + + SOKOL_ASSERT((desc->pass_pool_size > 0) && (desc->pass_pool_size < _SG_MAX_POOL_SIZE)); + _sg_init_pool(&p->pass_pool, desc->pass_pool_size); + size_t pass_pool_byte_size = sizeof(_sg_pass_t) * (size_t)p->pass_pool.size; + p->passes = (_sg_pass_t*) SOKOL_MALLOC(pass_pool_byte_size); + SOKOL_ASSERT(p->passes); + memset(p->passes, 0, pass_pool_byte_size); + + SOKOL_ASSERT((desc->context_pool_size > 0) && (desc->context_pool_size < _SG_MAX_POOL_SIZE)); + _sg_init_pool(&p->context_pool, desc->context_pool_size); + size_t context_pool_byte_size = sizeof(_sg_context_t) * (size_t)p->context_pool.size; + p->contexts = (_sg_context_t*) SOKOL_MALLOC(context_pool_byte_size); + SOKOL_ASSERT(p->contexts); + memset(p->contexts, 0, context_pool_byte_size); +} + +_SOKOL_PRIVATE void _sg_discard_pools(_sg_pools_t* p) { + SOKOL_ASSERT(p); + SOKOL_FREE(p->contexts); p->contexts = 0; + SOKOL_FREE(p->passes); p->passes = 0; + SOKOL_FREE(p->pipelines); p->pipelines = 0; + SOKOL_FREE(p->shaders); p->shaders = 0; + SOKOL_FREE(p->images); p->images = 0; + SOKOL_FREE(p->buffers); p->buffers = 0; + _sg_discard_pool(&p->context_pool); + _sg_discard_pool(&p->pass_pool); + _sg_discard_pool(&p->pipeline_pool); + _sg_discard_pool(&p->shader_pool); + _sg_discard_pool(&p->image_pool); + _sg_discard_pool(&p->buffer_pool); +} + +/* allocate the slot at slot_index: + - bump the slot's generation counter + - create a resource id from the generation counter and slot index + - set the slot's id to this id + - set the slot's state to ALLOC + - return the resource id +*/ +_SOKOL_PRIVATE uint32_t _sg_slot_alloc(_sg_pool_t* pool, _sg_slot_t* slot, int slot_index) { + /* FIXME: add handling for an overflowing generation counter, + for now, just overflow (another option is to disable + the slot) + */ + SOKOL_ASSERT(pool && pool->gen_ctrs); + SOKOL_ASSERT((slot_index > _SG_INVALID_SLOT_INDEX) && (slot_index < pool->size)); + SOKOL_ASSERT((slot->state == SG_RESOURCESTATE_INITIAL) && (slot->id == SG_INVALID_ID)); + uint32_t ctr = ++pool->gen_ctrs[slot_index]; + slot->id = (ctr<<_SG_SLOT_SHIFT)|(slot_index & _SG_SLOT_MASK); + slot->state = SG_RESOURCESTATE_ALLOC; + return slot->id; +} + +/* extract slot index from id */ +_SOKOL_PRIVATE int _sg_slot_index(uint32_t id) { + int slot_index = (int) (id & _SG_SLOT_MASK); + SOKOL_ASSERT(_SG_INVALID_SLOT_INDEX != slot_index); + return slot_index; +} + +/* returns pointer to resource by id without matching id check */ +_SOKOL_PRIVATE _sg_buffer_t* _sg_buffer_at(const _sg_pools_t* p, uint32_t buf_id) { + SOKOL_ASSERT(p && (SG_INVALID_ID != buf_id)); + int slot_index = _sg_slot_index(buf_id); + SOKOL_ASSERT((slot_index > _SG_INVALID_SLOT_INDEX) && (slot_index < p->buffer_pool.size)); + return &p->buffers[slot_index]; +} + +_SOKOL_PRIVATE _sg_image_t* _sg_image_at(const _sg_pools_t* p, uint32_t img_id) { + SOKOL_ASSERT(p && (SG_INVALID_ID != img_id)); + int slot_index = _sg_slot_index(img_id); + SOKOL_ASSERT((slot_index > _SG_INVALID_SLOT_INDEX) && (slot_index < p->image_pool.size)); + return &p->images[slot_index]; +} + +_SOKOL_PRIVATE _sg_shader_t* _sg_shader_at(const _sg_pools_t* p, uint32_t shd_id) { + SOKOL_ASSERT(p && (SG_INVALID_ID != shd_id)); + int slot_index = _sg_slot_index(shd_id); + SOKOL_ASSERT((slot_index > _SG_INVALID_SLOT_INDEX) && (slot_index < p->shader_pool.size)); + return &p->shaders[slot_index]; +} + +_SOKOL_PRIVATE _sg_pipeline_t* _sg_pipeline_at(const _sg_pools_t* p, uint32_t pip_id) { + SOKOL_ASSERT(p && (SG_INVALID_ID != pip_id)); + int slot_index = _sg_slot_index(pip_id); + SOKOL_ASSERT((slot_index > _SG_INVALID_SLOT_INDEX) && (slot_index < p->pipeline_pool.size)); + return &p->pipelines[slot_index]; +} + +_SOKOL_PRIVATE _sg_pass_t* _sg_pass_at(const _sg_pools_t* p, uint32_t pass_id) { + SOKOL_ASSERT(p && (SG_INVALID_ID != pass_id)); + int slot_index = _sg_slot_index(pass_id); + SOKOL_ASSERT((slot_index > _SG_INVALID_SLOT_INDEX) && (slot_index < p->pass_pool.size)); + return &p->passes[slot_index]; +} + +_SOKOL_PRIVATE _sg_context_t* _sg_context_at(const _sg_pools_t* p, uint32_t context_id) { + SOKOL_ASSERT(p && (SG_INVALID_ID != context_id)); + int slot_index = _sg_slot_index(context_id); + SOKOL_ASSERT((slot_index > _SG_INVALID_SLOT_INDEX) && (slot_index < p->context_pool.size)); + return &p->contexts[slot_index]; +} + +/* returns pointer to resource with matching id check, may return 0 */ +_SOKOL_PRIVATE _sg_buffer_t* _sg_lookup_buffer(const _sg_pools_t* p, uint32_t buf_id) { + if (SG_INVALID_ID != buf_id) { + _sg_buffer_t* buf = _sg_buffer_at(p, buf_id); + if (buf->slot.id == buf_id) { + return buf; + } + } + return 0; +} + +_SOKOL_PRIVATE _sg_image_t* _sg_lookup_image(const _sg_pools_t* p, uint32_t img_id) { + if (SG_INVALID_ID != img_id) { + _sg_image_t* img = _sg_image_at(p, img_id); + if (img->slot.id == img_id) { + return img; + } + } + return 0; +} + +_SOKOL_PRIVATE _sg_shader_t* _sg_lookup_shader(const _sg_pools_t* p, uint32_t shd_id) { + SOKOL_ASSERT(p); + if (SG_INVALID_ID != shd_id) { + _sg_shader_t* shd = _sg_shader_at(p, shd_id); + if (shd->slot.id == shd_id) { + return shd; + } + } + return 0; +} + +_SOKOL_PRIVATE _sg_pipeline_t* _sg_lookup_pipeline(const _sg_pools_t* p, uint32_t pip_id) { + SOKOL_ASSERT(p); + if (SG_INVALID_ID != pip_id) { + _sg_pipeline_t* pip = _sg_pipeline_at(p, pip_id); + if (pip->slot.id == pip_id) { + return pip; + } + } + return 0; +} + +_SOKOL_PRIVATE _sg_pass_t* _sg_lookup_pass(const _sg_pools_t* p, uint32_t pass_id) { + SOKOL_ASSERT(p); + if (SG_INVALID_ID != pass_id) { + _sg_pass_t* pass = _sg_pass_at(p, pass_id); + if (pass->slot.id == pass_id) { + return pass; + } + } + return 0; +} + +_SOKOL_PRIVATE _sg_context_t* _sg_lookup_context(const _sg_pools_t* p, uint32_t ctx_id) { + SOKOL_ASSERT(p); + if (SG_INVALID_ID != ctx_id) { + _sg_context_t* ctx = _sg_context_at(p, ctx_id); + if (ctx->slot.id == ctx_id) { + return ctx; + } + } + return 0; +} + +_SOKOL_PRIVATE void _sg_destroy_all_resources(_sg_pools_t* p, uint32_t ctx_id) { + /* this is a bit dumb since it loops over all pool slots to + find the occupied slots, on the other hand it is only ever + executed at shutdown + NOTE: ONLY EXECUTE THIS AT SHUTDOWN + ...because the free queues will not be reset + and the resource slots not be cleared! + */ + for (int i = 1; i < p->buffer_pool.size; i++) { + if (p->buffers[i].slot.ctx_id == ctx_id) { + sg_resource_state state = p->buffers[i].slot.state; + if ((state == SG_RESOURCESTATE_VALID) || (state == SG_RESOURCESTATE_FAILED)) { + _sg_destroy_buffer(&p->buffers[i]); + } + } + } + for (int i = 1; i < p->image_pool.size; i++) { + if (p->images[i].slot.ctx_id == ctx_id) { + sg_resource_state state = p->images[i].slot.state; + if ((state == SG_RESOURCESTATE_VALID) || (state == SG_RESOURCESTATE_FAILED)) { + _sg_destroy_image(&p->images[i]); + } + } + } + for (int i = 1; i < p->shader_pool.size; i++) { + if (p->shaders[i].slot.ctx_id == ctx_id) { + sg_resource_state state = p->shaders[i].slot.state; + if ((state == SG_RESOURCESTATE_VALID) || (state == SG_RESOURCESTATE_FAILED)) { + _sg_destroy_shader(&p->shaders[i]); + } + } + } + for (int i = 1; i < p->pipeline_pool.size; i++) { + if (p->pipelines[i].slot.ctx_id == ctx_id) { + sg_resource_state state = p->pipelines[i].slot.state; + if ((state == SG_RESOURCESTATE_VALID) || (state == SG_RESOURCESTATE_FAILED)) { + _sg_destroy_pipeline(&p->pipelines[i]); + } + } + } + for (int i = 1; i < p->pass_pool.size; i++) { + if (p->passes[i].slot.ctx_id == ctx_id) { + sg_resource_state state = p->passes[i].slot.state; + if ((state == SG_RESOURCESTATE_VALID) || (state == SG_RESOURCESTATE_FAILED)) { + _sg_destroy_pass(&p->passes[i]); + } + } + } +} + +/*== VALIDATION LAYER ========================================================*/ +#if defined(SOKOL_DEBUG) +/* return a human readable string for an _sg_validate_error */ +_SOKOL_PRIVATE const char* _sg_validate_string(_sg_validate_error_t err) { + switch (err) { + /* buffer creation validation errors */ + case _SG_VALIDATE_BUFFERDESC_CANARY: return "sg_buffer_desc not initialized"; + case _SG_VALIDATE_BUFFERDESC_SIZE: return "sg_buffer_desc.size cannot be 0"; + case _SG_VALIDATE_BUFFERDESC_DATA: return "immutable buffers must be initialized with data (sg_buffer_desc.data.ptr and sg_buffer_desc.data.size)"; + case _SG_VALIDATE_BUFFERDESC_DATA_SIZE: return "immutable buffer data size differs from buffer size"; + case _SG_VALIDATE_BUFFERDESC_NO_DATA: return "dynamic/stream usage buffers cannot be initialized with data"; + + /* image data (in image creation and updating) */ + case _SG_VALIDATE_IMAGEDATA_NODATA: return "sg_image_data: no data (.ptr and/or .size is zero)"; + case _SG_VALIDATE_IMAGEDATA_DATA_SIZE: return "sg_image_data: data size doesn't match expected surface size"; + + /* image creation validation errros */ + case _SG_VALIDATE_IMAGEDESC_CANARY: return "sg_image_desc not initialized"; + case _SG_VALIDATE_IMAGEDESC_WIDTH: return "sg_image_desc.width must be > 0"; + case _SG_VALIDATE_IMAGEDESC_HEIGHT: return "sg_image_desc.height must be > 0"; + case _SG_VALIDATE_IMAGEDESC_RT_PIXELFORMAT: return "invalid pixel format for render-target image"; + case _SG_VALIDATE_IMAGEDESC_NONRT_PIXELFORMAT: return "invalid pixel format for non-render-target image"; + case _SG_VALIDATE_IMAGEDESC_MSAA_BUT_NO_RT: return "non-render-target images cannot be multisampled"; + case _SG_VALIDATE_IMAGEDESC_NO_MSAA_RT_SUPPORT: return "MSAA not supported for this pixel format"; + case _SG_VALIDATE_IMAGEDESC_RT_IMMUTABLE: return "render target images must be SG_USAGE_IMMUTABLE"; + case _SG_VALIDATE_IMAGEDESC_RT_NO_DATA: return "render target images cannot be initialized with data"; + case _SG_VALIDATE_IMAGEDESC_INJECTED_NO_DATA: return "images with injected textures cannot be initialized with data"; + case _SG_VALIDATE_IMAGEDESC_DYNAMIC_NO_DATA: return "dynamic/stream images cannot be initialized with data"; + case _SG_VALIDATE_IMAGEDESC_COMPRESSED_IMMUTABLE: return "compressed images must be immutable"; + + /* shader creation */ + case _SG_VALIDATE_SHADERDESC_CANARY: return "sg_shader_desc not initialized"; + case _SG_VALIDATE_SHADERDESC_SOURCE: return "shader source code required"; + case _SG_VALIDATE_SHADERDESC_BYTECODE: return "shader byte code required"; + case _SG_VALIDATE_SHADERDESC_SOURCE_OR_BYTECODE: return "shader source or byte code required"; + case _SG_VALIDATE_SHADERDESC_NO_BYTECODE_SIZE: return "shader byte code length (in bytes) required"; + case _SG_VALIDATE_SHADERDESC_NO_CONT_UBS: return "shader uniform blocks must occupy continuous slots"; + case _SG_VALIDATE_SHADERDESC_NO_CONT_UB_MEMBERS: return "uniform block members must occupy continuous slots"; + case _SG_VALIDATE_SHADERDESC_NO_UB_MEMBERS: return "GL backend requires uniform block member declarations"; + case _SG_VALIDATE_SHADERDESC_UB_MEMBER_NAME: return "uniform block member name missing"; + case _SG_VALIDATE_SHADERDESC_UB_SIZE_MISMATCH: return "size of uniform block members doesn't match uniform block size"; + case _SG_VALIDATE_SHADERDESC_UB_ARRAY_COUNT: return "uniform array count must be >= 1"; + case _SG_VALIDATE_SHADERDESC_UB_STD140_ARRAY_TYPE: return "uniform arrays only allowed for FLOAT4, INT4, MAT4 in std140 layout"; + + case _SG_VALIDATE_SHADERDESC_NO_CONT_IMGS: return "shader images must occupy continuous slots"; + case _SG_VALIDATE_SHADERDESC_IMG_NAME: return "GL backend requires uniform block member names"; + case _SG_VALIDATE_SHADERDESC_ATTR_NAMES: return "GLES2 backend requires vertex attribute names"; + case _SG_VALIDATE_SHADERDESC_ATTR_SEMANTICS: return "D3D11 backend requires vertex attribute semantics"; + case _SG_VALIDATE_SHADERDESC_ATTR_STRING_TOO_LONG: return "vertex attribute name/semantic string too long (max len 16)"; + + /* pipeline creation */ + case _SG_VALIDATE_PIPELINEDESC_CANARY: return "sg_pipeline_desc not initialized"; + case _SG_VALIDATE_PIPELINEDESC_SHADER: return "sg_pipeline_desc.shader missing or invalid"; + case _SG_VALIDATE_PIPELINEDESC_NO_ATTRS: return "sg_pipeline_desc.layout.attrs is empty or not continuous"; + case _SG_VALIDATE_PIPELINEDESC_LAYOUT_STRIDE4: return "sg_pipeline_desc.layout.buffers[].stride must be multiple of 4"; + case _SG_VALIDATE_PIPELINEDESC_ATTR_NAME: return "GLES2/WebGL missing vertex attribute name in shader"; + case _SG_VALIDATE_PIPELINEDESC_ATTR_SEMANTICS: return "D3D11 missing vertex attribute semantics in shader"; + + /* pass creation */ + case _SG_VALIDATE_PASSDESC_CANARY: return "sg_pass_desc not initialized"; + case _SG_VALIDATE_PASSDESC_NO_COLOR_ATTS: return "sg_pass_desc.color_attachments[0] must be valid"; + case _SG_VALIDATE_PASSDESC_NO_CONT_COLOR_ATTS: return "color attachments must occupy continuous slots"; + case _SG_VALIDATE_PASSDESC_IMAGE: return "pass attachment image is not valid"; + case _SG_VALIDATE_PASSDESC_MIPLEVEL: return "pass attachment mip level is bigger than image has mipmaps"; + case _SG_VALIDATE_PASSDESC_FACE: return "pass attachment image is cubemap, but face index is too big"; + case _SG_VALIDATE_PASSDESC_LAYER: return "pass attachment image is array texture, but layer index is too big"; + case _SG_VALIDATE_PASSDESC_SLICE: return "pass attachment image is 3d texture, but slice value is too big"; + case _SG_VALIDATE_PASSDESC_IMAGE_NO_RT: return "pass attachment image must be render targets"; + case _SG_VALIDATE_PASSDESC_COLOR_INV_PIXELFORMAT: return "pass color-attachment images must have a renderable pixel format"; + case _SG_VALIDATE_PASSDESC_DEPTH_INV_PIXELFORMAT: return "pass depth-attachment image must have depth pixel format"; + case _SG_VALIDATE_PASSDESC_IMAGE_SIZES: return "all pass attachments must have the same size"; + case _SG_VALIDATE_PASSDESC_IMAGE_SAMPLE_COUNTS: return "all pass attachments must have the same sample count"; + + /* sg_begin_pass */ + case _SG_VALIDATE_BEGINPASS_PASS: return "sg_begin_pass: pass must be valid"; + case _SG_VALIDATE_BEGINPASS_IMAGE: return "sg_begin_pass: one or more attachment images are not valid"; + + /* sg_apply_pipeline */ + case _SG_VALIDATE_APIP_PIPELINE_VALID_ID: return "sg_apply_pipeline: invalid pipeline id provided"; + case _SG_VALIDATE_APIP_PIPELINE_EXISTS: return "sg_apply_pipeline: pipeline object no longer alive"; + case _SG_VALIDATE_APIP_PIPELINE_VALID: return "sg_apply_pipeline: pipeline object not in valid state"; + case _SG_VALIDATE_APIP_SHADER_EXISTS: return "sg_apply_pipeline: shader object no longer alive"; + case _SG_VALIDATE_APIP_SHADER_VALID: return "sg_apply_pipeline: shader object not in valid state"; + case _SG_VALIDATE_APIP_ATT_COUNT: return "sg_apply_pipeline: number of pipeline color attachments doesn't match number of pass color attachments"; + case _SG_VALIDATE_APIP_COLOR_FORMAT: return "sg_apply_pipeline: pipeline color attachment pixel format doesn't match pass color attachment pixel format"; + case _SG_VALIDATE_APIP_DEPTH_FORMAT: return "sg_apply_pipeline: pipeline depth pixel_format doesn't match pass depth attachment pixel format"; + case _SG_VALIDATE_APIP_SAMPLE_COUNT: return "sg_apply_pipeline: pipeline MSAA sample count doesn't match render pass attachment sample count"; + + /* sg_apply_bindings */ + case _SG_VALIDATE_ABND_PIPELINE: return "sg_apply_bindings: must be called after sg_apply_pipeline"; + case _SG_VALIDATE_ABND_PIPELINE_EXISTS: return "sg_apply_bindings: currently applied pipeline object no longer alive"; + case _SG_VALIDATE_ABND_PIPELINE_VALID: return "sg_apply_bindings: currently applied pipeline object not in valid state"; + case _SG_VALIDATE_ABND_VBS: return "sg_apply_bindings: number of vertex buffers doesn't match number of pipeline vertex layouts"; + case _SG_VALIDATE_ABND_VB_EXISTS: return "sg_apply_bindings: vertex buffer no longer alive"; + case _SG_VALIDATE_ABND_VB_TYPE: return "sg_apply_bindings: buffer in vertex buffer slot is not a SG_BUFFERTYPE_VERTEXBUFFER"; + case _SG_VALIDATE_ABND_VB_OVERFLOW: return "sg_apply_bindings: buffer in vertex buffer slot is overflown"; + case _SG_VALIDATE_ABND_NO_IB: return "sg_apply_bindings: pipeline object defines indexed rendering, but no index buffer provided"; + case _SG_VALIDATE_ABND_IB: return "sg_apply_bindings: pipeline object defines non-indexed rendering, but index buffer provided"; + case _SG_VALIDATE_ABND_IB_EXISTS: return "sg_apply_bindings: index buffer no longer alive"; + case _SG_VALIDATE_ABND_IB_TYPE: return "sg_apply_bindings: buffer in index buffer slot is not a SG_BUFFERTYPE_INDEXBUFFER"; + case _SG_VALIDATE_ABND_IB_OVERFLOW: return "sg_apply_bindings: buffer in index buffer slot is overflown"; + case _SG_VALIDATE_ABND_VS_IMGS: return "sg_apply_bindings: vertex shader image count doesn't match sg_shader_desc"; + case _SG_VALIDATE_ABND_VS_IMG_EXISTS: return "sg_apply_bindings: vertex shader image no longer alive"; + case _SG_VALIDATE_ABND_VS_IMG_TYPES: return "sg_apply_bindings: one or more vertex shader image types don't match sg_shader_desc"; + case _SG_VALIDATE_ABND_FS_IMGS: return "sg_apply_bindings: fragment shader image count doesn't match sg_shader_desc"; + case _SG_VALIDATE_ABND_FS_IMG_EXISTS: return "sg_apply_bindings: fragment shader image no longer alive"; + case _SG_VALIDATE_ABND_FS_IMG_TYPES: return "sg_apply_bindings: one or more fragment shader image types don't match sg_shader_desc"; + + /* sg_apply_uniforms */ + case _SG_VALIDATE_AUB_NO_PIPELINE: return "sg_apply_uniforms: must be called after sg_apply_pipeline()"; + case _SG_VALIDATE_AUB_NO_UB_AT_SLOT: return "sg_apply_uniforms: no uniform block declaration at this shader stage UB slot"; + case _SG_VALIDATE_AUB_SIZE: return "sg_apply_uniforms: data size exceeds declared uniform block size"; + + /* sg_update_buffer */ + case _SG_VALIDATE_UPDATEBUF_USAGE: return "sg_update_buffer: cannot update immutable buffer"; + case _SG_VALIDATE_UPDATEBUF_SIZE: return "sg_update_buffer: update size is bigger than buffer size"; + case _SG_VALIDATE_UPDATEBUF_ONCE: return "sg_update_buffer: only one update allowed per buffer and frame"; + case _SG_VALIDATE_UPDATEBUF_APPEND: return "sg_update_buffer: cannot call sg_update_buffer and sg_append_buffer in same frame"; + + /* sg_append_buffer */ + case _SG_VALIDATE_APPENDBUF_USAGE: return "sg_append_buffer: cannot append to immutable buffer"; + case _SG_VALIDATE_APPENDBUF_SIZE: return "sg_append_buffer: overall appended size is bigger than buffer size"; + case _SG_VALIDATE_APPENDBUF_UPDATE: return "sg_append_buffer: cannot call sg_append_buffer and sg_update_buffer in same frame"; + + /* sg_update_image */ + case _SG_VALIDATE_UPDIMG_USAGE: return "sg_update_image: cannot update immutable image"; + case _SG_VALIDATE_UPDIMG_ONCE: return "sg_update_image: only one update allowed per image and frame"; + + default: return "unknown validation error"; + } +} +#endif /* defined(SOKOL_DEBUG) */ + +/*-- validation checks -------------------------------------------------------*/ +#if defined(SOKOL_DEBUG) +_SOKOL_PRIVATE void _sg_validate_begin(void) { + _sg.validate_error = _SG_VALIDATE_SUCCESS; +} + +_SOKOL_PRIVATE void _sg_validate(bool cond, _sg_validate_error_t err) { + if (!cond) { + _sg.validate_error = err; + SOKOL_LOG(_sg_validate_string(err)); + } +} + +_SOKOL_PRIVATE bool _sg_validate_end(void) { + if (_sg.validate_error != _SG_VALIDATE_SUCCESS) { +#if !defined(SOKOL_VALIDATE_NON_FATAL) + SOKOL_LOG("^^^^ SOKOL-GFX VALIDATION FAILED, TERMINATING ^^^^"); + SOKOL_ASSERT(false); +#endif + return false; + } + else { + return true; + } +} +#endif + +_SOKOL_PRIVATE bool _sg_validate_buffer_desc(const sg_buffer_desc* desc) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(desc); + return true; +#else + SOKOL_ASSERT(desc); + SOKOL_VALIDATE_BEGIN(); + SOKOL_VALIDATE(desc->_start_canary == 0, _SG_VALIDATE_BUFFERDESC_CANARY); + SOKOL_VALIDATE(desc->_end_canary == 0, _SG_VALIDATE_BUFFERDESC_CANARY); + SOKOL_VALIDATE(desc->size > 0, _SG_VALIDATE_BUFFERDESC_SIZE); + bool injected = (0 != desc->gl_buffers[0]) || + (0 != desc->mtl_buffers[0]) || + (0 != desc->d3d11_buffer) || + (0 != desc->wgpu_buffer); + if (!injected && (desc->usage == SG_USAGE_IMMUTABLE)) { + SOKOL_VALIDATE((0 != desc->data.ptr) && (desc->data.size > 0), _SG_VALIDATE_BUFFERDESC_DATA); + SOKOL_VALIDATE(desc->size == desc->data.size, _SG_VALIDATE_BUFFERDESC_DATA_SIZE); + } + else { + SOKOL_VALIDATE(0 == desc->data.ptr, _SG_VALIDATE_BUFFERDESC_NO_DATA); + } + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE void _sg_validate_image_data(const sg_image_data* data, sg_pixel_format fmt, int width, int height, int num_faces, int num_mips, int num_slices) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(data); + _SOKOL_UNUSED(fmt); + _SOKOL_UNUSED(width); + _SOKOL_UNUSED(height); + _SOKOL_UNUSED(num_faces); + _SOKOL_UNUSED(num_mips); + _SOKOL_UNUSED(num_slices); +#else + for (int face_index = 0; face_index < num_faces; face_index++) { + for (int mip_index = 0; mip_index < num_mips; mip_index++) { + const bool has_data = data->subimage[face_index][mip_index].ptr != 0; + const bool has_size = data->subimage[face_index][mip_index].size > 0; + SOKOL_VALIDATE(has_data && has_size, _SG_VALIDATE_IMAGEDATA_NODATA); + const int mip_width = _sg_max(width >> mip_index, 1); + const int mip_height = _sg_max(height >> mip_index, 1); + const int bytes_per_slice = _sg_surface_pitch(fmt, mip_width, mip_height, 1); + const int expected_size = bytes_per_slice * num_slices; + SOKOL_VALIDATE(expected_size == (int)data->subimage[face_index][mip_index].size, _SG_VALIDATE_IMAGEDATA_DATA_SIZE); + } + } +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_image_desc(const sg_image_desc* desc) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(desc); + return true; +#else + SOKOL_ASSERT(desc); + SOKOL_VALIDATE_BEGIN(); + SOKOL_VALIDATE(desc->_start_canary == 0, _SG_VALIDATE_IMAGEDESC_CANARY); + SOKOL_VALIDATE(desc->_end_canary == 0, _SG_VALIDATE_IMAGEDESC_CANARY); + SOKOL_VALIDATE(desc->width > 0, _SG_VALIDATE_IMAGEDESC_WIDTH); + SOKOL_VALIDATE(desc->height > 0, _SG_VALIDATE_IMAGEDESC_HEIGHT); + const sg_pixel_format fmt = desc->pixel_format; + const sg_usage usage = desc->usage; + const bool injected = (0 != desc->gl_textures[0]) || + (0 != desc->mtl_textures[0]) || + (0 != desc->d3d11_texture) || + (0 != desc->wgpu_texture); + if (desc->render_target) { + SOKOL_ASSERT(((int)fmt >= 0) && ((int)fmt < _SG_PIXELFORMAT_NUM)); + SOKOL_VALIDATE(_sg.formats[fmt].render, _SG_VALIDATE_IMAGEDESC_RT_PIXELFORMAT); + /* on GLES2, sample count for render targets is completely ignored */ +#if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + if (!_sg.gl.gles2) { +#endif + if (desc->sample_count > 1) { + SOKOL_VALIDATE(_sg.features.msaa_render_targets && _sg.formats[fmt].msaa, _SG_VALIDATE_IMAGEDESC_NO_MSAA_RT_SUPPORT); + } +#if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + } +#endif + SOKOL_VALIDATE(usage == SG_USAGE_IMMUTABLE, _SG_VALIDATE_IMAGEDESC_RT_IMMUTABLE); + SOKOL_VALIDATE(desc->data.subimage[0][0].ptr==0, _SG_VALIDATE_IMAGEDESC_RT_NO_DATA); + } + else { + SOKOL_VALIDATE(desc->sample_count <= 1, _SG_VALIDATE_IMAGEDESC_MSAA_BUT_NO_RT); + const bool valid_nonrt_fmt = !_sg_is_valid_rendertarget_depth_format(fmt); + SOKOL_VALIDATE(valid_nonrt_fmt, _SG_VALIDATE_IMAGEDESC_NONRT_PIXELFORMAT); + const bool is_compressed = _sg_is_compressed_pixel_format(desc->pixel_format); + const bool is_immutable = (usage == SG_USAGE_IMMUTABLE); + if (is_compressed) { + SOKOL_VALIDATE(is_immutable, _SG_VALIDATE_IMAGEDESC_COMPRESSED_IMMUTABLE); + } + if (!injected && is_immutable) { + // image desc must have valid data + _sg_validate_image_data(&desc->data, + desc->pixel_format, + desc->width, + desc->height, + (desc->type == SG_IMAGETYPE_CUBE) ? 6 : 1, + desc->num_mipmaps, + desc->num_slices); + } + else { + // image desc must not have data + for (int face_index = 0; face_index < SG_CUBEFACE_NUM; face_index++) { + for (int mip_index = 0; mip_index < SG_MAX_MIPMAPS; mip_index++) { + const bool no_data = 0 == desc->data.subimage[face_index][mip_index].ptr; + const bool no_size = 0 == desc->data.subimage[face_index][mip_index].size; + if (injected) { + SOKOL_VALIDATE(no_data && no_size, _SG_VALIDATE_IMAGEDESC_INJECTED_NO_DATA); + } + if (!is_immutable) { + SOKOL_VALIDATE(no_data && no_size, _SG_VALIDATE_IMAGEDESC_DYNAMIC_NO_DATA); + } + } + } + } + } + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_shader_desc(const sg_shader_desc* desc) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(desc); + return true; +#else + SOKOL_ASSERT(desc); + SOKOL_VALIDATE_BEGIN(); + SOKOL_VALIDATE(desc->_start_canary == 0, _SG_VALIDATE_SHADERDESC_CANARY); + SOKOL_VALIDATE(desc->_end_canary == 0, _SG_VALIDATE_SHADERDESC_CANARY); +#if defined(SOKOL_GLES2) + SOKOL_VALIDATE(0 != desc->attrs[0].name, _SG_VALIDATE_SHADERDESC_ATTR_NAMES); +#elif defined(SOKOL_D3D11) + SOKOL_VALIDATE(0 != desc->attrs[0].sem_name, _SG_VALIDATE_SHADERDESC_ATTR_SEMANTICS); +#endif +#if defined(SOKOL_GLCORE33) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + /* on GL, must provide shader source code */ + SOKOL_VALIDATE(0 != desc->vs.source, _SG_VALIDATE_SHADERDESC_SOURCE); + SOKOL_VALIDATE(0 != desc->fs.source, _SG_VALIDATE_SHADERDESC_SOURCE); +#elif defined(SOKOL_METAL) || defined(SOKOL_D3D11) + /* on Metal or D3D11, must provide shader source code or byte code */ + SOKOL_VALIDATE((0 != desc->vs.source)||(0 != desc->vs.bytecode.ptr), _SG_VALIDATE_SHADERDESC_SOURCE_OR_BYTECODE); + SOKOL_VALIDATE((0 != desc->fs.source)||(0 != desc->fs.bytecode.ptr), _SG_VALIDATE_SHADERDESC_SOURCE_OR_BYTECODE); +#elif defined(SOKOL_WGPU) + /* on WGPU byte code must be provided */ + SOKOL_VALIDATE((0 != desc->vs.bytecode.ptr), _SG_VALIDATE_SHADERDESC_BYTECODE); + SOKOL_VALIDATE((0 != desc->fs.bytecode.ptr), _SG_VALIDATE_SHADERDESC_BYTECODE); +#else + /* Dummy Backend, don't require source or bytecode */ +#endif + for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTES; i++) { + if (desc->attrs[i].name) { + SOKOL_VALIDATE(strlen(desc->attrs[i].name) < _SG_STRING_SIZE, _SG_VALIDATE_SHADERDESC_ATTR_STRING_TOO_LONG); + } + if (desc->attrs[i].sem_name) { + SOKOL_VALIDATE(strlen(desc->attrs[i].sem_name) < _SG_STRING_SIZE, _SG_VALIDATE_SHADERDESC_ATTR_STRING_TOO_LONG); + } + } + /* if shader byte code, the size must also be provided */ + if (0 != desc->vs.bytecode.ptr) { + SOKOL_VALIDATE(desc->vs.bytecode.size > 0, _SG_VALIDATE_SHADERDESC_NO_BYTECODE_SIZE); + } + if (0 != desc->fs.bytecode.ptr) { + SOKOL_VALIDATE(desc->fs.bytecode.size > 0, _SG_VALIDATE_SHADERDESC_NO_BYTECODE_SIZE); + } + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + const sg_shader_stage_desc* stage_desc = (stage_index == 0)? &desc->vs : &desc->fs; + bool uniform_blocks_continuous = true; + for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBS; ub_index++) { + const sg_shader_uniform_block_desc* ub_desc = &stage_desc->uniform_blocks[ub_index]; + if (ub_desc->size > 0) { + SOKOL_VALIDATE(uniform_blocks_continuous, _SG_VALIDATE_SHADERDESC_NO_CONT_UBS); +#if defined(_SOKOL_ANY_GL) + bool uniforms_continuous = true; + uint32_t uniform_offset = 0; + int num_uniforms = 0; + for (int u_index = 0; u_index < SG_MAX_UB_MEMBERS; u_index++) { + const sg_shader_uniform_desc* u_desc = &ub_desc->uniforms[u_index]; + if (u_desc->type != SG_UNIFORMTYPE_INVALID) { + SOKOL_VALIDATE(uniforms_continuous, _SG_VALIDATE_SHADERDESC_NO_CONT_UB_MEMBERS); +#if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + SOKOL_VALIDATE(0 != u_desc->name, _SG_VALIDATE_SHADERDESC_UB_MEMBER_NAME); +#endif + const int array_count = u_desc->array_count; + SOKOL_VALIDATE(array_count > 0, _SG_VALIDATE_SHADERDESC_UB_ARRAY_COUNT); + const uint32_t u_align = _sg_uniform_alignment(u_desc->type, array_count, ub_desc->layout); + const uint32_t u_size = _sg_uniform_size(u_desc->type, array_count, ub_desc->layout); + uniform_offset = _sg_align_u32(uniform_offset, u_align); + uniform_offset += u_size; + num_uniforms++; + // with std140, arrays are only allowed for FLOAT4, INT4, MAT4 + if (ub_desc->layout == SG_UNIFORMLAYOUT_STD140) { + if (array_count > 1) { + SOKOL_VALIDATE((u_desc->type == SG_UNIFORMTYPE_FLOAT4) || (u_desc->type == SG_UNIFORMTYPE_INT4) || (u_desc->type == SG_UNIFORMTYPE_MAT4), _SG_VALIDATE_SHADERDESC_UB_STD140_ARRAY_TYPE); + } + } + } + else { + uniforms_continuous = false; + } + } + if (ub_desc->layout == SG_UNIFORMLAYOUT_STD140) { + uniform_offset = _sg_align_u32(uniform_offset, 16); + } + SOKOL_VALIDATE((size_t)uniform_offset == ub_desc->size, _SG_VALIDATE_SHADERDESC_UB_SIZE_MISMATCH); + SOKOL_VALIDATE(num_uniforms > 0, _SG_VALIDATE_SHADERDESC_NO_UB_MEMBERS); +#endif + } + else { + uniform_blocks_continuous = false; + } + } + bool images_continuous = true; + for (int img_index = 0; img_index < SG_MAX_SHADERSTAGE_IMAGES; img_index++) { + const sg_shader_image_desc* img_desc = &stage_desc->images[img_index]; + if (img_desc->image_type != _SG_IMAGETYPE_DEFAULT) { + SOKOL_VALIDATE(images_continuous, _SG_VALIDATE_SHADERDESC_NO_CONT_IMGS); +#if defined(SOKOL_GLES2) + SOKOL_VALIDATE(0 != img_desc->name, _SG_VALIDATE_SHADERDESC_IMG_NAME); +#endif + } + else { + images_continuous = false; + } + } + } + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_pipeline_desc(const sg_pipeline_desc* desc) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(desc); + return true; +#else + SOKOL_ASSERT(desc); + SOKOL_VALIDATE_BEGIN(); + SOKOL_VALIDATE(desc->_start_canary == 0, _SG_VALIDATE_PIPELINEDESC_CANARY); + SOKOL_VALIDATE(desc->_end_canary == 0, _SG_VALIDATE_PIPELINEDESC_CANARY); + SOKOL_VALIDATE(desc->shader.id != SG_INVALID_ID, _SG_VALIDATE_PIPELINEDESC_SHADER); + for (int buf_index = 0; buf_index < SG_MAX_SHADERSTAGE_BUFFERS; buf_index++) { + const sg_buffer_layout_desc* l_desc = &desc->layout.buffers[buf_index]; + if (l_desc->stride == 0) { + continue; + } + SOKOL_VALIDATE((l_desc->stride & 3) == 0, _SG_VALIDATE_PIPELINEDESC_LAYOUT_STRIDE4); + } + SOKOL_VALIDATE(desc->layout.attrs[0].format != SG_VERTEXFORMAT_INVALID, _SG_VALIDATE_PIPELINEDESC_NO_ATTRS); + const _sg_shader_t* shd = _sg_lookup_shader(&_sg.pools, desc->shader.id); + SOKOL_VALIDATE(0 != shd, _SG_VALIDATE_PIPELINEDESC_SHADER); + if (shd) { + SOKOL_VALIDATE(shd->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_PIPELINEDESC_SHADER); + bool attrs_cont = true; + for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) { + const sg_vertex_attr_desc* a_desc = &desc->layout.attrs[attr_index]; + if (a_desc->format == SG_VERTEXFORMAT_INVALID) { + attrs_cont = false; + continue; + } + SOKOL_VALIDATE(attrs_cont, _SG_VALIDATE_PIPELINEDESC_NO_ATTRS); + SOKOL_ASSERT(a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS); +#if defined(SOKOL_GLES2) + /* on GLES2, vertex attribute names must be provided */ + SOKOL_VALIDATE(!_sg_strempty(&shd->gl.attrs[attr_index].name), _SG_VALIDATE_PIPELINEDESC_ATTR_NAME); +#elif defined(SOKOL_D3D11) + /* on D3D11, semantic names (and semantic indices) must be provided */ + SOKOL_VALIDATE(!_sg_strempty(&shd->d3d11.attrs[attr_index].sem_name), _SG_VALIDATE_PIPELINEDESC_ATTR_SEMANTICS); +#endif + } + } + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_pass_desc(const sg_pass_desc* desc) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(desc); + return true; +#else + SOKOL_ASSERT(desc); + SOKOL_VALIDATE_BEGIN(); + SOKOL_VALIDATE(desc->_start_canary == 0, _SG_VALIDATE_PASSDESC_CANARY); + SOKOL_VALIDATE(desc->_end_canary == 0, _SG_VALIDATE_PASSDESC_CANARY); + bool atts_cont = true; + int width = -1, height = -1, sample_count = -1; + for (int att_index = 0; att_index < SG_MAX_COLOR_ATTACHMENTS; att_index++) { + const sg_pass_attachment_desc* att = &desc->color_attachments[att_index]; + if (att->image.id == SG_INVALID_ID) { + SOKOL_VALIDATE(att_index > 0, _SG_VALIDATE_PASSDESC_NO_COLOR_ATTS); + atts_cont = false; + continue; + } + SOKOL_VALIDATE(atts_cont, _SG_VALIDATE_PASSDESC_NO_CONT_COLOR_ATTS); + const _sg_image_t* img = _sg_lookup_image(&_sg.pools, att->image.id); + SOKOL_ASSERT(img); + SOKOL_VALIDATE(img->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_PASSDESC_IMAGE); + SOKOL_VALIDATE(att->mip_level < img->cmn.num_mipmaps, _SG_VALIDATE_PASSDESC_MIPLEVEL); + if (img->cmn.type == SG_IMAGETYPE_CUBE) { + SOKOL_VALIDATE(att->slice < 6, _SG_VALIDATE_PASSDESC_FACE); + } + else if (img->cmn.type == SG_IMAGETYPE_ARRAY) { + SOKOL_VALIDATE(att->slice < img->cmn.num_slices, _SG_VALIDATE_PASSDESC_LAYER); + } + else if (img->cmn.type == SG_IMAGETYPE_3D) { + SOKOL_VALIDATE(att->slice < img->cmn.num_slices, _SG_VALIDATE_PASSDESC_SLICE); + } + SOKOL_VALIDATE(img->cmn.render_target, _SG_VALIDATE_PASSDESC_IMAGE_NO_RT); + if (att_index == 0) { + width = img->cmn.width >> att->mip_level; + height = img->cmn.height >> att->mip_level; + sample_count = img->cmn.sample_count; + } + else { + SOKOL_VALIDATE(width == img->cmn.width >> att->mip_level, _SG_VALIDATE_PASSDESC_IMAGE_SIZES); + SOKOL_VALIDATE(height == img->cmn.height >> att->mip_level, _SG_VALIDATE_PASSDESC_IMAGE_SIZES); + SOKOL_VALIDATE(sample_count == img->cmn.sample_count, _SG_VALIDATE_PASSDESC_IMAGE_SAMPLE_COUNTS); + } + SOKOL_VALIDATE(_sg_is_valid_rendertarget_color_format(img->cmn.pixel_format), _SG_VALIDATE_PASSDESC_COLOR_INV_PIXELFORMAT); + } + if (desc->depth_stencil_attachment.image.id != SG_INVALID_ID) { + const sg_pass_attachment_desc* att = &desc->depth_stencil_attachment; + const _sg_image_t* img = _sg_lookup_image(&_sg.pools, att->image.id); + SOKOL_ASSERT(img); + SOKOL_VALIDATE(img->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_PASSDESC_IMAGE); + SOKOL_VALIDATE(att->mip_level < img->cmn.num_mipmaps, _SG_VALIDATE_PASSDESC_MIPLEVEL); + if (img->cmn.type == SG_IMAGETYPE_CUBE) { + SOKOL_VALIDATE(att->slice < 6, _SG_VALIDATE_PASSDESC_FACE); + } + else if (img->cmn.type == SG_IMAGETYPE_ARRAY) { + SOKOL_VALIDATE(att->slice < img->cmn.num_slices, _SG_VALIDATE_PASSDESC_LAYER); + } + else if (img->cmn.type == SG_IMAGETYPE_3D) { + SOKOL_VALIDATE(att->slice < img->cmn.num_slices, _SG_VALIDATE_PASSDESC_SLICE); + } + SOKOL_VALIDATE(img->cmn.render_target, _SG_VALIDATE_PASSDESC_IMAGE_NO_RT); + SOKOL_VALIDATE(width == img->cmn.width >> att->mip_level, _SG_VALIDATE_PASSDESC_IMAGE_SIZES); + SOKOL_VALIDATE(height == img->cmn.height >> att->mip_level, _SG_VALIDATE_PASSDESC_IMAGE_SIZES); + SOKOL_VALIDATE(sample_count == img->cmn.sample_count, _SG_VALIDATE_PASSDESC_IMAGE_SAMPLE_COUNTS); + SOKOL_VALIDATE(_sg_is_valid_rendertarget_depth_format(img->cmn.pixel_format), _SG_VALIDATE_PASSDESC_DEPTH_INV_PIXELFORMAT); + } + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_begin_pass(_sg_pass_t* pass) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(pass); + return true; +#else + SOKOL_VALIDATE_BEGIN(); + SOKOL_VALIDATE(pass->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_BEGINPASS_PASS); + + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + const _sg_pass_attachment_t* att = &pass->cmn.color_atts[i]; + const _sg_image_t* img = _sg_pass_color_image(pass, i); + if (img) { + SOKOL_VALIDATE(img->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_BEGINPASS_IMAGE); + SOKOL_VALIDATE(img->slot.id == att->image_id.id, _SG_VALIDATE_BEGINPASS_IMAGE); + } + } + const _sg_image_t* ds_img = _sg_pass_ds_image(pass); + if (ds_img) { + const _sg_pass_attachment_t* att = &pass->cmn.ds_att; + SOKOL_VALIDATE(ds_img->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_BEGINPASS_IMAGE); + SOKOL_VALIDATE(ds_img->slot.id == att->image_id.id, _SG_VALIDATE_BEGINPASS_IMAGE); + } + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_apply_pipeline(sg_pipeline pip_id) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(pip_id); + return true; +#else + SOKOL_VALIDATE_BEGIN(); + /* the pipeline object must be alive and valid */ + SOKOL_VALIDATE(pip_id.id != SG_INVALID_ID, _SG_VALIDATE_APIP_PIPELINE_VALID_ID); + const _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, pip_id.id); + SOKOL_VALIDATE(pip != 0, _SG_VALIDATE_APIP_PIPELINE_EXISTS); + if (!pip) { + return SOKOL_VALIDATE_END(); + } + SOKOL_VALIDATE(pip->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_APIP_PIPELINE_VALID); + /* the pipeline's shader must be alive and valid */ + SOKOL_ASSERT(pip->shader); + SOKOL_VALIDATE(pip->shader->slot.id == pip->cmn.shader_id.id, _SG_VALIDATE_APIP_SHADER_EXISTS); + SOKOL_VALIDATE(pip->shader->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_APIP_SHADER_VALID); + /* check that pipeline attributes match current pass attributes */ + const _sg_pass_t* pass = _sg_lookup_pass(&_sg.pools, _sg.cur_pass.id); + if (pass) { + /* an offscreen pass */ + SOKOL_VALIDATE(pip->cmn.color_attachment_count == pass->cmn.num_color_atts, _SG_VALIDATE_APIP_ATT_COUNT); + for (int i = 0; i < pip->cmn.color_attachment_count; i++) { + const _sg_image_t* att_img = _sg_pass_color_image(pass, i); + SOKOL_VALIDATE(pip->cmn.color_formats[i] == att_img->cmn.pixel_format, _SG_VALIDATE_APIP_COLOR_FORMAT); + SOKOL_VALIDATE(pip->cmn.sample_count == att_img->cmn.sample_count, _SG_VALIDATE_APIP_SAMPLE_COUNT); + } + const _sg_image_t* att_dsimg = _sg_pass_ds_image(pass); + if (att_dsimg) { + SOKOL_VALIDATE(pip->cmn.depth_format == att_dsimg->cmn.pixel_format, _SG_VALIDATE_APIP_DEPTH_FORMAT); + } + else { + SOKOL_VALIDATE(pip->cmn.depth_format == SG_PIXELFORMAT_NONE, _SG_VALIDATE_APIP_DEPTH_FORMAT); + } + } + else { + /* default pass */ + SOKOL_VALIDATE(pip->cmn.color_attachment_count == 1, _SG_VALIDATE_APIP_ATT_COUNT); + SOKOL_VALIDATE(pip->cmn.color_formats[0] == _sg.desc.context.color_format, _SG_VALIDATE_APIP_COLOR_FORMAT); + SOKOL_VALIDATE(pip->cmn.depth_format == _sg.desc.context.depth_format, _SG_VALIDATE_APIP_DEPTH_FORMAT); + SOKOL_VALIDATE(pip->cmn.sample_count == _sg.desc.context.sample_count, _SG_VALIDATE_APIP_SAMPLE_COUNT); + } + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_apply_bindings(const sg_bindings* bindings) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(bindings); + return true; +#else + SOKOL_VALIDATE_BEGIN(); + + /* a pipeline object must have been applied */ + SOKOL_VALIDATE(_sg.cur_pipeline.id != SG_INVALID_ID, _SG_VALIDATE_ABND_PIPELINE); + const _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, _sg.cur_pipeline.id); + SOKOL_VALIDATE(pip != 0, _SG_VALIDATE_ABND_PIPELINE_EXISTS); + if (!pip) { + return SOKOL_VALIDATE_END(); + } + SOKOL_VALIDATE(pip->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_ABND_PIPELINE_VALID); + SOKOL_ASSERT(pip->shader && (pip->cmn.shader_id.id == pip->shader->slot.id)); + + /* has expected vertex buffers, and vertex buffers still exist */ + for (int i = 0; i < SG_MAX_SHADERSTAGE_BUFFERS; i++) { + if (bindings->vertex_buffers[i].id != SG_INVALID_ID) { + SOKOL_VALIDATE(pip->cmn.vertex_layout_valid[i], _SG_VALIDATE_ABND_VBS); + /* buffers in vertex-buffer-slots must be of type SG_BUFFERTYPE_VERTEXBUFFER */ + const _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, bindings->vertex_buffers[i].id); + SOKOL_VALIDATE(buf != 0, _SG_VALIDATE_ABND_VB_EXISTS); + if (buf && buf->slot.state == SG_RESOURCESTATE_VALID) { + SOKOL_VALIDATE(SG_BUFFERTYPE_VERTEXBUFFER == buf->cmn.type, _SG_VALIDATE_ABND_VB_TYPE); + SOKOL_VALIDATE(!buf->cmn.append_overflow, _SG_VALIDATE_ABND_VB_OVERFLOW); + } + } + else { + /* vertex buffer provided in a slot which has no vertex layout in pipeline */ + SOKOL_VALIDATE(!pip->cmn.vertex_layout_valid[i], _SG_VALIDATE_ABND_VBS); + } + } + + /* index buffer expected or not, and index buffer still exists */ + if (pip->cmn.index_type == SG_INDEXTYPE_NONE) { + /* pipeline defines non-indexed rendering, but index buffer provided */ + SOKOL_VALIDATE(bindings->index_buffer.id == SG_INVALID_ID, _SG_VALIDATE_ABND_IB); + } + else { + /* pipeline defines indexed rendering, but no index buffer provided */ + SOKOL_VALIDATE(bindings->index_buffer.id != SG_INVALID_ID, _SG_VALIDATE_ABND_NO_IB); + } + if (bindings->index_buffer.id != SG_INVALID_ID) { + /* buffer in index-buffer-slot must be of type SG_BUFFERTYPE_INDEXBUFFER */ + const _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, bindings->index_buffer.id); + SOKOL_VALIDATE(buf != 0, _SG_VALIDATE_ABND_IB_EXISTS); + if (buf && buf->slot.state == SG_RESOURCESTATE_VALID) { + SOKOL_VALIDATE(SG_BUFFERTYPE_INDEXBUFFER == buf->cmn.type, _SG_VALIDATE_ABND_IB_TYPE); + SOKOL_VALIDATE(!buf->cmn.append_overflow, _SG_VALIDATE_ABND_IB_OVERFLOW); + } + } + + /* has expected vertex shader images */ + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + _sg_shader_stage_t* stage = &pip->shader->cmn.stage[SG_SHADERSTAGE_VS]; + if (bindings->vs_images[i].id != SG_INVALID_ID) { + SOKOL_VALIDATE(i < stage->num_images, _SG_VALIDATE_ABND_VS_IMGS); + const _sg_image_t* img = _sg_lookup_image(&_sg.pools, bindings->vs_images[i].id); + SOKOL_VALIDATE(img != 0, _SG_VALIDATE_ABND_VS_IMG_EXISTS); + if (img && img->slot.state == SG_RESOURCESTATE_VALID) { + SOKOL_VALIDATE(img->cmn.type == stage->images[i].image_type, _SG_VALIDATE_ABND_VS_IMG_TYPES); + } + } + else { + SOKOL_VALIDATE(i >= stage->num_images, _SG_VALIDATE_ABND_VS_IMGS); + } + } + + /* has expected fragment shader images */ + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) { + _sg_shader_stage_t* stage = &pip->shader->cmn.stage[SG_SHADERSTAGE_FS]; + if (bindings->fs_images[i].id != SG_INVALID_ID) { + SOKOL_VALIDATE(i < stage->num_images, _SG_VALIDATE_ABND_FS_IMGS); + const _sg_image_t* img = _sg_lookup_image(&_sg.pools, bindings->fs_images[i].id); + SOKOL_VALIDATE(img != 0, _SG_VALIDATE_ABND_FS_IMG_EXISTS); + if (img && img->slot.state == SG_RESOURCESTATE_VALID) { + SOKOL_VALIDATE(img->cmn.type == stage->images[i].image_type, _SG_VALIDATE_ABND_FS_IMG_TYPES); + } + } + else { + SOKOL_VALIDATE(i >= stage->num_images, _SG_VALIDATE_ABND_FS_IMGS); + } + } + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_apply_uniforms(sg_shader_stage stage_index, int ub_index, const sg_range* data) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(stage_index); + _SOKOL_UNUSED(ub_index); + _SOKOL_UNUSED(data); + return true; +#else + SOKOL_ASSERT((stage_index == SG_SHADERSTAGE_VS) || (stage_index == SG_SHADERSTAGE_FS)); + SOKOL_ASSERT((ub_index >= 0) && (ub_index < SG_MAX_SHADERSTAGE_UBS)); + SOKOL_VALIDATE_BEGIN(); + SOKOL_VALIDATE(_sg.cur_pipeline.id != SG_INVALID_ID, _SG_VALIDATE_AUB_NO_PIPELINE); + const _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, _sg.cur_pipeline.id); + SOKOL_ASSERT(pip && (pip->slot.id == _sg.cur_pipeline.id)); + SOKOL_ASSERT(pip->shader && (pip->shader->slot.id == pip->cmn.shader_id.id)); + + /* check that there is a uniform block at 'stage' and 'ub_index' */ + const _sg_shader_stage_t* stage = &pip->shader->cmn.stage[stage_index]; + SOKOL_VALIDATE(ub_index < stage->num_uniform_blocks, _SG_VALIDATE_AUB_NO_UB_AT_SLOT); + + /* check that the provided data size doesn't exceed the uniform block size */ + SOKOL_VALIDATE(data->size <= stage->uniform_blocks[ub_index].size, _SG_VALIDATE_AUB_SIZE); + + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_update_buffer(const _sg_buffer_t* buf, const sg_range* data) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(buf); + _SOKOL_UNUSED(data); + return true; +#else + SOKOL_ASSERT(buf && data && data->ptr); + SOKOL_VALIDATE_BEGIN(); + SOKOL_VALIDATE(buf->cmn.usage != SG_USAGE_IMMUTABLE, _SG_VALIDATE_UPDATEBUF_USAGE); + SOKOL_VALIDATE(buf->cmn.size >= (int)data->size, _SG_VALIDATE_UPDATEBUF_SIZE); + SOKOL_VALIDATE(buf->cmn.update_frame_index != _sg.frame_index, _SG_VALIDATE_UPDATEBUF_ONCE); + SOKOL_VALIDATE(buf->cmn.append_frame_index != _sg.frame_index, _SG_VALIDATE_UPDATEBUF_APPEND); + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_append_buffer(const _sg_buffer_t* buf, const sg_range* data) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(buf); + _SOKOL_UNUSED(data); + return true; +#else + SOKOL_ASSERT(buf && data && data->ptr); + SOKOL_VALIDATE_BEGIN(); + SOKOL_VALIDATE(buf->cmn.usage != SG_USAGE_IMMUTABLE, _SG_VALIDATE_APPENDBUF_USAGE); + SOKOL_VALIDATE(buf->cmn.size >= (buf->cmn.append_pos + (int)data->size), _SG_VALIDATE_APPENDBUF_SIZE); + SOKOL_VALIDATE(buf->cmn.update_frame_index != _sg.frame_index, _SG_VALIDATE_APPENDBUF_UPDATE); + return SOKOL_VALIDATE_END(); +#endif +} + +_SOKOL_PRIVATE bool _sg_validate_update_image(const _sg_image_t* img, const sg_image_data* data) { +#if !defined(SOKOL_DEBUG) + _SOKOL_UNUSED(img); + _SOKOL_UNUSED(data); + return true; +#else + SOKOL_ASSERT(img && data); + SOKOL_VALIDATE_BEGIN(); + SOKOL_VALIDATE(img->cmn.usage != SG_USAGE_IMMUTABLE, _SG_VALIDATE_UPDIMG_USAGE); + SOKOL_VALIDATE(img->cmn.upd_frame_index != _sg.frame_index, _SG_VALIDATE_UPDIMG_ONCE); + _sg_validate_image_data(data, + img->cmn.pixel_format, + img->cmn.width, + img->cmn.height, + (img->cmn.type == SG_IMAGETYPE_CUBE) ? 6 : 1, + img->cmn.num_mipmaps, + img->cmn.num_slices); + return SOKOL_VALIDATE_END(); +#endif +} + +/*== fill in desc default values =============================================*/ +_SOKOL_PRIVATE sg_buffer_desc _sg_buffer_desc_defaults(const sg_buffer_desc* desc) { + sg_buffer_desc def = *desc; + def.type = _sg_def(def.type, SG_BUFFERTYPE_VERTEXBUFFER); + def.usage = _sg_def(def.usage, SG_USAGE_IMMUTABLE); + if (def.size == 0) { + def.size = def.data.size; + } + else if (def.data.size == 0) { + def.data.size = def.size; + } + return def; +} + +_SOKOL_PRIVATE sg_image_desc _sg_image_desc_defaults(const sg_image_desc* desc) { + sg_image_desc def = *desc; + def.type = _sg_def(def.type, SG_IMAGETYPE_2D); + def.num_slices = _sg_def(def.num_slices, 1); + def.num_mipmaps = _sg_def(def.num_mipmaps, 1); + def.usage = _sg_def(def.usage, SG_USAGE_IMMUTABLE); + if (desc->render_target) { + def.pixel_format = _sg_def(def.pixel_format, _sg.desc.context.color_format); + def.sample_count = _sg_def(def.sample_count, _sg.desc.context.sample_count); + } + else { + def.pixel_format = _sg_def(def.pixel_format, SG_PIXELFORMAT_RGBA8); + def.sample_count = _sg_def(def.sample_count, 1); + } + def.min_filter = _sg_def(def.min_filter, SG_FILTER_NEAREST); + def.mag_filter = _sg_def(def.mag_filter, SG_FILTER_NEAREST); + def.wrap_u = _sg_def(def.wrap_u, SG_WRAP_REPEAT); + def.wrap_v = _sg_def(def.wrap_v, SG_WRAP_REPEAT); + def.wrap_w = _sg_def(def.wrap_w, SG_WRAP_REPEAT); + def.border_color = _sg_def(def.border_color, SG_BORDERCOLOR_OPAQUE_BLACK); + def.max_anisotropy = _sg_def(def.max_anisotropy, 1); + def.max_lod = _sg_def_flt(def.max_lod, FLT_MAX); + return def; +} + +_SOKOL_PRIVATE sg_shader_desc _sg_shader_desc_defaults(const sg_shader_desc* desc) { + sg_shader_desc def = *desc; +#if defined(SOKOL_METAL) + def.vs.entry = _sg_def(def.vs.entry, "_main"); + def.fs.entry = _sg_def(def.fs.entry, "_main"); +#else + def.vs.entry = _sg_def(def.vs.entry, "main"); + def.fs.entry = _sg_def(def.fs.entry, "main"); +#endif +#if defined(SOKOL_D3D11) + if (def.vs.source) { + def.vs.d3d11_target = _sg_def(def.vs.d3d11_target, "vs_4_0"); + } + if (def.fs.source) { + def.fs.d3d11_target = _sg_def(def.fs.d3d11_target, "ps_4_0"); + } +#endif + for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) { + sg_shader_stage_desc* stage_desc = (stage_index == SG_SHADERSTAGE_VS)? &def.vs : &def.fs; + for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBS; ub_index++) { + sg_shader_uniform_block_desc* ub_desc = &stage_desc->uniform_blocks[ub_index]; + if (0 == ub_desc->size) { + break; + } + ub_desc->layout = _sg_def(ub_desc->layout, SG_UNIFORMLAYOUT_NATIVE); + for (int u_index = 0; u_index < SG_MAX_UB_MEMBERS; u_index++) { + sg_shader_uniform_desc* u_desc = &ub_desc->uniforms[u_index]; + if (u_desc->type == SG_UNIFORMTYPE_INVALID) { + break; + } + u_desc->array_count = _sg_def(u_desc->array_count, 1); + } + } + for (int img_index = 0; img_index < SG_MAX_SHADERSTAGE_IMAGES; img_index++) { + sg_shader_image_desc* img_desc = &stage_desc->images[img_index]; + if (img_desc->image_type == _SG_IMAGETYPE_DEFAULT) { + break; + } + img_desc->sampler_type = _sg_def(img_desc->sampler_type, SG_SAMPLERTYPE_FLOAT); + } + } + return def; +} + +_SOKOL_PRIVATE sg_pipeline_desc _sg_pipeline_desc_defaults(const sg_pipeline_desc* desc) { + sg_pipeline_desc def = *desc; + + def.primitive_type = _sg_def(def.primitive_type, SG_PRIMITIVETYPE_TRIANGLES); + def.index_type = _sg_def(def.index_type, SG_INDEXTYPE_NONE); + def.cull_mode = _sg_def(def.cull_mode, SG_CULLMODE_NONE); + def.face_winding = _sg_def(def.face_winding, SG_FACEWINDING_CW); + def.sample_count = _sg_def(def.sample_count, _sg.desc.context.sample_count); + + def.stencil.front.compare = _sg_def(def.stencil.front.compare, SG_COMPAREFUNC_ALWAYS); + def.stencil.front.fail_op = _sg_def(def.stencil.front.fail_op, SG_STENCILOP_KEEP); + def.stencil.front.depth_fail_op = _sg_def(def.stencil.front.depth_fail_op, SG_STENCILOP_KEEP); + def.stencil.front.pass_op = _sg_def(def.stencil.front.pass_op, SG_STENCILOP_KEEP); + def.stencil.back.compare = _sg_def(def.stencil.back.compare, SG_COMPAREFUNC_ALWAYS); + def.stencil.back.fail_op = _sg_def(def.stencil.back.fail_op, SG_STENCILOP_KEEP); + def.stencil.back.depth_fail_op = _sg_def(def.stencil.back.depth_fail_op, SG_STENCILOP_KEEP); + def.stencil.back.pass_op = _sg_def(def.stencil.back.pass_op, SG_STENCILOP_KEEP); + + def.depth.compare = _sg_def(def.depth.compare, SG_COMPAREFUNC_ALWAYS); + def.depth.pixel_format = _sg_def(def.depth.pixel_format, _sg.desc.context.depth_format); + def.color_count = _sg_def(def.color_count, 1); + if (def.color_count > SG_MAX_COLOR_ATTACHMENTS) { + def.color_count = SG_MAX_COLOR_ATTACHMENTS; + } + for (int i = 0; i < def.color_count; i++) { + sg_color_state* cs = &def.colors[i]; + cs->pixel_format = _sg_def(cs->pixel_format, _sg.desc.context.color_format); + cs->write_mask = _sg_def(cs->write_mask, SG_COLORMASK_RGBA); + sg_blend_state* bs = &def.colors[i].blend; + bs->src_factor_rgb = _sg_def(bs->src_factor_rgb, SG_BLENDFACTOR_ONE); + bs->dst_factor_rgb = _sg_def(bs->dst_factor_rgb, SG_BLENDFACTOR_ZERO); + bs->op_rgb = _sg_def(bs->op_rgb, SG_BLENDOP_ADD); + bs->src_factor_alpha = _sg_def(bs->src_factor_alpha, SG_BLENDFACTOR_ONE); + bs->dst_factor_alpha = _sg_def(bs->dst_factor_alpha, SG_BLENDFACTOR_ZERO); + bs->op_alpha = _sg_def(bs->op_alpha, SG_BLENDOP_ADD); + } + + for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) { + sg_vertex_attr_desc* a_desc = &def.layout.attrs[attr_index]; + if (a_desc->format == SG_VERTEXFORMAT_INVALID) { + break; + } + SOKOL_ASSERT(a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS); + sg_buffer_layout_desc* b_desc = &def.layout.buffers[a_desc->buffer_index]; + b_desc->step_func = _sg_def(b_desc->step_func, SG_VERTEXSTEP_PER_VERTEX); + b_desc->step_rate = _sg_def(b_desc->step_rate, 1); + } + + /* resolve vertex layout strides and offsets */ + int auto_offset[SG_MAX_SHADERSTAGE_BUFFERS]; + memset(auto_offset, 0, sizeof(auto_offset)); + bool use_auto_offset = true; + for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) { + /* to use computed offsets, *all* attr offsets must be 0 */ + if (def.layout.attrs[attr_index].offset != 0) { + use_auto_offset = false; + } + } + for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) { + sg_vertex_attr_desc* a_desc = &def.layout.attrs[attr_index]; + if (a_desc->format == SG_VERTEXFORMAT_INVALID) { + break; + } + SOKOL_ASSERT(a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS); + if (use_auto_offset) { + a_desc->offset = auto_offset[a_desc->buffer_index]; + } + auto_offset[a_desc->buffer_index] += _sg_vertexformat_bytesize(a_desc->format); + } + /* compute vertex strides if needed */ + for (int buf_index = 0; buf_index < SG_MAX_SHADERSTAGE_BUFFERS; buf_index++) { + sg_buffer_layout_desc* l_desc = &def.layout.buffers[buf_index]; + if (l_desc->stride == 0) { + l_desc->stride = auto_offset[buf_index]; + } + } + + return def; +} + +_SOKOL_PRIVATE sg_pass_desc _sg_pass_desc_defaults(const sg_pass_desc* desc) { + /* FIXME: no values to replace in sg_pass_desc? */ + sg_pass_desc def = *desc; + return def; +} + +/*== allocate/initialize resource private functions ==========================*/ +_SOKOL_PRIVATE sg_buffer _sg_alloc_buffer(void) { + sg_buffer res; + int slot_index = _sg_pool_alloc_index(&_sg.pools.buffer_pool); + if (_SG_INVALID_SLOT_INDEX != slot_index) { + res.id = _sg_slot_alloc(&_sg.pools.buffer_pool, &_sg.pools.buffers[slot_index].slot, slot_index); + } + else { + /* pool is exhausted */ + res.id = SG_INVALID_ID; + } + return res; +} + +_SOKOL_PRIVATE sg_image _sg_alloc_image(void) { + sg_image res; + int slot_index = _sg_pool_alloc_index(&_sg.pools.image_pool); + if (_SG_INVALID_SLOT_INDEX != slot_index) { + res.id = _sg_slot_alloc(&_sg.pools.image_pool, &_sg.pools.images[slot_index].slot, slot_index); + } + else { + /* pool is exhausted */ + res.id = SG_INVALID_ID; + } + return res; +} + +_SOKOL_PRIVATE sg_shader _sg_alloc_shader(void) { + sg_shader res; + int slot_index = _sg_pool_alloc_index(&_sg.pools.shader_pool); + if (_SG_INVALID_SLOT_INDEX != slot_index) { + res.id = _sg_slot_alloc(&_sg.pools.shader_pool, &_sg.pools.shaders[slot_index].slot, slot_index); + } + else { + /* pool is exhausted */ + res.id = SG_INVALID_ID; + } + return res; +} + +_SOKOL_PRIVATE sg_pipeline _sg_alloc_pipeline(void) { + sg_pipeline res; + int slot_index = _sg_pool_alloc_index(&_sg.pools.pipeline_pool); + if (_SG_INVALID_SLOT_INDEX != slot_index) { + res.id =_sg_slot_alloc(&_sg.pools.pipeline_pool, &_sg.pools.pipelines[slot_index].slot, slot_index); + } + else { + /* pool is exhausted */ + res.id = SG_INVALID_ID; + } + return res; +} + +_SOKOL_PRIVATE sg_pass _sg_alloc_pass(void) { + sg_pass res; + int slot_index = _sg_pool_alloc_index(&_sg.pools.pass_pool); + if (_SG_INVALID_SLOT_INDEX != slot_index) { + res.id = _sg_slot_alloc(&_sg.pools.pass_pool, &_sg.pools.passes[slot_index].slot, slot_index); + } + else { + /* pool is exhausted */ + res.id = SG_INVALID_ID; + } + return res; +} + +_SOKOL_PRIVATE void _sg_dealloc_buffer(sg_buffer buf_id) { + SOKOL_ASSERT(buf_id.id != SG_INVALID_ID); + _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, buf_id.id); + SOKOL_ASSERT(buf && buf->slot.state == SG_RESOURCESTATE_ALLOC); + _sg_reset_slot(&buf->slot); + _sg_pool_free_index(&_sg.pools.buffer_pool, _sg_slot_index(buf_id.id)); +} + +_SOKOL_PRIVATE void _sg_dealloc_image(sg_image img_id) { + SOKOL_ASSERT(img_id.id != SG_INVALID_ID); + _sg_image_t* img = _sg_lookup_image(&_sg.pools, img_id.id); + SOKOL_ASSERT(img && img->slot.state == SG_RESOURCESTATE_ALLOC); + _sg_reset_slot(&img->slot); + _sg_pool_free_index(&_sg.pools.image_pool, _sg_slot_index(img_id.id)); +} + +_SOKOL_PRIVATE void _sg_dealloc_shader(sg_shader shd_id) { + SOKOL_ASSERT(shd_id.id != SG_INVALID_ID); + _sg_shader_t* shd = _sg_lookup_shader(&_sg.pools, shd_id.id); + SOKOL_ASSERT(shd && shd->slot.state == SG_RESOURCESTATE_ALLOC); + _sg_reset_slot(&shd->slot); + _sg_pool_free_index(&_sg.pools.shader_pool, _sg_slot_index(shd_id.id)); +} + +_SOKOL_PRIVATE void _sg_dealloc_pipeline(sg_pipeline pip_id) { + SOKOL_ASSERT(pip_id.id != SG_INVALID_ID); + _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, pip_id.id); + SOKOL_ASSERT(pip && pip->slot.state == SG_RESOURCESTATE_ALLOC); + _sg_reset_slot(&pip->slot); + _sg_pool_free_index(&_sg.pools.pipeline_pool, _sg_slot_index(pip_id.id)); +} + +_SOKOL_PRIVATE void _sg_dealloc_pass(sg_pass pass_id) { + SOKOL_ASSERT(pass_id.id != SG_INVALID_ID); + _sg_pass_t* pass = _sg_lookup_pass(&_sg.pools, pass_id.id); + SOKOL_ASSERT(pass && pass->slot.state == SG_RESOURCESTATE_ALLOC); + _sg_reset_slot(&pass->slot); + _sg_pool_free_index(&_sg.pools.pass_pool, _sg_slot_index(pass_id.id)); +} + +_SOKOL_PRIVATE void _sg_init_buffer(sg_buffer buf_id, const sg_buffer_desc* desc) { + SOKOL_ASSERT(buf_id.id != SG_INVALID_ID && desc); + _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, buf_id.id); + SOKOL_ASSERT(buf && buf->slot.state == SG_RESOURCESTATE_ALLOC); + buf->slot.ctx_id = _sg.active_context.id; + if (_sg_validate_buffer_desc(desc)) { + buf->slot.state = _sg_create_buffer(buf, desc); + } + else { + buf->slot.state = SG_RESOURCESTATE_FAILED; + } + SOKOL_ASSERT((buf->slot.state == SG_RESOURCESTATE_VALID)||(buf->slot.state == SG_RESOURCESTATE_FAILED)); +} + +_SOKOL_PRIVATE void _sg_init_image(sg_image img_id, const sg_image_desc* desc) { + SOKOL_ASSERT(img_id.id != SG_INVALID_ID && desc); + _sg_image_t* img = _sg_lookup_image(&_sg.pools, img_id.id); + SOKOL_ASSERT(img && img->slot.state == SG_RESOURCESTATE_ALLOC); + img->slot.ctx_id = _sg.active_context.id; + if (_sg_validate_image_desc(desc)) { + img->slot.state = _sg_create_image(img, desc); + } + else { + img->slot.state = SG_RESOURCESTATE_FAILED; + } + SOKOL_ASSERT((img->slot.state == SG_RESOURCESTATE_VALID)||(img->slot.state == SG_RESOURCESTATE_FAILED)); +} + +_SOKOL_PRIVATE void _sg_init_shader(sg_shader shd_id, const sg_shader_desc* desc) { + SOKOL_ASSERT(shd_id.id != SG_INVALID_ID && desc); + _sg_shader_t* shd = _sg_lookup_shader(&_sg.pools, shd_id.id); + SOKOL_ASSERT(shd && shd->slot.state == SG_RESOURCESTATE_ALLOC); + shd->slot.ctx_id = _sg.active_context.id; + if (_sg_validate_shader_desc(desc)) { + shd->slot.state = _sg_create_shader(shd, desc); + } + else { + shd->slot.state = SG_RESOURCESTATE_FAILED; + } + SOKOL_ASSERT((shd->slot.state == SG_RESOURCESTATE_VALID)||(shd->slot.state == SG_RESOURCESTATE_FAILED)); +} + +_SOKOL_PRIVATE void _sg_init_pipeline(sg_pipeline pip_id, const sg_pipeline_desc* desc) { + SOKOL_ASSERT(pip_id.id != SG_INVALID_ID && desc); + _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, pip_id.id); + SOKOL_ASSERT(pip && pip->slot.state == SG_RESOURCESTATE_ALLOC); + pip->slot.ctx_id = _sg.active_context.id; + if (_sg_validate_pipeline_desc(desc)) { + _sg_shader_t* shd = _sg_lookup_shader(&_sg.pools, desc->shader.id); + if (shd && (shd->slot.state == SG_RESOURCESTATE_VALID)) { + pip->slot.state = _sg_create_pipeline(pip, shd, desc); + } + else { + pip->slot.state = SG_RESOURCESTATE_FAILED; + } + } + else { + pip->slot.state = SG_RESOURCESTATE_FAILED; + } + SOKOL_ASSERT((pip->slot.state == SG_RESOURCESTATE_VALID)||(pip->slot.state == SG_RESOURCESTATE_FAILED)); +} + +_SOKOL_PRIVATE void _sg_init_pass(sg_pass pass_id, const sg_pass_desc* desc) { + SOKOL_ASSERT(pass_id.id != SG_INVALID_ID && desc); + _sg_pass_t* pass = _sg_lookup_pass(&_sg.pools, pass_id.id); + SOKOL_ASSERT(pass && pass->slot.state == SG_RESOURCESTATE_ALLOC); + pass->slot.ctx_id = _sg.active_context.id; + if (_sg_validate_pass_desc(desc)) { + /* lookup pass attachment image pointers */ + _sg_image_t* att_imgs[SG_MAX_COLOR_ATTACHMENTS + 1]; + for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + if (desc->color_attachments[i].image.id) { + att_imgs[i] = _sg_lookup_image(&_sg.pools, desc->color_attachments[i].image.id); + /* FIXME: this shouldn't be an assertion, but result in a SG_RESOURCESTATE_FAILED pass */ + SOKOL_ASSERT(att_imgs[i] && att_imgs[i]->slot.state == SG_RESOURCESTATE_VALID); + } + else { + att_imgs[i] = 0; + } + } + const int ds_att_index = SG_MAX_COLOR_ATTACHMENTS; + if (desc->depth_stencil_attachment.image.id) { + att_imgs[ds_att_index] = _sg_lookup_image(&_sg.pools, desc->depth_stencil_attachment.image.id); + /* FIXME: this shouldn't be an assertion, but result in a SG_RESOURCESTATE_FAILED pass */ + SOKOL_ASSERT(att_imgs[ds_att_index] && att_imgs[ds_att_index]->slot.state == SG_RESOURCESTATE_VALID); + } + else { + att_imgs[ds_att_index] = 0; + } + pass->slot.state = _sg_create_pass(pass, att_imgs, desc); + } + else { + pass->slot.state = SG_RESOURCESTATE_FAILED; + } + SOKOL_ASSERT((pass->slot.state == SG_RESOURCESTATE_VALID)||(pass->slot.state == SG_RESOURCESTATE_FAILED)); +} + +_SOKOL_PRIVATE bool _sg_uninit_buffer(sg_buffer buf_id) { + _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, buf_id.id); + if (buf) { + if (buf->slot.ctx_id == _sg.active_context.id) { + _sg_destroy_buffer(buf); + _sg_reset_buffer(buf); + return true; + } + else { + SOKOL_LOG("_sg_uninit_buffer: active context mismatch (must be same as for creation)"); + _SG_TRACE_NOARGS(err_context_mismatch); + } + } + return false; +} + +_SOKOL_PRIVATE bool _sg_uninit_image(sg_image img_id) { + _sg_image_t* img = _sg_lookup_image(&_sg.pools, img_id.id); + if (img) { + if (img->slot.ctx_id == _sg.active_context.id) { + _sg_destroy_image(img); + _sg_reset_image(img); + return true; + } + else { + SOKOL_LOG("_sg_uninit_image: active context mismatch (must be same as for creation)"); + _SG_TRACE_NOARGS(err_context_mismatch); + } + } + return false; +} + +_SOKOL_PRIVATE bool _sg_uninit_shader(sg_shader shd_id) { + _sg_shader_t* shd = _sg_lookup_shader(&_sg.pools, shd_id.id); + if (shd) { + if (shd->slot.ctx_id == _sg.active_context.id) { + _sg_destroy_shader(shd); + _sg_reset_shader(shd); + return true; + } + else { + SOKOL_LOG("_sg_uninit_shader: active context mismatch (must be same as for creation)"); + _SG_TRACE_NOARGS(err_context_mismatch); + } + } + return false; +} + +_SOKOL_PRIVATE bool _sg_uninit_pipeline(sg_pipeline pip_id) { + _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, pip_id.id); + if (pip) { + if (pip->slot.ctx_id == _sg.active_context.id) { + _sg_destroy_pipeline(pip); + _sg_reset_pipeline(pip); + return true; + } + else { + SOKOL_LOG("_sg_uninit_pipeline: active context mismatch (must be same as for creation)"); + _SG_TRACE_NOARGS(err_context_mismatch); + } + } + return false; +} + +_SOKOL_PRIVATE bool _sg_uninit_pass(sg_pass pass_id) { + _sg_pass_t* pass = _sg_lookup_pass(&_sg.pools, pass_id.id); + if (pass) { + if (pass->slot.ctx_id == _sg.active_context.id) { + _sg_destroy_pass(pass); + _sg_reset_pass(pass); + return true; + } + else { + SOKOL_LOG("_sg_uninit_pass: active context mismatch (must be same as for creation)"); + _SG_TRACE_NOARGS(err_context_mismatch); + } + } + return false; +} + +/*== PUBLIC API FUNCTIONS ====================================================*/ + +#if defined(SOKOL_METAL) +// this is ARC compatible +#if defined(__cplusplus) +#define _SG_CLEAR(type, item) { item = { }; } +#else +#define _SG_CLEAR(type, item) { item = (type) { 0 }; } +#endif +#else +#define _SG_CLEAR(type, item) { memset(&item, 0, sizeof(item)); } +#endif + +SOKOL_API_IMPL void sg_setup(const sg_desc* desc) { + SOKOL_ASSERT(desc); + SOKOL_ASSERT((desc->_start_canary == 0) && (desc->_end_canary == 0)); + _SG_CLEAR(_sg_state_t, _sg); + _sg.desc = *desc; + + /* replace zero-init items with their default values + NOTE: on WebGPU, the default color pixel format MUST be provided, + cannot be a default compile-time constant. + */ +#if defined(SOKOL_WGPU) + SOKOL_ASSERT(SG_PIXELFORMAT_NONE != _sg.desc.context.color_format); +#elif defined(SOKOL_METAL) || defined(SOKOL_D3D11) + _sg.desc.context.color_format = _sg_def(_sg.desc.context.color_format, SG_PIXELFORMAT_BGRA8); +#else + _sg.desc.context.color_format = _sg_def(_sg.desc.context.color_format, SG_PIXELFORMAT_RGBA8); +#endif + _sg.desc.context.depth_format = _sg_def(_sg.desc.context.depth_format, SG_PIXELFORMAT_DEPTH_STENCIL); + _sg.desc.context.sample_count = _sg_def(_sg.desc.context.sample_count, 1); + _sg.desc.buffer_pool_size = _sg_def(_sg.desc.buffer_pool_size, _SG_DEFAULT_BUFFER_POOL_SIZE); + _sg.desc.image_pool_size = _sg_def(_sg.desc.image_pool_size, _SG_DEFAULT_IMAGE_POOL_SIZE); + _sg.desc.shader_pool_size = _sg_def(_sg.desc.shader_pool_size, _SG_DEFAULT_SHADER_POOL_SIZE); + _sg.desc.pipeline_pool_size = _sg_def(_sg.desc.pipeline_pool_size, _SG_DEFAULT_PIPELINE_POOL_SIZE); + _sg.desc.pass_pool_size = _sg_def(_sg.desc.pass_pool_size, _SG_DEFAULT_PASS_POOL_SIZE); + _sg.desc.context_pool_size = _sg_def(_sg.desc.context_pool_size, _SG_DEFAULT_CONTEXT_POOL_SIZE); + _sg.desc.uniform_buffer_size = _sg_def(_sg.desc.uniform_buffer_size, _SG_DEFAULT_UB_SIZE); + _sg.desc.staging_buffer_size = _sg_def(_sg.desc.staging_buffer_size, _SG_DEFAULT_STAGING_SIZE); + _sg.desc.sampler_cache_size = _sg_def(_sg.desc.sampler_cache_size, _SG_DEFAULT_SAMPLER_CACHE_CAPACITY); + + _sg_setup_pools(&_sg.pools, &_sg.desc); + _sg.frame_index = 1; + _sg_setup_backend(&_sg.desc); + _sg.valid = true; + sg_setup_context(); +} + +SOKOL_API_IMPL void sg_shutdown(void) { + /* can only delete resources for the currently set context here, if multiple + contexts are used, the app code must take care of properly releasing them + (since only the app code can switch between 3D-API contexts) + */ + if (_sg.active_context.id != SG_INVALID_ID) { + _sg_context_t* ctx = _sg_lookup_context(&_sg.pools, _sg.active_context.id); + if (ctx) { + _sg_destroy_all_resources(&_sg.pools, _sg.active_context.id); + _sg_destroy_context(ctx); + } + } + _sg_discard_backend(); + _sg_discard_pools(&_sg.pools); + _sg.valid = false; +} + +SOKOL_API_IMPL bool sg_isvalid(void) { + return _sg.valid; +} + +SOKOL_API_IMPL sg_desc sg_query_desc(void) { + SOKOL_ASSERT(_sg.valid); + return _sg.desc; +} + +SOKOL_API_IMPL sg_backend sg_query_backend(void) { + SOKOL_ASSERT(_sg.valid); + return _sg.backend; +} + +SOKOL_API_IMPL sg_features sg_query_features(void) { + SOKOL_ASSERT(_sg.valid); + return _sg.features; +} + +SOKOL_API_IMPL sg_limits sg_query_limits(void) { + SOKOL_ASSERT(_sg.valid); + return _sg.limits; +} + +SOKOL_API_IMPL sg_pixelformat_info sg_query_pixelformat(sg_pixel_format fmt) { + SOKOL_ASSERT(_sg.valid); + int fmt_index = (int) fmt; + SOKOL_ASSERT((fmt_index > SG_PIXELFORMAT_NONE) && (fmt_index < _SG_PIXELFORMAT_NUM)); + return _sg.formats[fmt_index]; +} + +SOKOL_API_IMPL sg_context sg_setup_context(void) { + SOKOL_ASSERT(_sg.valid); + sg_context res; + int slot_index = _sg_pool_alloc_index(&_sg.pools.context_pool); + if (_SG_INVALID_SLOT_INDEX != slot_index) { + res.id = _sg_slot_alloc(&_sg.pools.context_pool, &_sg.pools.contexts[slot_index].slot, slot_index); + _sg_context_t* ctx = _sg_context_at(&_sg.pools, res.id); + ctx->slot.state = _sg_create_context(ctx); + SOKOL_ASSERT(ctx->slot.state == SG_RESOURCESTATE_VALID); + _sg_activate_context(ctx); + } + else { + /* pool is exhausted */ + res.id = SG_INVALID_ID; + } + _sg.active_context = res; + return res; +} + +SOKOL_API_IMPL void sg_discard_context(sg_context ctx_id) { + SOKOL_ASSERT(_sg.valid); + _sg_destroy_all_resources(&_sg.pools, ctx_id.id); + _sg_context_t* ctx = _sg_lookup_context(&_sg.pools, ctx_id.id); + if (ctx) { + _sg_destroy_context(ctx); + _sg_reset_context(ctx); + _sg_reset_slot(&ctx->slot); + _sg_pool_free_index(&_sg.pools.context_pool, _sg_slot_index(ctx_id.id)); + } + _sg.active_context.id = SG_INVALID_ID; + _sg_activate_context(0); +} + +SOKOL_API_IMPL void sg_activate_context(sg_context ctx_id) { + SOKOL_ASSERT(_sg.valid); + _sg.active_context = ctx_id; + _sg_context_t* ctx = _sg_lookup_context(&_sg.pools, ctx_id.id); + /* NOTE: ctx can be 0 here if the context is no longer valid */ + _sg_activate_context(ctx); +} + +SOKOL_API_IMPL sg_trace_hooks sg_install_trace_hooks(const sg_trace_hooks* trace_hooks) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(trace_hooks); + _SOKOL_UNUSED(trace_hooks); +#if defined(SOKOL_TRACE_HOOKS) + sg_trace_hooks old_hooks = _sg.hooks; + _sg.hooks = *trace_hooks; +#else + static sg_trace_hooks old_hooks; + SOKOL_LOG("sg_install_trace_hooks() called, but SG_TRACE_HOOKS is not defined!"); +#endif + return old_hooks; +} + +SOKOL_API_IMPL sg_buffer sg_alloc_buffer(void) { + SOKOL_ASSERT(_sg.valid); + sg_buffer res = _sg_alloc_buffer(); + _SG_TRACE_ARGS(alloc_buffer, res); + return res; +} + +SOKOL_API_IMPL sg_image sg_alloc_image(void) { + SOKOL_ASSERT(_sg.valid); + sg_image res = _sg_alloc_image(); + _SG_TRACE_ARGS(alloc_image, res); + return res; +} + +SOKOL_API_IMPL sg_shader sg_alloc_shader(void) { + SOKOL_ASSERT(_sg.valid); + sg_shader res = _sg_alloc_shader(); + _SG_TRACE_ARGS(alloc_shader, res); + return res; +} + +SOKOL_API_IMPL sg_pipeline sg_alloc_pipeline(void) { + SOKOL_ASSERT(_sg.valid); + sg_pipeline res = _sg_alloc_pipeline(); + _SG_TRACE_ARGS(alloc_pipeline, res); + return res; +} + +SOKOL_API_IMPL sg_pass sg_alloc_pass(void) { + SOKOL_ASSERT(_sg.valid); + sg_pass res = _sg_alloc_pass(); + _SG_TRACE_ARGS(alloc_pass, res); + return res; +} + +SOKOL_API_IMPL void sg_dealloc_buffer(sg_buffer buf_id) { + SOKOL_ASSERT(_sg.valid); + _sg_dealloc_buffer(buf_id); + _SG_TRACE_ARGS(dealloc_buffer, buf_id); +} + +SOKOL_API_IMPL void sg_dealloc_image(sg_image img_id) { + SOKOL_ASSERT(_sg.valid); + _sg_dealloc_image(img_id); + _SG_TRACE_ARGS(dealloc_image, img_id); +} + +SOKOL_API_IMPL void sg_dealloc_shader(sg_shader shd_id) { + SOKOL_ASSERT(_sg.valid); + _sg_dealloc_shader(shd_id); + _SG_TRACE_ARGS(dealloc_shader, shd_id); +} + +SOKOL_API_IMPL void sg_dealloc_pipeline(sg_pipeline pip_id) { + SOKOL_ASSERT(_sg.valid); + _sg_dealloc_pipeline(pip_id); + _SG_TRACE_ARGS(dealloc_pipeline, pip_id); +} + +SOKOL_API_IMPL void sg_dealloc_pass(sg_pass pass_id) { + SOKOL_ASSERT(_sg.valid); + _sg_dealloc_pass(pass_id); + _SG_TRACE_ARGS(dealloc_pass, pass_id); +} + +SOKOL_API_IMPL void sg_init_buffer(sg_buffer buf_id, const sg_buffer_desc* desc) { + SOKOL_ASSERT(_sg.valid); + sg_buffer_desc desc_def = _sg_buffer_desc_defaults(desc); + _sg_init_buffer(buf_id, &desc_def); + _SG_TRACE_ARGS(init_buffer, buf_id, &desc_def); +} + +SOKOL_API_IMPL void sg_init_image(sg_image img_id, const sg_image_desc* desc) { + SOKOL_ASSERT(_sg.valid); + sg_image_desc desc_def = _sg_image_desc_defaults(desc); + _sg_init_image(img_id, &desc_def); + _SG_TRACE_ARGS(init_image, img_id, &desc_def); +} + +SOKOL_API_IMPL void sg_init_shader(sg_shader shd_id, const sg_shader_desc* desc) { + SOKOL_ASSERT(_sg.valid); + sg_shader_desc desc_def = _sg_shader_desc_defaults(desc); + _sg_init_shader(shd_id, &desc_def); + _SG_TRACE_ARGS(init_shader, shd_id, &desc_def); +} + +SOKOL_API_IMPL void sg_init_pipeline(sg_pipeline pip_id, const sg_pipeline_desc* desc) { + SOKOL_ASSERT(_sg.valid); + sg_pipeline_desc desc_def = _sg_pipeline_desc_defaults(desc); + _sg_init_pipeline(pip_id, &desc_def); + _SG_TRACE_ARGS(init_pipeline, pip_id, &desc_def); +} + +SOKOL_API_IMPL void sg_init_pass(sg_pass pass_id, const sg_pass_desc* desc) { + SOKOL_ASSERT(_sg.valid); + sg_pass_desc desc_def = _sg_pass_desc_defaults(desc); + _sg_init_pass(pass_id, &desc_def); + _SG_TRACE_ARGS(init_pass, pass_id, &desc_def); +} + +SOKOL_API_IMPL bool sg_uninit_buffer(sg_buffer buf_id) { + SOKOL_ASSERT(_sg.valid); + bool res = _sg_uninit_buffer(buf_id); + _SG_TRACE_ARGS(uninit_buffer, buf_id); + return res; +} + +SOKOL_API_IMPL bool sg_uninit_image(sg_image img_id) { + SOKOL_ASSERT(_sg.valid); + bool res = _sg_uninit_image(img_id); + _SG_TRACE_ARGS(uninit_image, img_id); + return res; +} + +SOKOL_API_IMPL bool sg_uninit_shader(sg_shader shd_id) { + SOKOL_ASSERT(_sg.valid); + bool res = _sg_uninit_shader(shd_id); + _SG_TRACE_ARGS(uninit_shader, shd_id); + return res; +} + +SOKOL_API_IMPL bool sg_uninit_pipeline(sg_pipeline pip_id) { + SOKOL_ASSERT(_sg.valid); + bool res = _sg_uninit_pipeline(pip_id); + _SG_TRACE_ARGS(uninit_pipeline, pip_id); + return res; +} + +SOKOL_API_IMPL bool sg_uninit_pass(sg_pass pass_id) { + SOKOL_ASSERT(_sg.valid); + bool res = _sg_uninit_pass(pass_id); + _SG_TRACE_ARGS(uninit_pass, pass_id); + return res; +} + +/*-- set allocated resource to failed state ----------------------------------*/ +SOKOL_API_IMPL void sg_fail_buffer(sg_buffer buf_id) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(buf_id.id != SG_INVALID_ID); + _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, buf_id.id); + SOKOL_ASSERT(buf && buf->slot.state == SG_RESOURCESTATE_ALLOC); + buf->slot.ctx_id = _sg.active_context.id; + buf->slot.state = SG_RESOURCESTATE_FAILED; + _SG_TRACE_ARGS(fail_buffer, buf_id); +} + +SOKOL_API_IMPL void sg_fail_image(sg_image img_id) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(img_id.id != SG_INVALID_ID); + _sg_image_t* img = _sg_lookup_image(&_sg.pools, img_id.id); + SOKOL_ASSERT(img && img->slot.state == SG_RESOURCESTATE_ALLOC); + img->slot.ctx_id = _sg.active_context.id; + img->slot.state = SG_RESOURCESTATE_FAILED; + _SG_TRACE_ARGS(fail_image, img_id); +} + +SOKOL_API_IMPL void sg_fail_shader(sg_shader shd_id) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(shd_id.id != SG_INVALID_ID); + _sg_shader_t* shd = _sg_lookup_shader(&_sg.pools, shd_id.id); + SOKOL_ASSERT(shd && shd->slot.state == SG_RESOURCESTATE_ALLOC); + shd->slot.ctx_id = _sg.active_context.id; + shd->slot.state = SG_RESOURCESTATE_FAILED; + _SG_TRACE_ARGS(fail_shader, shd_id); +} + +SOKOL_API_IMPL void sg_fail_pipeline(sg_pipeline pip_id) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(pip_id.id != SG_INVALID_ID); + _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, pip_id.id); + SOKOL_ASSERT(pip && pip->slot.state == SG_RESOURCESTATE_ALLOC); + pip->slot.ctx_id = _sg.active_context.id; + pip->slot.state = SG_RESOURCESTATE_FAILED; + _SG_TRACE_ARGS(fail_pipeline, pip_id); +} + +SOKOL_API_IMPL void sg_fail_pass(sg_pass pass_id) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(pass_id.id != SG_INVALID_ID); + _sg_pass_t* pass = _sg_lookup_pass(&_sg.pools, pass_id.id); + SOKOL_ASSERT(pass && pass->slot.state == SG_RESOURCESTATE_ALLOC); + pass->slot.ctx_id = _sg.active_context.id; + pass->slot.state = SG_RESOURCESTATE_FAILED; + _SG_TRACE_ARGS(fail_pass, pass_id); +} + +/*-- get resource state */ +SOKOL_API_IMPL sg_resource_state sg_query_buffer_state(sg_buffer buf_id) { + SOKOL_ASSERT(_sg.valid); + _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, buf_id.id); + sg_resource_state res = buf ? buf->slot.state : SG_RESOURCESTATE_INVALID; + return res; +} + +SOKOL_API_IMPL sg_resource_state sg_query_image_state(sg_image img_id) { + SOKOL_ASSERT(_sg.valid); + _sg_image_t* img = _sg_lookup_image(&_sg.pools, img_id.id); + sg_resource_state res = img ? img->slot.state : SG_RESOURCESTATE_INVALID; + return res; +} + +SOKOL_API_IMPL sg_resource_state sg_query_shader_state(sg_shader shd_id) { + SOKOL_ASSERT(_sg.valid); + _sg_shader_t* shd = _sg_lookup_shader(&_sg.pools, shd_id.id); + sg_resource_state res = shd ? shd->slot.state : SG_RESOURCESTATE_INVALID; + return res; +} + +SOKOL_API_IMPL sg_resource_state sg_query_pipeline_state(sg_pipeline pip_id) { + SOKOL_ASSERT(_sg.valid); + _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, pip_id.id); + sg_resource_state res = pip ? pip->slot.state : SG_RESOURCESTATE_INVALID; + return res; +} + +SOKOL_API_IMPL sg_resource_state sg_query_pass_state(sg_pass pass_id) { + SOKOL_ASSERT(_sg.valid); + _sg_pass_t* pass = _sg_lookup_pass(&_sg.pools, pass_id.id); + sg_resource_state res = pass ? pass->slot.state : SG_RESOURCESTATE_INVALID; + return res; +} + +/*-- allocate and initialize resource ----------------------------------------*/ +SOKOL_API_IMPL sg_buffer sg_make_buffer(const sg_buffer_desc* desc) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(desc); + sg_buffer_desc desc_def = _sg_buffer_desc_defaults(desc); + sg_buffer buf_id = _sg_alloc_buffer(); + if (buf_id.id != SG_INVALID_ID) { + _sg_init_buffer(buf_id, &desc_def); + } + else { + SOKOL_LOG("buffer pool exhausted!"); + _SG_TRACE_NOARGS(err_buffer_pool_exhausted); + } + _SG_TRACE_ARGS(make_buffer, &desc_def, buf_id); + return buf_id; +} + +SOKOL_API_IMPL sg_image sg_make_image(const sg_image_desc* desc) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(desc); + sg_image_desc desc_def = _sg_image_desc_defaults(desc); + sg_image img_id = _sg_alloc_image(); + if (img_id.id != SG_INVALID_ID) { + _sg_init_image(img_id, &desc_def); + } + else { + SOKOL_LOG("image pool exhausted!"); + _SG_TRACE_NOARGS(err_image_pool_exhausted); + } + _SG_TRACE_ARGS(make_image, &desc_def, img_id); + return img_id; +} + +SOKOL_API_IMPL sg_shader sg_make_shader(const sg_shader_desc* desc) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(desc); + sg_shader_desc desc_def = _sg_shader_desc_defaults(desc); + sg_shader shd_id = _sg_alloc_shader(); + if (shd_id.id != SG_INVALID_ID) { + _sg_init_shader(shd_id, &desc_def); + } + else { + SOKOL_LOG("shader pool exhausted!"); + _SG_TRACE_NOARGS(err_shader_pool_exhausted); + } + _SG_TRACE_ARGS(make_shader, &desc_def, shd_id); + return shd_id; +} + +SOKOL_API_IMPL sg_pipeline sg_make_pipeline(const sg_pipeline_desc* desc) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(desc); + sg_pipeline_desc desc_def = _sg_pipeline_desc_defaults(desc); + sg_pipeline pip_id = _sg_alloc_pipeline(); + if (pip_id.id != SG_INVALID_ID) { + _sg_init_pipeline(pip_id, &desc_def); + } + else { + SOKOL_LOG("pipeline pool exhausted!"); + _SG_TRACE_NOARGS(err_pipeline_pool_exhausted); + } + _SG_TRACE_ARGS(make_pipeline, &desc_def, pip_id); + return pip_id; +} + +SOKOL_API_IMPL sg_pass sg_make_pass(const sg_pass_desc* desc) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(desc); + sg_pass_desc desc_def = _sg_pass_desc_defaults(desc); + sg_pass pass_id = _sg_alloc_pass(); + if (pass_id.id != SG_INVALID_ID) { + _sg_init_pass(pass_id, &desc_def); + } + else { + SOKOL_LOG("pass pool exhausted!"); + _SG_TRACE_NOARGS(err_pass_pool_exhausted); + } + _SG_TRACE_ARGS(make_pass, &desc_def, pass_id); + return pass_id; +} + +/*-- destroy resource --------------------------------------------------------*/ +SOKOL_API_IMPL void sg_destroy_buffer(sg_buffer buf_id) { + SOKOL_ASSERT(_sg.valid); + _SG_TRACE_ARGS(destroy_buffer, buf_id); + if (_sg_uninit_buffer(buf_id)) { + _sg_dealloc_buffer(buf_id); + } +} + +SOKOL_API_IMPL void sg_destroy_image(sg_image img_id) { + SOKOL_ASSERT(_sg.valid); + _SG_TRACE_ARGS(destroy_image, img_id); + if (_sg_uninit_image(img_id)) { + _sg_dealloc_image(img_id); + } +} + +SOKOL_API_IMPL void sg_destroy_shader(sg_shader shd_id) { + SOKOL_ASSERT(_sg.valid); + _SG_TRACE_ARGS(destroy_shader, shd_id); + if (_sg_uninit_shader(shd_id)) { + _sg_dealloc_shader(shd_id); + } +} + +SOKOL_API_IMPL void sg_destroy_pipeline(sg_pipeline pip_id) { + SOKOL_ASSERT(_sg.valid); + _SG_TRACE_ARGS(destroy_pipeline, pip_id); + if (_sg_uninit_pipeline(pip_id)) { + _sg_dealloc_pipeline(pip_id); + } +} + +SOKOL_API_IMPL void sg_destroy_pass(sg_pass pass_id) { + SOKOL_ASSERT(_sg.valid); + _SG_TRACE_ARGS(destroy_pass, pass_id); + if (_sg_uninit_pass(pass_id)) { + _sg_dealloc_pass(pass_id); + } +} + +SOKOL_API_IMPL void sg_begin_default_pass(const sg_pass_action* pass_action, int width, int height) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(pass_action); + SOKOL_ASSERT((pass_action->_start_canary == 0) && (pass_action->_end_canary == 0)); + sg_pass_action pa; + _sg_resolve_default_pass_action(pass_action, &pa); + _sg.cur_pass.id = SG_INVALID_ID; + _sg.pass_valid = true; + _sg_begin_pass(0, &pa, width, height); + _SG_TRACE_ARGS(begin_default_pass, pass_action, width, height); +} + +SOKOL_API_IMPL void sg_begin_default_passf(const sg_pass_action* pass_action, float width, float height) { + sg_begin_default_pass(pass_action, (int)width, (int)height); +} + +SOKOL_API_IMPL void sg_begin_pass(sg_pass pass_id, const sg_pass_action* pass_action) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(pass_action); + SOKOL_ASSERT((pass_action->_start_canary == 0) && (pass_action->_end_canary == 0)); + _sg.cur_pass = pass_id; + _sg_pass_t* pass = _sg_lookup_pass(&_sg.pools, pass_id.id); + if (pass && _sg_validate_begin_pass(pass)) { + _sg.pass_valid = true; + sg_pass_action pa; + _sg_resolve_default_pass_action(pass_action, &pa); + const _sg_image_t* img = _sg_pass_color_image(pass, 0); + SOKOL_ASSERT(img); + const int w = img->cmn.width; + const int h = img->cmn.height; + _sg_begin_pass(pass, &pa, w, h); + _SG_TRACE_ARGS(begin_pass, pass_id, pass_action); + } + else { + _sg.pass_valid = false; + _SG_TRACE_NOARGS(err_pass_invalid); + } +} + +SOKOL_API_IMPL void sg_apply_viewport(int x, int y, int width, int height, bool origin_top_left) { + SOKOL_ASSERT(_sg.valid); + if (!_sg.pass_valid) { + _SG_TRACE_NOARGS(err_pass_invalid); + return; + } + _sg_apply_viewport(x, y, width, height, origin_top_left); + _SG_TRACE_ARGS(apply_viewport, x, y, width, height, origin_top_left); +} + +SOKOL_API_IMPL void sg_apply_viewportf(float x, float y, float width, float height, bool origin_top_left) { + sg_apply_viewport((int)x, (int)y, (int)width, (int)height, origin_top_left); +} + +SOKOL_API_IMPL void sg_apply_scissor_rect(int x, int y, int width, int height, bool origin_top_left) { + SOKOL_ASSERT(_sg.valid); + if (!_sg.pass_valid) { + _SG_TRACE_NOARGS(err_pass_invalid); + return; + } + _sg_apply_scissor_rect(x, y, width, height, origin_top_left); + _SG_TRACE_ARGS(apply_scissor_rect, x, y, width, height, origin_top_left); +} + +SOKOL_API_IMPL void sg_apply_scissor_rectf(float x, float y, float width, float height, bool origin_top_left) { + sg_apply_scissor_rect((int)x, (int)y, (int)width, (int)height, origin_top_left); +} + +SOKOL_API_IMPL void sg_apply_pipeline(sg_pipeline pip_id) { + SOKOL_ASSERT(_sg.valid); + _sg.bindings_valid = false; + if (!_sg_validate_apply_pipeline(pip_id)) { + _sg.next_draw_valid = false; + _SG_TRACE_NOARGS(err_draw_invalid); + return; + } + if (!_sg.pass_valid) { + _SG_TRACE_NOARGS(err_pass_invalid); + return; + } + _sg.cur_pipeline = pip_id; + _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, pip_id.id); + SOKOL_ASSERT(pip); + _sg.next_draw_valid = (SG_RESOURCESTATE_VALID == pip->slot.state); + SOKOL_ASSERT(pip->shader && (pip->shader->slot.id == pip->cmn.shader_id.id)); + _sg_apply_pipeline(pip); + _SG_TRACE_ARGS(apply_pipeline, pip_id); +} + +SOKOL_API_IMPL void sg_apply_bindings(const sg_bindings* bindings) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(bindings); + SOKOL_ASSERT((bindings->_start_canary == 0) && (bindings->_end_canary==0)); + if (!_sg_validate_apply_bindings(bindings)) { + _sg.next_draw_valid = false; + _SG_TRACE_NOARGS(err_draw_invalid); + return; + } + _sg.bindings_valid = true; + + _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, _sg.cur_pipeline.id); + SOKOL_ASSERT(pip); + + _sg_buffer_t* vbs[SG_MAX_SHADERSTAGE_BUFFERS] = { 0 }; + int num_vbs = 0; + for (int i = 0; i < SG_MAX_SHADERSTAGE_BUFFERS; i++, num_vbs++) { + if (bindings->vertex_buffers[i].id) { + vbs[i] = _sg_lookup_buffer(&_sg.pools, bindings->vertex_buffers[i].id); + SOKOL_ASSERT(vbs[i]); + _sg.next_draw_valid &= (SG_RESOURCESTATE_VALID == vbs[i]->slot.state); + _sg.next_draw_valid &= !vbs[i]->cmn.append_overflow; + } + else { + break; + } + } + + _sg_buffer_t* ib = 0; + if (bindings->index_buffer.id) { + ib = _sg_lookup_buffer(&_sg.pools, bindings->index_buffer.id); + SOKOL_ASSERT(ib); + _sg.next_draw_valid &= (SG_RESOURCESTATE_VALID == ib->slot.state); + _sg.next_draw_valid &= !ib->cmn.append_overflow; + } + + _sg_image_t* vs_imgs[SG_MAX_SHADERSTAGE_IMAGES] = { 0 }; + int num_vs_imgs = 0; + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++, num_vs_imgs++) { + if (bindings->vs_images[i].id) { + vs_imgs[i] = _sg_lookup_image(&_sg.pools, bindings->vs_images[i].id); + SOKOL_ASSERT(vs_imgs[i]); + _sg.next_draw_valid &= (SG_RESOURCESTATE_VALID == vs_imgs[i]->slot.state); + } + else { + break; + } + } + + _sg_image_t* fs_imgs[SG_MAX_SHADERSTAGE_IMAGES] = { 0 }; + int num_fs_imgs = 0; + for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++, num_fs_imgs++) { + if (bindings->fs_images[i].id) { + fs_imgs[i] = _sg_lookup_image(&_sg.pools, bindings->fs_images[i].id); + SOKOL_ASSERT(fs_imgs[i]); + _sg.next_draw_valid &= (SG_RESOURCESTATE_VALID == fs_imgs[i]->slot.state); + } + else { + break; + } + } + if (_sg.next_draw_valid) { + const int* vb_offsets = bindings->vertex_buffer_offsets; + int ib_offset = bindings->index_buffer_offset; + _sg_apply_bindings(pip, vbs, vb_offsets, num_vbs, ib, ib_offset, vs_imgs, num_vs_imgs, fs_imgs, num_fs_imgs); + _SG_TRACE_ARGS(apply_bindings, bindings); + } + else { + _SG_TRACE_NOARGS(err_draw_invalid); + } +} + +SOKOL_API_IMPL void sg_apply_uniforms(sg_shader_stage stage, int ub_index, const sg_range* data) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT((stage == SG_SHADERSTAGE_VS) || (stage == SG_SHADERSTAGE_FS)); + SOKOL_ASSERT((ub_index >= 0) && (ub_index < SG_MAX_SHADERSTAGE_UBS)); + SOKOL_ASSERT(data && data->ptr && (data->size > 0)); + if (!_sg_validate_apply_uniforms(stage, ub_index, data)) { + _sg.next_draw_valid = false; + _SG_TRACE_NOARGS(err_draw_invalid); + return; + } + if (!_sg.pass_valid) { + _SG_TRACE_NOARGS(err_pass_invalid); + return; + } + if (!_sg.next_draw_valid) { + _SG_TRACE_NOARGS(err_draw_invalid); + return; + } + _sg_apply_uniforms(stage, ub_index, data); + _SG_TRACE_ARGS(apply_uniforms, stage, ub_index, data); +} + +SOKOL_API_IMPL void sg_draw(int base_element, int num_elements, int num_instances) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(base_element >= 0); + SOKOL_ASSERT(num_elements >= 0); + SOKOL_ASSERT(num_instances >= 0); +#if defined(SOKOL_DEBUG) + if (!_sg.bindings_valid) { + SOKOL_LOG("attempting to draw without resource bindings"); + } +#endif + if (!_sg.pass_valid) { + _SG_TRACE_NOARGS(err_pass_invalid); + return; + } + if (!_sg.next_draw_valid) { + _SG_TRACE_NOARGS(err_draw_invalid); + return; + } + if (!_sg.bindings_valid) { + _SG_TRACE_NOARGS(err_bindings_invalid); + return; + } + /* attempting to draw with zero elements or instances is not technically an + error, but might be handled as an error in the backend API (e.g. on Metal) + */ + if ((0 == num_elements) || (0 == num_instances)) { + _SG_TRACE_NOARGS(err_draw_invalid); + return; + } + _sg_draw(base_element, num_elements, num_instances); + _SG_TRACE_ARGS(draw, base_element, num_elements, num_instances); +} + +SOKOL_API_IMPL void sg_end_pass(void) { + SOKOL_ASSERT(_sg.valid); + if (!_sg.pass_valid) { + _SG_TRACE_NOARGS(err_pass_invalid); + return; + } + _sg_end_pass(); + _sg.cur_pass.id = SG_INVALID_ID; + _sg.cur_pipeline.id = SG_INVALID_ID; + _sg.pass_valid = false; + _SG_TRACE_NOARGS(end_pass); +} + +SOKOL_API_IMPL void sg_commit(void) { + SOKOL_ASSERT(_sg.valid); + _sg_commit(); + _SG_TRACE_NOARGS(commit); + _sg.frame_index++; +} + +SOKOL_API_IMPL void sg_reset_state_cache(void) { + SOKOL_ASSERT(_sg.valid); + _sg_reset_state_cache(); + _SG_TRACE_NOARGS(reset_state_cache); +} + +SOKOL_API_IMPL void sg_update_buffer(sg_buffer buf_id, const sg_range* data) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(data && data->ptr && (data->size > 0)); + _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, buf_id.id); + if ((data->size > 0) && buf && (buf->slot.state == SG_RESOURCESTATE_VALID)) { + if (_sg_validate_update_buffer(buf, data)) { + SOKOL_ASSERT(data->size <= (size_t)buf->cmn.size); + /* only one update allowed per buffer and frame */ + SOKOL_ASSERT(buf->cmn.update_frame_index != _sg.frame_index); + /* update and append on same buffer in same frame not allowed */ + SOKOL_ASSERT(buf->cmn.append_frame_index != _sg.frame_index); + _sg_update_buffer(buf, data); + buf->cmn.update_frame_index = _sg.frame_index; + } + } + _SG_TRACE_ARGS(update_buffer, buf_id, data); +} + +SOKOL_API_IMPL int sg_append_buffer(sg_buffer buf_id, const sg_range* data) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(data && data->ptr); + _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, buf_id.id); + int result; + if (buf) { + /* rewind append cursor in a new frame */ + if (buf->cmn.append_frame_index != _sg.frame_index) { + buf->cmn.append_pos = 0; + buf->cmn.append_overflow = false; + } + if ((buf->cmn.append_pos + _sg_roundup((int)data->size, 4)) > buf->cmn.size) { + buf->cmn.append_overflow = true; + } + const int start_pos = buf->cmn.append_pos; + if (buf->slot.state == SG_RESOURCESTATE_VALID) { + if (_sg_validate_append_buffer(buf, data)) { + if (!buf->cmn.append_overflow && (data->size > 0)) { + /* update and append on same buffer in same frame not allowed */ + SOKOL_ASSERT(buf->cmn.update_frame_index != _sg.frame_index); + int copied_num_bytes = _sg_append_buffer(buf, data, buf->cmn.append_frame_index != _sg.frame_index); + buf->cmn.append_pos += copied_num_bytes; + buf->cmn.append_frame_index = _sg.frame_index; + } + } + } + result = start_pos; + } + else { + /* FIXME: should we return -1 here? */ + result = 0; + } + _SG_TRACE_ARGS(append_buffer, buf_id, data, result); + return result; +} + +SOKOL_API_IMPL bool sg_query_buffer_overflow(sg_buffer buf_id) { + SOKOL_ASSERT(_sg.valid); + _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, buf_id.id); + bool result = buf ? buf->cmn.append_overflow : false; + return result; +} + +SOKOL_API_IMPL void sg_update_image(sg_image img_id, const sg_image_data* data) { + SOKOL_ASSERT(_sg.valid); + _sg_image_t* img = _sg_lookup_image(&_sg.pools, img_id.id); + if (img && img->slot.state == SG_RESOURCESTATE_VALID) { + if (_sg_validate_update_image(img, data)) { + SOKOL_ASSERT(img->cmn.upd_frame_index != _sg.frame_index); + _sg_update_image(img, data); + img->cmn.upd_frame_index = _sg.frame_index; + } + } + _SG_TRACE_ARGS(update_image, img_id, data); +} + +SOKOL_API_IMPL void sg_push_debug_group(const char* name) { + SOKOL_ASSERT(_sg.valid); + SOKOL_ASSERT(name); + _SOKOL_UNUSED(name); + _SG_TRACE_ARGS(push_debug_group, name); +} + +SOKOL_API_IMPL void sg_pop_debug_group(void) { + SOKOL_ASSERT(_sg.valid); + _SG_TRACE_NOARGS(pop_debug_group); +} + +SOKOL_API_IMPL sg_buffer_info sg_query_buffer_info(sg_buffer buf_id) { + SOKOL_ASSERT(_sg.valid); + sg_buffer_info info; + memset(&info, 0, sizeof(info)); + const _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, buf_id.id); + if (buf) { + info.slot.state = buf->slot.state; + info.slot.res_id = buf->slot.id; + info.slot.ctx_id = buf->slot.ctx_id; + info.update_frame_index = buf->cmn.update_frame_index; + info.append_frame_index = buf->cmn.append_frame_index; + info.append_pos = buf->cmn.append_pos; + info.append_overflow = buf->cmn.append_overflow; +#if defined(SOKOL_D3D11) + info.num_slots = 1; + info.active_slot = 0; +#else + info.num_slots = buf->cmn.num_slots; + info.active_slot = buf->cmn.active_slot; +#endif + } + return info; +} + +SOKOL_API_IMPL sg_image_info sg_query_image_info(sg_image img_id) { + SOKOL_ASSERT(_sg.valid); + sg_image_info info; + memset(&info, 0, sizeof(info)); + const _sg_image_t* img = _sg_lookup_image(&_sg.pools, img_id.id); + if (img) { + info.slot.state = img->slot.state; + info.slot.res_id = img->slot.id; + info.slot.ctx_id = img->slot.ctx_id; + info.upd_frame_index = img->cmn.upd_frame_index; +#if defined(SOKOL_D3D11) + info.num_slots = 1; + info.active_slot = 0; +#else + info.num_slots = img->cmn.num_slots; + info.active_slot = img->cmn.active_slot; +#endif + info.width = img->cmn.width; + info.height = img->cmn.height; + } + return info; +} + +SOKOL_API_IMPL sg_shader_info sg_query_shader_info(sg_shader shd_id) { + SOKOL_ASSERT(_sg.valid); + sg_shader_info info; + memset(&info, 0, sizeof(info)); + const _sg_shader_t* shd = _sg_lookup_shader(&_sg.pools, shd_id.id); + if (shd) { + info.slot.state = shd->slot.state; + info.slot.res_id = shd->slot.id; + info.slot.ctx_id = shd->slot.ctx_id; + } + return info; +} + +SOKOL_API_IMPL sg_pipeline_info sg_query_pipeline_info(sg_pipeline pip_id) { + SOKOL_ASSERT(_sg.valid); + sg_pipeline_info info; + memset(&info, 0, sizeof(info)); + const _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, pip_id.id); + if (pip) { + info.slot.state = pip->slot.state; + info.slot.res_id = pip->slot.id; + info.slot.ctx_id = pip->slot.ctx_id; + } + return info; +} + +SOKOL_API_IMPL sg_pass_info sg_query_pass_info(sg_pass pass_id) { + SOKOL_ASSERT(_sg.valid); + sg_pass_info info; + memset(&info, 0, sizeof(info)); + const _sg_pass_t* pass = _sg_lookup_pass(&_sg.pools, pass_id.id); + if (pass) { + info.slot.state = pass->slot.state; + info.slot.res_id = pass->slot.id; + info.slot.ctx_id = pass->slot.ctx_id; + } + return info; +} + +SOKOL_API_IMPL sg_buffer_desc sg_query_buffer_defaults(const sg_buffer_desc* desc) { + SOKOL_ASSERT(_sg.valid && desc); + return _sg_buffer_desc_defaults(desc); +} + +SOKOL_API_IMPL sg_image_desc sg_query_image_defaults(const sg_image_desc* desc) { + SOKOL_ASSERT(_sg.valid && desc); + return _sg_image_desc_defaults(desc); +} + +SOKOL_API_IMPL sg_shader_desc sg_query_shader_defaults(const sg_shader_desc* desc) { + SOKOL_ASSERT(_sg.valid && desc); + return _sg_shader_desc_defaults(desc); +} + +SOKOL_API_IMPL sg_pipeline_desc sg_query_pipeline_defaults(const sg_pipeline_desc* desc) { + SOKOL_ASSERT(_sg.valid && desc); + return _sg_pipeline_desc_defaults(desc); +} + +SOKOL_API_IMPL sg_pass_desc sg_query_pass_defaults(const sg_pass_desc* desc) { + SOKOL_ASSERT(_sg.valid && desc); + return _sg_pass_desc_defaults(desc); +} + +SOKOL_API_IMPL const void* sg_d3d11_device(void) { +#if defined(SOKOL_D3D11) + return (const void*) _sg.d3d11.dev; +#else + return 0; +#endif +} + +SOKOL_API_IMPL const void* sg_mtl_device(void) { +#if defined(SOKOL_METAL) + if (nil != _sg.mtl.device) { + return (__bridge const void*) _sg.mtl.device; + } + else { + return 0; + } +#else + return 0; +#endif +} + +SOKOL_API_IMPL const void* sg_mtl_render_command_encoder(void) { +#if defined(SOKOL_METAL) + if (nil != _sg.mtl.cmd_encoder) { + return (__bridge const void*) _sg.mtl.cmd_encoder; + } + else { + return 0; + } +#else + return 0; +#endif +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif /* SOKOL_GFX_IMPL */ \ No newline at end of file diff --git a/src_v2/platform/wasm/lumenarium_first_wasm.cpp b/src_v2/platform/wasm/lumenarium_first_wasm.cpp new file mode 100644 index 0000000..6e60e26 --- /dev/null +++ b/src_v2/platform/wasm/lumenarium_first_wasm.cpp @@ -0,0 +1,104 @@ + +#define WASM_EXPORT __attribute__((visibility("default"))) +#define WASM_EXTERN extern "C" + +#define EXTERN_C_BEGIN extern "C" { +#define EXTERN_C_END } + +#include "../lumenarium_compiler_flags.h" +#include "../lumenarium_platform_common_includes.h" + +#include "../../lumenarium_types.h" +#include "../../lumenarium_memory.h" +#include "../lumenarium_platform.h" +#include "../../lumenarium_first.cpp" + +#include "lumenarium_wasm_webgl.cpp" + +#include "lumenarium_wasm_memory.cpp" +// window +#include "lumenarium_wasm_time.cpp" +#include "lumenarium_wasm_file.cpp" +#include "lumenarium_wasm_thread.cpp" + +WASM_EXTERN void print(const char* text, int len); + +typedef void wasm_animation_frame_cb(u32 time_elapsed); +WASM_EXTERN void wasm_request_animation_frame(wasm_animation_frame_cb* cb); + +WASM_EXTERN void wasm_get_canvas_dim(u32* w_ptr, u32* h_ptr); + +EXTERN_C_BEGIN; + +int +str_len (char* str) +{ + int result = 0; + while (str[result] != 0) result++; + return result; +} + +u8* dest = 0; + +App_State* wasm_app_state = 0; + +WASM_EXPORT void +update(u32 time_elapsed) +{ + lumenarium_frame_prepare(wasm_app_state); + lumenarium_frame(wasm_app_state); + + // TODO(PS): check for app running flags + if (!glHadError()) + { + wasm_request_animation_frame(update); + } +} + +WASM_EXPORT int +main(void) +{ + wasm_app_state = lumenarium_init(); + if (has_flag(wasm_app_state->flags, AppState_RunEditor)) + { + u32 w, h; + wasm_get_canvas_dim(&w, &h); + wasm_app_state->editor->window_dim = v2{ + (r32)w, (r32)h + }; + } + wasm_request_animation_frame(update); + return 0; + +#if 0 + Platform_Ticks first = platform_get_ticks(); + + char* str0 = "Hi there!"; + int str0_len = str_len(str0); + print(str0, str0_len); + + char a = str0[0]; + char* str1 = (char*)platform_mem_reserve(32); + char b = str0[0]; + + for (int i = 0; i < str0_len; i++) + { + int it = str0_len - (i + 1); + str1[i] = str0[i]; + } + print(str1, str0_len); + + char* file = "text.txt"; + int file_len = str_len(file); + + dest = platform_mem_reserve(KB(4)); + wasm_fetch(file, file_len, dest, KB(4)); + + Platform_Ticks last = platform_get_ticks(); + r64 seconds_elapsed = get_seconds_elapsed(first, last); + + return last.value - first.value; +#endif +} + +EXTERN_C_END; \ No newline at end of file diff --git a/src_v2/platform/wasm/lumenarium_wasm_file.cpp b/src_v2/platform/wasm/lumenarium_wasm_file.cpp new file mode 100644 index 0000000..4cf4aad --- /dev/null +++ b/src_v2/platform/wasm/lumenarium_wasm_file.cpp @@ -0,0 +1,56 @@ + +WASM_EXTERN u32 wasm_fetch(char* file_path, u32 file_path_len, u8* dest, u32 size); +WASM_EXTERN void wasm_platform_file_async_work_on_job(char* path, u32 path_len, u8* data, u32 data_len, bool read, bool write); + +Platform_File_Handle +platform_file_open(String path, Platform_File_Access_Flags flags_access, Platform_File_Create_Flags flags_create) +{ + return {}; +} + +void +platform_file_close(Platform_File_Handle file_handle) +{ + return; +} + +Platform_File_Info +platform_file_get_info(Platform_File_Handle file_handle, Allocator* allocator) +{ + return {}; +} + +Data +platform_file_read_all(Platform_File_Handle file_handle, Allocator* allocator) +{ + return {}; +} + +bool +platform_file_write_all(Platform_File_Handle file_handle, Data file_data) +{ + return {}; +} + +String +platform_get_exe_path(Allocator* allocator) +{ + return {}; +} + +bool +platform_pwd_set(String path) +{ + return false; +} + +void +platform_file_async_work_on_job(Platform_File_Async_Job* job) +{ + wasm_platform_file_async_work_on_job( + (char*)job->args.path.str, job->args.path.len, + job->args.data.base, job->args.data.size, + has_flag(job->args.flags, PlatformFileAsyncJob_Read), + has_flag(job->args.flags, PlatformFileAsyncJob_Write) + ); +} \ No newline at end of file diff --git a/src_v2/platform/wasm/lumenarium_wasm_imports.js b/src_v2/platform/wasm/lumenarium_wasm_imports.js new file mode 100644 index 0000000..ff42920 --- /dev/null +++ b/src_v2/platform/wasm/lumenarium_wasm_imports.js @@ -0,0 +1,507 @@ +var lumenarium_wasm_module = null; +var lumenarium_wasm_instance = null; + +var WASM_PAGE_SIZE = 65536; + +function wasm_mem_get_u8_arr(inst, ptr, size) +{ + let view = new Uint8Array(inst.exports.memory.buffer, ptr, size); + return view; +} + +function wasm_read_string(inst, ptr, len) +{ + let view = wasm_mem_get_u8_arr(inst, ptr, len); + let string = ''; + for (let i = 0; i < len; i++) + { + string += String.fromCharCode(view[i]); + } + return string; +} + +function wasm_write_bytes(inst, src, ptr, len) +{ + let view = wasm_mem_get_u8_arr(inst, ptr, len); + for (let i = 0; i < len; i++) view[i] = src[i]; +} + +function wasm_get_proc(inst, proc_ptr) +{ + let result = inst.exports.__indirect_function_table.get(proc_ptr); + return result; +} + +function fract (v) { return v % 1; } + +function u32_to_byte_array_32 (v) +{ + let result = [0, 0, 0, 0]; + result[0] = (v & 0xff); + result[1] = (((v - result[0]) >> 8 ) & 0xff); + result[2] = (((v - result[1]) >> 16) & 0xff); + result[3] = (((v - result[2]) >> 24) & 0xff); + return result; +} + +function byte_array_32_to_u32 (arr) +{ + // NOTE(PS): the '>>>' operators in this function deal with the fact + // that bit shift operators convert numbers to s32's. The >>> just + // converts them back to u32s + let r0 = ((arr[0] & 0xff) << 0 ); + let r1 = ((arr[1] & 0xff) << 8 ); + let r2 = ((arr[2] & 0xff) << 16); + let r3 = (((arr[3] & 0xff) << 24) >>> 0); + let result = (r0 | r1 | r2 | r3) >>> 0; + return result; +} + +function put_u32 (ptr, value) +{ + let src = u32_to_byte_array_32(value); + wasm_write_bytes(lumenarium_wasm_instance, src, ptr, 4); +} + +var lumenarium_wasm_imports = { + + memset: (dst, size, value) => { + let view_dst = wasm_mem_get_u8_arr(lumenarium_wasm_instance, dst, size); + for (let i = 0; i < size; i++) + { + view_dst[i] = value; + } + }, + + memcpy: (dst, src, size) => { + let view_dst = wasm_mem_get_u8_arr(lumenarium_wasm_instance, dst, size); + let view_src = wasm_mem_get_u8_arr(lumenarium_wasm_instance, src, size); + for (let i = 0; i < size; i++) + { + view_dst[i] = view_src[i]; + } + }, + + wasm_assert_always: (file, file_len, line) => { + let file_str = wasm_read_string(lumenarium_wasm_instance, file, file_len); + console.assert(false, "At: " + file_str + "::" + line); + }, + + wasm_get_memory_size: () => { + return instance.exports.memory.buffer.byteLength; + }, + + wasm_mem_grow: (new_size) => { + let new_size_ = new_size >>> 0; + let pages = new_size_ / WASM_PAGE_SIZE; + let pages_rem = fract(pages); + if (pages_rem > 0) pages = Math.floor(pages) + 1; + let size_before = lumenarium_wasm_instance.exports.memory.buffer.byteLength; + let old_page_count = lumenarium_wasm_instance.exports.memory.grow(pages); + + console.log("mem_grow\n", + "req size: ", new_size_, "\n", + "old size: ", (old_page_count * WASM_PAGE_SIZE), "\n", + "old size: ", size_before, "\n", + "grew by: ", (pages * WASM_PAGE_SIZE), "\n", + "new size: ", lumenarium_wasm_instance.exports.memory.buffer.byteLength, ""); + }, + + malloc: (size) => { + + }, + + free: (base) => { + + }, + + sin: Math.sin, + sinf: Math.sin, + cos: Math.cos, + cosf: Math.cos, + tan: Math.tan, + tanf: Math.tan, + asin: Math.asin, + asinf: Math.asin, + acos: Math.acos, + acosf: Math.acos, + atan: Math.atan, + atanf: Math.atan, + pow: Math.pow, + powf: Math.pow, + fmodf: (f,d) => { return f % d; }, + strlen: (ptr) => { + let len = 0; + let len_checked = 0; + let len_to_check = 256; + let found_end = false; + while (true) + { + let string = wasm_mem_get_u8_arr(lumenarium_wasm_instance, ptr, len_checked); + for (let i = len_checked; i < len_to_check; i++) + { + if (string[i] == 0) + { + len = i; + break; + } + } + len_checked *= 2; + } + return len_checked; + }, + + wasm_platform_file_async_work_on_job: (path, path_len, data, data_size, read, write) => { + + }, + + wasm_performance_now: () => { + return performance.now(); + }, + + wasm_sleep: (milliseconds) => { + let start = Date.now(); + for (let at = Date.now(); (at - start) < milliseconds; at = Date.now()) {} + }, + + wasm_fetch: async (file_path, file_path_len, dest, dest_size) => { + let path = wasm_read_string(lumenarium_wasm_instance, file_path, file_path_len); + fetch(path) + .then(async (res) => { + // TODO(PS): success checking + let reader = res.body.getReader(); + let read_res = { done: false }; + + let view = wasm_mem_get_u8_arr(lumenarium_wasm_instance, dest, dest_size); + let last_write = 0; + while (!read_res.done) + { + read_res = await reader.read(); + if (read_res.done) break; + + let len = read_res.value.length; + let write_end = last_write + len; + for (let i = last_write; i < write_end; i++) + { + view[i] = read_res.value[i - last_write]; + } + last_write = write_end + 1; + } + }); + return 0; + }, + + wasm_request_animation_frame: (cb) => { + let cb_proc = wasm_get_proc(lumenarium_wasm_instance, cb); + window.requestAnimationFrame(cb_proc); + }, + + print: (str_base, len) => { + let string = wasm_read_string(lumenarium_wasm_instance, str_base, len); + console.log(string); + }, + + wasm_get_canvas_dim: (w_ptr, h_ptr) => { + const canvas = document.querySelector("#gl_canvas"); + + let w_view = wasm_mem_get_u8_arr(lumenarium_wasm_instance, w_ptr, 4); + let w = canvas.width; + let wb = u32_to_byte_array_32(w); + for (let i = 0; i < 4; i++) w_view[i] = wb[i]; + + let h_view = wasm_mem_get_u8_arr(lumenarium_wasm_instance, h_ptr, 4); + let h = canvas.height; + let hb = u32_to_byte_array_32(h); + for (let i = 0; i < 4; i++) h_view[i] = hb[i]; + }, +}; + +/////////////////////////////////////// +// Web GL Imports + +let gl = null; +let gl_error = false; + +function glErrorReport(outer_args) { + const err = gl.getError(); + if (err == gl.NO_ERROR) return; + + gl_error = true; + let msg = ""; + switch (err) { + case gl.NO_ERROR: { msg = "NO_ERROR"; } break; + case gl.INVALID_ENUM: { msg = "INVALID_ENUM"; } break; + case gl.INVALID_VALUE: { msg = "INVALID_VALUE"; } break; + case gl.INVALID_OPERATION: { msg = "INVALID_OPERATION"; } break; + case gl.INVALID_FRAMEBUFFER_OPERATION: { msg = "INVALID_FRAMEBUFFER_OPERATION"; } break; + case gl.OUT_OF_MEMORY: { msg = "OUT_OF_MEMORY"; } break; + case gl.CONTEXT_LOST_WEBGL: { msg = "CONTEXT_LOST_WEBGL"; } break; + default: { msg = "Uknown error"; } break; + } + console.error(`WebGL Error: ${msg} ${err}`, outer_args); +} + +// NOTE(PS): it seems like its not enough to set +// the values of imports to gl.function +// ie. imports.glClearColor = gl.clearColor +// instead we need to wrap them for some reason. +// Not sure why +function glClearColor (r, g, b, a) { return gl.clearColor(r,g,b,a); } +function glEnable(v) { + const r = gl.enable(v); + glErrorReport(arguments); + return r; +} +function glDisable(v) { + const r = gl.disable(v); + glErrorReport(arguments); + return r; +} +function glBlendFunc(a,b) { + const r = gl.blendFunc(a,b); + glErrorReport(arguments); + return r; +} +function glViewport(xmin, ymin, xmax, ymax) { return gl.viewport(xmin,ymin,xmax,ymax); } +function glDepthFunc(v) { + const r = gl.depthFunc(v); + glErrorReport(arguments); + return r; +} +function glClear(mask) { + const r = gl.clear(mask); + glErrorReport(arguments); + return r; +} + +let glBuffers = []; +let glShaders = []; +let glPrograms = []; +let glTextures = []; +function gl_get_managed_resource(arr, id) { + if (id == 0) return null; + return arr[id - 1]; +} +function gl_get_buffer(id) { return gl_get_managed_resource(glBuffers, id); } +function gl_get_shader(id) { return gl_get_managed_resource(glShaders, id); } +function gl_get_program(id) { return gl_get_managed_resource(glPrograms, id); } +function gl_get_texture(id) { return gl_get_managed_resource(glTextures, id); } + +function glCreateBuffer() { + let buffer = gl.createBuffer(); + glErrorReport(arguments); + let new_len = glBuffers.push(buffer); + return new_len; +} + +function glBindBuffer(buffer_kind, buffer_id) +{ + const r = gl.bindBuffer(buffer_kind, gl_get_buffer(buffer_id)); + glErrorReport(arguments); + return r; +} + +function glBufferData(target, size, ptr, usage) +{ + let data = wasm_mem_get_u8_arr(lumenarium_wasm_instance, ptr, size); + const r = gl.bufferData(target, data, usage); + glErrorReport(arguments); + return r; +} + +function glBufferSubData(target, offset, size, ptr) +{ + let data = wasm_mem_get_u8_arr(lumenarium_wasm_instance, ptr, size); + const r = gl.bufferSubData(target, offset, data, 0, size); + glErrorReport(arguments); + return r; +} + +function glCreateShader(kind) +{ + let shader = gl.createShader(kind); + glErrorReport(arguments); + let new_len = glShaders.push(shader); + return new_len; +} + +function glShaderSource(shader_id, shader_code, shader_code_len) +{ + let str = wasm_read_string(lumenarium_wasm_instance, shader_code, shader_code_len); + const r = gl.shaderSource(gl_get_shader(shader_id), str); + glErrorReport(arguments); + return r; +} + +function glCompileShader(shader_id) +{ + let s = gl_get_shader(shader_id); + let r = gl.compileShader(s); + glErrorReport(arguments); + let m = gl.getShaderInfoLog(s); + glErrorReport(arguments); + if (m.length > 0) + { + console.error("glCompileShader: \n\n" + m); + } +} + +function glCreateProgram() +{ + let prog = gl.createProgram(); + glErrorReport(arguments); + let new_len = glPrograms.push(prog); + return new_len; +} + +function glAttachShader(program, shader) +{ + let s = gl_get_shader(shader); + let p = gl_get_program(program); + const r = gl.attachShader(p, s); + glErrorReport(arguments); + return r; +} + +function glLinkProgram(program) +{ + let p = gl_get_program(program); + gl.linkProgram(p); + if (!gl.getProgramParameter(p, gl.LINK_STATUS)) { + var info = gl.getProgramInfoLog(p); + console.error("Failed to compile WebGL program. \n\n"+info); + } +} + +function glUseProgram(program) +{ + let p = gl_get_program(program); + const r = gl.useProgram(p); + glErrorReport(arguments); + return r; +} + +function glGetAttribLocation(program, name, name_len) +{ + let str = wasm_read_string(lumenarium_wasm_instance, name, name_len); + const r = gl.getAttribLocation(gl_get_program(program), str); + glErrorReport(arguments); + return r; +} + +function glVertexAttribPointer(attr, size, type, normalized, stride, pointer) +{ + const r = gl.vertexAttribPointer(attr, size, type, normalized, stride, pointer); + glErrorReport(arguments); + return r; +} + +function glEnableVertexAttribArray(index) +{ + const r = gl.enableVertexAttribArray(index); + glErrorReport(arguments); + return r; +} + +function glDrawElements(type, index_count, ele_type, indices) +{ + const r = gl.drawElements(type, index_count, ele_type, indices); + glErrorReport(arguments); + return r; +} + +function glGenTextures(count, ids_ptr, ids_size) +{ + for (let i = 0; i < count; i++) + { + const tex = gl.createTexture(); + glErrorReport(arguments); + let new_len = glTextures.push(tex); + put_u32(ids_ptr + (i * 4), new_len); + } +} + +function glBindTexture(slot, id) +{ + let tex = gl_get_texture(id); + const r = gl.bindTexture(slot, tex); + glErrorReport(arguments); + return r; +} + +function glTexParameteri(slot, param, value) +{ + const r = gl.texParameteri(slot, param, value); + glErrorReport(arguments); + return r; +} + +function glTexImage2D(target, level, internalformat, width, height, border, format, type, data_ptr, data_size) +{ + const data = wasm_mem_get_u8_arr(lumenarium_wasm_instance, data_ptr, data_size); + const r = gl.texImage2D(target, level, internalformat, width, height, border, format, type, data); + glErrorReport(arguments); + return r; +} + +function glTexSubImage2D(target, level, offsetx, offsety, width, height, format, type, data_ptr, data_size) +{ + const data = wasm_mem_get_u8_arr(lumenarium_wasm_instance, data_ptr, data_size); + const r = gl.texSubImage2D(target, level, offsetx, offsety, width, height, format, type, data); + glErrorReport(arguments); + return r; +} + +function glGetUniformLocation(program, name, name_len) +{ + // TODO(PS): complete + return 0; +} + +function glUniformMatrix4fv() +{ + // TODO(PS): +} + +function webgl_add_imports (canvas_selector, imports) { + const canvas = document.querySelector(canvas_selector); + if (!canvas) return console.error("no canvas"); + + gl = canvas.getContext("webgl2"); + if (gl === null) return console.error("no webgl ctx"); + + imports.glHadError = () => { return gl_error; }; + imports.glClearColor = glClearColor; + imports.glEnable = glEnable; + imports.glDisable = glDisable; + imports.glBlendFunc = glBlendFunc; + imports.glViewport = glViewport; + imports.glDepthFunc = glDepthFunc; + imports.glClear = glClear; + + imports.glCreateBuffer = glCreateBuffer; + imports.glBindBuffer = glBindBuffer; + imports.glBufferData = glBufferData; + imports.glBufferSubData = glBufferSubData; + imports.glCreateShader = glCreateShader; + imports.glShaderSource = glShaderSource; + imports.glCompileShader = glCompileShader; + imports.glCreateProgram = glCreateProgram; + imports.glAttachShader = glAttachShader; + imports.glLinkProgram = glLinkProgram; + imports.glUseProgram = glUseProgram; + imports.glGetAttribLocation = glGetAttribLocation; + imports.glVertexAttribPointer = glVertexAttribPointer; + imports.glEnableVertexAttribArray = glEnableVertexAttribArray; + imports.glDrawElements = glDrawElements; + imports.glGenTextures = glGenTextures; + imports.glBindTexture = glBindTexture; + imports.glTexParameteri = glTexParameteri; + imports.glTexImage2D = glTexImage2D; + imports.glTexSubImage2D = glTexSubImage2D; + imports.glBindTexture = glBindTexture; + imports.glGetUniformLocation = glGetUniformLocation; + imports.glUniformMatrix4fv = glUniformMatrix4fv; + + return imports; +} \ No newline at end of file diff --git a/src_v2/platform/wasm/lumenarium_wasm_memory.cpp b/src_v2/platform/wasm/lumenarium_wasm_memory.cpp new file mode 100644 index 0000000..77713f2 --- /dev/null +++ b/src_v2/platform/wasm/lumenarium_wasm_memory.cpp @@ -0,0 +1,67 @@ + +#define WASM_PAGE_SIZE KB(64) + +u64 +platform_page_size() +{ + return WASM_PAGE_SIZE; +} + +// this comes from: https://surma.dev/things/c-to-webassembly/ +extern u8 __heap_base; +global u8* heap_base = &__heap_base; +global u64 heap_used = 0; + +WASM_EXTERN u32 wasm_get_memory_size(); +WASM_EXTERN u32 wasm_mem_grow(u32 new_size); + +u64 +wasm_get_heap_size() +{ + u64 memory_size = wasm_get_memory_size(); + u64 heap_base_addr = (u64)&__heap_base; + u64 heap_size = memory_size - heap_base_addr; + return heap_size; +} + +u8* +platform_mem_reserve(u64 size) +{ + // if we are out of memory, double the size of wasm memory + u64 heap_size = wasm_get_heap_size(); + if (heap_used + size >= heap_size) + { + u32 heap_size_new = heap_size * 2; + if (heap_used + size >= heap_size_new) + { + heap_size_new = heap_used + size; + } + wasm_mem_grow(heap_size_new); + } + assert(heap_used + size <= wasm_get_heap_size()); + + u64 ptr_addr = (u64)(heap_base + heap_used); + u8* result = heap_base + heap_used; + heap_used += size; // TODO(PS): alignment + return result; +} + +u8* +platform_mem_commit(u8* base, u64 size) +{ + return base; +} + +bool +platform_mem_decommit(u8* base, u64 size) +{ + return true; +} + +bool +platform_mem_release(u8* base, u64 size) +{ + // TODO(PS): we probably actually want to implement free at some point + return true; +} + diff --git a/src_v2/platform/wasm/lumenarium_wasm_thread.cpp b/src_v2/platform/wasm/lumenarium_wasm_thread.cpp new file mode 100644 index 0000000..4fd1f84 --- /dev/null +++ b/src_v2/platform/wasm/lumenarium_wasm_thread.cpp @@ -0,0 +1,24 @@ + +Platform_Thread_Handle +platform_thread_begin(Platform_Thread_Proc* proc, u8* user_data) +{ + return {}; +} + +void +platform_thread_end(Platform_Thread_Handle thread_handle) +{ + return; +} + +u32 +platform_interlocked_increment(volatile u32* value) +{ + return 0; +} + +u32 +platform_interlocked_cmp_exchg(volatile u32* dest, u32 new_value, u32 old_value) +{ + return 0; +} diff --git a/src_v2/platform/wasm/lumenarium_wasm_time.cpp b/src_v2/platform/wasm/lumenarium_wasm_time.cpp new file mode 100644 index 0000000..182193a --- /dev/null +++ b/src_v2/platform/wasm/lumenarium_wasm_time.cpp @@ -0,0 +1,26 @@ + +// NOTE(PS): should call performance.now() which is in milliseconds +WASM_EXTERN u32 wasm_performance_now(); + +WASM_EXTERN void wasm_sleep(u32 milliseconds); + +Platform_Ticks +platform_get_ticks() +{ + Platform_Ticks result = {}; + result.value = (u64)wasm_performance_now(); + return result; +} + +r64 +platform_ticks_to_seconds(Platform_Ticks ticks) +{ + r64 result = (r64)(ticks.value * 1000); + return result; +} + +void +platform_sleep(r64 milliseconds) +{ + wasm_sleep(milliseconds); +} \ No newline at end of file diff --git a/src_v2/platform/wasm/lumenarium_wasm_webgl.cpp b/src_v2/platform/wasm/lumenarium_wasm_webgl.cpp new file mode 100644 index 0000000..e17ff7f --- /dev/null +++ b/src_v2/platform/wasm/lumenarium_wasm_webgl.cpp @@ -0,0 +1,334 @@ +// + +// TODO(PS): +// TODO(PS): +// TODO(PS): +// TODO(PS): you guessed the data types and names of ALL of this +// fix it! + +typedef int GLint; +typedef unsigned int GLuint; +typedef float GLfloat; +typedef unsigned int GLenum; +typedef bool GLboolean; +typedef unsigned int GLsizei; + +// NOTE(PS): these values and function signatures all come from +// the GLES2/gl2.h header file that can be found here: +// https://www.khronos.org/registry/OpenGL/api/GLES2/gl2.h +// +// I resorted to hard coding these rather than passing them in because +// passing them in didn't seem to be working. + +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_BLEND 0x0BE2 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DEPTH_TEST 0x0B71 +#define GL_LESS 0x0201 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_STATIC_DRAW 0x88e4 +#define GL_FRAGMENT_SHADER 0x8b30 +#define GL_VERTEX_SHADER 0x8b31 +#define GL_TRIANGLES 0x0004 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_REPEAT 0x2901 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_LINEAR 0x2601 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_CLAMP_TO_EDGE 0x812F + +WASM_EXTERN bool glHadError(); +WASM_EXTERN void glClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a); +WASM_EXTERN void glEnable(GLuint i); +WASM_EXTERN void glDisable(GLuint i); +WASM_EXTERN void glBlendFunc(GLuint a, GLuint b); +WASM_EXTERN void glViewport(GLuint xmin, GLuint ymin, GLuint xmax, GLuint ymax); +WASM_EXTERN void glDepthFunc(GLuint i); +WASM_EXTERN void glClear(GLuint i); + +WASM_EXTERN GLuint glCreateBuffer(); +WASM_EXTERN void glBindBuffer(GLenum buffer_kind, GLuint buffer_id); +WASM_EXTERN void glBufferData(GLenum target, size_t size, const void* data, GLenum usage); +WASM_EXTERN void glBufferSubData(GLenum target, size_t offset, size_t size, const void* data); +WASM_EXTERN GLuint glCreateShader(GLenum kind); +WASM_EXTERN GLuint glShaderSource(GLuint shader_id, char* shader_code, GLuint shader_code_len); +WASM_EXTERN void glCompileShader(GLuint shader_id); +WASM_EXTERN GLuint glCreateProgram(void); +WASM_EXTERN void glAttachShader(GLuint program, GLuint shader); +WASM_EXTERN void glLinkProgram(GLuint program); +WASM_EXTERN void glUseProgram(GLuint program); +WASM_EXTERN GLuint glGetAttribLocation(GLuint program, const char* name, GLuint name_len); +WASM_EXTERN GLuint glGetUniformLocation(GLuint program, const char* name, u32 len); +WASM_EXTERN void glUniformMatrix4fv(GLuint uniform, GLuint count, GLenum normalize, GLfloat* elements); +WASM_EXTERN void glVertexAttribPointer(GLuint attr, GLuint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +WASM_EXTERN void glEnableVertexAttribArray(GLuint index); +WASM_EXTERN void glDrawElements(GLenum type, GLuint count, GLenum ele_type, void* indices); +WASM_EXTERN void glGenTextures(GLuint count, GLuint* ids, u32 ids_size); +WASM_EXTERN void glBindTexture(GLenum slot, GLuint id); +WASM_EXTERN void glTexParameteri(GLenum slot, GLenum param, GLenum value); +WASM_EXTERN void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * data, u32 data_size); +WASM_EXTERN void glBindTexture(GLenum target, GLuint id); +WASM_EXTERN void glTexSubImage2D(GLenum target, GLint level, GLuint offsetx, GLuint offsety, GLuint w, GLuint h, GLenum format, GLenum type, void* ptr, u32 ptr_size); + +Platform_Geometry_Buffer +platform_geometry_buffer_create( + r32* vertices, GLuint vertices_len, + GLuint* indices, GLuint indices_len + ){ + Platform_Geometry_Buffer result = {}; + + result.buffer_id_vertices = glCreateBuffer(); + result.buffer_id_indices = glCreateBuffer(); + + // Vertices + glBindBuffer(GL_ARRAY_BUFFER, result.buffer_id_vertices); + glBufferData( + GL_ARRAY_BUFFER, sizeof(r32) * vertices_len, vertices, GL_STATIC_DRAW + ); + + // Indices + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.buffer_id_indices); + glBufferData( + GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint) * indices_len, indices, GL_STATIC_DRAW + ); + result.indices_len = indices_len; + + glBindBuffer(GL_ARRAY_BUFFER, (GLuint)NULL); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)NULL); + + return result; +} + +void +platform_geometry_buffer_update( + Platform_Geometry_Buffer* buffer, + r32* verts, + u32 verts_offset, + u32 verts_len, + u32* indices, + u32 indices_offset, + u32 indices_len + ){ + glBindBuffer(GL_ARRAY_BUFFER, buffer->buffer_id_vertices); + if (verts_len > buffer->vertices_len) + { + // NOTE(PS): this is because we're going to delete the old buffer and + // create a new one. In order to do that and not lose data, the update + // function needs to have been passed all the buffer's data + assert(verts_offset == 0); + glBufferData( + GL_ARRAY_BUFFER, verts_len * sizeof(r32), (void*)verts, GL_STATIC_DRAW + ); + } + else + { + glBufferSubData( + GL_ARRAY_BUFFER, verts_offset * sizeof(r32), verts_len * sizeof(r32), (void*)verts + ); + } + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer->buffer_id_indices); + if (indices_len > buffer->indices_len) + { + // NOTE(PS): this is because we're going to delete the old buffer and + // create a new one. In order to do that and not lose data, the update + // function needs to have been passed all the buffer's data + assert(indices_offset == 0); + glBufferData( + GL_ELEMENT_ARRAY_BUFFER, indices_len * sizeof(u32), (void*)indices, GL_STATIC_DRAW + ); + } + else + { + glBufferSubData( + GL_ELEMENT_ARRAY_BUFFER, indices_offset * sizeof(u32), indices_len * sizeof(u32), (void*)indices + ); + } +} + +Platform_Shader +platform_shader_create( + String code_vert, String code_frag, String* attrs, GLuint attrs_len, String* uniforms, GLuint uniforms_len + ){ + Platform_Shader result = {}; + + GLuint shader_vert = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(shader_vert, str_expand(code_vert)); + glCompileShader(shader_vert); + + GLuint shader_frag = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(shader_frag, str_expand(code_frag)); + glCompileShader(shader_frag); + + result.id = (GLuint)glCreateProgram(); + glAttachShader(result.id, shader_vert); + glAttachShader(result.id, shader_frag); + glLinkProgram(result.id); + glUseProgram(result.id); + + // TODO(PS): delete the vert and frag programs + + assert(attrs_len < PLATFORM_SHADER_MAX_ATTRS); + for (GLuint i = 0; i < attrs_len; i++) + { + s32 len = (s32)attrs[i].len; + result.attrs[i] = glGetAttribLocation( + result.id, (char*)attrs[i].str, len + ); + } + result.attrs[attrs_len] = PLATFORM_SHADER_ATTR_LAST; + + assert(uniforms_len < PLATFORM_SHADER_MAX_ATTRS); + for (GLuint i = 0; i < uniforms_len; i++) + { + s32 len = (s32)uniforms[i].len; + result.uniforms[i] = glGetUniformLocation( + result.id, (char*)uniforms[i].str, uniforms[i].len + ); + } + result.uniforms[uniforms_len] = PLATFORM_SHADER_ATTR_LAST; + + return result; +} + +void +platform_geometry_bind(Platform_Geometry_Buffer geo) +{ + glBindBuffer(GL_ARRAY_BUFFER, geo.buffer_id_vertices); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, geo.buffer_id_indices); +} + +void +platform_shader_bind(Platform_Shader shader) +{ + glUseProgram(shader.id); + for (GLuint i = 0; i < PLATFORM_SHADER_MAX_ATTRS && shader.attrs[i] != PLATFORM_SHADER_ATTR_LAST; i++) + { + glEnableVertexAttribArray(shader.attrs[i]); + } +} + +void +platform_set_uniform(Platform_Shader shader, u32 index, m44 u) +{ + glUniformMatrix4fv(shader.uniforms[index], 1, GL_FALSE, (r32*)u.Elements); +} + +void +platform_geometry_draw( + Platform_Geometry_Buffer geo, u32 indices + ){ + glDrawElements(GL_TRIANGLES, indices, GL_UNSIGNED_INT, 0); +} + +void +platform_geometry_draw( + Platform_Geometry_Buffer geo + ){ + glDrawElements(GL_TRIANGLES, geo.indices_len, GL_UNSIGNED_INT, 0); +} + +void platform_vertex_attrib_pointer( + Platform_Geometry_Buffer geo, Platform_Shader shader, u32 count, u32 attr_index, u32 stride, u32 offset + ){ + //platform_shader_bind(shader); + platform_geometry_bind(geo); + glVertexAttribPointer(shader.attrs[attr_index], count, GL_FLOAT, false, stride * sizeof(float), (void*)(offset * sizeof(float))); +} + +Platform_Texture +platform_texture_create(u8* pixels, u32 width, u32 height, u32 stride) +{ + Platform_Texture result = {}; + glGenTextures(1, &result.id, sizeof(u32)); + glBindTexture(GL_TEXTURE_2D, result.id); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexImage2D( + GL_TEXTURE_2D, + 0, + GL_RGBA, + width, + height, + 0, + GL_RGBA, + GL_UNSIGNED_BYTE, + pixels, + (width * height) * sizeof(u32) + ); + + result.w = width; + result.h = height; + result.s = stride; + + return result; +} + +void +platform_texture_update(Platform_Texture tex, u8* new_pixels, u32 width, u32 height, u32 stride) +{ + // NOTE(PS): this function simply replaces the entire image + // we can write a more granular version if we need it + + assert(tex.w == width && tex.h == height && tex.s == stride); + platform_texture_bind(tex); + glTexSubImage2D( + GL_TEXTURE_2D, + 0, + 0, 0, // offset + width, height, + GL_RGBA, + GL_UNSIGNED_BYTE, + new_pixels, + width * height * sizeof(u32) + ); +} + + +void +platform_texture_bind(Platform_Texture tex) +{ + glBindTexture(GL_TEXTURE_2D, tex.id); +} + +void +platform_frame_begin(Platform_Graphics_Frame_Desc desc) +{ + v4 cc = desc.clear_color; + glClearColor(cc.r, cc.g, cc.b, cc.a); + + v2 vmin = desc.viewport_min; + v2 vmax = desc.viewport_max; + glViewport(vmin.x, vmin.y, vmax.x, vmax.y); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + //glDisable(GL_TEXTURE_2D); + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); +} + +void +platform_frame_clear() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +} \ No newline at end of file diff --git a/src_v2/platform/wglext.h b/src_v2/platform/wglext.h new file mode 100644 index 0000000..c8455bb --- /dev/null +++ b/src_v2/platform/wglext.h @@ -0,0 +1,845 @@ +#ifndef __wgl_wglext_h_ +#define __wgl_wglext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + + /* + ** Copyright 2013-2020 The Khronos Group Inc. + ** SPDX-License-Identifier: MIT + ** + ** This header is generated from the Khronos OpenGL / OpenGL ES XML + ** API Registry. The current version of the Registry, generator scripts + ** used to make the header, and the header can be found at + ** https://github.com/KhronosGroup/OpenGL-Registry + */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include <windows.h> +#endif + +#define WGL_WGLEXT_VERSION 20211115 + + /* Generated C header for: + * API: wgl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: wgl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef WGL_ARB_buffer_region +#define WGL_ARB_buffer_region 1 +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 + typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); + typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); + typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); + typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#ifdef WGL_WGLEXT_PROTOTYPES + HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); + VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); + BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); + BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#endif +#endif /* WGL_ARB_buffer_region */ + +#ifndef WGL_ARB_context_flush_control +#define WGL_ARB_context_flush_control 1 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif /* WGL_ARB_context_flush_control */ + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 + typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); +#ifdef WGL_WGLEXT_PROTOTYPES + HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif +#endif /* WGL_ARB_create_context */ + +#ifndef WGL_ARB_create_context_no_error +#define WGL_ARB_create_context_no_error 1 +#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 +#endif /* WGL_ARB_create_context_no_error */ + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif /* WGL_ARB_create_context_profile */ + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* WGL_ARB_create_context_robustness */ + +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 + typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES + const char *WINAPI wglGetExtensionsStringARB (HDC hdc); +#endif +#endif /* WGL_ARB_extensions_string */ + +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif /* WGL_ARB_framebuffer_sRGB */ + +#ifndef WGL_ARB_make_current_read +#define WGL_ARB_make_current_read 1 +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 + typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); + typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); + HDC WINAPI wglGetCurrentReadDCARB (void); +#endif +#endif /* WGL_ARB_make_current_read */ + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif /* WGL_ARB_multisample */ + +#ifndef WGL_ARB_pbuffer +#define WGL_ARB_pbuffer 1 + DECLARE_HANDLE(HPBUFFERARB); +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 + typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); + typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); + typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); + typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); + typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES + HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); + HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); + int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); + BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); + BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_ARB_pbuffer */ + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C + typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); + typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); + typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); + BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); + BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif +#endif /* WGL_ARB_pixel_format */ + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif /* WGL_ARB_pixel_format_float */ + +#ifndef WGL_ARB_render_texture +#define WGL_ARB_render_texture 1 +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 + typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); + typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); + typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); + BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); + BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); +#endif +#endif /* WGL_ARB_render_texture */ + +#ifndef WGL_ARB_robustness_application_isolation +#define WGL_ARB_robustness_application_isolation 1 +#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* WGL_ARB_robustness_application_isolation */ + +#ifndef WGL_ARB_robustness_share_group_isolation +#define WGL_ARB_robustness_share_group_isolation 1 +#endif /* WGL_ARB_robustness_share_group_isolation */ + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif /* WGL_3DFX_multisample */ + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 + typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); +#endif +#endif /* WGL_3DL_stereo_control */ + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 + typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); + typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void *data); + typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); + typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); + typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); + typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); + typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); + typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); + typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef WGL_WGLEXT_PROTOTYPES + UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); + INT WINAPI wglGetGPUInfoAMD (UINT id, INT property, GLenum dataType, UINT size, void *data); + UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); + HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); + HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); + BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); + BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); + HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); + VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* WGL_AMD_gpu_association */ + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#endif /* WGL_ATI_pixel_format_float */ + +#ifndef WGL_ATI_render_texture_rectangle +#define WGL_ATI_render_texture_rectangle 1 +#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 +#endif /* WGL_ATI_render_texture_rectangle */ + +#ifndef WGL_EXT_colorspace +#define WGL_EXT_colorspace 1 +#define WGL_COLORSPACE_EXT 0x309D +#define WGL_COLORSPACE_SRGB_EXT 0x3089 +#define WGL_COLORSPACE_LINEAR_EXT 0x308A +#endif /* WGL_EXT_colorspace */ + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile 1 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es2_profile */ + +#ifndef WGL_EXT_create_context_es_profile +#define WGL_EXT_create_context_es_profile 1 +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es_profile */ + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif /* WGL_EXT_depth_float */ + +#ifndef WGL_EXT_display_color_table +#define WGL_EXT_display_color_table 1 + typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); + typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); + typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); + typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#ifdef WGL_WGLEXT_PROTOTYPES + GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); + GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); + GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); + VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); +#endif +#endif /* WGL_EXT_display_color_table */ + +#ifndef WGL_EXT_extensions_string +#define WGL_EXT_extensions_string 1 + typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES + const char *WINAPI wglGetExtensionsStringEXT (void); +#endif +#endif /* WGL_EXT_extensions_string */ + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 +#endif /* WGL_EXT_framebuffer_sRGB */ + +#ifndef WGL_EXT_make_current_read +#define WGL_EXT_make_current_read 1 +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 + typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); + typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); + HDC WINAPI wglGetCurrentReadDCEXT (void); +#endif +#endif /* WGL_EXT_make_current_read */ + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif /* WGL_EXT_multisample */ + +#ifndef WGL_EXT_pbuffer +#define WGL_EXT_pbuffer 1 + DECLARE_HANDLE(HPBUFFEREXT); +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 + typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); + typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); + typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); + typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); + typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES + HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); + HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); + int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); + BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); + BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_EXT_pbuffer */ + +#ifndef WGL_EXT_pixel_format +#define WGL_EXT_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C + typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); + typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); + typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); + BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); + BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif +#endif /* WGL_EXT_pixel_format */ + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 +#endif /* WGL_EXT_pixel_format_packed_float */ + +#ifndef WGL_EXT_swap_control +#define WGL_EXT_swap_control 1 + typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); + typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglSwapIntervalEXT (int interval); + int WINAPI wglGetSwapIntervalEXT (void); +#endif +#endif /* WGL_EXT_swap_control */ + +#ifndef WGL_EXT_swap_control_tear +#define WGL_EXT_swap_control_tear 1 +#endif /* WGL_EXT_swap_control_tear */ + +#ifndef WGL_I3D_digital_video_control +#define WGL_I3D_digital_video_control 1 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 + typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); + typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); + BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); +#endif +#endif /* WGL_I3D_digital_video_control */ + +#ifndef WGL_I3D_gamma +#define WGL_I3D_gamma 1 +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F + typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); + typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); + typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); + typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); + BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); + BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); + BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#endif +#endif /* WGL_I3D_gamma */ + +#ifndef WGL_I3D_genlock +#define WGL_I3D_genlock 1 +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C + typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); + typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); + typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); + typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); + typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); + typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); + typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); + typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); + typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); + typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); + typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); + typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglEnableGenlockI3D (HDC hDC); + BOOL WINAPI wglDisableGenlockI3D (HDC hDC); + BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); + BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); + BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); + BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); + BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); + BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); + BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); + BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); + BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); + BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif +#endif /* WGL_I3D_genlock */ + +#ifndef WGL_I3D_image_buffer +#define WGL_I3D_image_buffer 1 +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 + typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); + typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); + typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); + typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#ifdef WGL_WGLEXT_PROTOTYPES + LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); + BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); + BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); + BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); +#endif +#endif /* WGL_I3D_image_buffer */ + +#ifndef WGL_I3D_swap_frame_lock +#define WGL_I3D_swap_frame_lock 1 + typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); + typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); + typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); + typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglEnableFrameLockI3D (void); + BOOL WINAPI wglDisableFrameLockI3D (void); + BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); + BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); +#endif +#endif /* WGL_I3D_swap_frame_lock */ + +#ifndef WGL_I3D_swap_frame_usage +#define WGL_I3D_swap_frame_usage 1 + typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); + typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); + typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); + typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); + BOOL WINAPI wglBeginFrameTrackingI3D (void); + BOOL WINAPI wglEndFrameTrackingI3D (void); + BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif +#endif /* WGL_I3D_swap_frame_usage */ + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 +#define WGL_ACCESS_READ_ONLY_NV 0x00000000 +#define WGL_ACCESS_READ_WRITE_NV 0x00000001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 + typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); + typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); + typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); + typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); + typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); + typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); + typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); + typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); + HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); + BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); + HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); + BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); + BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); + BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); + BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +#endif +#endif /* WGL_NV_DX_interop */ + +#ifndef WGL_NV_DX_interop2 +#define WGL_NV_DX_interop2 1 +#endif /* WGL_NV_DX_interop2 */ + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 + typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* WGL_NV_copy_image */ + +#ifndef WGL_NV_delay_before_swap +#define WGL_NV_delay_before_swap 1 + typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds); +#endif +#endif /* WGL_NV_delay_before_swap */ + +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif /* WGL_NV_float_buffer */ + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 + DECLARE_HANDLE(HGPUNV); + struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; + }; + typedef struct _GPU_DEVICE *PGPU_DEVICE; +#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 + typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); + typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); + typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); + typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); + typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); + BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); + HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); + BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); + BOOL WINAPI wglDeleteDCNV (HDC hdc); +#endif +#endif /* WGL_NV_gpu_affinity */ + +#ifndef WGL_NV_multigpu_context +#define WGL_NV_multigpu_context 1 +#define WGL_CONTEXT_MULTIGPU_ATTRIB_NV 0x20AA +#define WGL_CONTEXT_MULTIGPU_ATTRIB_SINGLE_NV 0x20AB +#define WGL_CONTEXT_MULTIGPU_ATTRIB_AFR_NV 0x20AC +#define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTICAST_NV 0x20AD +#define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTI_DISPLAY_MULTICAST_NV 0x20AE +#endif /* WGL_NV_multigpu_context */ + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 +#endif /* WGL_NV_multisample_coverage */ + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 + DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 + typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); + typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); + typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES + int WINAPI wglEnumerateVideoDevicesNV (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); + BOOL WINAPI wglBindVideoDeviceNV (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); + BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); +#endif +#endif /* WGL_NV_present_video */ + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif /* WGL_NV_render_depth_texture */ + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif /* WGL_NV_render_texture_rectangle */ + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 + typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); + typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); + typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); + typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); + typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); + typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); + BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); + BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); + BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); + BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); + BOOL WINAPI wglResetFrameCountNV (HDC hDC); +#endif +#endif /* WGL_NV_swap_group */ + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 + typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); + typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#ifdef WGL_WGLEXT_PROTOTYPES + void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); + void WINAPI wglFreeMemoryNV (void *pointer); +#endif +#endif /* WGL_NV_vertex_array_range */ + +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 + DECLARE_HANDLE(HVIDEOINPUTDEVICENV); +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF + typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); + typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); + typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); + typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); + typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); + UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); + BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); + BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); + BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#endif +#endif /* WGL_NV_video_capture */ + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 + DECLARE_HANDLE(HPVIDEODEV); +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC + typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); + typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); + typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); + typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); + typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); + typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); + BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); + BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); + BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); + BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); + BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif +#endif /* WGL_NV_video_output */ + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 + typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); + typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); + typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); + typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); + typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); + typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#ifdef WGL_WGLEXT_PROTOTYPES + BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); + BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); + INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); + INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); + BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); + BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif +#endif /* WGL_OML_sync_control */ + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/src_v2/platform/win32/lumenarium_first_win32.cpp b/src_v2/platform/win32/lumenarium_first_win32.cpp new file mode 100644 index 0000000..e90418e --- /dev/null +++ b/src_v2/platform/win32/lumenarium_first_win32.cpp @@ -0,0 +1,312 @@ + +#include "../lumenarium_compiler_flags.h" +#include "../lumenarium_platform_common_includes.h" + +#include <windows.h> +#include <gl/gl.h> +#include <stdio.h> + +#include "../../lumenarium_types.h" +#include "../../lumenarium_memory.h" +#include "../lumenarium_platform.h" +#include "../../lumenarium_first.cpp" + +global DWORD win32_last_error = 0; +void +win32_get_last_error() +{ + win32_last_error = GetLastError(); +} + +global bool running = true; + +#include "lumenarium_win32_opengl.h" + +global Win32_OpenGL_Extensions gl; + +#include "lumenarium_win32_memory.cpp" +#include "lumenarium_win32_window.cpp" +#include "lumenarium_win32_time.cpp" +#include "lumenarium_win32_file.cpp" +#include "lumenarium_win32_thread.cpp" +#include "lumenarium_win32_graphics.cpp" + +internal Platform_Key_Flags +win32_get_key_flags_mod() +{ + Platform_Key_Flags result = 0; + if (GetKeyState(VK_SHIFT) & 0x8000) add_flag(result, KeyFlag_Mod_Shift); + if (GetKeyState(VK_MENU) & 0x8000) add_flag(result, KeyFlag_Mod_Alt); + if (GetKeyState(VK_CONTROL) & 0x8000) add_flag(result, KeyFlag_Mod_Ctrl); + return result; +} + +internal void +win32_mouse_capture(Win32_Window* win) +{ + // NOTE(Peter): We capture events when the mouse goes down so that + // if the user drags outside the window, we still get the mouse up + // event and can process it. Otherwise, we can get into cases where + // an event was started, didn't end, but the user can click again and + // try to start the event again. + // We relase event capture on mouse up. + SetCapture(win->window_handle); +} + +internal void +win32_mouse_release(Win32_Window* win) +{ + ReleaseCapture(); +} + +internal Platform_Window_Event +win32_button_event(Platform_Key_Code key, bool is_down, bool was_down) +{ + Platform_Window_Event evt = {}; + evt.kind = WindowEvent_ButtonDown; + evt.key_code = key; + evt.key_flags = win32_get_key_flags_mod(); + if (is_down) add_flag(evt.key_flags, KeyFlag_State_IsDown); + if (was_down) add_flag(evt.key_flags, KeyFlag_State_WasDown); + return evt; +} + +internal void +win32_set_mouse_pos_evt(Platform_Window_Event* evt) +{ + POINT mouse_p; + GetCursorPos(&mouse_p); + ScreenToClient(win32_main_window.window_handle, &mouse_p); + + evt->mouse_x = mouse_p.x; + evt->mouse_y = mouse_p.y; +} + +internal void +win32_window_handle_event(MSG msg, Win32_Window* win, App_State* state) +{ + switch (msg.message) + { + case WM_MOUSEWHEEL: + { + Platform_Window_Event evt = {}; + evt.kind = WindowEvent_MouseScroll; + evt.scroll_amt = GET_WHEEL_DELTA_WPARAM(msg.wParam); + lumenarium_event(evt, state); + }break; + + case WM_LBUTTONDOWN: + { + Platform_Window_Event evt = win32_button_event( + KeyCode_MouseLeftButton, + true, false + ); + win32_set_mouse_pos_evt(&evt); + lumenarium_event(evt, state); + win32_mouse_capture(win); + }break; + + case WM_MBUTTONDOWN: + { + Platform_Window_Event evt = win32_button_event( + KeyCode_MouseMiddleButton, + true, false + ); + win32_set_mouse_pos_evt(&evt); + lumenarium_event(evt, state); + win32_mouse_capture(win); + }break; + + case WM_RBUTTONDOWN: + { + Platform_Window_Event evt = win32_button_event( + KeyCode_MouseRightButton, + true, false + ); + win32_set_mouse_pos_evt(&evt); + lumenarium_event(evt, state); + win32_mouse_capture(win); + }break; + + case WM_LBUTTONUP: + { + Platform_Window_Event evt = win32_button_event( + KeyCode_MouseLeftButton, + false, true + ); + win32_set_mouse_pos_evt(&evt); + lumenarium_event(evt, state); + win32_mouse_release(win); + }break; + + case WM_MBUTTONUP: + { + Platform_Window_Event evt = win32_button_event( + KeyCode_MouseMiddleButton, + false, true + ); + win32_set_mouse_pos_evt(&evt); + lumenarium_event(evt, state); + win32_mouse_release(win); + }break; + + case WM_RBUTTONUP: + { + Platform_Window_Event evt = win32_button_event( + KeyCode_MouseRightButton, + false, true + ); + win32_set_mouse_pos_evt(&evt); + lumenarium_event(evt, state); + win32_mouse_release(win); + }break; + + case WM_SYSKEYDOWN: + case WM_SYSKEYUP: + case WM_KEYDOWN: + case WM_KEYUP: + { + Platform_Key_Code key = 0; + b32 was_down = (msg.lParam & (1 << 30)) != 0; + b32 is_down = (msg.lParam & (1 << 31)) == 0; + Platform_Window_Event evt = win32_button_event(key, is_down, was_down); + lumenarium_event(evt, state); + TranslateMessage(&msg); + DispatchMessage(&msg); + }break; + + case WM_CHAR: + { + Platform_Window_Event evt = {}; + evt.kind = WindowEvent_Char; + evt.char_value = (char)msg.wParam; + lumenarium_event(evt, state); + }break; + + default: + { + TranslateMessage(&msg); + DispatchMessage(&msg); + }break; + } +} + +INT WINAPI +WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + PSTR lpCmdLine, + INT nCmdShow) +{ + open_err_file(); + + // Window Setup + win32_window_create( + &win32_main_window, + hInstance, + "Lumenariumtest0", + 1400, + 800, + win32_window_event_handler + ); + win32_window_update_dim(&win32_main_window); + + win32_time_init(); + win32_files_init(); + win32_threads_init(); + + App_State* state = lumenarium_init(); + if (!has_flag(state->flags, AppState_IsRunning)) return 0; + + Platform_Ticks ticks_start = platform_get_ticks(); + while (running && has_flag(state->flags, AppState_IsRunning)) + { + win32_threads_reclaim(); + lumenarium_frame_prepare(state); + + // Potentially pass the window closed event to the runtime + if (win32_window_event_flags & WindowEventFlag_CloseRequested) + { + Platform_Window_Event evt = { + WindowEvent_WindowClosed, + }; + lumenarium_event(evt, state); + } + + // Get the position of the mouse every frame + { + POINT mouse_p; + GetCursorPos(&mouse_p); + ScreenToClient(win32_main_window.window_handle, &mouse_p); + + Platform_Window_Event evt = {}; + evt.kind = WindowEvent_MouseMoved; + evt.mouse_x = mouse_p.x; + evt.mouse_y = mouse_p.y; + + lumenarium_event(evt, state); + } + + // Pass Window Events to the runtime + MSG window_msg; + while (PeekMessageA( + &window_msg, + win32_main_window.window_handle, + 0, + 0, + PM_REMOVE) + ){ + win32_window_handle_event(window_msg, &win32_main_window, state); + } + + // NOTE(PS): WM_CLOSE and WM_DESTROY can both be issued + // the same frame, meaning our drawing context is destroyed + // before calling lumenarium_frame so skipping here to avoid + // using invalid resources + if (!running || !has_flag(state->flags, AppState_IsRunning)) continue; + + // Update window size + if (has_flag(state->flags, AppState_RunEditor)) + { + state->editor->window_dim = (v2){ + (r32)win32_main_window.info.width, + (r32)win32_main_window.info.height + }; + } + + lumenarium_frame(state); + + SwapBuffers(win32_main_window.dc); + + //////////////////////////////////////// + // Maintain Frame Rate + + Platform_Ticks ticks_end = platform_get_ticks(); + r64 seconds_elapsed = get_seconds_elapsed(ticks_start, ticks_end); + while (seconds_elapsed < target_seconds_per_frame) + { + u32 sleep_time = (u32)(1000.0f * (target_seconds_per_frame - seconds_elapsed)); + Sleep(sleep_time); + + ticks_end = platform_get_ticks(); + seconds_elapsed = get_seconds_elapsed(ticks_start, ticks_end); + } + ticks_start = ticks_end; + } + + lumenarium_cleanup(state); + + // threads cleanup + for (u32 i = 1; i < win32_threads_cap; i++) + { + if (win32_threads[i] == INVALID_HANDLE_VALUE) continue; + TerminateThread(win32_threads[i], 0); + } + + // windows cleanup + UnregisterClass(win32_main_window.window_class.lpszClassName, hInstance); + + close_err_file(); + return 0; +} + diff --git a/src_v2/platform/win32/lumenarium_win32_file.cpp b/src_v2/platform/win32/lumenarium_win32_file.cpp new file mode 100644 index 0000000..5ca09e3 --- /dev/null +++ b/src_v2/platform/win32/lumenarium_win32_file.cpp @@ -0,0 +1,258 @@ +#define win32_open_files_cap 32 +char win32_open_file_paths[win32_open_files_cap][MAX_PATH]; +u64 win32_open_files_len = 1; // zero is invalid +HANDLE win32_open_files[win32_open_files_cap]; + +void +win32_files_init() +{ + for (u32 i = 0; i < win32_open_files_cap; i++) + { + win32_open_files[i] = INVALID_HANDLE_VALUE; + } +} + +HANDLE +win32_get_open_file_handle(Platform_File_Handle file) +{ + return win32_open_files[file.value]; +} + +internal u64 +win32_high_low_to_u64(u32 low_part, u32 high_part) +{ + ULARGE_INTEGER Time = {}; + Time.LowPart = low_part; + Time.HighPart = high_part; + u64 result = Time.QuadPart; + return result; +} + +internal u64 +win32_file_time_to_u64(FILETIME file_time) +{ + return win32_high_low_to_u64(file_time.dwLowDateTime, file_time.dwHighDateTime); +} + +Platform_File_Handle +platform_file_open(String path, Platform_File_Access_Flags flags_access, Platform_File_Create_Flags flags_create) +{ + Platform_File_Handle result = {}; + + DWORD flags_create_ = OPEN_EXISTING; + + HANDLE file_handle = CreateFileA( + (char*)path.str, + (DWORD)flags_access, + 0, // share mode + NULL, // security attributes + (DWORD)flags_create, + FILE_ATTRIBUTE_NORMAL, + NULL + ); + + if (file_handle != INVALID_HANDLE_VALUE) + { + if (win32_open_files_len < win32_open_files_cap) + { + result.value = win32_open_files_len++; + } + else + { + // search for emtpy index + for (u32 i = 1; i < win32_open_files_cap; i++) + { + if (win32_open_files[i] == INVALID_HANDLE_VALUE) + { + result.value = i; + } + } + } + + assert(result.value != 0); + win32_open_files[result.value] = file_handle; + + memory_copy(path.str, (u8*)win32_open_file_paths[result.value], path.len); + win32_open_file_paths[result.value][path.len] = 0; // null term + } + else + { + win32_get_last_error(); + } + + return result; +} + +void +platform_file_close(Platform_File_Handle file_handle) +{ + assert(file_handle.value < win32_open_files_len); + CloseHandle(win32_get_open_file_handle(file_handle)); + win32_open_files[file_handle.value] = INVALID_HANDLE_VALUE; +} + +u64 +win32_get_file_size(HANDLE h) +{ + DWORD size_low, size_high; + size_low = GetFileSize(h, &size_high); + if (size_low == INVALID_FILE_SIZE) + { + win32_get_last_error(); + return 0; + } + LARGE_INTEGER win32_size; + win32_size.LowPart = size_low; + win32_size.HighPart = size_high; + return (u64)win32_size.QuadPart; +} + +Platform_File_Info +platform_file_get_info(Platform_File_Handle file_handle, Allocator* allocator) +{ + Platform_File_Info result = {}; + HANDLE h = win32_get_open_file_handle(file_handle); + if (h == INVALID_HANDLE_VALUE) return result; + + // File Size + u64 win32_size = win32_get_file_size(h); + if (win32_size == 0 && win32_last_error != 0) return result; + + // File Times + FILETIME time_created, time_last_write; + if (!GetFileTime(h, &time_created, (LPFILETIME)0, &time_last_write)) + { + win32_get_last_error(); + return result; + } + + // File Path + // call GetFullPathName with empty dest just to get the length needed + DWORD file_name_len_needed = GetFullPathName( + win32_open_file_paths[file_handle.value], 0, 0, 0 + ); + if (!file_name_len_needed) + { + win32_get_last_error(); + return result; + } + + result.path = allocator_alloc_string(allocator, (u64)file_name_len_needed); + result.path.len = (u64)GetFullPathName( + win32_open_file_paths[file_handle.value], + (DWORD)result.path.cap, + (char*)result.path.str, + 0 + ); + result.path_abs = result.path; + + // File Attributes + DWORD file_attrs = GetFileAttributesA((char*)result.path.str); + if (!file_attrs) + { + win32_get_last_error(); + return result; + } + + result.size = win32_size; + result.time_created = win32_file_time_to_u64(time_created); + result.time_last_write = win32_file_time_to_u64(time_last_write); + + if (has_flag(file_attrs, FILE_ATTRIBUTE_DIRECTORY)) + { + add_flag(result.flags, FileFlag_IsDir); + } + + return result; +} + +Data +platform_file_read_all(Platform_File_Handle file_handle, Allocator* allocator) +{ + Data result = {}; + + HANDLE h = win32_get_open_file_handle(file_handle); + if (h == INVALID_HANDLE_VALUE) return result; + + u64 file_size = win32_get_file_size(h); + if (file_size == 0 && win32_last_error != 0) return result; + + result.base = allocator_alloc(allocator, file_size + 1); + result.size = file_size + 1; + + DWORD bytes_read = 0; + if (ReadFile(h, (void*)result.base, (DWORD)result.size, &bytes_read, NULL)) + { + result.base[result.size - 1] = 0; + } + else + { + win32_get_last_error(); + } + + return result; +} + +bool +platform_file_write_all(Platform_File_Handle file_handle, Data file_data) +{ + bool result = false; + + HANDLE h = win32_get_open_file_handle(file_handle); + if (h == INVALID_HANDLE_VALUE) return result; + + // Set file pointer to beginning + SetFilePointer(h, 0, 0, FILE_BEGIN); + + DWORD bytes_written = 0; + if (WriteFile(h, file_data.base, (DWORD)file_data.size, &bytes_written, NULL)) + { + result = (bytes_written == file_data.size); + } + + return result; +} + +void +platform_dir_enum_(String path, Platform_Enum_Dir_Flags flags, Allocator* allocator, Platform_File_Info_List* list) +{ + WIN32_FIND_DATA ffd; + HANDLE search_handle = FindFirstFile((char*)path.str, &ffd); + if (search_handle != INVALID_HANDLE_VALUE) + { + do + { + Platform_File_Info_List_Ele* ele = allocator_alloc_struct( + allocator, Platform_File_Info_List_Ele + ); + + sll_push(list->first, list->last, ele); + } while (FindNextFile(search_handle, &ffd)); + } +} + +Platform_File_Info_List +platform_dir_enum(String path, Platform_Enum_Dir_Flags flags, Allocator* allocator) +{ + Platform_File_Info_List result = {}; + platform_dir_enum_(path, flags, allocator, &result); + return result; +} + +String +platform_get_exe_path(Allocator* allocator) +{ + String result = allocator_alloc_string(allocator, (u64)MAX_PATH); + result.len = (u64)GetModuleFileName(NULL, (char*)result.str, (DWORD)result.cap); + if (!result.len) return result; + + return result; +} + +bool +platform_pwd_set(String path) +{ + bool result = SetCurrentDirectory((char*)path.str); + if (!result) win32_get_last_error(); + return result; +} \ No newline at end of file diff --git a/src_v2/platform/win32/lumenarium_win32_graphics.cpp b/src_v2/platform/win32/lumenarium_win32_graphics.cpp new file mode 100644 index 0000000..354bf93 --- /dev/null +++ b/src_v2/platform/win32/lumenarium_win32_graphics.cpp @@ -0,0 +1,336 @@ + +#define win32_gl_no_error() win32_gl_no_error_(__FILE__, __LINE__) +void win32_gl_no_error_(char* file, u32 line) { + u32 error = glGetError(); + char* str = 0; + if (error) { + str = win32_gl_error_to_string(error); + } + if (error != 0) + { + err_write("OpenGL error: %s:%d\n\t%s :: %d\n", file, line, str, error); + invalid_code_path; + } +} + +Platform_Geometry_Buffer +platform_geometry_buffer_create( + r32* vertices, u32 vertices_len, + u32* indices, u32 indices_len + ){ + Platform_Geometry_Buffer result = {}; + + gl.glGenVertexArrays(1, &result.buffer_id_vao); + win32_gl_no_error(); + + GLuint buffers[2]; + gl.glGenBuffers(2, (GLuint*)buffers); + win32_gl_no_error(); + + result.buffer_id_vertices = buffers[0]; + result.buffer_id_indices = buffers[1]; + + // Vertices + gl.glBindVertexArray(result.buffer_id_vao); + gl.glBindBuffer(GL_ARRAY_BUFFER, result.buffer_id_vertices); + win32_gl_no_error(); + + gl.glBufferData( + GL_ARRAY_BUFFER, sizeof(r32) * vertices_len, vertices, GL_STATIC_DRAW + ); + win32_gl_no_error(); + result.vertices_len = vertices_len; + + // Indices + gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.buffer_id_indices); + win32_gl_no_error(); + + gl.glBufferData( + GL_ELEMENT_ARRAY_BUFFER, sizeof(u32) * indices_len, indices, GL_STATIC_DRAW + ); + win32_gl_no_error(); + result.indices_len = indices_len; + + gl.glBindBuffer(GL_ARRAY_BUFFER, NULL); + gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, NULL); + + return result; +} + +void +platform_geometry_buffer_update( + Platform_Geometry_Buffer* buffer, + r32* verts, + u32 verts_offset, + u32 verts_len, + u32* indices, + u32 indices_offset, + u32 indices_len + ){ + gl.glBindVertexArray(buffer->buffer_id_vao); + gl.glBindBuffer(GL_ARRAY_BUFFER, buffer->buffer_id_vertices); + win32_gl_no_error(); + + if (verts_len > buffer->vertices_len) + { + // NOTE(PS): this is because we're going to delete the old buffer and + // create a new one. In order to do that and not lose data, the update + // function needs to have been passed all the buffer's data + assert(verts_offset == 0); + gl.glBufferData( + GL_ARRAY_BUFFER, verts_len * sizeof(r32), (void*)verts, GL_STATIC_DRAW + ); + } + else + { + gl.glBufferSubData( + GL_ARRAY_BUFFER, verts_offset * sizeof(r32), verts_len * sizeof(r32), (void*)verts + ); + } + win32_gl_no_error(); + + gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer->buffer_id_indices); + win32_gl_no_error(); + if (indices_len > buffer->indices_len) + { + // NOTE(PS): this is because we're going to delete the old buffer and + // create a new one. In order to do that and not lose data, the update + // function needs to have been passed all the buffer's data + assert(indices_offset == 0); + gl.glBufferData( + GL_ELEMENT_ARRAY_BUFFER, indices_len * sizeof(u32), (void*)indices, GL_STATIC_DRAW + ); + } + else + { + gl.glBufferSubData( + GL_ELEMENT_ARRAY_BUFFER, indices_offset * sizeof(u32), indices_len * sizeof(u32), (void*)indices + ); + } + win32_gl_no_error(); +} + +Platform_Shader +platform_shader_create( + String code_vert, String code_frag, String* attrs, u32 attrs_len, String* uniforms, u32 uniforms_len + ){ + Platform_Shader result = {}; + + GLuint shader_vert = gl.glCreateShader(GL_VERTEX_SHADER); + gl.glShaderSource(shader_vert, 1, (const char**)&code_vert.str, &(s32)code_vert.len); + gl.glCompileShader(shader_vert); + { // errors + GLint shader_vert_compiled; + gl.glGetShaderiv(shader_vert, GL_COMPILE_STATUS, &shader_vert_compiled); + if (!shader_vert_compiled) + { + GLsizei log_length = 0; + GLchar message[1024]; + gl.glGetShaderInfoLog(shader_vert, 1024, &log_length, message); + invalid_code_path; + } + } + + GLuint shader_frag = gl.glCreateShader(GL_FRAGMENT_SHADER); + gl.glShaderSource(shader_frag, 1, (const char**)&code_frag.str, &(s32)code_frag.len); + gl.glCompileShader(shader_frag); + { // errors + GLint shader_frag_compiled; + gl.glGetShaderiv(shader_frag, GL_COMPILE_STATUS, &shader_frag_compiled); + if (!shader_frag_compiled) + { + GLsizei log_length = 0; + GLchar message[1024]; + gl.glGetShaderInfoLog(shader_frag, 1024, &log_length, message); + invalid_code_path; + } + } + + result.id = (u32)gl.glCreateProgram(); + gl.glAttachShader(result.id, shader_vert); + gl.glAttachShader(result.id, shader_frag); + gl.glLinkProgram(result.id); + + GLint program_linked; + gl.glGetProgramiv(result.id, GL_LINK_STATUS, &program_linked); + if (program_linked != GL_TRUE) + { + GLsizei log_length = 0; + GLchar message[1024]; + gl.glGetProgramInfoLog(result.id, 1024, &log_length, message); + invalid_code_path; + } + + gl.glUseProgram(result.id); + + // TODO(PS): delete the vert and frag programs + + assert(attrs_len < PLATFORM_SHADER_MAX_ATTRS); + for (u32 i = 0; i < attrs_len; i++) + { + result.attrs[i] = gl.glGetAttribLocation( + result.id, (char*)attrs[i].str + ); + win32_gl_no_error(); + } + result.attrs[attrs_len] = PLATFORM_SHADER_ATTR_LAST; + + assert(uniforms_len < PLATFORM_SHADER_MAX_ATTRS); + for (GLuint i = 0; i < uniforms_len; i++) + { + s32 len = (s32)uniforms[i].len; + result.uniforms[i] = gl.glGetUniformLocation( + result.id, (char*)uniforms[i].str + ); + } + result.uniforms[uniforms_len] = PLATFORM_SHADER_ATTR_LAST; + + return result; +} + +void +platform_set_uniform(Platform_Shader shader, u32 index, m44 u) +{ + gl.glUniformMatrix4fv(shader.uniforms[index], 1, GL_FALSE, (r32*)u.Elements); +} + +void +platform_geometry_bind(Platform_Geometry_Buffer geo) +{ + gl.glBindVertexArray(geo.buffer_id_vao); + win32_gl_no_error(); + + gl.glBindBuffer(GL_ARRAY_BUFFER, geo.buffer_id_vertices); + win32_gl_no_error(); + + gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, geo.buffer_id_indices); + win32_gl_no_error(); +} + +void +platform_shader_bind(Platform_Shader shader) +{ + gl.glUseProgram(shader.id); + win32_gl_no_error(); + for (u32 i = 0; + ((i < PLATFORM_SHADER_MAX_ATTRS) && (shader.attrs[i] != PLATFORM_SHADER_ATTR_LAST)); + i++) + { + gl.glEnableVertexAttribArray(shader.attrs[i]); + win32_gl_no_error(); + } +} + +void +platform_geometry_draw( + Platform_Geometry_Buffer geo, u32 indices + ){ + glDrawElements(GL_TRIANGLES, indices, GL_UNSIGNED_INT, 0); + win32_gl_no_error(); +} + +void +platform_geometry_draw( + Platform_Geometry_Buffer geo + ){ + platform_geometry_draw(geo, geo.indices_len); +} + +void platform_vertex_attrib_pointer( + Platform_Geometry_Buffer geo, Platform_Shader shader, GLuint count, GLuint attr_index, GLuint stride, GLuint offset + ){ + platform_geometry_bind(geo); + gl.glVertexAttribPointer(shader.attrs[attr_index], count, GL_FLOAT, false, stride * sizeof(float), (void*)(offset * sizeof(float))); + win32_gl_no_error(); + gl.glEnableVertexAttribArray(shader.attrs[attr_index]); + win32_gl_no_error(); +} + +Platform_Texture +platform_texture_create(u8* pixels, u32 width, u32 height, u32 stride) +{ + Platform_Texture result = {}; + glGenTextures(1, &result.id); + win32_gl_no_error(); + + glBindTexture(GL_TEXTURE_2D, result.id); + win32_gl_no_error(); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + win32_gl_no_error(); + + glTexImage2D( + GL_TEXTURE_2D, + 0, + GL_RGBA, + width, + height, + 0, + GL_RGBA, + GL_UNSIGNED_BYTE, + pixels + ); + win32_gl_no_error(); + + result.w = width; + result.h = height; + result.s = stride; + + return result; +} + +void +platform_texture_update(Platform_Texture tex, u8* new_pixels, u32 width, u32 height, u32 stride) +{ + // NOTE(PS): this function simply replaces the entire image + // we can write a more granular version if we need it + + assert(tex.w == width && tex.h == height && tex.s == stride); + platform_texture_bind(tex); + glTexSubImage2D( + GL_TEXTURE_2D, + 0, + 0, 0, // offset + width, height, + GL_RGBA, + GL_UNSIGNED_BYTE, + new_pixels + ); +} + +void +platform_texture_bind(Platform_Texture tex) +{ + glBindTexture(GL_TEXTURE_2D, tex.id); + win32_gl_no_error(); +} + +void +platform_frame_begin(Platform_Graphics_Frame_Desc desc) +{ + v4 cc = desc.clear_color; + glClearColor(cc.r, cc.g, cc.b, cc.a); + + v2 vmin = desc.viewport_min; + v2 vmax = desc.viewport_max; + glViewport((GLsizei)vmin.x, (GLsizei)vmin.y, (GLint)vmax.x, (GLint)vmax.y); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glDisable(GL_CULL_FACE); + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + win32_gl_no_error(); +} + +void +platform_frame_clear() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +} \ No newline at end of file diff --git a/src_v2/platform/win32/lumenarium_win32_memory.cpp b/src_v2/platform/win32/lumenarium_win32_memory.cpp new file mode 100644 index 0000000..3c39c44 --- /dev/null +++ b/src_v2/platform/win32/lumenarium_win32_memory.cpp @@ -0,0 +1,45 @@ +#define WIN32_PAGE_SIZE KB(4) + +u64 platform_page_size() { return WIN32_PAGE_SIZE; } + +u8* +platform_mem_reserve(u64 size) +{ + size_t size_cvt = (size_t)round_size_to_page_multiple(size); + DWORD alloc_type = MEM_RESERVE; + DWORD protection = PAGE_READWRITE; + u8* result = (u8*)VirtualAlloc(0, size_cvt, alloc_type, protection); + if (!result) win32_get_last_error(); + return result; +} + +u8* +platform_mem_commit(u8* base, u64 size) +{ + size_t size_cvt = (size_t)round_size_to_page_multiple(size); + DWORD alloc_type = MEM_COMMIT; + DWORD protection = PAGE_READWRITE; + u8* result = (u8*)VirtualAlloc(base, size_cvt, alloc_type, protection); + if (!result) win32_get_last_error(); + return result; +} + +bool +platform_mem_decommit(u8* base, u64 size) +{ + DWORD free_type = MEM_DECOMMIT; + bool result = VirtualFree(base, (size_t)size, free_type); + if (!result) win32_get_last_error(); + return result; +} + +bool +platform_mem_release(u8* base, u64 size) +{ + DWORD free_type = MEM_RELEASE; + // according to the docs, if we're releasing memory, the size must be + // zero as its implied VirtualFree will free the entire region + bool result = VirtualFree(base, 0, free_type); + if (!result) win32_get_last_error(); + return result; +} diff --git a/src_v2/platform/win32/lumenarium_win32_opengl.h b/src_v2/platform/win32/lumenarium_win32_opengl.h new file mode 100644 index 0000000..29526bb --- /dev/null +++ b/src_v2/platform/win32/lumenarium_win32_opengl.h @@ -0,0 +1,85 @@ +/* date = March 24th 2022 6:05 pm */ + +#ifndef LUMENARIUM_WIN32_OPENGL_H +#define LUMENARIUM_WIN32_OPENGL_H + +// glext.h - https://github.com/KhronosGroup/OpenGL-Registry/blob/main/api/GL/glext.h +// wglext.h - + +// OpenGL 3.3+ Context Creation +typedef const char *WINAPI proc_wglGetExtensionsStringARB(HDC hdc); +typedef BOOL proc_wglChoosePixelFormatARB(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +typedef HGLRC proc_wglCreateContextAttribsARB(HDC hDC, HGLRC hshareContext, const int *attribList); + +// OpenGL 3.3+ Extensions +typedef void proc_glGenVertexArrays(GLsizei n, GLuint *arrays); +typedef void proc_glBindVertexArray(GLuint array); +typedef void proc_glGenBuffers (GLsizei n, GLuint *buffers); +typedef void proc_glBindBuffer(GLenum target, GLuint buffer); +typedef void proc_glBufferData(GLenum target, size_t size, const void *data, GLenum usage); +typedef void proc_glBufferSubData(GLenum target, size_t offset, size_t size, const void* data); +typedef GLuint proc_glCreateShader(GLenum type); +typedef void proc_glShaderSource(GLuint shader, u32 count, const char* const* string, const GLint *length); +typedef void proc_glCompileShader(GLuint shader); +typedef GLuint proc_glCreateProgram(void); +typedef void proc_glAttachShader(GLuint program, GLuint shader); +typedef void proc_glLinkProgram(GLuint program); +typedef void proc_glUseProgram(GLuint program); +typedef GLuint proc_glGetAttribLocation(GLuint program, const char* name); +typedef void proc_glVertexAttribPointer(GLuint attr, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void proc_glEnableVertexAttribArray(GLuint index); +typedef void proc_glGetShaderiv(GLuint shader, GLenum ele, GLint* value_out); +typedef void proc_glGetShaderInfoLog(GLuint shader, GLuint buf_len, GLsizei* len_out, GLchar* buf); +typedef void proc_glGetProgramiv(GLuint program, GLenum ele, GLint* value_out); +typedef void proc_glGetProgramInfoLog(GLuint program, GLuint cap, GLsizei* len_out, GLchar* buf); +typedef GLuint proc_glGetUniformLocation(GLuint program, const char* name); +typedef void proc_glUniformMatrix4fv(GLuint uniform, GLuint count, GLenum normalize, GLfloat* elements); +struct Win32_OpenGL_Extensions +{ + proc_wglGetExtensionsStringARB* wglGetExtensionsStringARB; + proc_wglChoosePixelFormatARB* wglChoosePixelFormatARB; + proc_wglCreateContextAttribsARB* wglCreateContextAttribsARB; + + proc_glGenVertexArrays* glGenVertexArrays; + proc_glBindVertexArray* glBindVertexArray; + proc_glGenBuffers* glGenBuffers; + proc_glBindBuffer* glBindBuffer; + proc_glBufferData* glBufferData; + proc_glBufferSubData* glBufferSubData; + proc_glCreateShader* glCreateShader; + proc_glShaderSource* glShaderSource; + proc_glCompileShader* glCompileShader; + proc_glCreateProgram* glCreateProgram; + proc_glAttachShader* glAttachShader; + proc_glLinkProgram* glLinkProgram; + proc_glUseProgram* glUseProgram; + proc_glGetAttribLocation* glGetAttribLocation; + proc_glVertexAttribPointer* glVertexAttribPointer; + proc_glEnableVertexAttribArray* glEnableVertexAttribArray; + proc_glGetShaderiv* glGetShaderiv; + proc_glGetShaderInfoLog* glGetShaderInfoLog; + proc_glGetProgramiv* glGetProgramiv; + proc_glGetProgramInfoLog* glGetProgramInfoLog; + proc_glGetUniformLocation* glGetUniformLocation; + proc_glUniformMatrix4fv* glUniformMatrix4fv; +}; + +//////////////////////////////////////// +// error strings + +#define WIN32_GL_ERROR_CASE(code) case (code): { result = #code; } break + +char* +win32_gl_error_to_string(u32 error) +{ + char* result = 0; + switch (error) + { + WIN32_GL_ERROR_CASE(GL_INVALID_VALUE); + WIN32_GL_ERROR_CASE(GL_INVALID_ENUM ); + WIN32_GL_ERROR_CASE(GL_INVALID_OPERATION); + default: { result = "unknown"; } + } + return result; +} +#endif //LUMENARIUM_WIN32_OPENGL_H diff --git a/src_v2/platform/win32/lumenarium_win32_thread.cpp b/src_v2/platform/win32/lumenarium_win32_thread.cpp new file mode 100644 index 0000000..0fdf3ed --- /dev/null +++ b/src_v2/platform/win32/lumenarium_win32_thread.cpp @@ -0,0 +1,97 @@ + +#define win32_threads_cap 9 +global u32 win32_threads_len = 1; +global HANDLE win32_threads[win32_threads_cap]; +global Platform_Thread_Data win32_threads_data[win32_threads_cap]; + +DWORD WINAPI +win32_thread_wrapper(void* d) +{ + Platform_Thread_Result result = {}; + Platform_Thread_Data* thread_data = (Platform_Thread_Data*)d; + thread_data->thread_id = GetCurrentThreadId(); + if (thread_data->thread_proc) + { + result = thread_data->thread_proc(thread_data); + } + return result.code; +} + +void +win32_threads_init() +{ + for (u32 i = 1; i < win32_threads_cap; i++) win32_threads[i] = INVALID_HANDLE_VALUE; +} + +void +win32_threads_reclaim() +{ + u32 highest_valid = 0; + for (u32 i = 1; i < win32_threads_cap; i++) + { + if (win32_threads[i] != INVALID_HANDLE_VALUE) + { + highest_valid = i; + } + } + + win32_threads_len = highest_valid + 1; +} + +Platform_Thread_Handle +platform_thread_begin(Platform_Thread_Proc* proc, u8* user_data) +{ + Platform_Thread_Handle result = {}; + if (win32_threads_len < win32_threads_cap) + { + result.value = win32_threads_len++; + } + else + { + for (u32 i = 1; i < win32_threads_cap; i++) + { + if (win32_threads[i] == INVALID_HANDLE_VALUE) + { + result.value = i; + break; + } + } + } + assert(result.value != 0); + + Platform_Thread_Data* thread_data = &win32_threads_data[result.value]; + thread_data->thread_handle = result; + thread_data->thread_proc = proc; + thread_data->user_data = user_data; + + HANDLE thread_handle = CreateThread( + 0, 0, win32_thread_wrapper, (void*)thread_data, 0, 0 + ); + win32_threads[result.value] = thread_handle; + + return result; +} + +void +platform_thread_end(Platform_Thread_Handle thread) +{ + HANDLE thread_handle = win32_threads[thread.value]; + bool result = TerminateThread(thread_handle, 0); + if (!result) { + win32_get_last_error(); + invalid_code_path; + } + win32_threads[thread.value] = INVALID_HANDLE_VALUE; +} + +u32 +platform_interlocked_increment(volatile u32* value) +{ + return InterlockedIncrement((LONG volatile*)value); +} + +u32 +platform_interlocked_cmp_exchg(volatile u32* dest, u32 new_value, u32 old_value) +{ + return InterlockedCompareExchange((LONG volatile*)dest, new_value, old_value); +} diff --git a/src_v2/platform/win32/lumenarium_win32_time.cpp b/src_v2/platform/win32/lumenarium_win32_time.cpp new file mode 100644 index 0000000..6bd090c --- /dev/null +++ b/src_v2/platform/win32/lumenarium_win32_time.cpp @@ -0,0 +1,48 @@ + +// set by calling win32_get_performance_frequency() +global s64 win32_performance_counter_freq_s64 = 0; +global r64 win32_performance_counter_freq_r64 = 0; + +s64 +win32_get_performance_frequency() +{ + LARGE_INTEGER freq; + if (!QueryPerformanceFrequency(&freq)) + { + win32_get_last_error(); + // TODO(Peter): I'm waiting to see an error actually occur here + // to know what it could possibly be. + invalid_code_path; + } + return (s64)freq.QuadPart; +} + +void +win32_time_init() +{ + win32_performance_counter_freq_s64 = win32_get_performance_frequency(); + win32_performance_counter_freq_r64 = (r64)win32_performance_counter_freq_s64; +} + +Platform_Ticks +platform_get_ticks() +{ + Platform_Ticks result = {}; + LARGE_INTEGER time; + if (!QueryPerformanceCounter(&time)) + { + win32_get_last_error(); + // TODO(Peter): I'm waiting to see an error actually occur here + // to know what it could possibly be. + invalid_code_path; + } + result.value = (s64)time.QuadPart; + return result; +} + +r64 +platform_ticks_to_seconds(Platform_Ticks ticks) +{ + r64 result = (r64)ticks.value / win32_performance_counter_freq_r64; + return result; +} \ No newline at end of file diff --git a/src_v2/platform/win32/lumenarium_win32_window.cpp b/src_v2/platform/win32/lumenarium_win32_window.cpp new file mode 100644 index 0000000..bc5030c --- /dev/null +++ b/src_v2/platform/win32/lumenarium_win32_window.cpp @@ -0,0 +1,422 @@ +typedef u32 Win32_Window_Event_Flags; +enum +{ + WindowEventFlag_None = 0, + WindowEventFlag_CloseRequested = 1, + WindowEventFlag_WindowIsActive = 2, +}; + +struct Win32_Window_OpenGL_Info +{ + BYTE bits_color; + BYTE bits_alpha; + BYTE bits_depth; + + HGLRC rc; +}; + +struct Win32_Window_Info +{ + char* name; + char* class_name; + s32 width; + s32 height; +}; + +struct Win32_Window +{ + Win32_Window_Info info; + WNDCLASSEX window_class; + WNDPROC window_event_handler; + HWND window_handle; + HDC dc; + Win32_Window_OpenGL_Info opengl_info; +}; + +////////////////////////////////////////// +// Main Window +// +// At the moment, we only need one window, so this is easier to +// track globally. Replace this if we need more windows + +global Win32_Window_Event_Flags win32_window_event_flags = 0; +global Win32_Window win32_main_window = {}; + +////////////////////////////////////////// +// + +internal bool +win32_window_create( + Win32_Window* dest, + HINSTANCE hinstance, + char* window_name, + s32 width, + s32 height, + WNDPROC window_event_handler + ) +{ + dest->info.name = window_name; + dest->info.class_name = window_name; + dest->info.width = width; + dest->info.height = height; + + dest->window_event_handler = window_event_handler; + + dest->window_class = {}; + dest->window_class.cbSize = sizeof(WNDCLASSEX); + dest->window_class.style = ( + CS_HREDRAW | + CS_VREDRAW | + CS_OWNDC // TODO(PS): need to know what this is + ); + dest->window_class.lpfnWndProc = window_event_handler; + dest->window_class.cbClsExtra = 0; + dest->window_class.cbWndExtra = 0; + dest->window_class.hInstance = hinstance; + dest->window_class.hIcon = NULL; + dest->window_class.hCursor = NULL; + dest->window_class.hbrBackground = NULL; + dest->window_class.lpszMenuName = 0; + dest->window_class.lpszClassName = window_name; // "main_window_class"; + dest->window_class.hIconSm = NULL; + + if (RegisterClassEx(&dest->window_class)) + { + dest->window_handle = CreateWindowEx( + 0, + dest->window_class.lpszClassName, + window_name, + WS_OVERLAPPEDWINDOW | WS_VISIBLE, + CW_USEDEFAULT, + CW_USEDEFAULT, + width, + height, + 0, + 0, + hinstance, + 0 + ); + return true; + } + return false; +} + +internal void +win32_window_update_dim(Win32_Window* win) +{ + RECT client_rect; + GetClientRect(win->window_handle, &client_rect); + win->info.width = client_rect.right - client_rect.left; + win->info.height = client_rect.bottom - client_rect.top; +} + +internal void win32_window_opengl_ctx_create(Win32_Window* win, Win32_Window_OpenGL_Info info, HINSTANCE hinstance); + +LRESULT CALLBACK +win32_window_event_handler(HWND window_handle, UINT msg, WPARAM wparam, LPARAM lparam) +{ + LRESULT result = 0; + + switch (msg) + { + case WM_CREATE: + { + win32_main_window.dc = GetDC(window_handle); + HINSTANCE hinstance = GetModuleHandle(NULL); + win32_window_opengl_ctx_create(&win32_main_window, { 32, 8, 0 }, hinstance); + }break; + + case WM_SIZE: + { + win32_window_update_dim(&win32_main_window); + }break; + + case WM_CLOSE: + { + if (win32_main_window.opengl_info.rc) + { + wglDeleteContext(win32_main_window.opengl_info.rc); + win32_main_window.opengl_info.rc = NULL; + } + if (win32_main_window.dc) + { + ReleaseDC(win32_main_window.window_handle, win32_main_window.dc); + win32_main_window.dc = NULL; + } + + add_flag(win32_window_event_flags, WindowEventFlag_CloseRequested); + running = false; + + DestroyWindow(win32_main_window.window_handle); + }break; + + case WM_DESTROY: + { + if (win32_main_window.opengl_info.rc) + { + wglDeleteContext(win32_main_window.opengl_info.rc); + win32_main_window.opengl_info.rc = NULL; + } + if (win32_main_window.dc) + { + ReleaseDC(win32_main_window.window_handle, win32_main_window.dc); + win32_main_window.dc = NULL; + } + + //PostQuitMessage(0); + //result = DefWindowProc(window_handle, msg, wparam, lparam); + }break; + + case WM_PAINT: + { + PAINTSTRUCT paint_struct; + HDC device_ctx; + b32 paint_result; + + device_ctx = BeginPaint(window_handle, &paint_struct); + paint_result = EndPaint(window_handle, &paint_struct); + }break; + + case WM_ACTIVATE: + { + bool WindowIsActive = ( + LOWORD(wparam) == WA_ACTIVE || LOWORD(wparam) == WA_CLICKACTIVE + ); + if (WindowIsActive) + { + add_flag(win32_window_event_flags, WindowEventFlag_WindowIsActive); + } + else + { + rem_flag(win32_window_event_flags, WindowEventFlag_WindowIsActive); + } + }break; + + default: + { + result = DefWindowProc(window_handle, msg, wparam, lparam); + } + } + + return result; +} + +//////////////////////////////////////////// +// OpenGL dummy window functions + +LRESULT CALLBACK +win32_opengl_event_handler(HWND window_handle, UINT msg, WPARAM wparam, LPARAM lparam) +{ + LRESULT result = 0; + + switch (msg) + { + case WM_CREATE: { }break; + case WM_CLOSE: { DestroyWindow(window_handle); }break; + case WM_DESTROY: { } break; + default: { return DefWindowProc(window_handle, msg, wparam, lparam); } break; + } + + return result; +} + +internal void +win32_window_opengl_ctx_create_no_ext(HDC dc, Win32_Window_OpenGL_Info* info) +{ + // Setup pixel format + { + PIXELFORMATDESCRIPTOR pixel_format_desc = { 0 }; + pixel_format_desc.nSize = sizeof(PIXELFORMATDESCRIPTOR); + pixel_format_desc.nVersion = 1; + pixel_format_desc.dwFlags = ( + PFD_SUPPORT_OPENGL | + PFD_DRAW_TO_WINDOW | + PFD_DOUBLEBUFFER + ); + + pixel_format_desc.cColorBits = info->bits_color; + pixel_format_desc.cAlphaBits = info->bits_alpha; + pixel_format_desc.cDepthBits = info->bits_depth; + pixel_format_desc.iPixelType = PFD_TYPE_RGBA; + pixel_format_desc.dwLayerMask = PFD_MAIN_PLANE; + + s32 pixel_fmt = ChoosePixelFormat(dc, &pixel_format_desc); + if (pixel_fmt == 0) + { + win32_get_last_error(); + invalid_code_path; + } + if ((pixel_fmt = ChoosePixelFormat(dc, &pixel_format_desc)) == 0) + { + win32_get_last_error(); + invalid_code_path; + } + if (SetPixelFormat(dc, pixel_fmt, &pixel_format_desc) == FALSE) + { + win32_get_last_error(); + invalid_code_path; + } + } + + // Create rendering context + { + info->rc = wglCreateContext(dc); + if (info->rc == NULL) { + win32_get_last_error(); + invalid_code_path; + } + if (!wglMakeCurrent(dc, info->rc)) + { + win32_get_last_error(); + invalid_code_path; + } + } +} + +// Based on documentation at: +// https://www.opengl.org/wiki/Creating_an_OpenGL_Context_(WGL)#Proper_Context_Creation +internal void +win32_window_opengl_ctx_create_ext(HDC dc, Win32_Window_OpenGL_Info* info) +{ + const int pixel_fmt_attribs[] = { + WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, + WGL_SUPPORT_OPENGL_ARB, GL_TRUE, + WGL_DOUBLE_BUFFER_ARB, GL_TRUE, + WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, + WGL_COLOR_BITS_ARB, 32, + WGL_DEPTH_BITS_ARB, 24, + WGL_STENCIL_BITS_ARB, 8, + 0, 0 + }; + + s32 pixel_fmt; + u32 num_formats; + + // this will contain the description of pixel_fmt after we set it + PIXELFORMATDESCRIPTOR pixel_format_desc = { 0 }; + + if (!gl.wglChoosePixelFormatARB(dc, pixel_fmt_attribs, NULL, 1, &pixel_fmt, &num_formats)) + { + win32_get_last_error(); + invalid_code_path; + } + if (SetPixelFormat(dc, pixel_fmt, &pixel_format_desc) == FALSE) + { + win32_get_last_error(); + invalid_code_path; + } + + int ctx_flags = WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + +#if defined(DEBUG) + ctx_flags |= WGL_CONTEXT_DEBUG_BIT_ARB; +#endif + + const int ctx_attribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + WGL_CONTEXT_FLAGS_ARB, ctx_flags, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + + 0, 0, + }; + + info->rc = gl.wglCreateContextAttribsARB(dc, 0, ctx_attribs); + if (info->rc == NULL) { + win32_get_last_error(); + invalid_code_path; + } + if (!wglMakeCurrent(dc, info->rc)) + { + win32_get_last_error(); + invalid_code_path; + } + + char* version_string = (char*)glGetString(GL_VERSION); + err_write("OpenGL Version: %s\n", version_string); +} + +internal void +win32_window_opengl_make_current(Win32_Window* win) +{ + +} + +#define wgl_load_ext(e,n) e.n = (proc_##n*)wglGetProcAddress(#n); assert((e.n) != 0) + +internal Win32_OpenGL_Extensions +win32_window_opengl_get_wgl_ext(HINSTANCE hinstance) +{ + Win32_OpenGL_Extensions result = {0}; + + WNDCLASSEX window_class = {}; + window_class.cbSize = sizeof(WNDCLASSEX); + window_class.style = (CS_HREDRAW | CS_VREDRAW | CS_OWNDC); + window_class.lpfnWndProc = win32_opengl_event_handler; + window_class.hInstance = hinstance; + window_class.lpszClassName = "opengl_window_class"; + if (RegisterClassEx(&window_class)) + { + HWND window_handle = CreateWindowEx(0, window_class.lpszClassName, + "opengl_window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + CW_USEDEFAULT, CW_USEDEFAULT, 32, 32, 0, 0, hinstance, 0 + ); + + HDC dc = GetDC(window_handle); + Win32_Window_OpenGL_Info info = { 32, 24, 8 }; + win32_window_opengl_ctx_create_no_ext(dc, &info); + + wgl_load_ext(result, wglGetExtensionsStringARB); + if (result.wglGetExtensionsStringARB != 0) + { + const char* extension_string = result.wglGetExtensionsStringARB(dc); + OutputDebugStringA("OpenGL Extensions: \n"); + OutputDebugStringA(extension_string); + OutputDebugStringA("\n\n"); + + wgl_load_ext(result, wglChoosePixelFormatARB); + wgl_load_ext(result, wglCreateContextAttribsARB); + wgl_load_ext(result, glGenVertexArrays); + wgl_load_ext(result, glBindVertexArray); + wgl_load_ext(result, glGenBuffers); + wgl_load_ext(result, glBindBuffer); + wgl_load_ext(result, glBufferData); + wgl_load_ext(result, glBufferSubData); + wgl_load_ext(result, glCreateShader); + wgl_load_ext(result, glShaderSource); + wgl_load_ext(result, glCompileShader); + wgl_load_ext(result, glCreateProgram); + wgl_load_ext(result, glAttachShader); + wgl_load_ext(result, glLinkProgram); + wgl_load_ext(result, glUseProgram); + wgl_load_ext(result, glGetAttribLocation); + wgl_load_ext(result, glVertexAttribPointer); + wgl_load_ext(result, glEnableVertexAttribArray); + wgl_load_ext(result, glGetShaderiv); + wgl_load_ext(result, glGetShaderInfoLog); + wgl_load_ext(result, glGetProgramiv); + wgl_load_ext(result, glGetProgramInfoLog); + wgl_load_ext(result, glGetUniformLocation); + wgl_load_ext(result, glUniformMatrix4fv); + } + + wglMakeCurrent(NULL, NULL); + wglDeleteContext(info.rc); + ReleaseDC(window_handle, dc); + DestroyWindow(window_handle); + } + + return result; +} + +internal void +win32_window_opengl_ctx_create(Win32_Window* win, Win32_Window_OpenGL_Info info, HINSTANCE hinstance) +{ + if (gl.wglGetExtensionsStringARB == 0) + { + gl = win32_window_opengl_get_wgl_ext(hinstance); + } + + win32_window_opengl_ctx_create_ext(win->dc, &info); + win->opengl_info = info; +} diff --git a/src_v2/platform/win32/test.cpp b/src_v2/platform/win32/test.cpp new file mode 100644 index 0000000..f4c32c1 --- /dev/null +++ b/src_v2/platform/win32/test.cpp @@ -0,0 +1,423 @@ +/* + * Example of a Windows OpenGL program. + * The OpenGL code is the same as that used in + * the X Window System sample + */ +#include <windows.h> +#include <GL/gl.h> +//#include <GL/glu.h> + +/* Windows globals, defines, and prototypes */ +CHAR szAppName[]="Win OpenGL"; +HWND ghWnd; +HDC ghDC; +HGLRC ghRC; + +#define SWAPBUFFERS SwapBuffers(ghDC) +#define BLACK_INDEX 0 +#define RED_INDEX 13 +#define GREEN_INDEX 14 +#define BLUE_INDEX 16 +#define WIDTH 300 +#define HEIGHT 200 + +LONG WINAPI MainWndProc (HWND, UINT, WPARAM, LPARAM); +BOOL bSetupPixelFormat(HDC); + +/* OpenGL globals, defines, and prototypes */ +GLfloat latitude, longitude, latinc, longinc; +GLdouble radius; + +#define GLOBE 1 +#define CYLINDER 2 +#define CONE 3 + +GLvoid resize(GLsizei, GLsizei); +GLvoid initializeGL(GLsizei, GLsizei); +GLvoid drawScene(GLvoid); +void polarView( GLdouble, GLdouble, GLdouble, GLdouble); + +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + MSG msg; + WNDCLASS wndclass; + + /* Register the frame class */ + wndclass.style = 0; + wndclass.lpfnWndProc = (WNDPROC)MainWndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = hInstance; + wndclass.hIcon = LoadIcon (hInstance, szAppName); + wndclass.hCursor = LoadCursor (NULL,IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wndclass.lpszMenuName = szAppName; + wndclass.lpszClassName = szAppName; + + DWORD r0 = RegisterClass (&wndclass); + if (!r0) return FALSE; + + /* Create the frame */ + ghWnd = CreateWindow (szAppName, + "Generic OpenGL Sample", + WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE, + CW_USEDEFAULT, + CW_USEDEFAULT, + WIDTH, + HEIGHT, + NULL, + NULL, + hInstance, + NULL); + + /* make sure window was created */ + if (!ghWnd) + return FALSE; + + /* show and update main window */ + ShowWindow (ghWnd, nCmdShow); + + UpdateWindow (ghWnd); + + /* animation loop */ + while (1) { + /* + * Process all pending messages + */ + + while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) == TRUE) + { + if (GetMessage(&msg, NULL, 0, 0) ) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } else { + return TRUE; + } + } + drawScene(); + } +} + +/* main window procedure */ +LONG WINAPI MainWndProc ( + HWND hWnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) +{ + LONG lRet = 1; + PAINTSTRUCT ps; + RECT rect; + + switch (uMsg) { + + case WM_CREATE: + ghDC = GetDC(hWnd); + if (!bSetupPixelFormat(ghDC)) + PostQuitMessage (0); + + ghRC = wglCreateContext(ghDC); + wglMakeCurrent(ghDC, ghRC); + GetClientRect(hWnd, &rect); + initializeGL(rect.right, rect.bottom); + break; + + case WM_PAINT: + BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + break; + + case WM_SIZE: + GetClientRect(hWnd, &rect); + resize(rect.right, rect.bottom); + break; + + case WM_CLOSE: + if (ghRC) + wglDeleteContext(ghRC); + if (ghDC) + ReleaseDC(hWnd, ghDC); + ghRC = 0; + ghDC = 0; + + DestroyWindow (hWnd); + break; + + case WM_DESTROY: + if (ghRC) + wglDeleteContext(ghRC); + if (ghDC) + ReleaseDC(hWnd, ghDC); + + PostQuitMessage (0); + break; + + case WM_KEYDOWN: + switch (wParam) { + case VK_LEFT: + longinc += 0.5F; + break; + case VK_RIGHT: + longinc -= 0.5F; + break; + case VK_UP: + latinc += 0.5F; + break; + case VK_DOWN: + latinc -= 0.5F; + break; + } + + default: + lRet = (LONG)DefWindowProc (hWnd, uMsg, wParam, lParam); + break; + } + + return lRet; +} + +BOOL bSetupPixelFormat(HDC hdc) +{ + PIXELFORMATDESCRIPTOR pfd, *ppfd; + int pixelformat; + + ppfd = &pfd; + + ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR); + ppfd->nVersion = 1; + ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | + PFD_DOUBLEBUFFER; + ppfd->dwLayerMask = PFD_MAIN_PLANE; + ppfd->iPixelType = PFD_TYPE_COLORINDEX; + ppfd->cColorBits = 8; + ppfd->cDepthBits = 16; + ppfd->cAccumBits = 0; + ppfd->cStencilBits = 0; + + pixelformat = ChoosePixelFormat(hdc, ppfd); + + if ( (pixelformat = ChoosePixelFormat(hdc, ppfd)) == 0 ) + { + MessageBox(NULL, "ChoosePixelFormat failed", "Error", MB_OK); + return FALSE; + } + + if (SetPixelFormat(hdc, pixelformat, ppfd) == FALSE) + { + MessageBox(NULL, "SetPixelFormat failed", "Error", MB_OK); + return FALSE; + } + + return TRUE; +} + +/* OpenGL code */ + +GLvoid resize( GLsizei width, GLsizei height ) +{ + GLfloat aspect; + + glViewport( 0, 0, width, height ); + + aspect = (GLfloat) width / height; + + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + //gluPerspective( 45.0, aspect, 3.0, 7.0 ); + //glMatrixMode( GL_MODELVIEW ); +} + +#if 0 +GLvoid createObjects() +{ + GLUquadricObj *quadObj; + + glNewList(GLOBE, GL_COMPILE); + quadObj = gluNewQuadric (); + gluQuadricDrawStyle (quadObj, GLU_LINE); + gluSphere (quadObj, 1.5, 16, 16); + glEndList(); + + glNewList(CONE, GL_COMPILE); + quadObj = gluNewQuadric (); + gluQuadricDrawStyle (quadObj, GLU_FILL); + gluQuadricNormals (quadObj, GLU_SMOOTH); + gluCylinder(quadObj, 0.3, 0.0, 0.6, 15, 10); + glEndList(); + + glNewList(CYLINDER, GL_COMPILE); + glPushMatrix (); + glRotatef ((GLfloat)90.0, (GLfloat)1.0, (GLfloat)0.0, (GLfloat)0.0); + glTranslatef ((GLfloat)0.0, (GLfloat)0.0, (GLfloat)-1.0); + quadObj = gluNewQuadric (); + gluQuadricDrawStyle (quadObj, GLU_FILL); + gluQuadricNormals (quadObj, GLU_SMOOTH); + gluCylinder (quadObj, 0.3, 0.3, 0.6, 12, 2); + glPopMatrix (); + glEndList(); +} +#endif + +GLvoid initializeGL(GLsizei width, GLsizei height) +{ + GLfloat maxObjectSize, aspect; + GLdouble near_plane, far_plane; + + glClearIndex( (GLfloat)BLACK_INDEX); + glClearDepth( 1.0 ); + + glEnable(GL_DEPTH_TEST); + + glMatrixMode( GL_PROJECTION ); + aspect = (GLfloat) width / height; + //gluPerspective( 45.0, aspect, 3.0, 7.0 ); + glMatrixMode( GL_MODELVIEW ); + + near_plane = 3.0; + far_plane = 7.0; + maxObjectSize = 3.0F; + radius = near_plane + maxObjectSize/2.0; + + latitude = 0.0F; + longitude = 0.0F; + latinc = 6.0F; + longinc = 2.5F; + + //createObjects(); +} + +void polarView(GLdouble radius_, GLdouble twist, GLdouble latitude_, + GLdouble longitude_) +{ + glTranslated(0.0, 0.0, -radius_); + glRotated(-twist, 0.0, 0.0, 1.0); + glRotated(-latitude_, 1.0, 0.0, 0.0); + glRotated(longitude_, 0.0, 0.0, 1.0); + +} + +GLvoid drawScene(GLvoid) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + + latitude += latinc; + longitude += longinc; + + polarView( radius, 0, latitude, longitude ); + + glIndexi(RED_INDEX); + glCallList(CONE); + + glIndexi(BLUE_INDEX); + glCallList(GLOBE); + + glIndexi(GREEN_INDEX); + glPushMatrix(); + glTranslatef(0.8F, -0.65F, 0.0F); + glRotatef(30.0F, 1.0F, 0.5F, 1.0F); + glCallList(CYLINDER); + glPopMatrix(); + + glPopMatrix(); + + SWAPBUFFERS; +} + +#if 0 +#include "windows.h" +#include <gl/gl.h> + +# define assert_always (*((volatile int*)0) = 0xFFFF) + +LRESULT CALLBACK +window_event_handler(HWND h, UINT m, WPARAM w, LPARAM l) +{ + switch (m) + { + case WM_CLOSE: { return DefWindowProc(h, m, w, l); } break; + case WM_DESTROY: { return DefWindowProc(h, m, w, l); } break; + default: { return DefWindowProc(h, m, w, l); } break; + } +} + +INT WINAPI +WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + PSTR lpCmdLine, + INT nCmdShow) +{ + WNDCLASSEX window_class = {0}; + HWND window_handle = NULL; + HDC dc = NULL; + HGLRC rc = NULL; + + window_class = {}; + window_class.cbSize = sizeof(WNDCLASSEX); + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.lpfnWndProc = window_event_handler; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = hInstance; + window_class.hIcon = NULL; + window_class.hCursor = NULL; + window_class.hbrBackground = NULL; + window_class.lpszMenuName = 0; + window_class.lpszClassName = "my_window_class"; // TODO(PS): does this need to be different from the window itself? + window_class.hIconSm = NULL; + + if (RegisterClassEx(&window_class)) + { + window_handle = CreateWindowEx( + 0, + window_class.lpszClassName, + "my_window", + WS_OVERLAPPEDWINDOW | WS_VISIBLE, + CW_USEDEFAULT, + CW_USEDEFAULT, + 600, + 400, + 0, + 0, + hInstance, + 0 + ); + dc = GetDC(window_handle); + } + else + { + assert_always; + } + + // Setup pixel format + PIXELFORMATDESCRIPTOR pixel_format_desc = { 0 }; + pixel_format_desc.nSize = sizeof(PIXELFORMATDESCRIPTOR); + pixel_format_desc.nVersion = 1; + pixel_format_desc.dwFlags = ( + PFD_SUPPORT_OPENGL | + PFD_DRAW_TO_WINDOW | + PFD_DOUBLEBUFFER + ); + pixel_format_desc.cColorBits = 32; + pixel_format_desc.cAlphaBits = 8; + pixel_format_desc.cDepthBits = 0; + pixel_format_desc.iPixelType = PFD_TYPE_RGBA; + pixel_format_desc.dwLayerMask = PFD_MAIN_PLANE; + + int pixel_fmt = ChoosePixelFormat(dc, &pixel_format_desc); + if (!pixel_fmt) { assert_always; } + if (!SetPixelFormat(dc, pixel_fmt, &pixel_format_desc)) + { + assert_always; + } + + // Create rendering context + rc = wglCreateContext(dc); + wglMakeCurrent(dc, rc); + + return 0; +} +#endif \ No newline at end of file diff --git a/src_v2/scratch/lumenarium b/src_v2/scratch/lumenarium new file mode 100755 index 0000000..3c26db2 Binary files /dev/null and b/src_v2/scratch/lumenarium differ diff --git a/src_v2/tools/convert_csv.c b/src_v2/tools/convert_csv.c new file mode 100644 index 0000000..e3c8255 --- /dev/null +++ b/src_v2/tools/convert_csv.c @@ -0,0 +1,155 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <stdint.h> +#include <math.h> +#include <stdbool.h> +#include <errno.h> +#include <limits.h> +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "../platform/linux/lumenarium_linux_memory.h" +#include "../core/lumenarium_core.h" +#include "../platform/lumenarium_os.h" + +#define linux_err_print(sub_proc) linux_err_print_((char*)__FUNCTION__, (char*)(sub_proc), errno) +void +linux_err_print_(char* proc, char* sub_proc, s32 errsv) +{ + printf("Error: %s:%s - %d\n\t%s\n\n", proc, sub_proc, errsv, strerror(errsv)); +} + +#define OS_FILE_HANDLE_TYPE s32 +#define OS_FILE_MAX_PATH PATH_MAX +#define OS_FILE_INVALID_HANDLE -1 +#define OS_SOCKET_TYPE s32 +#define OS_SOCKET_INVALID_HANDLE -1 +#include "../platform/shared/lumenarium_shared_file_tracker.h" +#include "../platform/linux/lumenarium_linux_file.h" + +char* cvtcsv_header = ""; + +Allocator* a = 0; + +internal char* +cvtcsv_seek_next_line(char* at) +{ + char* result = at; + while(*result && !(*result == '\n' || *result == '\r')) result++; + while(*result && (*result == '\n' || *result == '\r')) result++; + return result; +} + +internal char* +cvtcsv_seek_comma(char* at) +{ + char* result = at; + while (*result && *result != ',') { result++; } + return result; +} + +internal void +cvtcsv_process_line(u32 line_number, char* start, char* end, FILE* out) +{ + char* col_end_0 = cvtcsv_seek_comma(start); + char* col_end_1 = cvtcsv_seek_comma(col_end_0 + 1); + char* col_end_2 = cvtcsv_seek_comma(col_end_1 + 1); + char* col_end_3 = end; + + char* col_start_1 = col_end_0 + 1; + char* col_start_2 = col_end_1 + 1; + char* col_start_3 = col_end_2 + 1; + + s32 col_len_0 = (u32)(col_end_0 - start); + s32 col_len_1 = (u32)(col_end_1 - (col_end_0 + 1)); + s32 col_len_2 = (u32)(col_end_2 - (col_end_1 + 1)); + s32 col_len_3 = (u32)(col_end_3 - (col_end_2 + 1)); + + fprintf(out, "[%d] = {", line_number); + fprintf(out, " %.*s, ", col_len_0, start); // city id + fprintf(out, " %.*s, ", col_len_1, col_start_1); // year + fprintf(out, " %.*s, ", col_len_2, col_start_2); // month + fprintf(out, " %.*s, ", col_len_3, col_start_3); // prop + fprintf(out, "},\n"); +} + +internal void +cvtcsv_convert(char* path) +{ + // Reading in the csv + String in_path = string_f(a, "../../../data/incenter_data/csv/%s.csv", path); + File_Handle csv_file = os_file_open(in_path, FileAccess_Read, FileCreate_OpenExisting); + if (csv_file.value == 0) { printf("could not open %.*s\n", str_varg(in_path)); return; } + Data csv_ = os_file_read_all(csv_file, a); + os_file_close(csv_file); + if (csv_.size == 0) { printf("could not read %.*s\n", str_varg(in_path)); return; } + + String csv = (String){ + .str = csv_.base, + .len = csv_.size, + .cap = csv_.size + }; + + // Writing out the c file + String out_path = string_f(a, "../../../data/incenter_data/c/%s.h", path); + printf("%.*s -> %.*s\n", str_varg(in_path), str_varg(out_path)); + FILE* out = fopen((char*)out_path.str, "wb"); + if (!out) { printf("Cannot write to file: %.*s\n", str_varg(out_path)); return; } + fprintf(out, "%s", cvtcsv_header); + fprintf(out, "static Incenter_Data_Row %s_data[] = {\n", path); + + char* at = cvtcsv_seek_next_line((char*)csv.str); + u32 col = 0; + u32 line = 0; + char* line_start = at; + while (*at != 0) + { + if (*at == ',') col += 1; + if (*at == '\n') { + cvtcsv_process_line(line, line_start, at, out); + line += 1; + col = 0; + line_start = at + 1; + } + at++; + } +// cvtcsv_process_line(line, line_start, at, out); + fprintf(out, "};\nglobal u32 %s_len = sizeof(%s_data) / sizeof(%s_data[0]);", path, path, path); + + fclose(out); +} + +int main (int arg_c, char** args) +{ + a = bump_allocator_create_reserve(MB(1)); + + cvtcsv_convert("question_1"); + cvtcsv_convert("question_2"); + cvtcsv_convert("question_3"); + cvtcsv_convert("question_4"); + cvtcsv_convert("question_5"); + cvtcsv_convert("question_6"); + cvtcsv_convert("question_7"); + cvtcsv_convert("question_8"); + cvtcsv_convert("question_9"); + cvtcsv_convert("question_10"); + cvtcsv_convert("question_11"); + cvtcsv_convert("question_12"); + cvtcsv_convert("question_13"); + cvtcsv_convert("question_14"); + cvtcsv_convert("question_15"); + cvtcsv_convert("question_16"); + cvtcsv_convert("question_17"); + cvtcsv_convert("question_18"); + cvtcsv_convert("question_19"); + cvtcsv_convert("question_20"); + cvtcsv_convert("question_21"); + + + + printf("Done\n"); + return 0; +} \ No newline at end of file diff --git a/src_v2/tools/convert_csv_build.sh b/src_v2/tools/convert_csv_build.sh new file mode 100644 index 0000000..dcf3f93 --- /dev/null +++ b/src_v2/tools/convert_csv_build.sh @@ -0,0 +1 @@ +clang convert_csv.c \ No newline at end of file diff --git a/src_v2/user_space/incenter_gen_cities.h b/src_v2/user_space/incenter_gen_cities.h new file mode 100644 index 0000000..0308980 --- /dev/null +++ b/src_v2/user_space/incenter_gen_cities.h @@ -0,0 +1,2180 @@ +// NOTE: This file is autogenerated by csv_to_cstruct.js +// NOTE: These are values for Incenter_City_Id +#define BLACK_ROCK_LED_FIRST 90 +#define BLACK_ROCK_LED_OPL 140 + +enum { + + city_black_rock = 0, + city_bucharest = 1, + city_brisbane = 2, + city_chengdu = 3, + city_new_delhi = 4, + city_paris = 5, + city_san_francisco = 6, + city_denver = 7, + city_ankara = 8, + city_harare = 9, + city_hanoi = 10, + city_washington = 11, + city_bangkok = 12, + city_tunis = 13, + city_seoul = 14, + city_belgrade = 15, + city_moscow = 16, + city_lima = 17, + city_islamabad = 18, + city_abuja = 19, + city_managua = 20, + city_amsterdam = 21, + city_rabat = 22, + city_ulaanbaatar = 23, + city_mexico_city = 24, + city_nairobi = 25, + city_tokyo = 26, + city_baghdad = 27, + city_tehran = 28, + city_jakarta = 29, + city_guatemala_city = 30, + city_berlin = 31, + city_addis_ababa = 32, + city_cairo = 33, + city_quito = 34, + city_bogota = 35, + city_beijing = 36, + city_accra = 37, + city_ottawa = 38, + city_brasilia = 39, + city_la_paz = 40, + city_dhaka = 41, + city_yerevan = 42, + city_chicago = 43, + city_kyiv = 44, + city_dubai = 45, + city_mumbai = 46, + city_madrid = 47, + city_count, + city_secondary_first = city_count + 1, + city_secondary_lagos = 48, + city_secondary_kinshasa = 49, + city_secondary_luanda = 50, + city_secondary_dar_es_salaam = 51, + city_secondary_khartoum = 52, + city_secondary_giza = 53, + city_secondary_abidjan = 54, + city_secondary_johannesburg = 55, + city_secondary_casablanca = 56, + city_secondary_algiers = 57, + city_secondary_antananarivo = 58, + city_secondary_ouagadougou = 59, + city_secondary_yaounde = 60, + city_secondary_mogadishu = 61, + city_secondary_kumasi = 62, + city_secondary_bamako = 63, + city_secondary_blantyre = 64, + city_secondary_meru = 65, + city_secondary_brazzaville = 66, + city_secondary_lusaka = 67, + city_secondary_conakry = 68, + city_secondary_kampala = 69, + city_secondary_maputo = 70, + city_secondary_pikine = 71, + city_secondary_kigali = 72, + city_secondary_tripoli = 73, + city_secondary_ndjamena = 74, + city_secondary_nouakchott = 75, + city_secondary_niamey = 76, + city_secondary_monrovia = 77, + city_secondary_asmara = 78, + city_secondary_freetown = 79, + city_secondary_bangui = 80, + city_secondary_lome = 81, + city_secondary_libreville = 82, + city_secondary_cotonou = 83, + city_secondary_bujumbura = 84, + city_secondary_djibouti = 85, + city_secondary_bissau = 86, + city_secondary_juba = 87, + city_secondary_maseru = 88, + city_secondary_windhoek = 89, + city_secondary_gaborone = 90, + city_secondary_saint_denis = 91, + city_secondary_malabo = 92, + city_secondary_port_louis = 93, + city_secondary_praia = 94, + city_secondary_moroni = 95, + city_secondary_mbabane = 96, + city_secondary_sao_tome = 97, + city_secondary_banjul = 98, + city_secondary_mamoudzou = 99, + city_secondary_victoria = 100, + city_secondary_jamestown = 101, + city_secondary_bulawayo = 102, + city_secondary_sidi_bouzid = 103, + city_secondary_nazret = 104, + city_secondary_delhi = 105, + city_secondary_manila = 106, + city_secondary_shanghai = 107, + city_secondary_osaka = 108, + city_secondary_istanbul = 109, + city_secondary_karachi = 110, + city_secondary_ho_chi_minh_city = 111, + city_secondary_kuala_lumpur = 112, + city_secondary_hong_kong = 113, + city_secondary_riyadh = 114, + city_secondary_rangoon = 115, + city_secondary_singapore = 116, + city_secondary_kabul = 117, + city_secondary_amman = 118, + city_secondary_busan = 119, + city_secondary_mashhad = 120, + city_secondary_kuwait_city = 121, + city_secondary_sanaa = 122, + city_secondary_bandung = 123, + city_secondary_pyongyang = 124, + city_secondary_chattogram = 125, + city_secondary_tashkent = 126, + city_secondary_baku = 127, + city_secondary_phnom_penh = 128, + city_secondary_aleppo = 129, + city_secondary_almaty = 130, + city_secondary_mosul = 131, + city_secondary_abu_dhabi = 132, + city_secondary_muscat = 133, + city_secondary_doha = 134, + city_secondary_tbilisi = 135, + city_secondary_bishkek = 136, + city_secondary_kathmandu = 137, + city_secondary_vientiane = 138, + city_secondary_jerusalem = 139, + city_secondary_dushanbe = 140, + city_secondary_colombo = 141, + city_secondary_beirut = 142, + city_secondary_nicosia = 143, + city_secondary_dili = 144, + city_secondary_male = 145, + city_secondary_manama = 146, + city_secondary_thimphu = 147, + city_secondary_bandar_seri_begawan = 148, + city_secondary_ashgabat = 149, + city_secondary_macau = 150, + city_secondary_nonthaburi = 151, + city_secondary_moron = 152, + city_secondary_gyumri = 153, + city_secondary_london = 154, + city_secondary_saint_petersburg = 155, + city_secondary_barcelona = 156, + city_secondary_rome = 157, + city_secondary_minsk = 158, + city_secondary_vienna = 159, + city_secondary_hamburg = 160, + city_secondary_warsaw = 161, + city_secondary_brussels = 162, + city_secondary_budapest = 163, + city_secondary_kharkiv = 164, + city_secondary_prague = 165, + city_secondary_sofia = 166, + city_secondary_copenhagen = 167, + city_secondary_stockholm = 168, + city_secondary_zagreb = 169, + city_secondary_oslo = 170, + city_secondary_athens = 171, + city_secondary_helsinki = 172, + city_secondary_skopje = 173, + city_secondary_chisinau = 174, + city_secondary_riga = 175, + city_secondary_vilnius = 176, + city_secondary_dublin = 177, + city_secondary_the_hague = 178, + city_secondary_lisbon = 179, + city_secondary_bratislava = 180, + city_secondary_tallinn = 181, + city_secondary_tirana = 182, + city_secondary_ljubljana = 183, + city_secondary_sarajevo = 184, + city_secondary_gibraltar = 185, + city_secondary_podgorica = 186, + city_secondary_bern = 187, + city_secondary_luxembourg = 188, + city_secondary_reykjavik = 189, + city_secondary_monaco = 190, + city_secondary_saint_helier = 191, + city_secondary_douglas = 192, + city_secondary_andorra_la_vella = 193, + city_secondary_torshavn = 194, + city_secondary_valletta = 195, + city_secondary_vaduz = 196, + city_secondary_san_marino = 197, + city_secondary_vatican_city = 198, + city_secondary_marseille = 199, + city_secondary_novi_sad = 200, + city_secondary_cluj_napoca = 201, + city_secondary_new_york = 202, + city_secondary_guadalajara = 203, + city_secondary_toronto = 204, + city_secondary_santo_domingo = 205, + city_secondary_havana = 206, + city_secondary_comayaguela = 207, + city_secondary_port_au_prince = 208, + city_secondary_panama_city = 209, + city_secondary_kingston = 210, + city_secondary_san_salvador = 211, + city_secondary_san_jose = 212, + city_secondary_nassau = 213, + city_secondary_fort_de_france = 214, + city_secondary_willemstad = 215, + city_secondary_bridgetown = 216, + city_secondary_castries = 217, + city_secondary_hamilton = 218, + city_secondary_port_of_spain = 219, + city_secondary_oranjestad = 220, + city_secondary_george_town = 221, + city_secondary_kingstown = 222, + city_secondary_saint_johns = 223, + city_secondary_nuuk = 224, + city_secondary_belmopan = 225, + city_secondary_roseau = 226, + city_secondary_basseterre = 227, + city_secondary_grand_turk = 228, + city_secondary_saint_georges = 229, + city_secondary_basse_terre = 230, + city_secondary_brades = 231, + city_secondary_villa_nueva = 232, + city_secondary_san_juan = 233, + city_secondary_boaco = 234, + city_secondary_sydney = 235, + city_secondary_auckland = 236, + city_secondary_port_moresby = 237, + city_secondary_papeete = 238, + city_secondary_noumea = 239, + city_secondary_honiara = 240, + city_secondary_suva = 241, + city_secondary_port_vila = 242, + city_secondary_apia = 243, + city_secondary_tarawa = 244, + city_secondary_majuro = 245, + city_secondary_nukualofa = 246, + city_secondary_pago_pago = 247, + city_secondary_palikir = 248, + city_secondary_funafuti = 249, + city_secondary_avarua = 250, + city_secondary_capitol_hill = 251, + city_secondary_alofi = 252, + city_secondary_hagta = 253, + city_secondary_ngerulmud = 254, + city_secondary_sao_paulo = 255, + city_secondary_buenos_aires = 256, + city_secondary_santiago = 257, + city_secondary_timbio = 258, + city_secondary_santa_cruz = 259, + city_secondary_guayaquil = 260, + city_secondary_caracas = 261, + city_secondary_montevideo = 262, + city_secondary_callao = 263, + city_secondary_asuncion = 264, + city_secondary_paramaribo = 265, + city_secondary_georgetown = 266, + city_secondary_cayenne = 267, + city_secondary_stanley = 268, + city_secondary_grytviken = 269, + city_secondary_count, +}; + +global Incenter_City_Desc city_descs[] = { + [city_bucharest] = { + .id = city_bucharest, + .lat = 44.4, + .lon = 26.0833, + .sacn_universe = 165, + }, + [city_brisbane] = { + .id = city_brisbane, + .lat = -27.4678, + .lon = 153.0281, + .sacn_universe = 61, + }, + [city_chengdu] = { + .id = city_chengdu, + .lat = 30.66, + .lon = 104.0633, + .sacn_universe = 35, + }, + [city_new_delhi] = { + .id = city_new_delhi, + .lat = 28.6139, + .lon = 77.209, + .sacn_universe = 41, + }, + [city_paris] = { + .id = city_paris, + .lat = 48.8566, + .lon = 2.3522, + .sacn_universe = 189, + }, + [city_san_francisco] = { + .id = city_san_francisco, + .lat = 37.7562, + .lon = -122.443, + .sacn_universe = 21, + }, + [city_denver] = { + .id = city_denver, + .lat = 39.7621, + .lon = -104.8759, + .sacn_universe = 7, + }, + [city_ankara] = { + .id = city_ankara, + .lat = 39.93, + .lon = 32.85, + .sacn_universe = 203, + }, + [city_harare] = { + .id = city_harare, + .lat = -17.8292, + .lon = 31.0522, + .sacn_universe = 213, + }, + [city_hanoi] = { + .id = city_hanoi, + .lat = 21.0245, + .lon = 105.8412, + .sacn_universe = 33, + }, + [city_washington] = { + .id = city_washington, + .lat = 38.9047, + .lon = -77.0163, + .sacn_universe = 3, + }, + [city_bangkok] = { + .id = city_bangkok, + .lat = 13.75, + .lon = 100.5167, + .sacn_universe = 39, + }, + [city_tunis] = { + .id = city_tunis, + .lat = 36.8008, + .lon = 10.18, + .sacn_universe = 167, + }, + [city_seoul] = { + .id = city_seoul, + .lat = 37.56, + .lon = 126.99, + .sacn_universe = 57, + }, + [city_belgrade] = { + .id = city_belgrade, + .lat = 44.8167, + .lon = 20.4667, + .sacn_universe = 171, + }, + [city_moscow] = { + .id = city_moscow, + .lat = 55.7558, + .lon = 37.6178, + .sacn_universe = 197, + }, + [city_lima] = { + .id = city_lima, + .lat = -12.06, + .lon = -77.0375, + .sacn_universe = 19, + }, + [city_islamabad] = { + .id = city_islamabad, + .lat = 33.6989, + .lon = 73.0369, + .sacn_universe = 223, + }, + [city_abuja] = { + .id = city_abuja, + .lat = 9.0556, + .lon = 7.4914, + .sacn_universe = 183, + }, + [city_managua] = { + .id = city_managua, + .lat = 12.15, + .lon = -86.2667, + .sacn_universe = 5, + }, + [city_amsterdam] = { + .id = city_amsterdam, + .lat = 52.3667, + .lon = 4.8833, + .sacn_universe = 191, + }, + [city_rabat] = { + .id = city_rabat, + .lat = 34.0253, + .lon = -6.8361, + .sacn_universe = 187, + }, + [city_ulaanbaatar] = { + .id = city_ulaanbaatar, + .lat = 47.9214, + .lon = 106.9055, + .sacn_universe = 53, + }, + [city_mexico_city] = { + .id = city_mexico_city, + .lat = 19.4333, + .lon = -99.1333, + .sacn_universe = 9, + }, + [city_nairobi] = { + .id = city_nairobi, + .lat = -1.2864, + .lon = 36.8172, + .sacn_universe = 219, + }, + [city_tokyo] = { + .id = city_tokyo, + .lat = 35.6839, + .lon = 139.7744, + .sacn_universe = 59, + }, + [city_baghdad] = { + .id = city_baghdad, + .lat = 33.35, + .lon = 44.4167, + .sacn_universe = 195, + }, + [city_tehran] = { + .id = city_tehran, + .lat = 35.7, + .lon = 51.4167, + .sacn_universe = 205, + }, + [city_jakarta] = { + .id = city_jakarta, + .lat = -6.2146, + .lon = 106.8451, + .sacn_universe = 63, + }, + [city_guatemala_city] = { + .id = city_guatemala_city, + .lat = 14.6099, + .lon = -90.5252, + .sacn_universe = 13, + }, + [city_berlin] = { + .id = city_berlin, + .lat = 52.5167, + .lon = 13.3833, + .sacn_universe = 169, + }, + [city_addis_ababa] = { + .id = city_addis_ababa, + .lat = 9.0272, + .lon = 38.7369, + .sacn_universe = 201, + }, + [city_cairo] = { + .id = city_cairo, + .lat = 30.0444, + .lon = 31.2358, + .sacn_universe = 163, + }, + [city_quito] = { + .id = city_quito, + .lat = -0.22, + .lon = -78.5125, + .sacn_universe = 23, + }, + [city_bogota] = { + .id = city_bogota, + .lat = 4.6126, + .lon = -74.0705, + .sacn_universe = 25, + }, + [city_beijing] = { + .id = city_beijing, + .lat = 39.904, + .lon = 116.4075, + .sacn_universe = 55, + }, + [city_accra] = { + .id = city_accra, + .lat = 5.6037, + .lon = -0.187, + .sacn_universe = 161, + }, + [city_ottawa] = { + .id = city_ottawa, + .lat = 45.4247, + .lon = -75.695, + .sacn_universe = 31, + }, + [city_brasilia] = { + .id = city_brasilia, + .lat = -15.7939, + .lon = -47.8828, + .sacn_universe = 181, + }, + [city_la_paz] = { + .id = city_la_paz, + .lat = -16.4942, + .lon = -68.1475, + .sacn_universe = 27, + }, + [city_dhaka] = { + .id = city_dhaka, + .lat = 23.7289, + .lon = 90.3944, + .sacn_universe = 43, + }, + [city_yerevan] = { + .id = city_yerevan, + .lat = 40.1814, + .lon = 44.5144, + .sacn_universe = 211, + }, + [city_chicago] = { + .id = city_chicago, + .lat = 41.8373, + .lon = -87.6862, + .sacn_universe = 11, + }, + [city_kyiv] = { + .id = city_kyiv, + .lat = 50.45, + .lon = 30.5236, + .sacn_universe = 199, + }, + [city_dubai] = { + .id = city_dubai, + .lat = 25.2697, + .lon = 55.3094, + .sacn_universe = 193, + }, + [city_mumbai] = { + .id = city_mumbai, + .lat = 19.0758, + .lon = 72.8775, + .sacn_universe = 217, + }, + [city_madrid] = { + .id = city_madrid, + .lat = 40.4167, + .lon = -3.7167, + .sacn_universe = 185, + }, + + // Black Rock City + [city_black_rock] = { + .id = city_black_rock, + .lat = -90.0f, + .lon = 0, + .sacn_universe = 29, + }, + [city_secondary_lagos] = { + .id = city_secondary_lagos, + .lat = 6.45, + .lon = 3.4, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kinshasa] = { + .id = city_secondary_kinshasa, + .lat = -4.3317, + .lon = 15.3139, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_luanda] = { + .id = city_secondary_luanda, + .lat = -8.8383, + .lon = 13.2344, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_dar_es_salaam] = { + .id = city_secondary_dar_es_salaam, + .lat = -6.8, + .lon = 39.2833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_khartoum] = { + .id = city_secondary_khartoum, + .lat = 15.6031, + .lon = 32.5265, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_giza] = { + .id = city_secondary_giza, + .lat = 29.987, + .lon = 31.2118, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_abidjan] = { + .id = city_secondary_abidjan, + .lat = 5.3364, + .lon = -4.0267, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_johannesburg] = { + .id = city_secondary_johannesburg, + .lat = -26.2044, + .lon = 28.0416, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_casablanca] = { + .id = city_secondary_casablanca, + .lat = 33.5992, + .lon = -7.62, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_algiers] = { + .id = city_secondary_algiers, + .lat = 36.7764, + .lon = 3.0586, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_antananarivo] = { + .id = city_secondary_antananarivo, + .lat = -18.9386, + .lon = 47.5214, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_ouagadougou] = { + .id = city_secondary_ouagadougou, + .lat = 12.3686, + .lon = -1.5275, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_yaounde] = { + .id = city_secondary_yaounde, + .lat = 3.8578, + .lon = 11.5181, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_mogadishu] = { + .id = city_secondary_mogadishu, + .lat = 2.0408, + .lon = 45.3425, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kumasi] = { + .id = city_secondary_kumasi, + .lat = 6.6833, + .lon = -1.6167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bamako] = { + .id = city_secondary_bamako, + .lat = 12.6458, + .lon = -7.9922, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_blantyre] = { + .id = city_secondary_blantyre, + .lat = -15.7861, + .lon = 35.0058, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_meru] = { + .id = city_secondary_meru, + .lat = 0.05, + .lon = 37.65, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_brazzaville] = { + .id = city_secondary_brazzaville, + .lat = -4.2667, + .lon = 15.2833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_lusaka] = { + .id = city_secondary_lusaka, + .lat = -15.4167, + .lon = 28.2833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_conakry] = { + .id = city_secondary_conakry, + .lat = 9.538, + .lon = -13.6773, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kampala] = { + .id = city_secondary_kampala, + .lat = 0.3136, + .lon = 32.5811, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_maputo] = { + .id = city_secondary_maputo, + .lat = -25.9153, + .lon = 32.5764, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_pikine] = { + .id = city_secondary_pikine, + .lat = 14.75, + .lon = -17.4, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kigali] = { + .id = city_secondary_kigali, + .lat = -1.9536, + .lon = 30.0606, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_tripoli] = { + .id = city_secondary_tripoli, + .lat = 32.8752, + .lon = 13.1875, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_ndjamena] = { + .id = city_secondary_ndjamena, + .lat = 12.11, + .lon = 15.05, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_nouakchott] = { + .id = city_secondary_nouakchott, + .lat = 18.0858, + .lon = -15.9785, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_niamey] = { + .id = city_secondary_niamey, + .lat = 13.5086, + .lon = 2.1111, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_monrovia] = { + .id = city_secondary_monrovia, + .lat = 6.3106, + .lon = -10.8047, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_asmara] = { + .id = city_secondary_asmara, + .lat = 15.3333, + .lon = 38.9167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_freetown] = { + .id = city_secondary_freetown, + .lat = 8.4833, + .lon = -13.2331, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bangui] = { + .id = city_secondary_bangui, + .lat = 4.3732, + .lon = 18.5628, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_lome] = { + .id = city_secondary_lome, + .lat = 6.1319, + .lon = 1.2228, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_libreville] = { + .id = city_secondary_libreville, + .lat = 0.3901, + .lon = 9.4544, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_cotonou] = { + .id = city_secondary_cotonou, + .lat = 6.402, + .lon = 2.5180000000000002, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bujumbura] = { + .id = city_secondary_bujumbura, + .lat = -3.3825, + .lon = 29.3611, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_djibouti] = { + .id = city_secondary_djibouti, + .lat = 11.595, + .lon = 43.1481, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bissau] = { + .id = city_secondary_bissau, + .lat = 11.8592, + .lon = -15.5956, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_juba] = { + .id = city_secondary_juba, + .lat = 4.85, + .lon = 31.6, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_maseru] = { + .id = city_secondary_maseru, + .lat = -29.31, + .lon = 27.48, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_windhoek] = { + .id = city_secondary_windhoek, + .lat = -22.57, + .lon = 17.0836, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_gaborone] = { + .id = city_secondary_gaborone, + .lat = -24.6569, + .lon = 25.9086, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_saint_denis] = { + .id = city_secondary_saint_denis, + .lat = -20.8789, + .lon = 55.4481, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_malabo] = { + .id = city_secondary_malabo, + .lat = 3.7521, + .lon = 8.7737, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_port_louis] = { + .id = city_secondary_port_louis, + .lat = -20.1667, + .lon = 57.5, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_praia] = { + .id = city_secondary_praia, + .lat = 14.9177, + .lon = -23.5092, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_moroni] = { + .id = city_secondary_moroni, + .lat = -11.7036, + .lon = 43.2536, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_mbabane] = { + .id = city_secondary_mbabane, + .lat = -26.3208, + .lon = 31.1617, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_sao_tome] = { + .id = city_secondary_sao_tome, + .lat = 0.3333, + .lon = 6.7333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_banjul] = { + .id = city_secondary_banjul, + .lat = 13.4531, + .lon = -16.5775, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_mamoudzou] = { + .id = city_secondary_mamoudzou, + .lat = -12.7871, + .lon = 45.275, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_victoria] = { + .id = city_secondary_victoria, + .lat = -4.6236, + .lon = 55.4544, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_jamestown] = { + .id = city_secondary_jamestown, + .lat = -15.9251, + .lon = -5.7179, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bulawayo] = { + .id = city_secondary_bulawayo, + .lat = -20.1667, + .lon = 28.5667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_sidi_bouzid] = { + .id = city_secondary_sidi_bouzid, + .lat = 35.0381, + .lon = 9.4858, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_nazret] = { + .id = city_secondary_nazret, + .lat = 8.55, + .lon = 39.2667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_delhi] = { + .id = city_secondary_delhi, + .lat = 28.6667, + .lon = 77.2167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_manila] = { + .id = city_secondary_manila, + .lat = 14.6, + .lon = 120.9833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_shanghai] = { + .id = city_secondary_shanghai, + .lat = 31.1667, + .lon = 121.4667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_osaka] = { + .id = city_secondary_osaka, + .lat = 34.751999999999995, + .lon = 135.4582, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_istanbul] = { + .id = city_secondary_istanbul, + .lat = 41.01, + .lon = 28.9603, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_karachi] = { + .id = city_secondary_karachi, + .lat = 24.86, + .lon = 67.01, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_ho_chi_minh_city] = { + .id = city_secondary_ho_chi_minh_city, + .lat = 10.8167, + .lon = 106.6333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kuala_lumpur] = { + .id = city_secondary_kuala_lumpur, + .lat = 3.1478, + .lon = 101.6953, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_hong_kong] = { + .id = city_secondary_hong_kong, + .lat = 22.3069, + .lon = 114.1831, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_riyadh] = { + .id = city_secondary_riyadh, + .lat = 24.65, + .lon = 46.71, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_rangoon] = { + .id = city_secondary_rangoon, + .lat = 16.795, + .lon = 96.16, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_singapore] = { + .id = city_secondary_singapore, + .lat = 1.3, + .lon = 103.8, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kabul] = { + .id = city_secondary_kabul, + .lat = 34.5328, + .lon = 69.1658, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_amman] = { + .id = city_secondary_amman, + .lat = 31.95, + .lon = 35.9333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_busan] = { + .id = city_secondary_busan, + .lat = 35.1, + .lon = 129.0403, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_mashhad] = { + .id = city_secondary_mashhad, + .lat = 36.3069, + .lon = 59.6042, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kuwait_city] = { + .id = city_secondary_kuwait_city, + .lat = 29.375, + .lon = 47.98, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_sanaa] = { + .id = city_secondary_sanaa, + .lat = 15.35, + .lon = 44.2, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bandung] = { + .id = city_secondary_bandung, + .lat = -6.95, + .lon = 107.5667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_pyongyang] = { + .id = city_secondary_pyongyang, + .lat = 39.03, + .lon = 125.73, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_chattogram] = { + .id = city_secondary_chattogram, + .lat = 22.335, + .lon = 91.8325, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_tashkent] = { + .id = city_secondary_tashkent, + .lat = 41.3, + .lon = 69.2667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_baku] = { + .id = city_secondary_baku, + .lat = 40.3667, + .lon = 49.8352, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_phnom_penh] = { + .id = city_secondary_phnom_penh, + .lat = 11.5696, + .lon = 104.921, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_aleppo] = { + .id = city_secondary_aleppo, + .lat = 36.2, + .lon = 37.15, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_almaty] = { + .id = city_secondary_almaty, + .lat = 43.25, + .lon = 76.9, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_mosul] = { + .id = city_secondary_mosul, + .lat = 36.3667, + .lon = 43.1167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_abu_dhabi] = { + .id = city_secondary_abu_dhabi, + .lat = 24.4511, + .lon = 54.3969, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_muscat] = { + .id = city_secondary_muscat, + .lat = 23.6139, + .lon = 58.5922, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_doha] = { + .id = city_secondary_doha, + .lat = 25.3, + .lon = 51.5333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_tbilisi] = { + .id = city_secondary_tbilisi, + .lat = 41.7225, + .lon = 44.7925, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bishkek] = { + .id = city_secondary_bishkek, + .lat = 42.8667, + .lon = 74.5667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kathmandu] = { + .id = city_secondary_kathmandu, + .lat = 27.7167, + .lon = 85.3667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_vientiane] = { + .id = city_secondary_vientiane, + .lat = 17.9667, + .lon = 102.6, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_jerusalem] = { + .id = city_secondary_jerusalem, + .lat = 31.7833, + .lon = 35.2167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_dushanbe] = { + .id = city_secondary_dushanbe, + .lat = 38.5731, + .lon = 68.7864, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_colombo] = { + .id = city_secondary_colombo, + .lat = 6.9167, + .lon = 79.8333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_beirut] = { + .id = city_secondary_beirut, + .lat = 33.8869, + .lon = 35.5131, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_nicosia] = { + .id = city_secondary_nicosia, + .lat = 35.1725, + .lon = 33.365, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_dili] = { + .id = city_secondary_dili, + .lat = -8.5536, + .lon = 125.5783, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_male] = { + .id = city_secondary_male, + .lat = 4.175, + .lon = 73.5083, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_manama] = { + .id = city_secondary_manama, + .lat = 26.225, + .lon = 50.5775, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_thimphu] = { + .id = city_secondary_thimphu, + .lat = 27.4833, + .lon = 89.6333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bandar_seri_begawan] = { + .id = city_secondary_bandar_seri_begawan, + .lat = 4.9167, + .lon = 114.9167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_ashgabat] = { + .id = city_secondary_ashgabat, + .lat = 37.95, + .lon = 58.3833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_macau] = { + .id = city_secondary_macau, + .lat = 22.203000000000003, + .lon = 113.545, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_nonthaburi] = { + .id = city_secondary_nonthaburi, + .lat = 13.8667, + .lon = 100.5167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_moron] = { + .id = city_secondary_moron, + .lat = 49.6375, + .lon = 100.1614, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_gyumri] = { + .id = city_secondary_gyumri, + .lat = 40.7894, + .lon = 43.8475, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_london] = { + .id = city_secondary_london, + .lat = 51.5072, + .lon = -0.1275, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_saint_petersburg] = { + .id = city_secondary_saint_petersburg, + .lat = 59.95, + .lon = 30.3167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_barcelona] = { + .id = city_secondary_barcelona, + .lat = 41.3825, + .lon = 2.1769, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_rome] = { + .id = city_secondary_rome, + .lat = 41.8931, + .lon = 12.4828, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_minsk] = { + .id = city_secondary_minsk, + .lat = 53.9022, + .lon = 27.5618, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_vienna] = { + .id = city_secondary_vienna, + .lat = 48.2083, + .lon = 16.3725, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_hamburg] = { + .id = city_secondary_hamburg, + .lat = 53.55, + .lon = 10, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_warsaw] = { + .id = city_secondary_warsaw, + .lat = 52.23, + .lon = 21.0111, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_brussels] = { + .id = city_secondary_brussels, + .lat = 50.8353, + .lon = 4.3314, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_budapest] = { + .id = city_secondary_budapest, + .lat = 47.4983, + .lon = 19.0408, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kharkiv] = { + .id = city_secondary_kharkiv, + .lat = 50, + .lon = 36.2292, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_prague] = { + .id = city_secondary_prague, + .lat = 50.0833, + .lon = 14.4167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_sofia] = { + .id = city_secondary_sofia, + .lat = 42.6979, + .lon = 23.3217, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_copenhagen] = { + .id = city_secondary_copenhagen, + .lat = 55.6805, + .lon = 12.5615, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_stockholm] = { + .id = city_secondary_stockholm, + .lat = 59.3294, + .lon = 18.0686, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_zagreb] = { + .id = city_secondary_zagreb, + .lat = 45.8131, + .lon = 15.9772, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_oslo] = { + .id = city_secondary_oslo, + .lat = 59.9111, + .lon = 10.7528, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_athens] = { + .id = city_secondary_athens, + .lat = 37.9842, + .lon = 23.7281, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_helsinki] = { + .id = city_secondary_helsinki, + .lat = 60.1756, + .lon = 24.9342, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_skopje] = { + .id = city_secondary_skopje, + .lat = 41.9833, + .lon = 21.4333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_chisinau] = { + .id = city_secondary_chisinau, + .lat = 47.0228, + .lon = 28.8353, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_riga] = { + .id = city_secondary_riga, + .lat = 56.9475, + .lon = 24.1069, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_vilnius] = { + .id = city_secondary_vilnius, + .lat = 54.6833, + .lon = 25.2833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_dublin] = { + .id = city_secondary_dublin, + .lat = 53.3497, + .lon = -6.2603, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_the_hague] = { + .id = city_secondary_the_hague, + .lat = 52.08, + .lon = 4.31, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_lisbon] = { + .id = city_secondary_lisbon, + .lat = 38.708, + .lon = -9.139, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bratislava] = { + .id = city_secondary_bratislava, + .lat = 48.1447, + .lon = 17.1128, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_tallinn] = { + .id = city_secondary_tallinn, + .lat = 59.4372, + .lon = 24.745, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_tirana] = { + .id = city_secondary_tirana, + .lat = 41.33, + .lon = 19.82, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_ljubljana] = { + .id = city_secondary_ljubljana, + .lat = 46.05, + .lon = 14.5167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_sarajevo] = { + .id = city_secondary_sarajevo, + .lat = 43.8563, + .lon = 18.4132, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_gibraltar] = { + .id = city_secondary_gibraltar, + .lat = 36.1324, + .lon = -5.3781, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_podgorica] = { + .id = city_secondary_podgorica, + .lat = 42.4397, + .lon = 19.2661, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bern] = { + .id = city_secondary_bern, + .lat = 46.948, + .lon = 7.4474, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_luxembourg] = { + .id = city_secondary_luxembourg, + .lat = 49.6106, + .lon = 6.1328, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_reykjavik] = { + .id = city_secondary_reykjavik, + .lat = 64.1475, + .lon = -21.935, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_monaco] = { + .id = city_secondary_monaco, + .lat = 43.7396, + .lon = 7.4069, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_saint_helier] = { + .id = city_secondary_saint_helier, + .lat = 49.1858, + .lon = -2.11, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_douglas] = { + .id = city_secondary_douglas, + .lat = 54.15, + .lon = -4.4819, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_andorra_la_vella] = { + .id = city_secondary_andorra_la_vella, + .lat = 42.5, + .lon = 1.5, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_torshavn] = { + .id = city_secondary_torshavn, + .lat = 62, + .lon = -6.7833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_valletta] = { + .id = city_secondary_valletta, + .lat = 35.8978, + .lon = 14.5125, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_vaduz] = { + .id = city_secondary_vaduz, + .lat = 47.1397, + .lon = 9.5219, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_san_marino] = { + .id = city_secondary_san_marino, + .lat = 43.931999999999995, + .lon = 12.4484, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_vatican_city] = { + .id = city_secondary_vatican_city, + .lat = 41.9033, + .lon = 12.4534, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_marseille] = { + .id = city_secondary_marseille, + .lat = 43.2964, + .lon = 5.37, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_novi_sad] = { + .id = city_secondary_novi_sad, + .lat = 45.2644, + .lon = 19.8317, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_cluj_napoca] = { + .id = city_secondary_cluj_napoca, + .lat = 46.78, + .lon = 23.5594, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_new_york] = { + .id = city_secondary_new_york, + .lat = 40.6943, + .lon = -73.9249, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_guadalajara] = { + .id = city_secondary_guadalajara, + .lat = 20.6767, + .lon = -103.3475, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_toronto] = { + .id = city_secondary_toronto, + .lat = 43.7417, + .lon = -79.3733, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_santo_domingo] = { + .id = city_secondary_santo_domingo, + .lat = 18.4764, + .lon = -69.8933, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_havana] = { + .id = city_secondary_havana, + .lat = 23.1367, + .lon = -82.3589, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_comayaguela] = { + .id = city_secondary_comayaguela, + .lat = 14.0833, + .lon = -87.2167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_port_au_prince] = { + .id = city_secondary_port_au_prince, + .lat = 18.5425, + .lon = -72.3386, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_panama_city] = { + .id = city_secondary_panama_city, + .lat = 9, + .lon = -79.5, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kingston] = { + .id = city_secondary_kingston, + .lat = 17.9714, + .lon = -76.7931, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_san_salvador] = { + .id = city_secondary_san_salvador, + .lat = 13.6989, + .lon = -89.1914, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_san_jose] = { + .id = city_secondary_san_jose, + .lat = 9.9333, + .lon = -84.0833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_nassau] = { + .id = city_secondary_nassau, + .lat = 25.0667, + .lon = -77.3333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_fort_de_france] = { + .id = city_secondary_fort_de_france, + .lat = 14.6104, + .lon = -61.08, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_willemstad] = { + .id = city_secondary_willemstad, + .lat = 12.107999999999999, + .lon = -68.935, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_bridgetown] = { + .id = city_secondary_bridgetown, + .lat = 13.0975, + .lon = -59.6167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_castries] = { + .id = city_secondary_castries, + .lat = 14.0167, + .lon = -60.9833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_hamilton] = { + .id = city_secondary_hamilton, + .lat = 32.2942, + .lon = -64.7839, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_port_of_spain] = { + .id = city_secondary_port_of_spain, + .lat = 10.6667, + .lon = -61.5167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_oranjestad] = { + .id = city_secondary_oranjestad, + .lat = 12.5186, + .lon = -70.0358, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_george_town] = { + .id = city_secondary_george_town, + .lat = 19.2866, + .lon = -81.3744, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_kingstown] = { + .id = city_secondary_kingstown, + .lat = 13.1667, + .lon = -61.2333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_saint_johns] = { + .id = city_secondary_saint_johns, + .lat = 17.1211, + .lon = -61.8447, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_nuuk] = { + .id = city_secondary_nuuk, + .lat = 64.175, + .lon = -51.7333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_belmopan] = { + .id = city_secondary_belmopan, + .lat = 17.25, + .lon = -88.7675, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_roseau] = { + .id = city_secondary_roseau, + .lat = 15.3, + .lon = -61.3833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_basseterre] = { + .id = city_secondary_basseterre, + .lat = 17.2983, + .lon = -62.7342, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_grand_turk] = { + .id = city_secondary_grand_turk, + .lat = 21.4664, + .lon = -71.13600000000001, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_saint_georges] = { + .id = city_secondary_saint_georges, + .lat = 12.0444, + .lon = -61.7417, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_basse_terre] = { + .id = city_secondary_basse_terre, + .lat = 16.0104, + .lon = -61.7055, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_brades] = { + .id = city_secondary_brades, + .lat = 16.7928, + .lon = -62.2106, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_villa_nueva] = { + .id = city_secondary_villa_nueva, + .lat = 14.5314, + .lon = -90.5964, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_san_juan] = { + .id = city_secondary_san_juan, + .lat = 18.4037, + .lon = -66.0636, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_boaco] = { + .id = city_secondary_boaco, + .lat = 12.4667, + .lon = -85.6667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_sydney] = { + .id = city_secondary_sydney, + .lat = -33.865, + .lon = 151.2094, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_auckland] = { + .id = city_secondary_auckland, + .lat = -36.85, + .lon = 174.7833, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_port_moresby] = { + .id = city_secondary_port_moresby, + .lat = -9.4789, + .lon = 147.1494, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_papeete] = { + .id = city_secondary_papeete, + .lat = -17.5334, + .lon = -149.5667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_noumea] = { + .id = city_secondary_noumea, + .lat = -22.2625, + .lon = 166.4443, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_honiara] = { + .id = city_secondary_honiara, + .lat = -9.4333, + .lon = 159.95, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_suva] = { + .id = city_secondary_suva, + .lat = -18.1333, + .lon = 178.4333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_port_vila] = { + .id = city_secondary_port_vila, + .lat = -17.7333, + .lon = 168.3167, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_apia] = { + .id = city_secondary_apia, + .lat = -13.8333, + .lon = -171.8333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_tarawa] = { + .id = city_secondary_tarawa, + .lat = 1.3382, + .lon = 173.0176, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_majuro] = { + .id = city_secondary_majuro, + .lat = 7.0918, + .lon = 171.3802, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_nukualofa] = { + .id = city_secondary_nukualofa, + .lat = -21.1347, + .lon = -175.2083, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_pago_pago] = { + .id = city_secondary_pago_pago, + .lat = -14.274000000000001, + .lon = -170.7046, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_palikir] = { + .id = city_secondary_palikir, + .lat = 6.9178, + .lon = 158.185, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_funafuti] = { + .id = city_secondary_funafuti, + .lat = -8.5243, + .lon = 179.1942, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_avarua] = { + .id = city_secondary_avarua, + .lat = -21.206999999999997, + .lon = -159.77100000000002, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_capitol_hill] = { + .id = city_secondary_capitol_hill, + .lat = 15.2137, + .lon = 145.7546, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_alofi] = { + .id = city_secondary_alofi, + .lat = -19.055999999999997, + .lon = -169.921, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_hagta] = { + .id = city_secondary_hagta, + .lat = 13.4745, + .lon = 144.7504, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_ngerulmud] = { + .id = city_secondary_ngerulmud, + .lat = 7.5006, + .lon = 134.6242, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_sao_paulo] = { + .id = city_secondary_sao_paulo, + .lat = -23.5504, + .lon = -46.6339, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_buenos_aires] = { + .id = city_secondary_buenos_aires, + .lat = -34.5997, + .lon = -58.3819, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_santiago] = { + .id = city_secondary_santiago, + .lat = -33.45, + .lon = -70.6667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_timbio] = { + .id = city_secondary_timbio, + .lat = 2.3528, + .lon = -76.6819, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_santa_cruz] = { + .id = city_secondary_santa_cruz, + .lat = -17.7892, + .lon = -63.1975, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_guayaquil] = { + .id = city_secondary_guayaquil, + .lat = -2.19, + .lon = -79.8875, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_caracas] = { + .id = city_secondary_caracas, + .lat = 10.5, + .lon = -66.9333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_montevideo] = { + .id = city_secondary_montevideo, + .lat = -34.8667, + .lon = -56.1667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_callao] = { + .id = city_secondary_callao, + .lat = -12.0611, + .lon = -77.1333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_asuncion] = { + .id = city_secondary_asuncion, + .lat = -25.3, + .lon = -57.6333, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_paramaribo] = { + .id = city_secondary_paramaribo, + .lat = 5.8667, + .lon = -55.1667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_georgetown] = { + .id = city_secondary_georgetown, + .lat = 6.7833, + .lon = -58.1667, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_cayenne] = { + .id = city_secondary_cayenne, + .lat = 4.933, + .lon = -52.33, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_stanley] = { + .id = city_secondary_stanley, + .lat = -51.7, + .lon = -57.85, + .sacn_universe = incenter_secondary_city_universe, + }, + [city_secondary_grytviken] = { + .id = city_secondary_grytviken, + .lat = -54.2806, + .lon = -36.508, + .sacn_universe = incenter_secondary_city_universe, + }, +}; + +global char* city_strings[] = { + [city_bucharest] = "city_bucharest", + [city_brisbane] = "city_brisbane", + [city_chengdu] = "city_chengdu", + [city_new_delhi] = "city_new_delhi", + [city_paris] = "city_paris", + [city_san_francisco] = "city_san_francisco", + [city_denver] = "city_denver", + [city_ankara] = "city_ankara", + [city_harare] = "city_harare", + [city_hanoi] = "city_hanoi", + [city_washington] = "city_washington", + [city_bangkok] = "city_bangkok", + [city_tunis] = "city_tunis", + [city_seoul] = "city_seoul", + [city_belgrade] = "city_belgrade", + [city_moscow] = "city_moscow", + [city_lima] = "city_lima", + [city_islamabad] = "city_islamabad", + [city_abuja] = "city_abuja", + [city_managua] = "city_managua", + [city_amsterdam] = "city_amsterdam", + [city_rabat] = "city_rabat", + [city_ulaanbaatar] = "city_ulaanbaatar", + [city_mexico_city] = "city_mexico_city", + [city_nairobi] = "city_nairobi", + [city_tokyo] = "city_tokyo", + [city_baghdad] = "city_baghdad", + [city_tehran] = "city_tehran", + [city_jakarta] = "city_jakarta", + [city_guatemala_city] = "city_guatemala_city", + [city_berlin] = "city_berlin", + [city_addis_ababa] = "city_addis_ababa", + [city_cairo] = "city_cairo", + [city_quito] = "city_quito", + [city_bogota] = "city_bogota", + [city_beijing] = "city_beijing", + [city_accra] = "city_accra", + [city_ottawa] = "city_ottawa", + [city_brasilia] = "city_brasilia", + [city_la_paz] = "city_la_paz", + [city_dhaka] = "city_dhaka", + [city_yerevan] = "city_yerevan", + [city_chicago] = "city_chicago", + [city_kyiv] = "city_kyiv", + [city_dubai] = "city_dubai", + [city_mumbai] = "city_mumbai", + [city_madrid] = "city_madrid", + [city_black_rock] = "city_black_rock", + [city_secondary_lagos] = "city_secondary_lagos", + [city_secondary_kinshasa] = "city_secondary_kinshasa", + [city_secondary_luanda] = "city_secondary_luanda", + [city_secondary_dar_es_salaam] = "city_secondary_dar_es_salaam", + [city_secondary_khartoum] = "city_secondary_khartoum", + [city_secondary_giza] = "city_secondary_giza", + [city_secondary_abidjan] = "city_secondary_abidjan", + [city_secondary_johannesburg] = "city_secondary_johannesburg", + [city_secondary_casablanca] = "city_secondary_casablanca", + [city_secondary_algiers] = "city_secondary_algiers", + [city_secondary_antananarivo] = "city_secondary_antananarivo", + [city_secondary_ouagadougou] = "city_secondary_ouagadougou", + [city_secondary_yaounde] = "city_secondary_yaounde", + [city_secondary_mogadishu] = "city_secondary_mogadishu", + [city_secondary_kumasi] = "city_secondary_kumasi", + [city_secondary_bamako] = "city_secondary_bamako", + [city_secondary_blantyre] = "city_secondary_blantyre", + [city_secondary_meru] = "city_secondary_meru", + [city_secondary_brazzaville] = "city_secondary_brazzaville", + [city_secondary_lusaka] = "city_secondary_lusaka", + [city_secondary_conakry] = "city_secondary_conakry", + [city_secondary_kampala] = "city_secondary_kampala", + [city_secondary_maputo] = "city_secondary_maputo", + [city_secondary_pikine] = "city_secondary_pikine", + [city_secondary_kigali] = "city_secondary_kigali", + [city_secondary_tripoli] = "city_secondary_tripoli", + [city_secondary_ndjamena] = "city_secondary_ndjamena", + [city_secondary_nouakchott] = "city_secondary_nouakchott", + [city_secondary_niamey] = "city_secondary_niamey", + [city_secondary_monrovia] = "city_secondary_monrovia", + [city_secondary_asmara] = "city_secondary_asmara", + [city_secondary_freetown] = "city_secondary_freetown", + [city_secondary_bangui] = "city_secondary_bangui", + [city_secondary_lome] = "city_secondary_lome", + [city_secondary_libreville] = "city_secondary_libreville", + [city_secondary_cotonou] = "city_secondary_cotonou", + [city_secondary_bujumbura] = "city_secondary_bujumbura", + [city_secondary_djibouti] = "city_secondary_djibouti", + [city_secondary_bissau] = "city_secondary_bissau", + [city_secondary_juba] = "city_secondary_juba", + [city_secondary_maseru] = "city_secondary_maseru", + [city_secondary_windhoek] = "city_secondary_windhoek", + [city_secondary_gaborone] = "city_secondary_gaborone", + [city_secondary_saint_denis] = "city_secondary_saint_denis", + [city_secondary_malabo] = "city_secondary_malabo", + [city_secondary_port_louis] = "city_secondary_port_louis", + [city_secondary_praia] = "city_secondary_praia", + [city_secondary_moroni] = "city_secondary_moroni", + [city_secondary_mbabane] = "city_secondary_mbabane", + [city_secondary_sao_tome] = "city_secondary_sao_tome", + [city_secondary_banjul] = "city_secondary_banjul", + [city_secondary_mamoudzou] = "city_secondary_mamoudzou", + [city_secondary_victoria] = "city_secondary_victoria", + [city_secondary_jamestown] = "city_secondary_jamestown", + [city_secondary_bulawayo] = "city_secondary_bulawayo", + [city_secondary_sidi_bouzid] = "city_secondary_sidi_bouzid", + [city_secondary_nazret] = "city_secondary_nazret", + [city_secondary_delhi] = "city_secondary_delhi", + [city_secondary_manila] = "city_secondary_manila", + [city_secondary_shanghai] = "city_secondary_shanghai", + [city_secondary_osaka] = "city_secondary_osaka", + [city_secondary_istanbul] = "city_secondary_istanbul", + [city_secondary_karachi] = "city_secondary_karachi", + [city_secondary_ho_chi_minh_city] = "city_secondary_ho_chi_minh_city", + [city_secondary_kuala_lumpur] = "city_secondary_kuala_lumpur", + [city_secondary_hong_kong] = "city_secondary_hong_kong", + [city_secondary_riyadh] = "city_secondary_riyadh", + [city_secondary_rangoon] = "city_secondary_rangoon", + [city_secondary_singapore] = "city_secondary_singapore", + [city_secondary_kabul] = "city_secondary_kabul", + [city_secondary_amman] = "city_secondary_amman", + [city_secondary_busan] = "city_secondary_busan", + [city_secondary_mashhad] = "city_secondary_mashhad", + [city_secondary_kuwait_city] = "city_secondary_kuwait_city", + [city_secondary_sanaa] = "city_secondary_sanaa", + [city_secondary_bandung] = "city_secondary_bandung", + [city_secondary_pyongyang] = "city_secondary_pyongyang", + [city_secondary_chattogram] = "city_secondary_chattogram", + [city_secondary_tashkent] = "city_secondary_tashkent", + [city_secondary_baku] = "city_secondary_baku", + [city_secondary_phnom_penh] = "city_secondary_phnom_penh", + [city_secondary_aleppo] = "city_secondary_aleppo", + [city_secondary_almaty] = "city_secondary_almaty", + [city_secondary_mosul] = "city_secondary_mosul", + [city_secondary_abu_dhabi] = "city_secondary_abu_dhabi", + [city_secondary_muscat] = "city_secondary_muscat", + [city_secondary_doha] = "city_secondary_doha", + [city_secondary_tbilisi] = "city_secondary_tbilisi", + [city_secondary_bishkek] = "city_secondary_bishkek", + [city_secondary_kathmandu] = "city_secondary_kathmandu", + [city_secondary_vientiane] = "city_secondary_vientiane", + [city_secondary_jerusalem] = "city_secondary_jerusalem", + [city_secondary_dushanbe] = "city_secondary_dushanbe", + [city_secondary_colombo] = "city_secondary_colombo", + [city_secondary_beirut] = "city_secondary_beirut", + [city_secondary_nicosia] = "city_secondary_nicosia", + [city_secondary_dili] = "city_secondary_dili", + [city_secondary_male] = "city_secondary_male", + [city_secondary_manama] = "city_secondary_manama", + [city_secondary_thimphu] = "city_secondary_thimphu", + [city_secondary_bandar_seri_begawan] = "city_secondary_bandar_seri_begawan", + [city_secondary_ashgabat] = "city_secondary_ashgabat", + [city_secondary_macau] = "city_secondary_macau", + [city_secondary_nonthaburi] = "city_secondary_nonthaburi", + [city_secondary_moron] = "city_secondary_moron", + [city_secondary_gyumri] = "city_secondary_gyumri", + [city_secondary_london] = "city_secondary_london", + [city_secondary_saint_petersburg] = "city_secondary_saint_petersburg", + [city_secondary_barcelona] = "city_secondary_barcelona", + [city_secondary_rome] = "city_secondary_rome", + [city_secondary_minsk] = "city_secondary_minsk", + [city_secondary_vienna] = "city_secondary_vienna", + [city_secondary_hamburg] = "city_secondary_hamburg", + [city_secondary_warsaw] = "city_secondary_warsaw", + [city_secondary_brussels] = "city_secondary_brussels", + [city_secondary_budapest] = "city_secondary_budapest", + [city_secondary_kharkiv] = "city_secondary_kharkiv", + [city_secondary_prague] = "city_secondary_prague", + [city_secondary_sofia] = "city_secondary_sofia", + [city_secondary_copenhagen] = "city_secondary_copenhagen", + [city_secondary_stockholm] = "city_secondary_stockholm", + [city_secondary_zagreb] = "city_secondary_zagreb", + [city_secondary_oslo] = "city_secondary_oslo", + [city_secondary_athens] = "city_secondary_athens", + [city_secondary_helsinki] = "city_secondary_helsinki", + [city_secondary_skopje] = "city_secondary_skopje", + [city_secondary_chisinau] = "city_secondary_chisinau", + [city_secondary_riga] = "city_secondary_riga", + [city_secondary_vilnius] = "city_secondary_vilnius", + [city_secondary_dublin] = "city_secondary_dublin", + [city_secondary_the_hague] = "city_secondary_the_hague", + [city_secondary_lisbon] = "city_secondary_lisbon", + [city_secondary_bratislava] = "city_secondary_bratislava", + [city_secondary_tallinn] = "city_secondary_tallinn", + [city_secondary_tirana] = "city_secondary_tirana", + [city_secondary_ljubljana] = "city_secondary_ljubljana", + [city_secondary_sarajevo] = "city_secondary_sarajevo", + [city_secondary_gibraltar] = "city_secondary_gibraltar", + [city_secondary_podgorica] = "city_secondary_podgorica", + [city_secondary_bern] = "city_secondary_bern", + [city_secondary_luxembourg] = "city_secondary_luxembourg", + [city_secondary_reykjavik] = "city_secondary_reykjavik", + [city_secondary_monaco] = "city_secondary_monaco", + [city_secondary_saint_helier] = "city_secondary_saint_helier", + [city_secondary_douglas] = "city_secondary_douglas", + [city_secondary_andorra_la_vella] = "city_secondary_andorra_la_vella", + [city_secondary_torshavn] = "city_secondary_torshavn", + [city_secondary_valletta] = "city_secondary_valletta", + [city_secondary_vaduz] = "city_secondary_vaduz", + [city_secondary_san_marino] = "city_secondary_san_marino", + [city_secondary_vatican_city] = "city_secondary_vatican_city", + [city_secondary_marseille] = "city_secondary_marseille", + [city_secondary_novi_sad] = "city_secondary_novi_sad", + [city_secondary_cluj_napoca] = "city_secondary_cluj_napoca", + [city_secondary_new_york] = "city_secondary_new_york", + [city_secondary_guadalajara] = "city_secondary_guadalajara", + [city_secondary_toronto] = "city_secondary_toronto", + [city_secondary_santo_domingo] = "city_secondary_santo_domingo", + [city_secondary_havana] = "city_secondary_havana", + [city_secondary_comayaguela] = "city_secondary_comayaguela", + [city_secondary_port_au_prince] = "city_secondary_port_au_prince", + [city_secondary_panama_city] = "city_secondary_panama_city", + [city_secondary_kingston] = "city_secondary_kingston", + [city_secondary_san_salvador] = "city_secondary_san_salvador", + [city_secondary_san_jose] = "city_secondary_san_jose", + [city_secondary_nassau] = "city_secondary_nassau", + [city_secondary_fort_de_france] = "city_secondary_fort_de_france", + [city_secondary_willemstad] = "city_secondary_willemstad", + [city_secondary_bridgetown] = "city_secondary_bridgetown", + [city_secondary_castries] = "city_secondary_castries", + [city_secondary_hamilton] = "city_secondary_hamilton", + [city_secondary_port_of_spain] = "city_secondary_port_of_spain", + [city_secondary_oranjestad] = "city_secondary_oranjestad", + [city_secondary_george_town] = "city_secondary_george_town", + [city_secondary_kingstown] = "city_secondary_kingstown", + [city_secondary_saint_johns] = "city_secondary_saint_johns", + [city_secondary_nuuk] = "city_secondary_nuuk", + [city_secondary_belmopan] = "city_secondary_belmopan", + [city_secondary_roseau] = "city_secondary_roseau", + [city_secondary_basseterre] = "city_secondary_basseterre", + [city_secondary_grand_turk] = "city_secondary_grand_turk", + [city_secondary_saint_georges] = "city_secondary_saint_georges", + [city_secondary_basse_terre] = "city_secondary_basse_terre", + [city_secondary_brades] = "city_secondary_brades", + [city_secondary_villa_nueva] = "city_secondary_villa_nueva", + [city_secondary_san_juan] = "city_secondary_san_juan", + [city_secondary_boaco] = "city_secondary_boaco", + [city_secondary_sydney] = "city_secondary_sydney", + [city_secondary_auckland] = "city_secondary_auckland", + [city_secondary_port_moresby] = "city_secondary_port_moresby", + [city_secondary_papeete] = "city_secondary_papeete", + [city_secondary_noumea] = "city_secondary_noumea", + [city_secondary_honiara] = "city_secondary_honiara", + [city_secondary_suva] = "city_secondary_suva", + [city_secondary_port_vila] = "city_secondary_port_vila", + [city_secondary_apia] = "city_secondary_apia", + [city_secondary_tarawa] = "city_secondary_tarawa", + [city_secondary_majuro] = "city_secondary_majuro", + [city_secondary_nukualofa] = "city_secondary_nukualofa", + [city_secondary_pago_pago] = "city_secondary_pago_pago", + [city_secondary_palikir] = "city_secondary_palikir", + [city_secondary_funafuti] = "city_secondary_funafuti", + [city_secondary_avarua] = "city_secondary_avarua", + [city_secondary_capitol_hill] = "city_secondary_capitol_hill", + [city_secondary_alofi] = "city_secondary_alofi", + [city_secondary_hagta] = "city_secondary_hagta", + [city_secondary_ngerulmud] = "city_secondary_ngerulmud", + [city_secondary_sao_paulo] = "city_secondary_sao_paulo", + [city_secondary_buenos_aires] = "city_secondary_buenos_aires", + [city_secondary_santiago] = "city_secondary_santiago", + [city_secondary_timbio] = "city_secondary_timbio", + [city_secondary_santa_cruz] = "city_secondary_santa_cruz", + [city_secondary_guayaquil] = "city_secondary_guayaquil", + [city_secondary_caracas] = "city_secondary_caracas", + [city_secondary_montevideo] = "city_secondary_montevideo", + [city_secondary_callao] = "city_secondary_callao", + [city_secondary_asuncion] = "city_secondary_asuncion", + [city_secondary_paramaribo] = "city_secondary_paramaribo", + [city_secondary_georgetown] = "city_secondary_georgetown", + [city_secondary_cayenne] = "city_secondary_cayenne", + [city_secondary_stanley] = "city_secondary_stanley", + [city_secondary_grytviken] = "city_secondary_grytviken", +}; + diff --git a/src_v2/user_space/incenter_interface_connection.c b/src_v2/user_space/incenter_interface_connection.c new file mode 100644 index 0000000..c72d088 --- /dev/null +++ b/src_v2/user_space/incenter_interface_connection.c @@ -0,0 +1,241 @@ +internal void incenter_handle_interface_msg(Incenter_State* ins, Data msg); + +void +incenter_interface_connection_cleanup(Incenter_State* ins) +{ + if (ins->interface_socket.value == 0) return; + + if (!os_socket_close(ins->interface_socket)) { + printf("Error closing interface connection socket\n"); + } + ins->interface_socket = (Socket_Handle){0}; + printf("Incenter Interface Socket Connection Closed.\n"); +} + +Thread_Result +incenter_interface_connection_thread_proc(u8* user_data) +{ + Incenter_State* ins = (Incenter_State*)user_data; + + // Open Socket Connection To Server + ins->interface_socket = os_socket_create( + AF_INET, // IPv4 + SOCK_DGRAM, + 0 + ); + + // Bind the socket to the correct address + if (!os_socket_bind(ins->interface_socket, 1337)) { + printf("ERROR: Unable to bind incenter interface socket\n"); + return (Thread_Result){ 0 }; + } + + // Message Recv Loop + while (ins->running) + { + u32 next_msg_i = ins->interface_messages_write_next; + Data* next_msg = ins->interface_messages + next_msg_i; + next_msg->size = INTERFACE_MESSAGE_SIZE; // reset buffer of known size + + Socket_Error err = SocketError_NOERROR; + *next_msg = os_socket_recvfrom(ins->interface_socket, next_msg->base, next_msg->size, &err); + if (err == SocketError_EBADF && ins->running) { + if (!os_socket_close(ins->interface_socket)) { + printf("Trying to close interface socket before reopening. Socket was already closed.\n"); + } + ins->interface_socket = os_socket_create(AF_INET, SOCK_DGRAM, 0); + } + + if (err == SocketError_EINTR) { + printf("Recvfrom returned EINTR, trying again\n"); + continue; // retry the same operation, as it was interrupted + } + + if (err == SocketError_NOERROR) { + next_msg->base[next_msg->size] = 0; + // write_next isn't incremented until here because the message + // is not ready to be read until this point + ins->interface_messages_write_next = (ins->interface_messages_write_next + 1) % INTERFACE_MESSAGES_CAP; + } else { + char* errstr = (char*)"Invalid"; + if (err > SocketError_Invalid && err < SocketError_Count) { + errstr = socket_error_strings[err]; + } + // TODO: if you hit an EFAULT, go check how big the buffer + // recvfrom was trying to write into + printf("Socket Error: %s - code: %d\n", errstr, (s32)err); + } + } + + // Close Down once Incenter indicates it's time to stop running + incenter_interface_connection_cleanup(ins); + + return (Thread_Result){ 0 }; +} + +internal void +incenter_interface_connection_init(App_State* state, Incenter_State* ins) +{ + // Start Thread to handle blocking socket calls + ins->interface_thread = os_thread_begin(incenter_interface_connection_thread_proc, (u8*)ins); + + for (u32 msg_i = 0; msg_i < INTERFACE_MESSAGES_CAP; msg_i++) + { + ins->interface_messages[msg_i] = (Data){ + .base = allocator_alloc(permanent, INTERFACE_MESSAGE_SIZE), + .size = INTERFACE_MESSAGE_SIZE, + }; + } +} + +internal void +incenter_interface_connection_frame(App_State* state, Incenter_State* ins) +{ + while (ins->interface_messages_write_next != ins->interface_messages_read_next) + { + u32 read_next = ins->interface_messages_read_next; + ins->interface_messages_read_next = (read_next + 1) % INTERFACE_MESSAGES_CAP; + + Data msg_read = ins->interface_messages[read_next]; + printf("Handling message on the main thread\n"); + printf(" %s\n", (char*)msg_read.base); + + incenter_handle_interface_msg(ins, msg_read); + } +} + +#define INCENTER_CMP3(base, str) ((base[0] == str[0]) && (base[1] == str[1]) && (base[2] == str[2])) + +internal void +incenter_handle_sliding_scale_msg(Incenter_State* ins, Incenter_Scene scene, char msg) +{ + assert(scene.kind == Incenter_SceneKind_SlidingScale); + if (msg != 'M' && msg != 'L' && msg != 'C') { + printf("Invalid input sent to sliding scale scene: %c\n", msg); + printf(" Scene: %s\n", scene.name); + return; + } + + switch (msg) { + case 'M': { + ins->input_pct += 0.1f; + } break; + + case 'L': { + ins->input_pct -= 0.1f; + } break; + + case 'C': { + live_answers_input_r32(ins, scene, ins->input_pct); + } break; + } + + ins->scene_mode = Incenter_SceneMode_Passive; + ins->scene_time = 0; + + ins->input_pct = clamp(0, ins->input_pct, 1); +} + +internal void +incenter_handle_yes_no_msg(Incenter_State* ins, Incenter_Scene scene, char msg) +{ + assert(scene.kind == Incenter_SceneKind_YesOrNo); + if (msg != 'Y' && msg != 'N') { + printf("Invalid input sent to yes no scene: %c\n", msg); + printf(" Scene: %s\n", scene.name); + return; + } + + switch (msg) { + case 'Y': { + ins->input_option = 1; + } break; + + case 'N': { + ins->input_option = 0; + } break; + } + + live_answers_input_u32(ins, scene, ins->input_option); + ins->scene_mode = Incenter_SceneMode_Passive; + ins->scene_time = 0; +} + +internal void +incenter_handle_three_option_msg(Incenter_State* ins, Incenter_Scene scene, char msg) +{ + assert(scene.kind == Incenter_SceneKind_ThreeOption); + if (msg != '1' && msg != '2' && msg != '3') { + printf("Invalid input sent to 3 option scene: %c\n", msg); + printf(" Scene: %s\n", scene.name); + return; + } + + ins->input_option = (msg - '0') - 1; + + live_answers_input_u32(ins, scene, ins->input_option); + ins->scene_mode = Incenter_SceneMode_Passive; + ins->scene_time = 0; +} + +internal void +incenter_handle_interface_msg(Incenter_State* ins, Data msg) +{ + u32 msg_kind = Incenter_InterfaceMessage_Invalid; + u32 scene_id = 0; + if (INCENTER_CMP3(msg.base, "UIN")) { + msg_kind = Incenter_InterfaceMessage_UserInput; + } else if (INCENTER_CMP3(msg.base, "GTS")){ + msg_kind = Incenter_InterfaceMessage_GoToScene; + + char* scene_id_start = (char*)(msg.base + 3); + scene_id = scene_id_start[0] - '0'; + if (scene_id_start[1] != 0) { + scene_id *= 10; + scene_id += scene_id_start[1] - '0'; + } + } + + switch (msg_kind) + { + case Incenter_InterfaceMessage_GoToScene: + { + if (scene_id > Incenter_Scene_Invalid && + scene_id < Incenter_Scene_Count) + { + if (scene_id != ins->scene_at) { + incenter_scene_go_to(ins, scene_id); + } + } + else + { + printf("Unknown Scene ID Requested: %d\n", scene_id); + } + } break; + + case Incenter_InterfaceMessage_UserInput: + { + Incenter_Scene scene = ins->scenes[ins->scene_at]; + char input_kind = msg.base[3]; + switch (scene.kind) { + case Incenter_SceneKind_SlidingScale: { + incenter_handle_sliding_scale_msg(ins, scene, input_kind); + } break; + + case Incenter_SceneKind_YesOrNo: { + incenter_handle_yes_no_msg(ins, scene, input_kind); + } break; + + case Incenter_SceneKind_ThreeOption: { + incenter_handle_three_option_msg(ins, scene, input_kind); + } break; + } + } break; + + default: + { + printf("Unknown message kind: %d\n", msg_kind); + // TODO: Print the actual message received + } break; + } +} \ No newline at end of file diff --git a/src_v2/user_space/incenter_interface_connection.h b/src_v2/user_space/incenter_interface_connection.h new file mode 100644 index 0000000..6b445dd --- /dev/null +++ b/src_v2/user_space/incenter_interface_connection.h @@ -0,0 +1,13 @@ +/* date = August 11th 2022 5:38 pm */ + +#ifndef INCENTER_INTERFACE_CONNECTION_H +#define INCENTER_INTERFACE_CONNECTION_H + +enum { + Incenter_InterfaceMessage_Invalid = 0, + Incenter_InterfaceMessage_GoToScene = 1, + Incenter_InterfaceMessage_UserInput = 2, +}; + + +#endif //INCENTER_INTERFACE_CONNECTION_H diff --git a/src_v2/user_space/incenter_live_answers.c b/src_v2/user_space/incenter_live_answers.c new file mode 100644 index 0000000..1e05ab4 --- /dev/null +++ b/src_v2/user_space/incenter_live_answers.c @@ -0,0 +1,271 @@ + +internal void +live_answers_set_magic(char dst[4], char value[4]) +{ + dst[0] = value[0]; + dst[1] = value[1]; + dst[2] = value[2]; + dst[3] = value[3]; +} + +internal bool +live_answers_valid_magic(char dst[4], char value[4]) +{ + return ((dst[0] == value[0]) && + (dst[1] == value[1]) && + (dst[2] == value[2]) && + (dst[3] == value[3])); +} + +internal void +live_answers_init_bucket_u32(Live_Answers_File_Bucket* bucket, u32 answer, u32 count) +{ + live_answers_set_magic((char*)bucket->magic, LIVE_DATA_BUCKET_MAGIC_NUMBER); + bucket->answer_u32 = answer; + bucket->count = count; +} + +internal void +live_answers_init_bucket_r32(Live_Answers_File_Bucket* bucket, r32 answer, u32 count) +{ + live_answers_set_magic((char*)bucket->magic, LIVE_DATA_BUCKET_MAGIC_NUMBER); + bucket->answer_r32 = answer; + bucket->count = count; +} + +internal bool +live_answers_validate(Live_Answers_File file) +{ + bool valid = true; + if (!live_answers_valid_magic((char*)file.header->magic, LIVE_DATA_HEADER_MAGIC_NUMBER)) { + printf("Error: Live Answers File has corrupted header.\n"); + valid = false; + } + + // if there was an error in the header, we can't assume that the count + // its keeping of the number of buckets is correct + if (valid) + { + for (u32 i = 0; i < file.header->buckets_count; i++) + { + Live_Answers_File_Bucket* b = file.buckets + i; + if (!live_answers_valid_magic((char*)b->magic, LIVE_DATA_BUCKET_MAGIC_NUMBER)) + { + printf("Error: Live Answers Bucket has corrupted header.\n"); + valid = false; + } + } + } + + if (!valid) + { + printf(" Invalid Live Answers File: %.*s\n", str_varg(file.path)); + } + + return valid; +} + +internal Live_Answers_File +live_answers_load(Incenter_Scene scene, Allocator* allocator) +{ + Live_Answers_File result = {0}; + + // Read the File +#define USING_PLATFORM_LAYER 0 +#if !USING_PLATFORM_LAYER + result.path = string_f(allocator, "data/live_data/%s.incenterdata", scene.name); + Data file_data = {0}; + FILE* file = fopen((const char*)result.path.str, "rb"); + if (file) { + fseek(file, 0, SEEK_END); + s32 size = ftell(file); + fseek(file, 0, SEEK_SET); + file_data.base = allocator_alloc(allocator, size); + file_data.size = fread((void*)file_data.base, size, 1, file); + fclose(file); + } else { + printf("Creating live data file: %s\n", (char*)result.path.str); + } +#else + File_Handle file = os_file_open(result.path, FileAccess_Read, FileCreate_OpenExisting); + Data file_data = {0}; + if (file.value != 0) + { + file_data = os_file_read_all(file, allocator); + os_file_close(file); + } +#endif + + // Obtain structure of file data + if (file_data.size > 1) { + result.header = (Live_Answers_File_Header*)file_data.base; + result.buckets = (Live_Answers_File_Bucket*)(result.header + 1); + } else { + // create the file's initial contents + file_data.size = sizeof(Live_Answers_File_Header); + file_data.base = allocator_alloc(allocator, file_data.size); + + // obtain structure + result.header = (Live_Answers_File_Header*)file_data.base; + result.buckets = (Live_Answers_File_Bucket*)(result.header + 1); + + // initialize + live_answers_set_magic((char*)result.header->magic, LIVE_DATA_HEADER_MAGIC_NUMBER); + result.header->buckets_count = 0; + result.header->answers_total_count = 0; + } + + if (!live_answers_validate(result)) { + return (Live_Answers_File){0}; + } + + return result; +} + +internal void +live_answers_save(Live_Answers_File file, Live_Answers_File_Bucket* new_bucket) +{ + if (!live_answers_validate(file)) { + printf(" Not saving invalid live answers data\n"); + return; + } + +#if !USING_PLATFORM_LAYER + FILE* fh = fopen((const char*)file.path.str, "wb"); + if (!fh) { + printf("Error: Unable to open live data file for writing\n"); + printf(" Live Data File: %.*s\n", str_varg(file.path)); + return; + } +#else + File_Handle fh = os_file_open(file.path, FileAccess_Write, FileCreate_OpenAlways); + if (fh.value == 0) { + printf("Error: Unable to open live data file for writing\n"); + printf(" Live Data File: %.*s\n", str_varg(file.path)); + + // TODO(PS): maybe print out what the values should be so we can + // recover if necessary? + + return; + } +#endif + + Data existing_data = { + .base = (u8*)file.header, + .size = sizeof(Live_Answers_File_Header) + (sizeof(Live_Answers_File_Bucket) * file.header->buckets_count) + }; +#if !USING_PLATFORM_LAYER + s32 size_written = fwrite((void*)existing_data.base, 1, existing_data.size, fh); + if (size_written != existing_data.size) { + printf("Unable to write full file: %.*s\n", str_varg(file.path)); + printf(" Size Needed: %lu, Size Written: %d\n", existing_data.size, size_written); + } +#else + if (!os_file_write(fh, existing_data)) { + printf("Error: Could not write existing data to Live Data File\n"); + printf(" Live Data File: %.*s\n", str_varg(file.path)); + } +#endif + + if (new_bucket) { + Data new_data = { + .base = (u8*)new_bucket, + .size = sizeof(Live_Answers_File_Bucket) + }; +#if !USING_PLATFORM_LAYER + size_written = fwrite(new_data.base, 1, new_data.size, fh); + if (size_written != new_data.size) { + printf("Unable to add new data to file %.*s\n", str_varg(file.path)); + printf(" Size Needed: %lu, Size Written: %d\n", new_data.size, size_written); + } +#else + if (!os_file_write(fh, new_data)) { + printf("Error: Could not write new bucket data to Live Data File\n"); + printf(" Live Data File: %.*s\n", str_varg(file.path)); + } +#endif + } + +#if !USING_PLATFORM_LAYER + fclose(fh); +#else + os_file_close(fh); +#endif +} + +#if 1 +# define MAYBE_SKIP_SAVING_INPUT +#else +# define MAYBE_SKIP_SAVING_INPUT return +#endif + +internal void +live_answers_input_u32(Incenter_State* ins, Incenter_Scene scene, u32 value) +{ + MAYBE_SKIP_SAVING_INPUT; + + scratch_get(scratch); + Live_Answers_File file = live_answers_load(scene, scratch.a); + if (file.header == 0) { + printf("Unable to save live data file\n"); + return; + } + + bool found = false; + for (u32 i = 0; i < file.header->buckets_count; i++) + { + Live_Answers_File_Bucket* b = file.buckets + i; + if (b->answer_u32 == value) { + b->count += 1; + found = true; + break; + } + } + + Live_Answers_File_Bucket* new_bucket = 0; + if (!found) { + new_bucket = allocator_alloc_struct(scratch.a, Live_Answers_File_Bucket); + live_answers_init_bucket_u32(new_bucket, value, 1); + file.header->buckets_count += 1; + } + + file.header->answers_total_count += 1; + + live_answers_save(file, new_bucket); + + 4scratch_release(scratch); +} + +internal void +live_answers_input_r32(Incenter_State* ins, Incenter_Scene scene, r32 value) +{ + MAYBE_SKIP_SAVING_INPUT; + + scratch_get(scratch); + Live_Answers_File file = live_answers_load(scene, scratch.a); + if (file.header == 0) { + printf("Unable to save live data file\n"); + return; + } + + bool found = false; + for (u32 i = 0; i < file.header->buckets_count; i++) + { + Live_Answers_File_Bucket* b = file.buckets + i; + if (b->answer_r32 == value) { + b->count += 1; + found = true; + break; + } + } + + Live_Answers_File_Bucket* new_bucket = 0; + if (!found) { + new_bucket = allocator_alloc_struct(scratch.a, Live_Answers_File_Bucket); + live_answers_init_bucket_r32(new_bucket, value, 1); + } + + live_answers_save(file, new_bucket); + + scratch_release(scratch); +} \ No newline at end of file diff --git a/src_v2/user_space/incenter_patterns.c b/src_v2/user_space/incenter_patterns.c new file mode 100644 index 0000000..8fe9aff --- /dev/null +++ b/src_v2/user_space/incenter_patterns.c @@ -0,0 +1,1451 @@ +r32 +curve_ease_in_out(r32 t) +{ + r32 tc = clamp(0, t, 1); + r32 theta = (tc * r32_pi) - (r32_pi / 2.0f); + r32 s = sinf(theta); + r32 result = 0.5f + (s / 2.0f); + return result; +} + +#define incenter_pos_to_unit(p) (v4){ ((p.x / 6.0f) + 0.5f), ((p.y / 6.0f) + 0.5f), ((p.z / 6.0f) + 0.5f), 1.0f } +#define incenter_pos_to_bimodal(p) (v4){ (p.x / 3.0f), (p.y / 3.0f), (p.z / 3.0f), 1.0f } + +void +test_pattern(Assembly_Pixel_Buffer pixels) +{ + for (u32 j = 0; j < pixels.len; j++) + { + v4 p = pixels.positions[j]; + pixels.pixels[j].r = (u8)(((sinf((5 * tt) + (p.x * 10)) + 1) * 0.5f) * 255); + pixels.pixels[j].b = (u8)(((sinf((5 * tt) + (p.z * 10)) + 1) * 0.5f) * 255); + } +} + +void +pattern_debug(Assembly_Pixel_Buffer pixels) +{ + r32 scale = 6; + r32 offset = 0; + + for (u32 j = 0; j < pixels.len; j++) + { + v4 p = pixels.positions[j]; + v4 pp = incenter_pos_to_unit(p); + pixels.pixels[j].r = pp.x * 255; + pixels.pixels[j].g = pp.y * 255; + pixels.pixels[j].b = pp.z * 255; + } +} + +Assembly_Pixel +color_v3_to_assembly_pixel(v3 c) +{ + return (Assembly_Pixel){ + .r = (u8)(c.x * 255), + .g = (u8)(c.y * 255), + .b = (u8)(c.z * 255), + }; +} + +Assembly_Pixel +color_v3_to_assembly_pixel_faded(v3 c, r32 b) +{ + return (Assembly_Pixel){ + .r = (u8)(c.x * b * 255), + .g = (u8)(c.y * b * 255), + .b = (u8)(c.z * b * 255), + }; +} + +u8 +u8_add_safe(u8 a, u8 b) +{ + u8 r = a + b; + if (r < a || r < b) r = 255; + return r; +} + +Assembly_Pixel +assembly_pixel_add(Assembly_Pixel a, Assembly_Pixel b) +{ + Assembly_Pixel result = { + .r = u8_add_safe(a.r, b.r), + .g = u8_add_safe(a.g, b.g), + .b = u8_add_safe(a.b, b.b), + }; + return result; +} + +Assembly_Pixel +assembly_pixel_add_multi(u32 count, ...) +{ + Assembly_Pixel result = {}; + va_list args; + va_start(args, count); + for (u32 i = 0; i < count; i++) { + Assembly_Pixel p = va_arg(args, Assembly_Pixel); + result.r = u8_add_safe(result.r, p.r); + result.g = u8_add_safe(result.g, p.g); + result.b = u8_add_safe(result.b, p.b); + } + return result; +} + +Assembly_Pixel +assembly_pixel_scale(Assembly_Pixel p, r32 scale) +{ + Assembly_Pixel result = { + .r = (u8)(clamp(0, p.r * scale, 255)), + .g = (u8)(clamp(0, p.g * scale, 255)), + .b = (u8)(clamp(0, p.b * scale, 255)), + }; + return result; +} + +Assembly_Pixel +assembly_pixel_scale_u8(u32 r, u32 g, u32 b, r32 scale) +{ + Assembly_Pixel result = { + .r = (u8)(clamp(0, r * scale, 255)), + .g = (u8)(clamp(0, g * scale, 255)), + .b = (u8)(clamp(0, b * scale, 255)), + }; + return result; +} + +Assembly_Pixel +assembly_pixel_blend(Assembly_Pixel a, Assembly_Pixel b, r32 t) +{ + r32 rf = lerp((r32)a.r, t, (r32)b.r); + r32 gf = lerp((r32)a.g, t, (r32)b.g); + r32 bf = lerp((r32)a.b, t, (r32)b.b); + r32 rc = clamp(0, rf, 255); + r32 gc = clamp(0, gf, 255); + Assembly_Pixel result = { + .r = (u8)rc, + .g = (u8)clamp(0, gf, 255), + .b = (u8)clamp(0, bf, 255), + }; + return result; +} + +Assembly_Pixel +color_ramp_eval_pixel(Color_Ramp ramp, r32 pct) +{ + v3 c = color_ramp_eval(ramp, pct); + Assembly_Pixel r = color_v3_to_assembly_pixel(c); + return r; +} + +v3 +sun_center_for_pos(v4 p, v4 center, r32 radius, r32 falloff) +{ + v4 p_unit = incenter_pos_to_unit(p); + r32 d0 = HMM_LengthVec4(HMM_SubtractVec4(p_unit, center)); + r32 d1 = falloff - fabsf(d0 - (radius + (0.02f * sinf(tt)))); + r32 b = d1 / falloff; + + v3 result = {}; + if (b > 0) + { + v3 p0 = p.xyz; + v3 p1 = HMM_AddVec3(p0, (v3){ tt, -tt, 0 }); + + v3 color = { + .x = remap_r32(pm_fmb_3d(p0, tt), 0, 1, 0.5, 1), + .y = remap_r32(pm_noise_v3_to_r32(p1), 0, 1, 0, 0.3f), + .z = 0, + }; + result = HMM_MultiplyVec3f(color, b); + } + return result; +} + +void +sun_center(Assembly_Pixel_Buffer pixels, v4 center, r32 radius, r32 falloff) +{ + for (u32 j = 0; j < pixels.len; j++) + { + v3 color = sun_center_for_pos(pixels.positions[j], center, radius, falloff); + Assembly_Pixel ac = color_v3_to_assembly_pixel(color); + pixels.pixels[j] = assembly_pixel_add(ac, pixels.pixels[j]); + +#if 0 + r32 d0 = HMM_LengthVec4(HMM_SubtractVec4(p, center)); + r32 d1 = falloff - fabsf(d0 - (radius + (0.02f * sinf(tt)))); + r32 b = d1 / falloff; + + if (b > 0) + { + v3 p0 = pixels.positions[j].xyz; + v3 p1 = HMM_AddVec3(p0, (v3){ tt, -tt, 0 }); + + v3 color = { + .x = remap_r32(pm_fmb_3d(p0, tt), 0, 1, 0.5, 1), + .y = remap_r32(pm_noise_v3_to_r32(p1), 0, 1, 0, 0.3f), + .z = 0, + }; + Assembly_Pixel cc = color_v3_to_assembly_pixel(color); + v3 color_b = HMM_MultiplyVec3f(color, b); + Assembly_Pixel color_0 = color_v3_to_assembly_pixel(color_b); + Assembly_Pixel color_1 = assembly_pixel_add(color_0, pixels.pixels[j]); + pixels.pixels[j] = color_1; + } +#endif + } +} + +void +grow_pattern_sphere_function(Assembly_Pixel_Buffer pixels, v4 center, r32 radius, r32 falloff, Assembly_Pixel inner_color) +{ + for (u32 j = 0; j < pixels.len; j++) + { + v4 p = incenter_pos_to_unit(pixels.positions[j]); + r32 d0 = HMM_LengthVec4(HMM_SubtractVec4(p, center)); + r32 d1 = fabsf(d0 - (radius + (0.02f * sinf(tt)))); + r32 d2 = falloff - d1; + r32 b = d2 / falloff; + r32 inner_b = d0 < (radius - falloff) ? 1 : 0; + + v3 color = { + .x = 0.5f + 0.5f * sinf(p.x * r32_tau * 4.313f + tt * 1.3f), + .y = 0.5f + 0.5f * cosf(0.2314f + p.y * r32_tau * 3.915f + tt), + .z = 0.2f + 0.8f * p.z, + }; + v3 color_b = HMM_MultiplyVec3f(color, b); + Assembly_Pixel color_0 = color_v3_to_assembly_pixel(color_b); + Assembly_Pixel color_inner = assembly_pixel_scale(inner_color, inner_b); + Assembly_Pixel color_1 = assembly_pixel_add_multi(3, color_0, color_inner, pixels.pixels[j]); + + pixels.pixels[j] = color_1; + } +} + +void +grow_pattern(Assembly_Pixel_Buffer pixels, r32 time, Assembly_Pixel inner_color) +{ + v4 center = (v4){}; + r32 radius = 0; + r32 falloff = 0; + //phase 1 - light up to center + if (time < 6) + { + r32 height = -0.2f + curve_ease_in_out(time / 4) * 0.5f; + center = (v4){ 0.5f, 0.2f + height, 0.5f, 1 }; + radius = lerp(0.01f, (time / 6), 0.05f); + falloff = 0.1f; + } + else if (time >= 6) + { + r32 t = (time - 6) / 4; + center = (v4){ 0.5f, 0.5f, 0.5f, 1 }; + radius = 0.05f + curve_ease_in_out(t) * 0.6f; + falloff = 0.1f - (curve_ease_in_out(t) * 0.05f); + } + + grow_pattern_sphere_function(pixels, center, radius, falloff, inner_color); +} + +void +pattern_color(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, u8 r, u8 g, u8 b) +{ + for (u32 j = 0; j < pixels.len; j++) + { + pixels.pixels[j].r = r; + pixels.pixels[j].g = g; + pixels.pixels[j].b = b; + } +} + +void +pattern_blink(Assembly_Pixel_Buffer pixels) +{ + r32 t0 = clamp(0, tt, 1.5f) / 1.5f; + r32 t1 = pm_smoothstep_r32(t0); + r32 t2 = t1 * 0.43f; + v4 center = (v4){ + .x = 0.5f, + .y = t2, + .z = 0.5f, + .w = 1, + }; + r32 o = remap_r32(sinf(tt), -1, 1, 0.0015f, 0.002f); + for (u32 i = 0; i < pixels.len; i++) + { + v4 p = incenter_pos_to_unit(pixels.positions[i]); + v2 ho = (v2){ .x = fabsf(p.x - 0.5f), .y = fabsf(p.z - 0.5f) }; + r32 dh = HMM_LengthVec2(ho); + if (p.y < center.y && dh < 0.01f) + { + pixels.pixels[i].r = 0; + pixels.pixels[i].g = 128; + pixels.pixels[i].b = 255; + } + } + grow_pattern_sphere_function(pixels, center, o, 0.01f, (Assembly_Pixel){}); +} + +u32 year = 2019; +r32 month = (r32)MONTH_jan; + +#if 0 +s32 +test_data_find_nearest_row(Incenter_City_Id city, u32 year, Incenter_Month_Id month) +{ + s32 row_index = -1; + s32 nearest = 10000; + s32 months = (year * 12) + month; + for (s32 i = 0; i < test_data_len; i++) + { + Incenter_Test_Data_Row row = test_data[i]; + if (row.city != city) continue; + + s32 row_months = (row.year * 12) + row.month; + s32 months_offset = months - row_months; + if (months_offset < nearest && months_offset >= 0) { + nearest = months_offset; + row_index = i; + } + } + return row_index; +} + +global r32 city_last_values[city_count] = { -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, -0.2f, +}; +global r32 city_last_vel[city_count]; + +global Assembly_Pixel pixel_white = { 255, 255, 255 }; +global Assembly_Pixel pixel_black = { 0, 0, 0 }; + +void +pattern_test_data_scene_hombre(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Assembly_Pixel color_before_a, Assembly_Pixel color_before_b, Assembly_Pixel color_at, Assembly_Pixel color_after) +{ + Incenter_Test_Data_Row* rows = test_data; + + r32 rand_min = 1000; + r32 rand_max = -1000; + + r32 month_delta = 1.0f / 24.0f; + if (month >= 11) { + s32 x = 5; + } + for (u32 city = 0; city < city_count; city++) + { + Assembly_Strip strip = strips.strips[city + 1]; + s32 data_row = test_data_find_nearest_row(city, year, month); + if (data_row < 0) continue; + s32 data_row_next = data_row + 1; + + Incenter_Test_Data_Row row_curr = test_data[data_row]; + r32 target_p = test_data[data_row].value_0; + if (data_row_next < test_data_len) { + Incenter_Test_Data_Row row_next = test_data[data_row_next]; + if (row_next.city == row_curr.city) + { + r32 row_curr_months = (r32)((row_curr.year * 12) + row_curr.month); + r32 row_next_months = (r32)((row_next.year * 12) + row_next.month); + r32 curr_months = (r32)(year * 12) + month; + + r32 row_month_delta = row_next_months - row_curr_months; + r32 delta_from_row_curr = curr_months - row_curr_months; + r32 theta = delta_from_row_curr / row_month_delta; + + target_p = lerp(row_curr.value_0 * 0.8f, theta, row_next.value_0 * 0.8f); + } + } + + r32 last_value = city_last_values[city]; + r32 dist_to_target = (target_p - last_value); + r32 towards_target = dist_to_target > 0 ? 1 : -1; + dist_to_target = fabsf(dist_to_target); + r32 force_approach = dist_to_target * towards_target * 0.1f; + city_last_vel[city] += force_approach; + + r32 max_vel = 0.01f; + r32 force_damping = -max(1 - dist_to_target, 0) * (city_last_vel[city]); + city_last_vel[city] = clamp(-1 * max_vel, city_last_vel[city] + force_damping, max_vel); + + city_last_values[city] += city_last_vel[city]; + + for (u32 led = 0; led < strip.pixels_len; led++) + { + r32 pct = (r32)(strip.pixels_len - led) / (r32)strip.pixels_len; + u32 led_index = strip.pixels[led]; + v4 led_pos = incenter_pos_to_unit(pixels.positions[led_index]); + + // max(-|pct -pct_r|, 0) ^ 10 + r32 d0 = (-1 * fabsf(city_last_values[city] - pct)) + 1; + r32 d1 = max(0, d0); + r32 d2 = powf(d1, 20); + r32 d2_inverse = 1 - d2; + v3 noise_pos0 = HMM_MultiplyVec3f(HMM_AddVec3(led_pos.xyz, (v3){237, 111 + tt, 923}), 16); + r32 at_noise = pm_fmb_3d(noise_pos0, 1); + at_noise = pm_smoothstep_r32(at_noise); + r32 d3 = d2; + + v3 noise_pos1 = HMM_MultiplyVec3f(HMM_AddVec3(led_pos.xyz, (v3){237, 111 + (tt * 0.3f), 923}), 16); + r32 inner_noise = pm_smoothstep_r32(pm_fmb_3d(noise_pos1, 1)); + + r32 before = pct < city_last_values[city] ? d2_inverse : 0; + r32 after = pct > city_last_values[city] ? d2_inverse : 0; + + Assembly_Pixel color_before_ = assembly_pixel_scale( + assembly_pixel_blend(color_before_a, color_before_b, at_noise * at_noise * at_noise), + before + ); + Assembly_Pixel color_after_ = assembly_pixel_scale(color_after, after - (0.8f * inner_noise)); + Assembly_Pixel color_at_ = assembly_pixel_scale(color_at, d3); + + pixels.pixels[led_index] = assembly_pixel_add_multi(3, color_before_, color_after_, color_at_); + } + } + + month += month_delta; + if (month > (r32)MONTH_Dec + 1) { + month = (r32)MONTH_Jan; + year += 1; + if (year > 2022) { + year = 2019; + } + } +} + +void +pattern_test_data_scene(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips) +{ + Incenter_Test_Data_Row* rows = test_data; + + r32 month_delta = 1.0f / 24.0f; + if (month >= 11) { + s32 x = 5; + } + for (u32 city = 0; city < city_count; city++) + { + Assembly_Strip strip = strips.strips[city + 1]; + s32 data_row = test_data_find_nearest_row(city, year, month); + if (data_row < 0) continue; + s32 data_row_next = data_row + 1; + + Incenter_Test_Data_Row row_curr = test_data[data_row]; + r32 percent_r = test_data[data_row].value_0; + r32 percent_g = test_data[data_row].value_1; + r32 percent_b = test_data[data_row].value_2; + if (data_row_next < test_data_len) { + Incenter_Test_Data_Row row_next = test_data[data_row_next]; + if (row_next.city == row_curr.city) + { + r32 row_curr_months = (r32)((row_curr.year * 12) + row_curr.month); + r32 row_next_months = (r32)((row_next.year * 12) + row_next.month); + r32 curr_months = (r32)(year * 12) + month; + + r32 row_month_delta = row_next_months - row_curr_months; + r32 delta_from_row_curr = curr_months - row_curr_months; + r32 theta = delta_from_row_curr / row_month_delta; + + percent_r = lerp(row_curr.value_0, theta, row_next.value_0); + percent_g = lerp(row_curr.value_1, theta, row_next.value_1); + percent_b = lerp(row_curr.value_2, theta, row_next.value_2); + } + } + + // printf("%d %f - %f\n", year, month, percent_r); + + for (u32 led = 0; led < strip.pixels_len; led++) + { + r32 pct = (r32)(strip.pixels_len - led) / (r32)strip.pixels_len; + u32 led_index = strip.pixels[led]; + +#if 0 + pixels.pixels[led_index] = (Assembly_Pixel){ + .r = 32, + .g = 32, + .b = 32, + }; + + if (pct <= percent_r) pixels.pixels[led_index].r = 255; + if (pct <= percent_g) pixels.pixels[led_index].g = 255; + if (pct <= percent_b) pixels.pixels[led_index].b = 255; +#else + if (pct > percent_r) { + pixels.pixels[led_index] = (Assembly_Pixel){ + .r = 32, + .g = 32, + .b = 32, + }; + } else { + r32 pct_dist = percent_r - pct; + r32 ramp = (percent_r - pct_dist) / percent_r; + ramp = ramp * ramp; + + pixels.pixels[led_index] = (Assembly_Pixel){ + .r = 32 + (128 * ramp), + .g = 128 + (128 * ramp), + .b = 255, + }; + } +#endif + } + } + + month += month_delta; + if (month > (r32)MONTH_Dec + 1) { + month = (r32)MONTH_Jan; + year += 1; + if (year > 2022) { + year = 2019; + } + } +} + +#endif + +void +pattern_demo(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + // clear previous frame + pattern_color(pixels, strips, 0, 0, 0); + + r32 sun_limit = 5; + if (tt < sun_limit) + { + r32 r = 0.1f; + if (tt > (sun_limit - 1)) + { + r32 ttt = tt - (sun_limit - 1); + r = lerp(0.1f, ttt, 0.0f); + } + sun_center(pixels, (v4){0.5f, 0.5f, 0.5f, 1}, r, r); + } + pattern_blink(pixels); + + Assembly_Pixel data_less_than_color_a = { .r = 32, .g = 128, .b = 255 }; + Assembly_Pixel data_less_than_color_b = { .r = 32, .g = 255, .b = 128 }; + Assembly_Pixel data_border_color = { .r = 255, .g = 255, .b = 255 }; + Assembly_Pixel data_greater_than_color = { .r = 64, .g = 0, .b = 0 }; + + r32 grow_delay = 2; + if (tt > grow_delay && tt < grow_delay + 10) + { + grow_pattern(pixels, tt - grow_delay, data_greater_than_color); + } + + if (tt >= grow_delay + 9) { + //pattern_test_data_scene_hombre(pixels, strips, data_less_than_color_a, data_less_than_color_b, data_border_color, data_greater_than_color); + } +} + + +//////////// MOOD BOARD DEMOS //////////// + +#define hex_color(r, g, b) (v3){ .x = (r32)r / 255.f, .y = (r32)g / 255.f, .z = (r32)b / 255.f } + +global Color_Ramp aurora_ramp = { + .anchors = { + [0] = { .pct = 0, .color = { 0, 0, 0 } }, + [1] = { .pct = .4f, .color = { 0, 0, 0 } }, + [2] = { .pct = .55f, .color = { 176.f / 255.f, 65.f / 255.f, 36.f / 255.f } }, + [3] = { .pct = .7f, .color = { 237.f / 255.f, 201.f / 255.f, 138.f / 255.f } }, + [4] = { .pct = .80f, .color = { 49.f / 255.f, 156.f / 255.f, 255.f / 255.f } }, + [5] = { .pct = 1.0f, .color = { 49.f / 255.f, 156.f / 255.f, 255.f / 255.f } }, + }, + .anchors_count = 5, +}; + +global Color_Ramp sun_ramp = { + .anchors = { + [0] = { .pct = 0, .color = hex_color( 0, 0, 0), }, + [1] = { .pct = 0.2, .color = hex_color( 0, 0, 0), }, + [2] = { .pct = 0.3f, .color = hex_color(255, 85, 0), }, + [3] = { .pct = 0.6f, .color = hex_color(255, 0, 0), }, + [4] = { .pct = 0.9, .color = hex_color(255, 209, 54), }, + [5] = { .pct = 1, .color = hex_color(255, 209, 54), }, + }, + .anchors_count = 6 +}; + +global Color_Ramp cities_ramp = { + .anchors = { + [0] = { .pct = 0, .color = { 0, 0, 0 } }, + [1] = { .pct = .75f, .color = { 0, 0, 0 } }, + [2] = { .pct = 1, .color = { 255.f / 255.f, 194.f / 255.f, 86.f / 255.5 } }, + }, + .anchors_count = 3 +}; + +global Color_Ramp cities_sparkle_ramp = { + .anchors = { + [0] = { .pct = 0, .color = { 0, 0, 0 } }, + [1] = { .pct = .7f, .color = { 0, 0, 0 } }, + [2] = { .pct = .1f, .color = { 255.f / 255.f, 100.f / 255.f, 40.f / 255.5 } }, + }, + .anchors_count = 3 +}; + +global Color_Ramp xray_ramp = { + .anchors = { + [0] = { .pct = 0.0f, .color = { 32.f / 255.f, 2.f / 255.f, 186.f / 255.f } }, + [1] = { .pct = 0.5f, .color = { 230.f / 255.f, 37.f / 255.f, 7.f / 255.f } }, + [2] = { .pct = 1.0f, .color = { 255.f / 255.f, 162.f / 255.f, 0 } }, + }, + .anchors_count = 3 +}; + +global Color_Ramp xray_ramp_rev = { + .anchors = { + [2] = { .pct = 1.0f, .color = { 32.f / 255.f, 2.f / 255.f, 186.f / 255.f } }, + [1] = { .pct = 0.5f, .color = { 230.f / 255.f, 37.f / 255.f, 7.f / 255.f } }, + [0] = { .pct = 0.0f, .color = { 255.f / 255.f, 162.f / 255.f, 0 } }, + }, + .anchors_count = 3 +}; + +global Color_Ramp nature_ramp = { + .anchors = { + [0] = {.pct = 0.0f, .color = { 85.f / 255.f, 192.f / 255.f, 255.f / 255.f } }, + [1] = {.pct = 0.5f, .color = { 0, 1, 0.5f } }, + [2] = {.pct = 1.0f, .color = { 85.f / 255.f, 192.f / 255.f, 255.f / 255.f } }, + }, + .anchors_count = 3, +}; + +void +pattern_aurora_led(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, v4 pos, u32 index, r32 scene_time) +{ + v4 p_unit = incenter_pos_to_unit(pos); + v3 p_offset = HMM_AddVec3(pos.xyz, (v3){ 213.145f, 99.321f, 71.3f }); + v3 p_scaled = HMM_MultiplyVec3f(p_offset, 2); + r32 v = pm_fmb_3d(p_scaled, scene_time); + r32 vv = pm_smoothstep_r32(v); + v3 color = color_ramp_eval(aurora_ramp, vv); + pixels.pixels[index] = color_v3_to_assembly_pixel(color); +} + +void +pattern_aurora(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + r32 scene_time = ins->scene_time; + for (u32 j = 0; j < pixels.len; j++) + { + v4 p = pixels.positions[j]; + pattern_aurora_led(pixels, strips, p, j, scene_time); + } +} + +void +pattern_demo_2(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + for (u32 city = 0; city < city_count; city++) + { + Assembly_Strip strip = strips.strips[city + 1]; + for (u32 led = 0; led < strip.pixels_len; led++) + { + r32 pct = (r32)(strip.pixels_len - led) / (r32)strip.pixels_len; + u32 led_index = strip.pixels[led]; + + v3 color = color_ramp_eval(cities_ramp, 1 - pct); + pixels.pixels[led_index] = color_v3_to_assembly_pixel(color); + } + } +} + +// sunrise +void +pattern_demo_3(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + r32 scene_time = ins->scene_time; + v3 sun_dir = (v3){ sinf(scene_time), 0, cosf(scene_time) }; + for (u32 city = 0; city < city_count; city++) + { + Assembly_Strip strip = strips.strips[city + 1]; + for (u32 led = 0; led < strip.pixels_len; led++) + { + r32 pct = (r32)(strip.pixels_len - led) / (r32)strip.pixels_len; + u32 led_index = strip.pixels[led]; + + v3 cities_color = color_ramp_eval(cities_ramp, 1 - pct); + v4 p = pixels.positions[led_index]; + v4 p_unit = incenter_pos_to_bimodal(p); + r32 d = HMM_DotVec3(p_unit.xyz, sun_dir); + r32 dc = clamp(0, d, 1); + r32 ds = clamp(0, -1 * d, 1); + cities_color = HMM_MultiplyVec3f(cities_color, dc); + + v3 sky_color = { 49.f / 255.f, 156.f / 255.f, 255.f / 255.f }; + sky_color = HMM_MultiplyVec3f(sky_color, ds); + v3 day_color = HMM_AddVec3(sky_color, cities_color); + + //v3 sun_color = sun_center_for_pos(pixels.positions[led_index], (v4){0.5f, 0.5f, 0.5f, 1}, .1f, .1f); + v3 color = day_color; //HMM_AddVec3(day_color, sun_color); + pixels.pixels[led_index] = color_v3_to_assembly_pixel(color); + } + } +} + +// random fill +u32 city_hashes[city_count]; +u32 city_iters[city_count]; +void +pattern_random_fill_prep() +{ + Random_Series rs = random_series_create(1337); + for (u32 i = 0; i < city_count; i++) + { + city_iters[i] = random_series_next(&rs) % 127; + city_hashes[i] = hash_djb2_cstr_to_u32(city_strings[i]); + } +} + +void +pattern_random_fill(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + pattern_color(pixels, strips, 1, 38, 45); // dull green + + Assembly_Pixel color = color_v3_to_assembly_pixel((v3){1, .9f, 0}); + + r32 scene_time = ins->scene_time; + r32 dots_per_second = 5; + u32 iter_cap = scene_time * dots_per_second; + for (u32 city = 0; city < city_count; city++) + { + Random_Series rs = random_series_create(city_hashes[city]); + u32 city_iter = min(city_iters[city], iter_cap); + Assembly_Strip strip = strips.strips[city + 1]; + for (u32 i = 0; i < city_iter; i++) + { + u32 led = random_series_next(&rs) % strip.pixels_cap; + u32 led_index = strip.pixels[led]; + pixels.pixels[led_index] = color; + } + } +} + +r32 +hash_v3_to_r32(v3 p) +{ + u32 seed = hash_djb2_str_to_u32((char*)&p.x, 4); + seed = hash_djb2_append_str_to_u32(seed, (char*)&p.y, 4); + seed = hash_djb2_append_str_to_u32(seed, (char*)&p.z, 4); + Random_Series rs = random_series_create(seed); + return random_series_next_unilateral(&rs); +} + +r32 +noise_v3_to_r32(v3 p, r32 scale) +{ + p = pm_abs_v3(HMM_MultiplyVec3f(p, scale)); + v3 p_fl = pm_floor_v3(p); + v3 p_fr = pm_fract_v3(p); + v3 f = pm_smoothstep_v3(p_fr); + + v3 p_fl_0 = p_fl; + v3 p_fl_1 = HMM_AddVec3(p_fl, (v3){1, 0, 0}); + v3 p_fl_2 = HMM_AddVec3(p_fl, (v3){0, 1, 0}); + v3 p_fl_3 = HMM_AddVec3(p_fl, (v3){1, 1, 0}); + v3 p_fl_4 = HMM_AddVec3(p_fl, (v3){0, 0, 1}); + v3 p_fl_5 = HMM_AddVec3(p_fl, (v3){1, 0, 1}); + v3 p_fl_6 = HMM_AddVec3(p_fl, (v3){0, 1, 1}); + v3 p_fl_7 = HMM_AddVec3(p_fl, (v3){1, 1, 1}); + + r32 h0 = hash_v3_to_r32(p_fl_0); + r32 h1 = hash_v3_to_r32(p_fl_1); + r32 h2 = hash_v3_to_r32(p_fl_2); + r32 h3 = hash_v3_to_r32(p_fl_3); + r32 h4 = hash_v3_to_r32(p_fl_4); + r32 h5 = hash_v3_to_r32(p_fl_5); + r32 h6 = hash_v3_to_r32(p_fl_6); + r32 h7 = hash_v3_to_r32(p_fl_7); + + r32 h0_1 = lerp(h0, f.x, h1); + r32 h2_3 = lerp(h2, f.x, h3); + r32 h4_5 = lerp(h4, f.x, h5); + r32 h6_7 = lerp(h6, f.x, h7); + r32 h01_23 = lerp(h0_1, f.y, h2_3); + r32 h45_67 = lerp(h4_5, f.y, h6_7); + // r32 result = lerp( + // lerp( + // lerp(h0, f.x, h1), + // f.y, + // lerp(h2, f.x, h3) + // ), + // f.z, + // lerp( + // lerp(h4, f.x, h5), + // f.y, + // lerp(h6, f.x, h7) + // ) + // ); + r32 result = lerp(h01_23, f.z, h45_67); + + assert(result >= 0 && result <= 1); + return result; +} + +r32 +fbm_3d(v3 x, r32 scale) +{ + v3 pp = HMM_MultiplyVec3f(x, scale); + r32 f = 0.0f; + f += 0.500000f * noise_v3_to_r32(pp, 1); pp = HMM_MultiplyVec3f(pp, 2.02); + f += 0.300000f * noise_v3_to_r32(pp, 1); pp = HMM_MultiplyVec3f(pp, 2.03); + f += 0.125000f * noise_v3_to_r32(pp, 1); pp = HMM_MultiplyVec3f(pp, 2.01); + f += 0.062500f * noise_v3_to_r32(pp, 1); pp = HMM_MultiplyVec3f(pp, 2.04); + r32 d = 0.9875f; + f = f / d; + return f; +} + +// Data Flow Pattern +void +pattern_add_data_flow_ramp(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, + r32 period, r32 offset, r32 radius, + Color_Ramp color_ramp) +{ + Random_Series rs = random_series_create(133753); + + for (u32 city = 0; city < city_count; city++) + { + Assembly_Strip strip = strips.strips[city + 1]; + r32 city_offset = random_series_next_unilateral(&rs) * period; + for (u32 led = 0; led < strip.pixels_len; led++) + { + u32 led_index = strip.pixels[led]; + r32 led_pct = (r32)led_index / (r32)strip.pixels_len; + r32 dist = (-1 * fmodf(led_pct + offset + city_offset, period)) + radius; + dist = max(dist, 0) / radius; + v3 color = color_ramp_eval(color_ramp, led_pct); + pixels.pixels[led_index] = assembly_pixel_add( + pixels.pixels[led_index], + color_v3_to_assembly_pixel_faded(color, dist) + ); + } + } +} + +void +pattern_add_data_flow_color(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, + r32 period, r32 offset, r32 radius, + v3 color) +{ + Random_Series rs = random_series_create(133753); + + for (u32 city = 0; city < city_count; city++) + { + Assembly_Strip strip = strips.strips[city + 1]; + r32 city_offset = random_series_next_unilateral(&rs) * period; + for (u32 led = 0; led < strip.pixels_len; led++) + { + u32 led_index = strip.pixels[led]; + r32 led_pct = (r32)led_index / (r32)strip.pixels_len; + r32 dist = (-1 * fmodf(led_pct + offset + city_offset, period)) + radius; + dist = max(dist, 0) / radius; + pixels.pixels[led_index] = assembly_pixel_add( + pixels.pixels[led_index], + color_v3_to_assembly_pixel_faded(color, dist) + ); + } + } +} + +void +pattern_mask_noise(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, r32 scale, r32 offset) +{ + for (u32 city = 0; city < city_count; city++) + { + Assembly_Strip strip = strips.strips[city + 1]; + for (u32 led = 0; led < strip.pixels_len; led++) + { + u32 led_index = strip.pixels[led]; + v4 p = pixels.positions[led_index]; + r32 n = noise_v3_to_r32(HMM_AddVec3(p.xyz, (v3){offset, 0, 0}), 4); + pixels.pixels[led_index] = assembly_pixel_scale(pixels.pixels[led_index], n); + } + } +} + +void +pattern_data_flow(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + pattern_color(pixels, strips, 1, 38, 45); // dull green + + r32 tt_base = ins->scene_time; + pattern_add_data_flow_color(pixels, strips, .6f, tt_base, .02f, (v3){1, 0, .8f}); + pattern_add_data_flow_color(pixels, strips, .8f, tt_base * .5f, .035f, (v3){0, 1, 0}); + pattern_add_data_flow_color(pixels, strips, 1.2f, tt_base * .35f, .06f, (v3){0, 1, 1}); + pattern_mask_noise(pixels, strips, 5, tt); +} + + +void +pattern_fast_noise_test(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + for (u32 city = 0; city < city_count; city++) + { + Assembly_Strip strip = strips.strips[city + 1]; + for (u32 led = 0; led < strip.pixels_len; led++) + { + u32 led_index = strip.pixels[led]; + v4 p = pixels.positions[led_index]; + r32 n = noise_v3_to_r32(HMM_AddVec3(p.xyz, (v3){tt, 0, 0}), 4); + pixels.pixels[led_index] = color_v3_to_assembly_pixel((v3){n,n,n}); + } + } +} + +// City Lights Twinkle +void +secondary_pattern_twinkle(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + for (u32 i = 0; i < secondary_strips_len; i++) { + Assembly_Strip* strip = secondary_city_strips[i]; + for (u32 led = 0; led < strip->pixels_len; led++) + { + u32 led_index = strip->pixels[led]; + v4 p = pixels.positions[led_index]; + v4 p_unit = incenter_pos_to_unit(p); + v3 p_offset = HMM_AddVec3(p.xyz, (v3){ 213.145f, 99.321f, 71.3f }); + v3 p_scaled = HMM_MultiplyVec3f(p_offset, 2); + r32 v = pm_fmb_3d(p_scaled, ins->scene_time); + r32 vv = (2 * pm_smoothstep_r32(v)) - 1; + +#define TESTING_LEDS 0 +#if !TESTING_LEDS + v3 color = color_ramp_eval(cities_sparkle_ramp, vv); + pixels.pixels[led_index] = color_v3_to_assembly_pixel(color); +#else + pixels.pixels[led_index] = color_v3_to_assembly_pixel((v3){1, 0, 0}); +#endif + } + } +} + +Assembly_Pixel +sun(v3 pos, r32 radius2, Assembly_Pixel back_color, r32 t) +{ + Assembly_Pixel color_sun = { 255, 0, 0 }; + r32 sun_radius = INCENTER_FEET(3); + r32 sun_radius2 = sun_radius * sun_radius; + r32 sun_b = sdf_sphere2_d(sun_radius2, radius2); + Assembly_Pixel result = {0, 0, 0}; + if (sun_b > 0) { + sun_b = max(0, sun_b); + t *= 0.5f; + v3 pn = HMM_NormalizeVec3(pos); + pn = HMM_MultiplyVec3f(pn, -t); + pos = HMM_AddVec3(pos, pn); + pos = HMM_AddVec3(pos, (v3){ 4.1f * sin(t * 0.05f), 3 * cos(t * 0.05f), 0 }); + r32 p = fbm_3d(pos, 2); + result = color_ramp_eval_pixel(sun_ramp, pm_smoothstep_r32(p)); + result = assembly_pixel_blend(back_color, result, sun_b); + } + return result; +} + +void +pattern_sun_passive(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + r32 st = (r32)ins->scene_time; + for (u32 j = 0; j < pixels.len; j++) + { + v4 pos = pixels.positions[j]; + v4 p = incenter_pos_to_unit(pos); + r32 r2 = HMM_LengthSquaredVec3(pos.xyz); +#if !TESTING_LEDS + pixels.pixels[j] = sun(pos.xyz, r2, (Assembly_Pixel){0, 0, 0}, st); +#else + pixels.pixels[j] = color_v3_to_assembly_pixel((v3){0, 0, 1}); +#endif + + } + + secondary_pattern_twinkle(pixels, strips, ins); +} + +void +pattern_add_bar_chart(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins, Incenter_Scene scene, u32 year, Incenter_Month_Id month, Color_Ramp color_ramp) +{ + for (u32 row_i = 0; row_i < scene.data_len; row_i++) + { + Incenter_Data_Row row = scene.data[row_i]; + if (row.year != year || row.month != month) continue; + + Assembly_Strip strip = strips.strips[row.id]; + for (u32 led_i = 0; led_i < strip.pixels_len; led_i++) + { + u32 led_index = strip.pixels[led_i]; + + // Bar Chart + r32 pct = ((r32)led_i / (r32)strip.pixels_len); + if (pct < row.prop) { + r32 cpct = pct / row.prop; + Assembly_Pixel p = color_ramp_eval_pixel(color_ramp, cpct); + pixels.pixels[led_index] = p; + } + } + } +} + +void +pattern_bar_chart(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + Incenter_Scene scene = ins->scenes[ins->scene_at]; + if (!scene.data) return; + + pattern_color(pixels, strips, 0, 0, 0); + pattern_add_bar_chart(pixels, strips, ins, scene, scene.data[0].year, scene.data[0].month, xray_ramp); +} + +global bool needs_reset = true; +global u32 year_max = 0; +global Incenter_Month_Id month_max = 0; +global u32 year_at = 0; +global Incenter_Month_Id month_at = 0; +global r32 month_start_time = 0; + +void +pattern_bar_chart_over_time(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + Incenter_Scene scene = ins->scenes[ins->scene_at]; + if (!scene.data) return; + + if (needs_reset) + { + needs_reset = false; + + // Determine what the end of the data set is + for (u32 row_i = 0; row_i < scene.data_len; row_i++) + { + Incenter_Data_Row row = scene.data[row_i]; + if (row.year >= year_max) { + year_max = row.year; + month_max = max(row.month, month_max); + } + } + + year_at = scene.data[0].year; + month_at = scene.data[0].month; + month_start_time = ins->scene_time; + } + + r32 month_duration = 1; + r32 time_at_month = ins->scene_time - month_start_time; + if (time_at_month > month_duration) + { + if (year_at < year_max) { + month_at += 1; + if (month > MONTH_dec) { + month_at = MONTH_jan; + year_at += 1; + } + } else { + if (month < month_max) month += 1; + } + + month_start_time = ins->scene_time; + } + + pattern_color(pixels, strips, 0, 0, 0); + pattern_add_bar_chart(pixels, strips, ins, scene, year_at, month_at, xray_ramp); +} + + +void +pattern_scene_input_pulse(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + r32 pulse_duration = 1; + if (ins->scene_time > pulse_duration) return; + + r32 pulse_pct = min(ins->scene_time / pulse_duration, 1); + r32 height = (pm_easeout_cubic_r32(pulse_pct) * 1.4f) - 0.2f; + r32 brightness = 1 - pulse_pct; + + r32 strip_len = (r32)(BLACK_ROCK_LED_OPL - BLACK_ROCK_LED_FIRST); + + Assembly_Strip brc_strip = strips.strips[city_black_rock]; + for (u32 i = BLACK_ROCK_LED_FIRST; i < BLACK_ROCK_LED_OPL; i++) + { + u32 led_i = brc_strip.pixels[i]; + r32 pct_i = (r32)i / (r32)strip_len; + pct_i = 1 - pct_i; + r32 pct_d = fabsf(pct_i - height); + r32 b = max(0, 0.1f - pct_d) / 0.1f; + pixels.pixels[led_i] = color_v3_to_assembly_pixel_faded((v3){0, 0, 1}, b * brightness); + } +} + +//////////////////////////////////////// +// ANYBODY HOME? + +void +pattern_anybody_home(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + pattern_color(pixels, strips, 0, 0, 0); + + Assembly_Strip strip = strips.strips[city_black_rock]; + for (u32 i = BLACK_ROCK_LED_FIRST; i < BLACK_ROCK_LED_OPL; i++) + { + u32 led_i = strip.pixels[i]; + pixels.pixels[led_i] = color_v3_to_assembly_pixel((v3){0, 0, 1}); + } +} + + +//////////////////////////////////////// +// Felt Isolated + +Assembly_Pixel +pattern_felt_isolated_color(u32 pixel_i, u32 pixels_len, r32 b) +{ + r32 pp = 1 - ((r32)pixel_i / (r32)pixels_len); + Assembly_Pixel color0 = color_ramp_eval_pixel(xray_ramp, pp); + Assembly_Pixel color = assembly_pixel_scale(color0, b); + return color; +} + +void +pattern_felt_isolated_intro(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + Incenter_Scene scene = ins->scenes[ins->scene_at]; + pattern_color(pixels, strips, 0, 0, 0); + for (u32 row_i = 0; row_i < scene.data_len; row_i++) + { + Incenter_Data_Row row = scene.data[row_i]; + Assembly_Strip strip = strips.strips[row.id]; + u32 pixel_start = row.prop * strip.pixels_len; + u32 pixel_index = strip.pixels[pixel_start]; + r32 row_offset = (.1439f * row_i); + r32 b = pm_sinf_01(ins->scene_time + row_offset); + pixels.pixels[pixel_index] = pattern_felt_isolated_color( + pixel_start, + strip.pixels_len, + b + ); + } +} + +void +pattern_felt_isolated_passive(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + Incenter_Scene scene = ins->scenes[ins->scene_at]; + r32 scene_speed = 4; + r32 scene_time = ins->scene_time * scene_speed; + + pattern_color(pixels, strips, 0, 0, 0); + pattern_scene_input_pulse(pixels, strips, ins); + for (u32 row_i = 0; row_i < scene.data_len; row_i++) + { + Incenter_Data_Row row = scene.data[row_i]; + Assembly_Strip strip = strips.strips[row.id]; + s32 pixel_start = (row.prop * strip.pixels_len); + r32 row_offset = (.1439f * row_i); + r32 b = pm_sinf_01(ins->scene_time + row_offset); + + r32 grow_duration = 4.0f; + r32 grow_delay = row_offset * 5; + r32 grow_time = (scene_time - 2.0f) - grow_delay; + + r32 grow_pct = clamp(0, grow_time, grow_duration) / grow_duration; + r32 grow_pct_smoothed = pm_easeinout_cubic_r32(grow_pct); + s32 pixels_on = pixel_start * grow_pct_smoothed; + s32 pixel_stop = clamp(0, pixel_start - pixels_on, pixel_start - 1); + for (u32 pixel_i = + pixel_stop; pixel_i < pixel_start; pixel_i++) + { + u32 pixel_index = strip.pixels[pixel_i]; + pixels.pixels[pixel_index] = pattern_felt_isolated_color( + pixel_i, + strip.pixels_len, + b + ); + } + + } +} + +void +pattern_rainbow(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + Assembly_Pixel p = color_v3_to_assembly_pixel((v3){ + .x = pm_sinf_01(ins->scene_time), + .y = pm_cosf_01(ins->scene_time), + .z = 0.5f, + }); + for (u32 j = 0; j < pixels.len; j++) + { + pixels.pixels[j] = p; + } +} + +/////////////////////////////////// +// Begun to Heal + +void +pattern_bar_chart_bubbly_intro(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + Incenter_Scene scene = ins->scenes[ins->scene_at]; + if (!scene.data) return; + + pattern_color(pixels, strips, 0, 0, 0); + r32 scene_speed = 3; + r32 scene_time = ins->scene_time * scene_speed; + + for (u32 row_i = 0; row_i < scene.data_len; row_i++) + { + Incenter_Data_Row row = scene.data[row_i]; + Assembly_Strip strip = strips.strips[row.id]; + u32 led_index = strip.pixels[strip.pixels_len - 1]; + Assembly_Pixel p = color_v3_to_assembly_pixel(nature_ramp.anchors[0].color); + pixels.pixels[led_index] = p; + } +} + +void +pattern_bar_chart_bubbly_passive(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + Incenter_Scene scene = ins->scenes[ins->scene_at]; + if (!scene.data) return; + + pattern_color(pixels, strips, 0, 0, 0); + r32 scene_time = ins->scene_time; + r32 grow_time = 5; + r32 pct_grow_time = clamp(0, ((scene_time - INCENTER_TRANSITION_DURATION) / grow_time), 1); + + // create a ramp that is 0 at pct_grow_time = 0 and pct_grow_time = 1, + // but smoothly grows to 1 at pct_grow_time = 0.5 + r32 offset_influence = sinf((1 - pct_grow_time) * r32_pi); + + for (u32 row_i = 0; row_i < scene.data_len; row_i++) + { + Incenter_Data_Row row = scene.data[row_i]; + Assembly_Strip strip = strips.strips[row.id]; + + u32 first_led = strip.pixels[strip.pixels_len - 1]; + v3 first_led_pos = pixels.positions[first_led].xyz; + v3 root = HMM_AddVec3(first_led_pos, (v3){ ins->scene_time, 0, 0 }); + + r32 strip_pct = row.prop * pct_grow_time; + if (pct_grow_time < 1) { + r32 strip_offset = (pm_noise_v3_to_r32(root) * 0.4f) - 0.2f; + strip_pct += strip_offset * offset_influence; + strip_pct = clamp(0, strip_pct, row.prop); + } + + for (u32 led_i = 0; led_i < strip.pixels_len; led_i++) + { + u32 led_index = strip.pixels[led_i]; + + // Bar Chart + r32 pct = 1 - ((r32)led_i / (r32)strip.pixels_len); + if (pct < strip_pct) { + r32 cpct = fractf(((1 - pct) / row.prop) + (ins->scene_time * 0.3f)); + Assembly_Pixel p = color_ramp_eval_pixel(nature_ramp, cpct); + pixels.pixels[led_index] = p; + } + } + } +} + +/////////////////////////////////////////////////// +// Relationship Community Support + +void +pattern_bar_chart_with_connections(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + Incenter_Scene scene = ins->scenes[ins->scene_at]; + if (!scene.data) return; + + pattern_color(pixels, strips, 0, 0, 0); + + r32 scene_time = ins->scene_time; + pattern_add_bar_chart(pixels, strips, ins, scene, scene.data[0].year, scene.data[0].month, xray_ramp); + pattern_add_data_flow_color(pixels, strips, .3f, ins->scene_time, .01f, (v3){1,1,1}); + pattern_add_data_flow_color(pixels, strips, .15f, ins->scene_time, .005f, (v3){1,1,1}); +} + +///// +// Believe Science Renewable Tech + +void +pattern_bar_chart_random_fill(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + Incenter_Scene scene = ins->scenes[ins->scene_at]; + if (!scene.data) return; + + pattern_color(pixels, strips, 1, 38, 45); // dull green + + Assembly_Pixel color = color_v3_to_assembly_pixel((v3){1, .9f, 0}); + assert(color.r != 1); + + r32 scene_time = ins->scene_time * 8; + r32 dots_per_second = 5; + u32 iter_cap = scene_time * dots_per_second; + for (u32 row_i = 0; row_i < scene.data_len; row_i++) + { + Incenter_Data_Row row = scene.data[row_i]; + Assembly_Strip strip = strips.strips[row.id]; + u32 led_max = strip.pixels_len; + u32 led_min = strip.pixels_len * (1 - row.prop); + u32 led_range = led_max - led_min; + + Random_Series rs = random_series_create(city_hashes[row.id]); + u32 city_iter = min(iter_cap, led_range); + for (u32 i = 0; i < city_iter; i++) + { + u32 led_first = (random_series_next(&rs) % led_range) + led_min; + u32 led = led_first; + u32 led_index = 0; + do { + led = ((led + 1) % led_range) + led_min; + if (led == led_first) break; + led_index = strip.pixels[led]; + } while (pixels.pixels[led_index].r == 1); + pixels.pixels[led_index] = color; + } + } +#if 0 + for (u32 city = 0; city < city_count; city++) + { + Random_Series rs = random_series_create(city_hashes[city]); + u32 city_iter = min(city_iters[city], iter_cap); + Assembly_Strip strip = strips.strips[city + 1]; + for (u32 i = 0; i < city_iter; i++) + { + u32 led = random_series_next(&rs) % strip.pixels_cap; + u32 led_index = strip.pixels[led]; + pixels.pixels[led_index] = color; + } + } +#endif +} + +void +pattern_scene_input(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + Incenter_Scene scene = ins->scenes[ins->scene_at]; + Assembly_Strip brc_strip = strips.strips[city_black_rock]; + + pattern_color(pixels, strips, 0, 0, 0); + secondary_pattern_twinkle(pixels, strips, ins); + + // black out whole strip + for (u32 led_i = 0; led_i < brc_strip.pixels_len; led_i++) + { + u32 led = brc_strip.pixels[led_i]; + pixels.pixels[led] = (Assembly_Pixel){0,0,0}; + } + + u32 on_range_start = 0; + u32 on_range_stop = 0; + switch (scene.kind) + { + case Incenter_SceneKind_Information: + { + } break; + + case Incenter_SceneKind_YesOrNo: + { + u32 middle = brc_strip.pixels_len / 2; + on_range_start = ins->input_option == 0 ? 0 : middle; + on_range_stop = ins->input_option == 0 ? middle : brc_strip.pixels_len; + } break; + + case Incenter_SceneKind_ThreeOption: + { + u32 one_third = brc_strip.pixels_len / 3; + u32 two_thirds = one_third * 2; + u32 top = brc_strip.pixels_len; + switch (ins->input_option) { + case 0: { on_range_start = 0; on_range_stop = one_third; } break; + case 1: { on_range_start = one_third; on_range_stop = two_thirds; } break; + case 2: { on_range_start = two_thirds; on_range_stop = top; } break; + } + } break; + + case Incenter_SceneKind_SlidingScale: + { + on_range_start = 0; + on_range_stop = (r32)brc_strip.pixels_len * ins->input_pct; + } break; + + invalid_default_case; + } + + for (u32 led_i = on_range_start; led_i < on_range_stop; led_i++) + { + u32 led = brc_strip.pixels[led_i]; + pixels.pixels[led] = (Assembly_Pixel){255,255,255}; + } +} + +///////////////////////////////////////////// +// Transition Patterns + +void +pattern_sun_transition(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins, r32 radius_start, r32 radius_end, u32 back_scene_mode) +{ + r32 st = (r32)ins->transition_time; + r32 shrink_duration = INCENTER_TRANSITION_SUN_REVEAL_DURATION; + r32 shrink_progress_pct = (st / shrink_duration); + shrink_progress_pct = clamp(0, shrink_progress_pct, 1); + r32 radius = lerp(radius_start, shrink_progress_pct, radius_end); + r32 radius2 = radius * radius; + + //Assembly_Pixel color_shell = { 255, 255, 255 }; + Assembly_Pixel color_void = { 0, 0, 0 }; + + r32 falloff = INCENTER_FEET(1); + r32 falloff2 = falloff * falloff; + + Incenter_Scene back_scene = ins->scenes[ins->scene_at]; + Incenter_Pattern* back_pattern = 0; + if (back_scene_mode < Incenter_SceneMode_Count) { + back_pattern = back_scene.patterns[back_scene_mode]; + } else if (back_scene_mode == Incenter_SceneMode_Input) { + back_pattern = pattern_scene_input; + } + assert(back_pattern != 0); + + back_pattern(pixels, strips, ins); + + for (u32 j = 0; j < pixels.len; j++) + { + v4 pos = pixels.positions[j]; + v4 p = incenter_pos_to_unit(pos); + r32 r2 = HMM_LengthSquaredVec3(pos.xyz); + r32 b = sdf_sphere_hull2_d(radius2, 3, r2); + Assembly_Pixel back_color = pixels.pixels[j]; + if (r2 > radius2) { + back_color = sun(pos.xyz, r2, color_void, st); + } + + v3 color_shell_v3 = { + .x = 0.5f + 0.5f * sinf(p.x * r32_tau * 4.313f + tt * 1.3f), + .y = 0.5f + 0.5f * cosf(0.2314f + p.y * r32_tau * 3.915f + tt), + .z = 0.2f + 0.8f * p.z, + }; + Assembly_Pixel color_shell = color_v3_to_assembly_pixel(color_shell_v3); + pixels.pixels[j] = assembly_pixel_blend(back_color, color_shell, b); + } +} + +void +pattern_sun_transition_shrink(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + r32 radius_start = INCENTER_FEET(15); + r32 radius_end = INCENTER_FEET(0); + u32 scene_mode = Incenter_SceneMode_Passive; + pattern_sun_transition(pixels, strips, ins, radius_start, radius_end, scene_mode); +} + +void +pattern_sun_transition_grow(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) +{ + r32 radius_start = INCENTER_FEET(0); + r32 radius_end = INCENTER_FEET(40); + u32 scene_mode = Incenter_SceneMode_Input; + if (ins->scene_at == Incenter_Scene_WelcomeHome || + ins->scene_at == Incenter_Scene_AnyoneHome) { + scene_mode = Incenter_SceneMode_Passive; + } + pattern_sun_transition(pixels, strips, ins, radius_start, radius_end, scene_mode); +} diff --git a/src_v2/user_space/incenter_scenes.c b/src_v2/user_space/incenter_scenes.c new file mode 100644 index 0000000..82baa1d --- /dev/null +++ b/src_v2/user_space/incenter_scenes.c @@ -0,0 +1,289 @@ + +internal void +incenter_scene_descs_init() +{ + incenter_scene_descs[Incenter_Scene_AnyoneHome] = (Incenter_Scene){ + .name = "AnyoneHome", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_anybody_home, + [Incenter_SceneMode_Passive] = pattern_anybody_home, + }, + .kind = Incenter_SceneKind_Information, + }; + + incenter_scene_descs[Incenter_Scene_WelcomeHome] = (Incenter_Scene){ + .name = "WelcomeHome", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_sun_passive, + [Incenter_SceneMode_Passive] = pattern_sun_passive, + }, + .kind = Incenter_SceneKind_Information, + }; + + incenter_scene_descs[Incenter_Scene_Question_FeltIsolated] = (Incenter_Scene){ + .name = "FeltIsolated", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_felt_isolated_intro, + [Incenter_SceneMode_Passive] = pattern_felt_isolated_passive, + }, + .data = question_1_data, + .data_len = question_1_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_FeltFearAnxiety] = (Incenter_Scene){ + .name = "FeltFearAnxiety", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_felt_isolated_intro, + [Incenter_SceneMode_Passive] = pattern_felt_isolated_passive, + }, + .data = question_2_data, + .data_len = question_2_len, + .kind = Incenter_SceneKind_ThreeOption, + }; + + incenter_scene_descs[Incenter_Scene_Question_FeltPowerless] = (Incenter_Scene){ + .name = "FeltPowerless", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_felt_isolated_intro, + [Incenter_SceneMode_Passive] = pattern_felt_isolated_passive, + }, + .data = question_5_data, + .data_len = question_5_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_LostAccessToResources] = (Incenter_Scene){ + .name = "LostAccessToResources", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_3_data, + .data_len = question_3_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_LostLovedOne] = (Incenter_Scene){ + .name = "LostLovedOne", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart_over_time, + [Incenter_SceneMode_Passive] = pattern_bar_chart_over_time, + }, + .data = question_4_data, + .data_len = question_4_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + // TODO: We need an animation that communicates healing / connection + // grow out from the person's answer into the entire planet + incenter_scene_descs[Incenter_Scene_Question_BegunToHeal] = (Incenter_Scene){ + .name = "BegunToHeal", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart_bubbly_intro, + [Incenter_SceneMode_Passive] = pattern_bar_chart_bubbly_passive, + }, + // no data .data = question_6_data, + // no data .data_len = question_6_len, + .kind = Incenter_SceneKind_SlidingScale, + }; + + incenter_scene_descs[Incenter_Scene_OnPlayaResources] = (Incenter_Scene){ + .name = "OnPlayaResources", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .kind = Incenter_SceneKind_Information, + }; + + incenter_scene_descs[Incenter_Scene_Question_RelationshipCommunitySupport] = (Incenter_Scene){ + .name = "RelationshipCommunitySupport", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart_with_connections, + [Incenter_SceneMode_Passive] = pattern_bar_chart_with_connections, + }, + .data = question_7_data, + .data_len = question_7_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_ConnectionFriendsFamily] = (Incenter_Scene){ + .name = "ConnectionFriendsFamily", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart_with_connections, + [Incenter_SceneMode_Passive] = pattern_bar_chart_with_connections, + }, + .data = question_8_data, + .data_len = question_8_len, + .kind = Incenter_SceneKind_SlidingScale, + }; + + incenter_scene_descs[Incenter_Scene_Question_ValueConnections] = (Incenter_Scene){ + .name = "ValueConnections", + .patterns = { +#if 0 + [Incenter_SceneMode_Intro] = pattern_bar_chart_with_connections, + [Incenter_SceneMode_Passive] = pattern_bar_chart_with_connections, +#endif + [Incenter_SceneMode_Intro] = pattern_bar_chart_random_fill, + [Incenter_SceneMode_Passive] = pattern_bar_chart_random_fill, + }, + .data = question_9_data, + .data_len = question_9_len, + .kind = Incenter_SceneKind_SlidingScale, + }; + + incenter_scene_descs[Incenter_Scene_Question_FindHappiness] = (Incenter_Scene){ + .name = "FindHappiness", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_10_data, + .data_len = question_10_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_FeltExcludedIdentity] = (Incenter_Scene){ + .name = "FeltExcludedIdentity", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_13_data, + .data_len = question_13_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_RepresentedByLeadership] = (Incenter_Scene){ + .name = "RepresentedByLeadership", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_14_data, + .data_len = question_14_len, + .kind = Incenter_SceneKind_SlidingScale, + }; + + incenter_scene_descs[Incenter_Scene_Question_LearningOpenMinded] = (Incenter_Scene){ + .name = "LearningOpenMinded", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_12_data, + .data_len = question_12_len, + .kind = Incenter_SceneKind_SlidingScale, + }; + + incenter_scene_descs[Incenter_Scene_Question_ProtectOurEarth] = (Incenter_Scene){ + .name = "ProtectOurEarth", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_18_data, + .data_len = question_18_len, + .kind = Incenter_SceneKind_SlidingScale, + }; + + incenter_scene_descs[Incenter_Scene_Question_BelieveScienceRenewableTech] = (Incenter_Scene){ + .name = "BelieveScienceRenewableTech", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_felt_isolated_intro , + [Incenter_SceneMode_Passive] = pattern_felt_isolated_passive, + }, + .data = question_19_data, + .data_len = question_19_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_StriveMoreEcoFriendly] = (Incenter_Scene){ + .name = "StriveMoreEcoFriendly", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart_over_time, + [Incenter_SceneMode_Passive] = pattern_bar_chart_over_time, + }, + // .data = question_22_data, + // .data_len = question_22_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + + incenter_scene_descs[Incenter_Scene_Question_ActionToHelpPlanet] = (Incenter_Scene){ + .name = "ActionToHelpPlanet", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_20_data, + .data_len = question_20_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_HowYouFaceChallenges] = (Incenter_Scene){ + .name = "HowYouFaceChallenges", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_6_data, + .data_len = question_6_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_InspiredToHelpOthers] = (Incenter_Scene){ + .name = "InspiredToHelpOthers", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_11_data, + .data_len = question_11_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_PracticeChangeHopeFor] = (Incenter_Scene){ + .name = "PracticeChangeHopeFor", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_17_data, + .data_len = question_17_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_PracticeRadicalInclusion] = (Incenter_Scene){ + .name = "PracticeRadicalInclusion", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_16_data, + .data_len = question_16_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Question_CommunityFeelBelong] = (Incenter_Scene){ + .name = "CommunityFeelBelong", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .data = question_15_data, + .data_len = question_15_len, + .kind = Incenter_SceneKind_YesOrNo, + }; + + incenter_scene_descs[Incenter_Scene_Credits] = (Incenter_Scene){ + .name = "Credits", + .patterns = { + [Incenter_SceneMode_Intro] = pattern_bar_chart, + [Incenter_SceneMode_Passive] = pattern_bar_chart, + }, + .kind = Incenter_SceneKind_Information, + }; +} diff --git a/src_v2/user_space/incenter_scenes.h b/src_v2/user_space/incenter_scenes.h new file mode 100644 index 0000000..b4e9406 --- /dev/null +++ b/src_v2/user_space/incenter_scenes.h @@ -0,0 +1,44 @@ +/* date = August 2nd 2022 5:47 am */ + +#ifndef INCENTER_SCENES_H +#define INCENTER_SCENES_H + +typedef u8 Incenter_Scene_ID; +enum { + Incenter_Scene_Invalid = 0, + + Incenter_Scene_AnyoneHome = 1, + Incenter_Scene_WelcomeHome = 2, + Incenter_Scene_Question_FeltIsolated = 3, + Incenter_Scene_Question_FeltFearAnxiety = 4, + Incenter_Scene_Question_FeltPowerless = 5, + Incenter_Scene_Question_LostAccessToResources = 6, + Incenter_Scene_Question_LostLovedOne = 7, + Incenter_Scene_Question_BegunToHeal = 8, + Incenter_Scene_OnPlayaResources = 9, + Incenter_Scene_Question_RelationshipCommunitySupport = 10, + Incenter_Scene_Question_ConnectionFriendsFamily = 11, + Incenter_Scene_Question_ValueConnections = 12, + Incenter_Scene_Question_FindHappiness = 13, + Incenter_Scene_Question_FeltExcludedIdentity = 14, + Incenter_Scene_Question_RepresentedByLeadership = 15, + Incenter_Scene_Question_LearningOpenMinded = 16, + Incenter_Scene_Question_ProtectOurEarth = 17, + Incenter_Scene_Question_BelieveScienceRenewableTech = 18, + Incenter_Scene_Question_StriveMoreEcoFriendly = 19, + Incenter_Scene_Question_ActionToHelpPlanet = 20, + Incenter_Scene_Question_HowYouFaceChallenges = 21, + Incenter_Scene_Question_InspiredToHelpOthers = 22, + Incenter_Scene_Question_PracticeChangeHopeFor = 23, + Incenter_Scene_Question_PracticeRadicalInclusion = 24, + Incenter_Scene_Question_CommunityFeelBelong = 25, + Incenter_Scene_Credits = 26, + + Incenter_Scene_Count, +}; + +global Incenter_Scene incenter_scene_descs[Incenter_Scene_Count]; + +internal void incenter_scene_descs_init(); + +#endif //INCENTER_SCENES_H diff --git a/src_v2/user_space/incenter_secondary_patterns.c b/src_v2/user_space/incenter_secondary_patterns.c new file mode 100644 index 0000000..3c466eb --- /dev/null +++ b/src_v2/user_space/incenter_secondary_patterns.c @@ -0,0 +1,74 @@ +void +secondary_pattern_solid_color(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, v3 color) +{ + Assembly_Pixel color_final = color_v3_to_assembly_pixel(color); + Assembly_Strip strip = strips.strips[city_secondary_first]; + for (u32 led = 0; led < strip.pixels_len; led++) + { + u32 led_index = strip.pixels[led]; + pixels.pixels[led_index] = color_final; + } +} + +// Splash +Random_Series splash_rand = { .last_value = 5336 }; +#define SPLASH_CAP 15 +v3 splash_pos[SPLASH_CAP]; +r32 splash_age[SPLASH_CAP] = { 0, .31f, .87f, .9f, 1.23f, 1.23, 1.212, 3.121, 4.134, 1.312, 3.31, 2.1, 3.12 }; +v3 splash_col[SPLASH_CAP]; +r32 splash_duration = 5; + +v3 splash_colors[5] = { + {1, 1, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 1, 1}, +}; +u32 next_color = 0; + +void +secondary_pattern_splash(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips) +{ + Assembly_Strip strip = strips.strips[city_secondary_first]; + + // Clear the last frame + Assembly_Pixel black = color_v3_to_assembly_pixel((v3){0, 0, 0}); + for (u32 led = 0; led < strip.pixels_len; led++) + { + u32 led_index = strip.pixels[led]; + pixels.pixels[led_index] = black; + } + + for (u32 i = 0; i < SPLASH_CAP; i++) + { + // Update the splash + splash_age[i] += 1.0f / 30.0f; + if (splash_age[i] >= splash_duration) { + u32 city_i = city_secondary_first + (random_series_next(&splash_rand) % (city_secondary_count - city_secondary_first)); + assert(city_i >= city_secondary_first && city_i < city_secondary_count); + Incenter_City_Desc city = city_descs[city_i]; + splash_pos[i] = incenter_latlng_to_cartesian(city.lat, city.lon, 1).xyz; + splash_age[i] = random_series_next_unilateral(&splash_rand) * -2; + splash_col[i] = splash_colors[next_color]; + next_color = (next_color + 1) % 5; + } + + if (splash_age[i] < 0) continue; + + // Apply to lights + r32 pct = clamp(0, (splash_age[i] / splash_duration), 1); + r32 radius = pct * .8f; + r32 radius2 = radius * radius; + r32 b = pm_smoothstep_r32(1 - pct); + for (u32 led = 0; led < strip.pixels_len; led++) + { + u32 led_index = strip.pixels[led]; + v4 p = pixels.positions[led_index]; + v4 pp = incenter_pos_to_unit(p); + r32 d2 = HMM_LengthSquaredVec3(HMM_SubtractVec3(pp.xyz, splash_pos[i])); + if (d2 <= radius2) { + pixels.pixels[led_index] = assembly_pixel_add( + pixels.pixels[led_index], + color_v3_to_assembly_pixel_faded(splash_col[i], b) + ); + } + } + } +} \ No newline at end of file diff --git a/src_v2/user_space/incenter_user_space.c b/src_v2/user_space/incenter_user_space.c new file mode 100644 index 0000000..6618231 --- /dev/null +++ b/src_v2/user_space/incenter_user_space.c @@ -0,0 +1,381 @@ + +#define SECONDARY_CITY_CAP 50 +u32 secondary_strips_len = 0; +Assembly_Strip* secondary_city_strips[SECONDARY_CITY_CAP]; + +#include "incenter_scenes.h" +#include "../user_space/incenter_patterns.c" +#include "../user_space/incenter_secondary_patterns.c" +#include "incenter_scenes.c" +#include "incenter_live_answers.c" + +//////////////////////////////////////////////// +// INCENTER SCENES + +internal void +incenter_scenes_init(Incenter_State* ins, u32 cap, Allocator* a) +{ + incenter_scene_descs_init(); + ins->scenes = incenter_scene_descs; + ins->scenes_cap = Incenter_Scene_Count; + ins->scene_at = Incenter_Scene_AnyoneHome; + //Incenter_Scene_Question_LostAccessToResources; +} + +internal void +incenter_reset_inputs(Incenter_State* ins) +{ + // reset bar chart over time + needs_reset = true; + year_max = 0; + month_max = 0; + year_at = 0; + month_at = 0; + month_start_time = 0; + + // reset inputs + ins->input_pct = 0.5f; + ins->input_option = 0; + ins->input_advance = false; +} + +internal void +incenter_go_to_transitioning_in(Incenter_State* ins) +{ + if (ins->scene_next != Incenter_Scene_WelcomeHome || + ins->scene_at != Incenter_Scene_AnyoneHome) { + ins->transition_time = 0; + ins->scene_mode = Incenter_SceneMode_TransitioningIn; + ins->scene_time = 0; + } else { + ins->scene_mode = Incenter_SceneMode_Passive; + } + ins->scene_at = ins->scene_next; + incenter_reset_inputs(ins); +} + +internal void +incenter_scene_go_to(Incenter_State* ins, u32 index) +{ + ins->transition_time = 0; + ins->scene_next = index % ins->scenes_cap; + ins->scene_mode = Incenter_SceneMode_TransitioningOut; + if (ins->scene_at == Incenter_Scene_WelcomeHome) { + incenter_go_to_transitioning_in(ins); + } + + printf("Switching To: %d:%s\n", ins->scene_next, ins->scenes[ins->scene_next].name); +} + +internal void +incenter_scene_go_to_next(Incenter_State* ins) +{ + incenter_scene_go_to(ins, ins->scene_at + 1); +} + +internal void +incenter_scene_go_to_prev(Incenter_State* ins) +{ + incenter_scene_go_to(ins, ins->scene_at - 1); +} + +internal void +incenter_scene_set_mode(Incenter_State* ins, Incenter_Scene_Mode mode) +{ + ins->scene_mode = mode; +} + +internal void +incenter_scene_render(App_State* state, Incenter_State* ins) +{ + assert(ins->scene_mode != Incenter_SceneMode_Count); + Incenter_Pattern* pattern = 0; + if (ins->scene_mode > Incenter_SceneMode_Count) + { + // Update the transition if necessary + if (ins->transition_time >= INCENTER_TRANSITION_DURATION) { + if (ins->scene_mode == Incenter_SceneMode_TransitioningOut) { + incenter_go_to_transitioning_in(ins); + } else { + ins->scene_mode = Incenter_SceneMode_Input; + if (ins->scene_next == Incenter_Scene_WelcomeHome || + ins->scene_next == Incenter_Scene_AnyoneHome) { + ins->scene_mode = Incenter_SceneMode_Passive; + } + } + } + } + + // DRaw the transition + switch (ins->scene_mode) + { + case Incenter_SceneMode_TransitioningOut: pattern = pattern_sun_transition_shrink; break; + case Incenter_SceneMode_TransitioningIn: pattern = pattern_sun_transition_grow; break; + case Incenter_SceneMode_Input: pattern = pattern_scene_input; break; + default: { + Incenter_Scene scene = ins->scenes[ins->scene_at]; + pattern = scene.patterns[ins->scene_mode]; + } break; + } + + Assembly_Array assemblies = state->assemblies; + if (pattern) + { + pattern(assemblies.pixel_buffers[0], assemblies.strip_arrays[0], ins); + } + else + { + pattern_color(assemblies.pixel_buffers[0], assemblies.strip_arrays[0], 0, 0, 0); + } +} + +#include "incenter_interface_connection.h" +#include "incenter_interface_connection.c" + +//////////////////////////////////////////////// +// INCENTER LIFECYCLE + +internal App_Init_Desc +incenter_get_init_desc() +{ + App_Init_Desc result = {}; + result.assembly_cap = 4; + return result; +} + +#define INCENTER_RADIUS INCENTER_FEET(10) +internal Assembly_Strip* +incenter_add_secondary_city_strip(Assembly_Array* assemblies, Assembly_Handle ah, u32 universe, u32 count, Incenter_City_Id city) +{ + Assembly_Strip* s = assembly_add_strip(assemblies, ah, count); + s->output_kind = OutputData_NetworkSACN; + s->sacn_universe = universe; + + Incenter_City_Desc d = city_descs[city]; + v4 city_p = incenter_latlng_to_cartesian(d.lat, d.lon, INCENTER_RADIUS); + v4 end_p = incenter_latlng_to_cartesian(d.lat, d.lon, INCENTER_RADIUS * 2); + for (u32 i = 0; i < count; i++) + { + v4 p = pm_lerp_v4(city_p, (r32)i / (r32)count, end_p); + assembly_add_led(assemblies, ah, s, p); + } + + secondary_city_strips[secondary_strips_len++] = s; + return s; +} + +internal void +incenter_init(App_State* state) +{ + // create user space data + Incenter_State* ins = allocator_alloc_struct(permanent, Incenter_State); + state->user_space_data = (u8*)ins; + + incenter_scenes_init(ins, 8, permanent); + + // create the sculpture + u32 lights_per_primary_city = 123; + u32 primary_city_lights = (city_count + 1) * lights_per_primary_city; + u32 secondary_city_count = (city_secondary_count - city_secondary_first) + 1; + u32 secondary_city_lights = secondary_city_count; + u32 lights_cap = primary_city_lights + 800; + Assembly_Handle ah = assembly_add(&state->assemblies, lit_str("incenter"), lights_cap, city_count + 50); + + scratch_get(scratch); + Allocator* s = scratch.a; + + v3 start_p = (v3){0, 0, 0}; + + + Assembly_Strip* brc = assembly_add_strip(&state->assemblies, ah, 140); + brc->output_kind = OutputData_NetworkSACN; + brc->sacn_universe = city_descs[city_black_rock].sacn_universe; + // Arctic + assembly_strip_append_leds( + &state->assemblies, + ah, + brc, + (v3){0, INCENTER_RADIUS, 0}, + start_p, + 90 + ); + // BRC + assembly_strip_append_leds( + &state->assemblies, + ah, + brc, + start_p, + (v3){0, INCENTER_FEET(-4.5f), 0}, + 50 + ); + + // ADDING PRIMARY CITIES + r32 radius = INCENTER_RADIUS; + for (u32 i = 1; i < city_count; i++) + { + Incenter_City_Desc city = city_descs[i]; + if (city.sacn_universe == 0) { + printf("skipping %s\n", city_strings[i]); + continue; + } + + v3 end_p = incenter_latlng_to_cartesian(city.lat, city.lon, radius).xyz; + + Assembly_Strip* strip = assembly_add_strip(&state->assemblies, ah, 123); + strip->output_kind = OutputData_NetworkSACN; + strip->sacn_universe = city.sacn_universe; + + assembly_strip_append_leds(&state->assemblies, ah, strip, end_p, start_p, 88); + } + +#define USING_ON_PLAYA_SECONDARY_CITIES 1 +#if USING_ON_PLAYA_SECONDARY_CITIES + // ADDING SECONDARY CITIES + { + for (u32 i = 0; i < SECONDARY_CITY_CAP; i++) secondary_city_strips[i] = 0; + Assembly_Array* a = &state->assemblies; + + { // Australia + Assembly_Strip* aus_lef = incenter_add_secondary_city_strip(a, ah, 62, 10, city_brisbane); + Assembly_Strip* aus_rig = incenter_add_secondary_city_strip(a, ah, 64, 8, city_brisbane); + Assembly_Strip* aus_cen = incenter_add_secondary_city_strip(a, ah, 34, 6, city_brisbane); + } + { // Islands Above Australia + Assembly_Strip* indonesia1 = incenter_add_secondary_city_strip(a, ah, 44, 9, city_jakarta); + Assembly_Strip* indonesia2 = incenter_add_secondary_city_strip(a, ah, 36, 9, city_jakarta); + Assembly_Strip* north_left_asia = incenter_add_secondary_city_strip(a, ah, 54, 6, city_tokyo); + Assembly_Strip* phillipines = incenter_add_secondary_city_strip(a, ah, 56, 10, city_jakarta); + } + { // East Asia + // TODO(PS): update primary cities + Assembly_Strip* cen_china_to_thailand = incenter_add_secondary_city_strip(a, ah, 37, 19, city_jakarta); + Assembly_Strip* china_coast = incenter_add_secondary_city_strip(a, ah, 38, 29, city_jakarta); + Assembly_Strip* peninsula_below_china = incenter_add_secondary_city_strip(a, ah, 40, 10, city_jakarta); + Assembly_Strip* mainland_right_of_japan_north = incenter_add_secondary_city_strip(a, ah, 40, 10, city_tokyo); + Assembly_Strip* mainland_right_of_japan_south = incenter_add_secondary_city_strip(a, ah, 58, 9, city_tokyo); + } + { // Japan + Assembly_Strip* japan = incenter_add_secondary_city_strip(a, ah, 60, 10, city_tokyo); + } + { + Assembly_Strip* rig_south_africa = incenter_add_secondary_city_strip(a, ah, 196, 9, city_nairobi); + Assembly_Strip* georgia = incenter_add_secondary_city_strip(a, ah, 198, 10, city_tokyo); // TODO(PS): + Assembly_Strip* ethiopia = incenter_add_secondary_city_strip(a, ah, 200, 5, city_addis_ababa); + Assembly_Strip* turkey = incenter_add_secondary_city_strip(a, ah, 202, 10, city_ankara); + Assembly_Strip* sudan_egypt = incenter_add_secondary_city_strip(a, ah, 204, 7, city_cairo); + Assembly_Strip* iran = incenter_add_secondary_city_strip(a, ah, 206, 9, city_tehran); + Assembly_Strip* west_russia = incenter_add_secondary_city_strip(a, ah, 208, 25, city_kyiv); + Assembly_Strip* saudi_arabia = incenter_add_secondary_city_strip(a, ah, 212, 4, city_ankara); + Assembly_Strip* south_africa = incenter_add_secondary_city_strip(a, ah, 214, 25, city_nairobi); // TODO(PS): + Assembly_Strip* right_india = incenter_add_secondary_city_strip(a, ah, 215, 19, city_mumbai); + Assembly_Strip* central_russia_right = incenter_add_secondary_city_strip(a, ah, 218, 7, city_kyiv); + Assembly_Strip* left_africa = incenter_add_secondary_city_strip(a, ah, 220, 7, city_nairobi); + Assembly_Strip* the_stans = incenter_add_secondary_city_strip(a, ah, 221, 19, city_tehran); + Assembly_Strip* left_india = incenter_add_secondary_city_strip(a, ah, 222, 40, city_mumbai); + } + + { + Assembly_Strip* italy = incenter_add_secondary_city_strip(a, ah, 162, 9, city_paris); + Assembly_Strip* nigeria_cameroon = incenter_add_secondary_city_strip(a, ah, 164, 6, city_abuja); + Assembly_Strip* greece = incenter_add_secondary_city_strip(a, ah, 166, 9, city_belgrade); + Assembly_Strip* israel = incenter_add_secondary_city_strip(a, ah, 168, 6, city_cairo); + Assembly_Strip* central_europe = incenter_add_secondary_city_strip(a, ah, 170, 35, city_berlin); + Assembly_Strip* libya = incenter_add_secondary_city_strip(a, ah, 172, 9, city_tunis); + Assembly_Strip* peru = incenter_add_secondary_city_strip(a, ah, 182, 9, city_brasilia); + Assembly_Strip* right_north_africa = incenter_add_secondary_city_strip(a, ah, 184, 13, city_rabat); + Assembly_Strip* france = incenter_add_secondary_city_strip(a, ah, 188, 5, city_paris); + Assembly_Strip* uk = incenter_add_secondary_city_strip(a, ah, 190, 6, city_paris); + Assembly_Strip* scandanavia = incenter_add_secondary_city_strip(a, ah, 192, 5, city_berlin); + } + { + Assembly_Strip* us_east_coast = incenter_add_secondary_city_strip(a, ah, 1, 20, city_washington); + Assembly_Strip* central_americas = incenter_add_secondary_city_strip(a, ah, 2, 19, city_denver); + Assembly_Strip* colombia = incenter_add_secondary_city_strip(a, ah, 6, 9, city_bogota); + Assembly_Strip* missippi_river = incenter_add_secondary_city_strip(a, ah, 12, 9, city_washington); + Assembly_Strip* chile_south = incenter_add_secondary_city_strip(a, ah, 14, 9, city_la_paz); + Assembly_Strip* us_west_coast = incenter_add_secondary_city_strip(a, ah, 22, 17, city_san_francisco); + Assembly_Strip* venezuela = incenter_add_secondary_city_strip(a, ah, 26, 5, city_bogota); + Assembly_Strip* chile_north = incenter_add_secondary_city_strip(a, ah, 28, 10, city_la_paz); + Assembly_Strip* left_canada = incenter_add_secondary_city_strip(a, ah, 32, 5, city_san_francisco); + } + } + +#else + // TODO: This probably isn't how these lights will be hooked up + Assembly_Strip* secondary_strip = assembly_add_strip(&state->assemblies, ah, secondary_city_lights); + secondary_strip->output_kind = OutputData_NetworkSACN; + secondary_strip->sacn_universe = incenter_secondary_city_universe; + for (u32 i = city_secondary_first; i < city_secondary_count; i++) + { + Incenter_City_Desc city = city_descs[i]; + v4 light_p = incenter_latlng_to_cartesian(city.lat, city.lon, radius); + assembly_add_led(&state->assemblies, ah, secondary_strip, light_p); + } +#endif + + // PATTERN INIT + pattern_random_fill_prep(); + + r32 rad = 0.05f; + sculpture_updated(state, 5, rad); + + + ins->running = true; + incenter_interface_connection_init(state, ins); + + printf("Incenter Initialized\n"); + scratch_release(scratch); +} + +internal void +incenter_frame_prepare(App_State* state) +{ + +} + +#if defined(PLATFORM_SUPPORTS_EDITOR) +internal void +incenter_sculpture_visualizer_ui(App_State* state, Editor* ed) +{ + UI_Layout layout = *ed->ui.layout; + layout.mode = UILayout_Columns, + layout.bounds_min = (v2){0, 0}, + layout.bounds_max.x = 250; + ui_layout_push(&ed->ui, &layout); + + Incenter_State* ins = (Incenter_State*)state->user_space_data; + ui_text_f(&ed->ui, WHITE_V4, "Scene Time: %fs", ins->scene_time); + ui_text_f(&ed->ui, WHITE_V4, "Scene: %s", ins->scenes[ins->scene_at].name); + + ui_layout_pop(&ed->ui); +} +#endif + +internal void +incenter_frame(App_State* state) +{ + Incenter_State* ins = (Incenter_State*)state->user_space_data; + Assembly_Array assemblies = state->assemblies; + + { // INPUT HANDLING + Input_State* is = state->input_state; + if (input_key_went_down(is, KeyCode_LeftArrow)) incenter_scene_go_to_prev(ins); + if (input_key_went_down(is, KeyCode_RightArrow)) incenter_scene_go_to_next(ins); + } + + incenter_interface_connection_frame(state, ins); + + ins->scene_time += state->target_seconds_per_frame * 0.5f; + ins->transition_time += state->target_seconds_per_frame; + incenter_scene_render(state, ins); + +} + +internal void +incenter_cleanup(App_State* state) +{ + Incenter_State* ins = (Incenter_State*)state->user_space_data; + ins->running = false; + os_thread_end(ins->interface_thread); + incenter_interface_connection_cleanup(ins); +} \ No newline at end of file diff --git a/src_v2/user_space/incenter_user_space.h b/src_v2/user_space/incenter_user_space.h new file mode 100644 index 0000000..ab4ae46 --- /dev/null +++ b/src_v2/user_space/incenter_user_space.h @@ -0,0 +1,190 @@ + +#define INCENTER_METER 1.0f +#define INCENTER_FOOT 0.3048f +#define INCENTER_METERS(count) (count) * INCENTER_METER +#define INCENTER_FEET(count) (count) * INCENTER_FOOT +#define INCENTER_PER_METER(count) INCENTER_METER / (r32)(count) + +typedef u32 Incenter_City_Id; + +enum { + MONTH_jan, + MONTH_feb, + MONTH_mar, + MONTH_apr, + MONTH_may, + MONTH_jun, + MONTH_jul, + MONTH_aug, + MONTH_sep, + MONTH_oct, + MONTH_nov, + MONTH_dec, +}; +typedef u32 Incenter_Month_Id; + +typedef struct Incenter_City_Desc Incenter_City_Desc; +struct Incenter_City_Desc +{ + Incenter_City_Id id; + + r32 lat; + r32 lon; + + u32 sacn_universe; + + // TODO: Some way to access this cities strip of leds +}; + +typedef struct Incenter_Data_Row Incenter_Data_Row; +struct Incenter_Data_Row +{ + Incenter_City_Id id; + u32 year; + Incenter_Month_Id month; + r64 prop; +}; + +// TODO(PS): fix this to be the real universe +#define incenter_secondary_city_universe 33 +#include "incenter_gen_cities.h" + +// Data +#include "../../run_tree/data/incenter_data/c/question_1.h" +#include "../../run_tree/data/incenter_data/c/question_2.h" +#include "../../run_tree/data/incenter_data/c/question_3.h" +#include "../../run_tree/data/incenter_data/c/question_4.h" +#include "../../run_tree/data/incenter_data/c/question_5.h" +#include "../../run_tree/data/incenter_data/c/question_6.h" +#include "../../run_tree/data/incenter_data/c/question_7.h" +#include "../../run_tree/data/incenter_data/c/question_8.h" +#include "../../run_tree/data/incenter_data/c/question_9.h" +#include "../../run_tree/data/incenter_data/c/question_10.h" +#include "../../run_tree/data/incenter_data/c/question_11.h" +#include "../../run_tree/data/incenter_data/c/question_12.h" +#include "../../run_tree/data/incenter_data/c/question_13.h" +#include "../../run_tree/data/incenter_data/c/question_14.h" +#include "../../run_tree/data/incenter_data/c/question_15.h" +#include "../../run_tree/data/incenter_data/c/question_16.h" +#include "../../run_tree/data/incenter_data/c/question_17.h" +#include "../../run_tree/data/incenter_data/c/question_18.h" +#include "../../run_tree/data/incenter_data/c/question_19.h" +#include "../../run_tree/data/incenter_data/c/question_20.h" +#include "../../run_tree/data/incenter_data/c/question_21.h" + +typedef struct Incenter_State Incenter_State; + +typedef void Incenter_Pattern(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* state); + +typedef u32 Incenter_Scene_Mode; +enum { + Incenter_SceneMode_Intro, + Incenter_SceneMode_Passive, + Incenter_SceneMode_Count, + + Incenter_SceneMode_Input, + Incenter_SceneMode_TransitioningOut, + Incenter_SceneMode_TransitioningIn, +}; + +#define INCENTER_TRANSITION_DURATION 3 +#define INCENTER_TRANSITION_SUN_REVEAL_DURATION 2 + +typedef u8 Incenter_Scene_Kind; +enum { + Incenter_SceneKind_Information, + Incenter_SceneKind_YesOrNo, + Incenter_SceneKind_ThreeOption, + Incenter_SceneKind_SlidingScale, + Incenter_SceneKind_Count, +}; + +typedef struct Incenter_Scene Incenter_Scene; +struct Incenter_Scene +{ + char* name; + Incenter_Pattern* patterns[Incenter_SceneMode_Count]; + Incenter_Data_Row* data; + u32 data_len; + Incenter_Scene_Kind kind; +}; + +// INLH is abbrev for INcenter Live data Header +#define LIVE_DATA_HEADER_MAGIC_NUMBER "INLH" +// INLB is abbrev for INcenter Live data Bucket +#define LIVE_DATA_BUCKET_MAGIC_NUMBER "INLB" + +typedef struct Live_Answers_File_Header Live_Answers_File_Header; +struct Live_Answers_File_Header +{ + u8 magic[4]; + u32 buckets_count; + u32 answers_total_count; +}; + +typedef struct Live_Answers_File_Bucket Live_Answers_File_Bucket; +struct Live_Answers_File_Bucket +{ + u8 magic[4]; + + // the value this bucket represents. + union { + u32 answer_u32; + r32 answer_r32; + }; + + // The number of responses that fit within this bucket + u32 count; +}; + +typedef struct Live_Answers_File Live_Answers_File; +struct Live_Answers_File +{ + String path; + Live_Answers_File_Header* header; + Live_Answers_File_Bucket* buckets; +}; + +struct Incenter_State +{ + Incenter_Scene* scenes; + u32 scenes_cap; + u32 scene_at; + u32 scene_next; + Incenter_Scene_Mode scene_mode; + r64 scene_time; + r64 transition_time; + + bool running; + Thread_Handle interface_thread; + Socket_Handle interface_socket; + + // Ring buffer of interface messages. All +#define INTERFACE_MESSAGES_CAP 8 +#define INTERFACE_MESSAGE_SIZE 512 + Data interface_messages[INTERFACE_MESSAGES_CAP]; + u32 interface_messages_write_next; + u32 interface_messages_read_next; + + // User Input + r32 input_pct; + u32 input_option; + b8 input_advance; +}; + +internal v4 +incenter_latlng_to_cartesian(r32 lat, r32 lng, r32 radius) +{ + r32 theta = (lat / 180.0f) * r32_pi; + r32 phi = (lng / 180.0f) * r32_pi; + + // spherical to cartesian conversion + v4 result = { + radius * sinf(phi) * cosf(theta), + radius * sinf(phi) * sinf(theta), + radius * cosf(phi), + 1 + }; + + return result; +} diff --git a/test_motor_header.h b/test_motor_header.h deleted file mode 100644 index 3a443b3..0000000 --- a/test_motor_header.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// File: test_motor_header.h -// Author: Peter Slattery -// Creation Date: 2021-01-14 -// -#ifndef TEST_MOTOR_HEADER_H - -struct -{ - u8 MotorOnePos; - u8 MotorTwoPos; - u8 MotorThreePos; -} typedef packet; - -static packet -UnpackPacket - -#define TEST_MOTOR_HEADER_H -#endif // TEST_MOTOR_HEADER_H \ No newline at end of file diff --git a/test_sound_interface_packet.h b/test_sound_interface_packet.h deleted file mode 100644 index a046c21..0000000 --- a/test_sound_interface_packet.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// File: test_sound_interface_packet.h -// Author: Peter Slattery -// Creation Date: 2021-01-14 -// -#ifndef TEST_SOUND_INTERFACE_PACKET_H - -enum selectable_patterns -{ -}; - -typedef struct -{ - u8 PrimaryColor[3]; - u8 SecondaryColor[3]; - u32 PatternIndex; // Set via selectable_patterns - u8 Speed; // -} sound_interface_packet; - -// expects V to be in the range -1:1 -u8 FloatToSpeed (float V) -{ - u8 Result = (u8)(((V + 1) / 2) * 255); - return Result; -} - - -#define TEST_SOUND_INTERFACE_PACKET_H -#endif // TEST_SOUND_INTERFACE_PACKET_H \ No newline at end of file diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..0355424 --- /dev/null +++ b/todo.txt @@ -0,0 +1,51 @@ +- arctic - what do we want to do? +- (waiting) EFAULT error on receiving a message from the interface +- FILE IO bugs +x Timeout to idle + +LUSIO Light festival + +- kids love this thing "THATS THE COOLEST" +- conversation about "People probably haven't talked about their covid experience yet, this is really good." +- "This is the most peaceful I've felt in a long time" +- "Where are you from" - "I'm from the one that's full of light" +- Rando: "Hey close the door, its way better." +- "A whole new world" +- "Want to do it with me?" (goes on to correctly explain the piece without us having told her) +- "So you're inside the globe, that's why it's inside out, THAT'S SO COOL!" +- "So that question was about feeling represented in government." "OH WOW - holy shit brazil!" (chorus) +- "Come do the thing!" "Wait, in front of everybody?" +- "It's kind of temple-y, with the writing and atmosphere and stuff" + + +TODO: + +- Plasma Ray - light from primary city out to secondary splash +x Connection Pattern - fill part up with light, have the empty space do the data flow pattern +- Spatially Vertical Rain (not spherical) +- Something like rain for data viz + +- Rendering gifs to the secondary cities + + +Anyone Home +- some light, but low power mode +- blues, match screen - guide person towards display + +Welcome Home +- keep the secondary cities off + +Felt Isolated - blues, cooler tones, water? + +Nature - gold, pink/purple - drinking champagne - carousel colors +- bluring the ends of bars is ok, just keep it consistent + +For data sets that have really high values everywhere, grow them in one at a time +- for connection based ones: grow first, ripple out secondary cities to the next nearest primary city, grow that one + +QUESTION: Are we showing a statement about the data during the passive mode of each scene? +- Yes + +QUESTION: Can we change the scene ids? Does it matter if two screens have the same sceneId? + +TODO: Put together an ending scene \ No newline at end of file